I was just messing around in the sound editor and my sister said it sounds like a broken television so i made this. Dont ask why im uploading this
Help with tables
So I have a function for creating text with sprites (I'm sure people have done this already, but i specifically want help with one thing):
charspr{74,75,76,77,78,79,90,91,92,93,94,95,106,107,108,109,110,111,122,123,124,125,126,127,138,139,140,141,142,143,154,155,156,157,158,159,170,171,172,173,174,175,186,187,188} charname{"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","0","p","q","r","s","t","u","v","w","x","y","z",".","-","!","\"","\'",",",":",";","𝘹","?","1","2","3","4","5","6","7","8","9"," "} for i=0,#str,1 do spr(charspr[charname[sub(str,1,nil)]]) end |
Now the long tables charspr and charname are supposed to give out the id of a sprite. (I use charname to know the id of an item from charspr)
From my testing I found out that the problem (the one I want help with) is when I try to call charname[<a letter from sub()>]. Apparently it gives out [nil], but what i thought it would do is something like a block from Scratch:
(item # of (< item>) in [< list>]),
but apparently it doesn't. So I'm asking: if anyone would know about a workaround or how to do it properly.
I'm not entirely sure if this is bug or my mistake, but i can't figure it out.
Basicly I have code that should save what I'm typing (it's the last line) to a var named code.
However if i add a function for deletion it doesn't work properly:
I can still type, however i have to hold for few seconds before it registers key presses, which does not apply for the backspace.
I also figured out, that only the first code will work properly, meaning if i swap the if with the var set, only typing works.
if stat(31)=="\b" then code=sub(code,0,-2) end code=code..stat(31) |
I'd be really happy to know if it's my mistake or a bug.