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.
stat(31) returns the pressed key, but then removes it from the input buffer, so you can only call it once. @girres42 has the right idea, but I think they meant:
code ..= key, and also you probably don't want to add the backspace character to the string:
code ="" poke(0x5f2d, 1) function _draw() cls() print("code:"..code) end function _update() local key=stat(31) if key=="\b" then code=sub(code,0,-2) else code ..= key end end
[Please log in to post a comment]