tsc = {}

--[[ -- Original Cave Story-like values.
local FAST = 1
local SLOW = 5
]] -- Faster values for English. (English words are a little longer!)
local FAST = 0
local SLOW = 3


function tsc.think()
	if tsc.addtext and tsc.addtext[1] ~= #tsc.addtext[2]
		if tsc.addtext[3] == 0
			tsc.addtext[1] = tsc.addtext[1] + 1
			if input.buttons & 1<<BTN.OK ~= 0
				tsc.addtext[3] = FAST
			else
				tsc.addtext[3] = SLOW
			end
			local char = tsc.addtext[2]:sub(tsc.addtext[1],tsc.addtext[1])
			if char == '\n'
				table.insert(tsc.msgtext,1,"")
				tsc.msgtext[4] = nil
			else
				tsc.msgtext[1] = (tsc.msgtext[1] or "") .. char
			end
		else
			tsc.addtext[3] = tsc.addtext[3] - 1
		end
		if tsc.addtext[1] == #tsc.addtext[2]
			tsc.addtext = nil
			if not tsc.nod
				net.tsc_text()
			end
		end
	elseif tsc.nod and input.btn_start & 1<<BTN.OK ~= 0
		tsc.nod = false
		net.tsc_nod()
	end
end

function tsc.close()
	tsc.msgbox = nil
	tsc.msgtext = {}
	tsc.nod = false
	tsc.addtext = nil
end

function tsc.reset()
	tsc.close()
	tsc.keylock = nil
end
