LilBangarang Posted May 15, 2013 Posted May 15, 2013 I recently started using RP frames and want to create an elevator that uses ComputerCraft and RP. I need to know if this code is alright. os.pullEvent = os.pullEventRaw print ("Welcome, are you going up or down?") write ("") x = io.read() if x=="up" then print("Which floor are you going to?") write() if x=="1" then sleep(3) redstone.setOutput("top", true) sleep(1) redstone.setOutput("top", false) sleep(4) redstone.setOutput("bottom", true) sleep(10) redstone.setOutput("bottom", false) end else if x=="2" then sleep(3) redstone.setOutput("top", true) sleep(2) redstone.setOutput("top", false) sleep(4) redstone.setOutput("bottom", true) sleep(10) redstone.setOutput("bottom", false) end else if x=="3" then sleep(3) redstone.setOutput("top", true) sleep(3) redstone.setOutput("top", false) sleep(4) redstone.setOutput("bottom", true) sleep(10) redstone.setOutput("bottom", false) end else if x=="4" then sleep(3) redstone.setOutput("top", true) sleep(4) redstone.setOutput("top", false) sleep(4) redstone.setOutput("bottom", true) sleep(10) redstone.setOutput("bottom", false) end end sleep(4) os.shutdown Quote
Maxis010 Posted May 15, 2013 Posted May 15, 2013 Use Code Tags Instead of os.pullEventRaw use Pull event with Char Sleeping while the RS signal is on will still only make you advance 1 block, no matter how long you sleep Use a switch case to define how many blocks you need to elevate (Floor 1 is 5 blocks, floor 2 is 10 etc) Then use a for to run "rs on, sleep 1, rs off, sleep 1" for that many blocks After that sleep for 10 seconds then run the for again only in reverse so that the lift goes back down Some of this is assumptions based off of what info you have given me Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.