Jump to content

Recommended Posts

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...