../
kernel
functions
add
all
apply_delta
assert
atan2
btn
btnp
camera
cd
char
chooser
circ
circfill
clip
cls
color
cos
count
cp
create_delta
create_gui
create_process
cursor
date
del
deli
env
error
exit
fetch
fetch_metadata
fget
fillp
foreach
fset
fstat
fullpath
get_clipboard
get_display
get_draw_target
get_spr
include
input
key
keyp
line
ls
map
max
memcpy
memmap
memset
menuitem
mget
mkdir
mouse
mouselock
mset
music
mv
note
on_event
open
oval
ovalfill
peek
peek2
peek4
peek8
peektext
pget
pid
pod
poke
poke2
poke4
poke8
printh
pset
pwd
readtext
rect
rectfill
rm
rrect
rrectfill
scoresub
send_message
set_clipboard
set_draw_target
set_spr
sfx
sin
socket
split
spr
sspr
stat
stop
store
store_metadata
sub
time
tokenoid
type
unmap
unpod
userdata
vec
vid
window
input([prompt],[flags])
Overview
input is used to allow terminal programs to be interactive; this is a blocking function and stalls the program until the user enters a response.
The response of the user is returned.
Interactive terminal programs that run indefinitely do not have a _update or _draw callback, and instead can use input() in the mainloop.
Note that there is currently no way to respond to non-textinput keys (like cursors) from terminal programs.
Terminal programs can be run during development with ctrl-r, but as they occupy the same process as the terminal that is displaying them; there may be some disparities in behaviour.
Arguments
[prompt]: string
The string that shows to the left of the user's input, default: "?"
[flags]: bitfield
A bitfield that can change how inputs work.
Available flags:
- 0x1 hide the prompt once input() has returned
- 0x2 complete the input when a single character is given (do not wait for enter)
- 0x4 do not block -- return nil when there is no response that frame
Returns
response: string
The user's response to the input
Example
Sourced from the Picotron Manual
print("press k,l to adjust value or q to quit")
print("") -- is going to get consumed by \r below
val = 10
while true do
res = input("",0x7)
if (res == "q") exit()
if (res == "k") val -= 1
if (res == "l") val += 1
print("\rvalue: "..val) -- \r to write over previous line
end
print("finished")