This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Enderslime's profile picture

Pullevent help

Started by Enderslime, 02 December 2015 - 07:24 PM
Enderslime #1
Posted 02 December 2015 - 08:24 PM

local linked = ""
local current = ""

paintutils.drawFilledBox(1,1,100,100,colors.blue)
term.setCursorPos(3,3)

while true do
term.setCursorPos(3,3)
print(current)
local event, key = os.pullEvent( "key" )
if key == "keys.1" then
current = current..1
end
end

I am trying to test when I hit the number 1 and print it, whenever i hit 1 with this code it doesn't print 1, any idea why? (all of this is soon to be bigger code, ignore other stuff not in the while loop)
Lupus590 #2
Posted 02 December 2015 - 09:23 PM
change "keys.1" to keys.one
Edited on 02 December 2015 - 08:23 PM
KingofGamesYami #3
Posted 02 December 2015 - 11:30 PM
Key events return numbers. The keys API contains most of numbers according to the "name" of the key (eg. keys.a). keys.one is actually the number 2.


For a full list of the keys accessible from the keys API, go here

For an image of the keys and their respective numbers, go here.

Since you want a number input, I would consider using both 2 and 79, so that the numpad can be used (see the picture I linked).