2 posts
Posted 29 March 2012 - 04:36 PM
Hey I was wondering if their is a way to make a multiple choice question e.g.
Which safe would you like to access 1,2,3?
Enter Number:
Aswell a list of commands anywhere thanks :o/>/>
286 posts
Location
Bonn Germany
Posted 29 March 2012 - 05:04 PM
You could print out a list of items
Spoiler
-> Choice A <-
Choice B
Choice C
and then read out the key wich was pressed by the user. Then you change the variable saving wich Item is selected and reprint the list
pressing DOWN
Spoiler
Choice A
-> Choice B <-
Choice C
if the user preses Enter or so yould just read out what was currently selected.
Hope that's what you've been looking for
2 posts
Posted 29 March 2012 - 05:05 PM
You could print out a list of items
Spoiler
-> Choice A <-
Choice B
Choice C
and then read out the key wich was pressed by the user. Then you change the variable saving wich Item is selected and reprint the list
pressing DOWN
Spoiler
Choice A
-> Choice B <-
Choice C
if the user preses Enter or so yould just read out what was currently selected.
Hope that's what you've been looking for
I Dont Know how to do this Im new to computercraft
473 posts
Location
Poland
Posted 29 March 2012 - 05:15 PM
Then read the tutorials.
80 posts
Posted 29 March 2012 - 06:57 PM
Entering a number/name:
print("Choose a safe:")
while true do
term.setCursorPos(1,2)
term.clearLine()
local safe = read()
if safe == "1" then
print("Opening safe 1...")
--Open safe 1 here
break
elseif safe == "2" then
print("Opening safe 2...")
--Open safe 2 here
break
elseif safe == "3" then
print("Opening safe 3...")
--Open safe 3 here
break
else
print("Enter a number.")
sleep(2)
term.clearLine()
end
end
Choosing:
local s = 1
while true do
term.setCursorPos(1,1)
for i=1, 3 do
if i == s then
print("[Safe "..i.."]")
else
print(" Safe "..i.." ")
end
end
local event, p1 = os.pullEvent("key")
if p1 == 200 and s > 1 then
s = s - 1
elseif p1 == 208 and s < 3 then
s = s + 1
elseif p1 == 28 then
print("Opening safe "..s.."...")
if s == 1 then
--Open safe 1
elseif s == 2 then
--safe 2...
elseif s == 3 then
--safe 3...
end
end
end
Woo, 50 posts! :o/>/>