37 posts
Location
Germany, Osnabrueck
Posted 27 July 2013 - 11:23 AM
So I'm creating a custom Minecraft map using CC and a few other mods (Tekkit 3.2.1 - Yes, it's a modpack, but I'm not going over all the different mods) and I'd like the user to input a specific string into a computer, which then outputs a redstone signal, retracting a piston (Redstone inverter).
I've gotten about this far:
shell.run("clear")
print "Please type in the code to open the door to the next room:"
unlockCode = "<Variable content>"
userCode = io.read()
if userCode == unlockCode then
shell.run("redpulse(5)")
else
print "Wrong answer! The program will restart!"
win.Sleep(100)
shell.run("reboot")
end
But something's not right.
For some reason the program exits before the user can even input the string…
1522 posts
Location
The Netherlands
Posted 27 July 2013 - 11:32 AM
Here in CCLua, ComputerCraft Lua, we use a normal read(). without the io :P/>
It should work then if you replace that ( io.read() with read() )
Btw, win.Sleep should be a normal sleep in CCLua.
Spoiler
shell.run("clear")
print "Please type in the code to open the door to the next room:"
unlockCode = "<Variable content>"
userCode = read()
if userCode == unlockCode then
shell.run("redpulse(5)")
else
print "Wrong answer! The program will restart!"
sleep(100)
shell.run("reboot")
end
37 posts
Location
Germany, Osnabrueck
Posted 27 July 2013 - 12:00 PM
Here in CCLua, ComputerCraft Lua, we use a normal read(). without the io :P/>
It should work then if you replace that ( io.read() with read() )
Btw, win.Sleep should be a normal sleep in CCLua.
Spoiler
shell.run("clear")
print "Please type in the code to open the door to the next room:"
unlockCode = "<Variable content>"
userCode = read()
if userCode == unlockCode then
shell.run("redpulse(5)")
else
print "Wrong answer! The program will restart!"
sleep(100)
shell.run("reboot")
end
Ah, thanks :)/> I was getting those from the Lua foundation webs…
Thanks for the info :)/>
758 posts
Location
Budapest, Hungary
Posted 27 July 2013 - 12:21 PM
Guys…
shell.run("redpulse(5)")
You sure about that? As far as I know, that should say "No such program". This'll work:
shell.run("redpulse", "5")
37 posts
Location
Germany, Osnabrueck
Posted 27 July 2013 - 12:26 PM
Guys…
shell.run("redpulse(5)")
You sure about that? As far as I know, that should say "No such program". This'll work:
shell.run("redpulse", "5")
Yeah. I was just about to edit. Lol.
I found this works:
shell.run("redpulse", "back", "1", "5")
758 posts
Location
Budapest, Hungary
Posted 27 July 2013 - 12:29 PM
Better yet: Replace that part with this:
rs.setOutput("back", true)
sleep(5)
rs.setOutput("back", false)
Self-explaining IMO.