Posted 31 October 2012 - 05:43 PM
Im having trouble getting this to work right. It's an elevator operation code that uses frame motors, brick breaker, and deployer.
Also sorry Im not sure how to post code here otherwise.
–[[Frames Elevator code
Elevator will be lowered from roof of building.
When the elevator goes up a frame will be removed with a block breaker and sent to the deployer through pneumatic pipe.
When the elevator goes down a frame will be placed on top from a deployer.
Requirements
Will detect a redstone pulse from the right from either yellow (up) or blue (down).
On a yellow pulse it will send a redstone signal to the left to black (block breaker) then again left on white (frame motor up)
On a blue pulse it will send a redstone signal to the right to red (frame motor down) then a signal on the right to green (deployer)
The loop will operate 5 times (height of floors)
Additional ideas: replace yellow and blue buttons with rednet signals and have a selection of floors with a variable indicating which floor the elevator is on.
]]–
While true do
term.clear
term.setCursorPos(1,1) – clear and set cursor position
print("awaiting call") – tells operator that the program is looking for a signal
if rs.getInput("left") then – looks for an input
if colors.test(colors.yellow) then – is the
t = 0 – sets t (floor height counter) to 0
term.clear
term.setCursorPos(1,1) – clear and set cursor position
print("elevator moving up") – tells operator that the elevator is moving up
repeat – starts a repeat loop between the block breaker and the frame motor (up)
rs.setBundledOutput("right", colors.black) – turns on block breaker
rs.setBundledOutput("right", rs.getBundledOutput("right") - colors.black) – turns off block breaker
os.sleep(1) – this sleep is here to give the block breaker time to operate
rs.setBundledOutput("right", colors.white) – turns on frame motor (up)
rs.setBundledOutput("right", rs.getBundledOutput("right") - colors.white) – turns off frame motor (down)
os.sleep(1) – this sleep is here to give the frame motor time to operate
t = t + 1 – loop counter
until t == 5 – operates until next floor
end – ends repeat loop
if colors.test(colors.blue) then – if the signal is blue it will break here.
t = 0 – sets t (floor height counter) to 0
term.clear
term.setCursorPos(1,1) – clears and sets cursor position
print("elevator moving down") – tells the operator that the elevator is moving down
repeat – start of repeat loop between the frame motor (down) and the deployer
rs.setBundledOutput("right", colors.red) – turns on frame motor (down)
rs.setBundledOutput("right", rs.getBundledOutput("right") - colors.red) – turns off frame motor (down)
os.sleep(1) – this sleep to give the frame motor time to operate
rs.setBundledOutput("right", colors.green) – turns on deployer
rs.setBundledOutput("right", rs.getBundledOutput("right") - colors.green) – turns off deployer
os.sleep(1) – this sleep to give the deployer time to operate
t = t + 1 – loop counter
until t == 5 – operates until next floor
end – ends the loop
end – ends identify input color
end – ends detect loop
– At this point it should go back to the begining to wait for redstone signals from blue or yellow. I'm not sure how to do that in Lua.
Also sorry Im not sure how to post code here otherwise.
–[[Frames Elevator code
Elevator will be lowered from roof of building.
When the elevator goes up a frame will be removed with a block breaker and sent to the deployer through pneumatic pipe.
When the elevator goes down a frame will be placed on top from a deployer.
Requirements
Will detect a redstone pulse from the right from either yellow (up) or blue (down).
On a yellow pulse it will send a redstone signal to the left to black (block breaker) then again left on white (frame motor up)
On a blue pulse it will send a redstone signal to the right to red (frame motor down) then a signal on the right to green (deployer)
The loop will operate 5 times (height of floors)
Additional ideas: replace yellow and blue buttons with rednet signals and have a selection of floors with a variable indicating which floor the elevator is on.
]]–
While true do
term.clear
term.setCursorPos(1,1) – clear and set cursor position
print("awaiting call") – tells operator that the program is looking for a signal
if rs.getInput("left") then – looks for an input
if colors.test(colors.yellow) then – is the
t = 0 – sets t (floor height counter) to 0
term.clear
term.setCursorPos(1,1) – clear and set cursor position
print("elevator moving up") – tells operator that the elevator is moving up
repeat – starts a repeat loop between the block breaker and the frame motor (up)
rs.setBundledOutput("right", colors.black) – turns on block breaker
rs.setBundledOutput("right", rs.getBundledOutput("right") - colors.black) – turns off block breaker
os.sleep(1) – this sleep is here to give the block breaker time to operate
rs.setBundledOutput("right", colors.white) – turns on frame motor (up)
rs.setBundledOutput("right", rs.getBundledOutput("right") - colors.white) – turns off frame motor (down)
os.sleep(1) – this sleep is here to give the frame motor time to operate
t = t + 1 – loop counter
until t == 5 – operates until next floor
end – ends repeat loop
if colors.test(colors.blue) then – if the signal is blue it will break here.
t = 0 – sets t (floor height counter) to 0
term.clear
term.setCursorPos(1,1) – clears and sets cursor position
print("elevator moving down") – tells the operator that the elevator is moving down
repeat – start of repeat loop between the frame motor (down) and the deployer
rs.setBundledOutput("right", colors.red) – turns on frame motor (down)
rs.setBundledOutput("right", rs.getBundledOutput("right") - colors.red) – turns off frame motor (down)
os.sleep(1) – this sleep to give the frame motor time to operate
rs.setBundledOutput("right", colors.green) – turns on deployer
rs.setBundledOutput("right", rs.getBundledOutput("right") - colors.green) – turns off deployer
os.sleep(1) – this sleep to give the deployer time to operate
t = t + 1 – loop counter
until t == 5 – operates until next floor
end – ends the loop
end – ends identify input color
end – ends detect loop
– At this point it should go back to the begining to wait for redstone signals from blue or yellow. I'm not sure how to do that in Lua.