Jump to content




Get User Input And Check With Variable.


  • You cannot reply to this topic
5 replies to this topic

#1 Beatsleigher

  • Members
  • 37 posts
  • LocationGermany, Osnabrueck

Posted 27 July 2013 - 10: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...

#2 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 27 July 2013 - 10: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


#3 Beatsleigher

  • Members
  • 37 posts
  • LocationGermany, Osnabrueck

Posted 27 July 2013 - 11:00 AM

View PostEngineer, on 27 July 2013 - 10:32 AM, said:

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

Ah, thanks :) I was getting those from the Lua foundation webs...
Thanks for the info :)

#4 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 27 July 2013 - 11:21 AM

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")


#5 Beatsleigher

  • Members
  • 37 posts
  • LocationGermany, Osnabrueck

Posted 27 July 2013 - 11:26 AM

View PostLBPHacker, on 27 July 2013 - 11:21 AM, said:

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")


#6 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 27 July 2013 - 11:29 AM

Better yet: Replace that part with this:
rs.setOutput("back", true)
sleep(5)
rs.setOutput("back", false)
Self-explaining IMO.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users