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
P#74563 2020-04-08 13:44 ( Edited 2020-04-08 13:45)

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]
P#74568 2020-04-08 16:05 ( Edited 2020-04-08 16:10)

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

P#74570 2020-04-08 16:39

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 12:28:41 | 0.006s | Q:14