Log In  


What I'm trying to do is make a typewriter script, but when checking to see that the third line has less characters than the dialogue, I keep running into the same odd error. Is this not a string?

-- typewriter

dialogue = {d1={
	l1="qwertyuiop",
	l2="asdfghjkl",
	l3="zxcvbnm"}}
c_text_1 = "."
c_text_2 = "."
c_text_3 = "."
c_dia = 1

function typewriter(string,wait)
	if frame > wait and #c_text_3 != #tostr(dialogue[("d"..c_dia)[l3]]) then
		sfx(0)
		frame = 0
	end
end


I think the issue is the [], not the #. The expression

("d"..c_dia)[l3]

is trying to access an element contained within the string

"d"..c_dia

I assume you want something like

#tostr(dialogue["d"..c_dia][l3])

instead, where l3 is the index of an element inside

dialogue["d"..c_dia]

I did not think that would work with tables. Thank you! :D



[Please log in to post a comment]