This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
micmou's profile picture

Issue with RiM Elevator

Started by micmou, 23 December 2014 - 01:23 PM
micmou #1
Posted 23 December 2014 - 02:23 PM
SO I have a Remain In motion elevator with GUI buttons sending the id and message to the elevator thn this piece of code is suppose to handle it

function Up()
    drive = peripheral.wrap("right")
    local i = 1
    repeat
	    drive.move(1, false, true)
	    os.sleep(1)
    until i == 8
end

function Down()
    drive = peripheral.wrap("right")
    local i = 1
    repeat
	    drive.move(0, false, true)
	    os.sleep(1)
    until i == 8
end

function Toggle()
    rs.setOutput("bottom", true)
    os.sleep(.1)
    rs.setOutput("bottom", false)
end

while true do
    rednet.open("left")
    local event, senderId, message = os.pullEvent("rednet_message")
    if senderId == 38 and message == "Up" then
	    Up()
	    Toggle()
	    os.reboot()
    elseif senderId == 28 and message == "Down" then
	    Down()
	    Toggle()
	    os.reboot()
    elseif senderId == 30 and message == "Down" then
	    Down()
	    Ttoggle()
	    os.reboot()
    elseif senderId == 31 and message == "Up" then
	    Up()
	    Toggle()
	    os.reboot()
    end
end

Whichi it takes one of my hard coded Computers and decides to move up or down then it is suppose to toggle a redstone system then reboot



Issue is whenever I go up or down I have to manually restart the computer no error
KingofGamesYami #2
Posted 23 December 2014 - 02:24 PM
This is a problem with RiM elevators.
micmou #3
Posted 23 December 2014 - 05:35 PM
I thought It was fixed in RiM 2.3.0 which is what we have.
Any ideas on how to work my way around this D:
KingofGamesYami #4
Posted 23 December 2014 - 05:37 PM
Well, you could have another computer not moved by the elevator that reboots the computer by wrapping it as a peripheral, but then what is the point of the computer in the elevetor?

There's really nothing you can do code wise if the computer is frozen.
micmou #5
Posted 23 December 2014 - 05:39 PM
True Hmm I was thinking use one of the lower motors and apply a red stone signal so there is no issue with my code then? When I Re-Write I am going to put it up here for others with pics of my setup



Wait My computer doesn't move it is stationary D:
Edited on 23 December 2014 - 04:40 PM
micmou #6
Posted 23 December 2014 - 06:49 PM
Sorry For Double post here is the new code

function Up()
    local timer = os.startTimer(8) -- start a timer for 5 seconds
    while true do
	    print("test3")
	    rs.setOutput("back", true)
	    local evt, arg = os.pullEvent("timer")
	    if arg == timer then
		    rs.setOutput("back", false)
		    print("test4")
	    end
    end
end

function Down()
    local timer = os.startTimer(8)
    while true do
	    rs.setOutput("right", true)
	    print("test")
	    local evt, arg = os.pullEvent("timer")
	    if arg == timer then ed before
		    rs.setOutput("right", false)
		    print("test2")
	    end
    end
end

function Toggle()
    local timer = os.startTimer(.2)
    while true do
	    rs.setOutput("left", true)
	    print("test5")
	    local evt, arg = os.pullEvent("timer")
	    if arg == timer then
		    rs.setOutput("left", false)
		    print("test6")
	    end
    end
end

while true do
    rednet.open("top")
    local event, senderId, message = os.pullEvent("rednet_message")
    if senderId == 38 and message == "Up" then
	    Up()
	    Toggle()
    elseif senderId == 28 and message == "Down" then
	    Down()
	    Toggle()
    elseif senderId == 30 and message == "Down" then
	    Down()
	    Toggle()
    elseif senderId == 31 and message == "Up" then
	    Up()
	    Toggle()
    end
end

My issue is that it prints test then waits 8 seconds then test2 and then test again?
I want it to set the output wait then set the output off for a constant signal on up and down for 8 seconds then I want the toggle to toggle a Project red latch
KingofGamesYami #7
Posted 23 December 2014 - 07:03 PM
Down() will infinately repeat once called. Perhaps you meant to add a break?


function Down()
    local timer = os.startTimer(8)
    while true do
            rs.setOutput("right", true)
            print("test")
            local evt, arg = os.pullEvent("timer")
            if arg == timer then ed before
                    rs.setOutput("right", false)
                    print("test2")
                    break --#Here
            end
    end
end