TO LOAD THIS PICO-8 CART, in immediate mode, type:
I had recently received a bit of traffic regarding an old input routine I made found HERE:
so I decided to rewrite it entirely, so it is not coded with GOTO and interrupt main code but made it so it can run in the background additionally.
This means it uses the conventional _update() function and you call it by changing one variable called
INPUT to a string value.
Then the input engages - and the rest of your code can continue to run around it. In fact for this demo you can use the arrow keys to move the rainbow circle even as you are typing !
It also remembers the screen and unlike other programs that only remember once what was beneath it, this allows you to continue to draw to its message area even when visible and you will not lose a single pixel of your work.
You also do not need to initialize any variables inside _init(), the whole thing is self-contained.
To make it work you will need two functions
Firstlineinput is 32-tokens and Lastlineinput is 185-tokens.
Quite simply make the first line in your _update() function to call firstlineinput().
Then the last line of your _update() function to call lastlineinput().
function _init() end function _update() firstlineinput() (( your code + graphics )) if askname==1 then input="what is your name" elseif output!=nil then print("hello, "..output) output="" end lastlineinput() end
And that's it ! The rest is handled automatically including updating the screen even if you don't redraw the screen every frame The system is smart and recalls every pixel you draw even if you draw directly on top of it during operation or even as you are typing in text !
To call it, set the global variable
INPUT to be something like, "please enter your name."
That will then appear in a frame below, type what you want and press ENTER. Also during name entry only is the "P" and ENTER key taken over so you can press "P" without pausing the system. If you want to pause during text entry, hold the P for a moment and the regular menu will appear.
Press ENTER and the contents of your input are sent to global variable
OUTPUT When you are not entering a message the "P" and ENTER key function normally and will pause with a single keystroke.
It does use high memory from 0xF800 to 0xFFFF. As long as you are not using that this program will run just fine.
I am also using global variables that start with an underline and zero. If you have other variables that start with an underline but not a zero after that, you should also not run into any problems.
And there it is !
If you have any questions or comments, feel free to let me know.
[Please log in to post a comment]