Posted 03 September 2012 - 07:11 PM
I am trying to make a wired elevator using Railcraft's elevator rails and cables from Redpower with the Computercraft computers acting as controllers. Here is what I've made in my test world:
User interface side
Back end wiring
I am not very experienced with programming, much less computercraft programming.
I currently have two computers and a button on each floor:
I have what I thought would work for the bottom machine on each level but errors out saying "lift:3: bad argument: string expected, got nil". I know it is expecting a string now, but I don't want it to take the current value but to wait for a change in the bundle and then act.
Here is my current code for the floor controllers:
I haven't been able to come up with anything thats even plausibly workable for my user input other than this:
Any helpful advice would be appreciated.
Thanks,
User interface side
Back end wiring
I am not very experienced with programming, much less computercraft programming.
I currently have two computers and a button on each floor:
- The button is for summoning the elevator. When pressed, it sends a signal through the cable bundle of its color.
- The top computer is the user interface which will prompt the user to enter a destination. When a destination is input, it sends a signal into the cable bundle of the correct color for the requested floor.
- The bottom computer just waits for a signal input from the cable bundle. When a signal comes in, it first checks to see what color the signal is on. If the color matches its floor, then the computer will toggle all signals on the bundle off and then turns the local black wire on. If the signal received on the cable does not match its floor then it will turn its local black wire off.
I have what I thought would work for the bottom machine on each level but errors out saying "lift:3: bad argument: string expected, got nil". I know it is expecting a string now, but I don't want it to take the current value but to wait for a change in the bundle and then act.
Here is my current code for the floor controllers:
-- Floor 1 (pink)
while true do
x = rs.getBundledInput(right)
if x == "64" then
rs.setBundledOutput("front", 0)
rs.setOutput("right", true)
else
rs.setOutput("right", false)
end
end
I haven't been able to come up with anything thats even plausibly workable for my user input other than this:
-- Floor 1 User (pink)
while true do
compID = os.getComputerLable()
print("You are currently on "..compID..".")
print("Please select a floor: ")
end
All this does so far is to spam that message until I force quit the program.Any helpful advice would be appreciated.
Thanks,