Posted 25 March 2018 - 07:36 AM
Hey all! I've gotten great help here before, so I thought I'd ask about another issue I've encountered surrounding a different (and more complicated) program, this one controlling the movement of deployable "steps" that are moved depending on a series of conditions. There are a couple issues with my current program (seen below), primarily surrounding the redstone inputs.
Currently, the code seems to stall itself out. Nothing happens when I press the pressure plate (seen in the reference pictures, and referenced as the "source"), and the inputs are ignored.
In earlier iterations, the frames would ignore the inputs and upon starting the program would deploy and retract the frames (albeit correctly) without concern for the conditions.
What is wrong here? I've linked reference pictures and have the program below.
Reference pictures: https://imgur.com/a/rPXNp
Currently, the code seems to stall itself out. Nothing happens when I press the pressure plate (seen in the reference pictures, and referenced as the "source"), and the inputs are ignored.
In earlier iterations, the frames would ignore the inputs and upon starting the program would deploy and retract the frames (albeit correctly) without concern for the conditions.
What is wrong here? I've linked reference pictures and have the program below.
Reference pictures: https://imgur.com/a/rPXNp
--Current Problems:
--The program doesn't seem to care if the input and/or DoorOpen/DoorClosed conditions are met.
--The program repeats and sends itself into an error state, and resets.
--Upon changing resetDoor function conditions, the door no longer moves.
local DoorClosed = rs.testBundledInput("left",colors.purple)
local DoorOpen = rs.testBundledInput("left",colors.orange)
local input = rs.testBundledInput("left",colors.gray)
function openDoor()
if DoorClosed == false then
print("The door is already open.")
else
rs.setBundledOutput("left",colors.black+colors.red+colors.green)
sleep(1)
rs.setBundledOutput("left",colors.red+colors.green)
sleep(1)
rs.setBundledOutput("left",colors.green)
sleep(1)
rs.setBundledOutput("left",0)
sleep(1)
end
if DoorOpen == true then
print("The door is now open.")
else
print("The program has encountered a problem. Resetting the door now.")
resetDoor()
end
end
function closeDoor()
if DoorOpen == false then
print("The door is already closed.")
else
rs.setBundledOutput("left",colors.white+colors.blue+colors.yellow)
sleep(1)
rs.setBundledOutput("left",colors.blue+colors.yellow)
sleep(1)
rs.setBundledOutput("left",colors.yellow)
sleep(1)
rs.setBundledOutput("left",0)
sleep(1)
end
if DoorClosed == true then
print("The door is now closed.")
else
print("The program has encountered a problem. Resetting the door now.")
resetDoor()
end
end
function resetDoor()
repeat
rs.setBundledOutput("left",0)
rs.setBundledOutput("left",colors.yellow+colors.blue+colors.white)
sleep(5)
rs.setBundledOutput("left",colors.black+colors.red+colors.green)
sleep(1)
rs.setBundledOutput("left",0)
until DoorClosed == true
end
while true do --infinite loop
if input == true and DoorClosed == true then
openDoor()
sleep(5)
end
if input == true and DoorOpen == true then
closeDoor()
sleep(5)
end
if input == false and DoorOpen == true then
sleep(20)
closeDoor()
end
if input == false and DoorClosed == true then
sleep(1)
end
if DoorClosed == false and DoorOpen == false then
resetDoor()
end
sleep(1)
end