I'm trying to make a simple text-adventure game within the terminal (using the arrow keys as input), but the print() functions for the various options aren't kept permanently on screen.
What am I doing wrong here?
cls(0) -- left = "80" -- up = "82" -- right = "79" -- down = "81" print("Press a key:") for kp = 79,81 do if key(80) and key(kp) then print("left") elseif key(81) and key(kp) then print("center") elseif key(79) and key(kp) then print("right") end end |
1
Is this in your _draw? It looks like the second any key isn't pressed it'll just clear the screen completely with cls(0)
@crimson2877
Found out that I needed to remove the cls() function and change the key(kp) to keyp(kp) so that there’s no unnecessary duplication of the print() functions
1
@WidgetOtaku glad u figured it out! excited for a lil text adventure on here
[Please log in to post a comment]