Posted 05 November 2012 - 11:02 PM
I've been working on a spacy lift connecting the 5 floors of my base. The lift is a platform made of Frames on a long still also made out of frames. the motors are at the bottom floor, one is for up, on is for downward movement. on every floor there is a computer for controlling the lifts movements. The motors need a signal so they are both connoected to different colored insulated wires; the up motor is green, the down motor is red. The computers send their output signal from their BACK side.
Now, to enable every computer to use the same program, i made the following setup: on every floor there is a permanently ON redstone torch, linked to a repeater, which outputs into air, next to it is a redstone wire connecting to a colored insulated wire.
Now on the bottow of the platform i attached a block (stone, but it doesn't really matter) so when the lift is on a specific floor, the stone block is turned on by the repeater, the redstone wire gets turned on which then turns on the specicly colored insulated wire. That's how the computers know which floor the lift is on right now. The Input side of the computers for recieving the floors colored signal is RIGHT. and a bundled cable goes up the whole shaft which means that all computers would recieve yellow if the lift was on floor 2!
floor 1 i orange, 2 is yellow, 3 is lime, 4 is cyan, 5 is blue
so i've been making this program but i'm somewhat stuck at getting it to work really. Here it is
local side = "right"
local one = 1
local two = 2
local three = 3
local four = 4
local five = 5
local floor = redstone.getBundledInput(side)
local goal = ""
local c = ""
local a = ""
local input = ""
local output = "back"
while true do
term.clear()
term.setCursorPos(1,1)
write("Select a floor from 1 to 5: ")
local input = tonumber (read())
if input >= 1 and input <= 5 then
if floor == 2 then
local a = 1
elseif floor == 16 then
local a = 2
elseif floor == 32 then
local a = 3
elseif floor == 512 then
local a = 4
elseif floor == 2048 then
local a = 5
else
print("Error; uknown floor or damaged sensor")
if input == one then
local goal = 2
elseif input == two then
local goal = 16
elseif input == three then
local goal = 32
elseif input == four then
local goal = 512
elseif input == five then
local goal = 2048
else
print("Floor doesn't exist!")
if a > input then
while c ~= goal do
local c = getBundledInput(side)
redstone.setBundledOutput(output, colors.red)
sleep(0.1)
redstone.setBundledOutput(output, 0)
sleep(1)
if c == goal then
os.shutdown()
end
end
end
end
if input > a then
while c ~= goal do
local c = getBundledInput(side)
redstone.setBundledOutput(output, colors.green)
sleep(0.1)
redstone.setBundledOutput(output, 0)
sleep(1)
if c == goal then
os.shutdown()
end
end
end
end
if input == a then
print("You are already on that floor!")
sleep(1)
else
print("Floor doesn't exist")
sleep(1)
end
end
end
What it's supposed to do is: ask for an input, which has to be 1,2,3,4 or 5, if it isn't one of those, it should print out "flloor doesn't exist". Next it reads what color the input is so it knows which floor it is, and depending on the color, assigns a value to "a". Then it compares "a" to "input". if "a" > "input", it means that the lift will go down so the loop is set to output in the color red, if "a" < "input" it has to go up and the color is green. the variable "goal" depends on "input" and every loop, the program should check if the correct color signal is being detected.
I've never actually programmed with lua before this, so this caused me quite an amount of grief and frustration, simply because i'm not used to it.
the problem i'm stuck at right now is that no matter which number i type in for "input", the elseif statements don't assign a value to "goal" and i always get "floor doesn't exist".
any help would be very much appreciated, thanks in advance
Now, to enable every computer to use the same program, i made the following setup: on every floor there is a permanently ON redstone torch, linked to a repeater, which outputs into air, next to it is a redstone wire connecting to a colored insulated wire.
Now on the bottow of the platform i attached a block (stone, but it doesn't really matter) so when the lift is on a specific floor, the stone block is turned on by the repeater, the redstone wire gets turned on which then turns on the specicly colored insulated wire. That's how the computers know which floor the lift is on right now. The Input side of the computers for recieving the floors colored signal is RIGHT. and a bundled cable goes up the whole shaft which means that all computers would recieve yellow if the lift was on floor 2!
floor 1 i orange, 2 is yellow, 3 is lime, 4 is cyan, 5 is blue
so i've been making this program but i'm somewhat stuck at getting it to work really. Here it is
local side = "right"
local one = 1
local two = 2
local three = 3
local four = 4
local five = 5
local floor = redstone.getBundledInput(side)
local goal = ""
local c = ""
local a = ""
local input = ""
local output = "back"
while true do
term.clear()
term.setCursorPos(1,1)
write("Select a floor from 1 to 5: ")
local input = tonumber (read())
if input >= 1 and input <= 5 then
if floor == 2 then
local a = 1
elseif floor == 16 then
local a = 2
elseif floor == 32 then
local a = 3
elseif floor == 512 then
local a = 4
elseif floor == 2048 then
local a = 5
else
print("Error; uknown floor or damaged sensor")
if input == one then
local goal = 2
elseif input == two then
local goal = 16
elseif input == three then
local goal = 32
elseif input == four then
local goal = 512
elseif input == five then
local goal = 2048
else
print("Floor doesn't exist!")
if a > input then
while c ~= goal do
local c = getBundledInput(side)
redstone.setBundledOutput(output, colors.red)
sleep(0.1)
redstone.setBundledOutput(output, 0)
sleep(1)
if c == goal then
os.shutdown()
end
end
end
end
if input > a then
while c ~= goal do
local c = getBundledInput(side)
redstone.setBundledOutput(output, colors.green)
sleep(0.1)
redstone.setBundledOutput(output, 0)
sleep(1)
if c == goal then
os.shutdown()
end
end
end
end
if input == a then
print("You are already on that floor!")
sleep(1)
else
print("Floor doesn't exist")
sleep(1)
end
end
end
What it's supposed to do is: ask for an input, which has to be 1,2,3,4 or 5, if it isn't one of those, it should print out "flloor doesn't exist". Next it reads what color the input is so it knows which floor it is, and depending on the color, assigns a value to "a". Then it compares "a" to "input". if "a" > "input", it means that the lift will go down so the loop is set to output in the color red, if "a" < "input" it has to go up and the color is green. the variable "goal" depends on "input" and every loop, the program should check if the correct color signal is being detected.
I've never actually programmed with lua before this, so this caused me quite an amount of grief and frustration, simply because i'm not used to it.
the problem i'm stuck at right now is that no matter which number i type in for "input", the elseif statements don't assign a value to "goal" and i always get "floor doesn't exist".
any help would be very much appreciated, thanks in advance