Greetings;
Initially speaking, this thread was for an elevator program. I have one, however its a bit of a cheat. I use the Elevator mod, and either wireless redstone or bundled cable, and sticky pistons w/elevator base blocks above and below the floors. I'm no master programmer by a very long shot, but this works for me. Simply put, computer on each floor w/menu. Select your floor - it sends a signal to the designated floor, which based on your calculated direction, pushes out an elevator base either above or below the floor to stop you (depending on direction up or down). The mod has an elevator base block that prevents damage on long descents.
It requires:
Computercraft and computers.
Elevator Mod(allows for 'chutes' to be set up for specific directions (up or down or sideways))
Currently set up for bundled cable use, so it requires the bundleAPI - can be slightly altered for wireless redstone use and simple redstone input.
Output can be wired or wireless. Wireless works best.
Sends and receives signals through to the floors, no need to remember and no 'elevator' to call. Slight drawback if rednet is used to send signals, and that is distance of transmission. There is a limit for the rednet modems. There is no limit to wireless however. Something to consider in your designs.
****************************************
os.loadAPI("/rom/apis/bundleAPI")
-- elevator program
-- set modem side, cable side, computerid below
-- must have bundleAPI loaded
flr = 0
curflr = 6 -- your current floor of installation
outputside = "back"
modemside = "right"
-- computer id numbers
-- comp# = current floor
-- # = computer id #
comp1 = 1
comp2 = 5
comp3 = 3
comp4 = 16
comp5 = 5
comp6 = 18
comp7 = 7
comp8 = 20
comp9 = 21
comp10 = 22
local self = os.getComputerLabel()
function chgflr(flr,dir)
print(flr," = floor passed")
if flr == 1 then
flr = tonumber(comp1)
elseif flr == 2 then
flr = tonumber(comp2)
elseif flr == 3 then
flr = tonumber(comp3)
elseif flr == 4 then
flr = tonumber(comp4)
elseif flr == 5 then
flr = tonumber(comp5)
elseif flr == 6 then
flr = tonumber(comp6)
elseif flr == 7 then
flr = tonumber(comp7)
elseif flr == 8 then
flr = tonumber(comp8)
elseif flr == 9 then
flr = tonumber(comp9)
elseif flr == 10 then
flr = tonumber(comp10)
end
print(flr," ",dir)
rednet.send(flr,dir)
print("Message sent to the ",flr," floor")
print("Your direction is ",dir)
print("You have 10 seconds to arrive.")
os.sleep(10)
term.clear()
end
function scrnmsg(flr,dir)
term.clear()
term.setCursorPos(1,1)
print("Hello, I am ", self)
print("Please select floor: ")
print("1: Floor 1 ")
print("2: Floor 2")
print("3: Floor 3")
print("4: Floor 4")
print("5: Floor 5")
print("6: Floor 6")
print("7: Floor 7")
print("8: Floor 8")
print("9: Floor 9")
print(" ")
print("Any other key to exit")
flr = read()
-- can insert an integrity check here to ensure choice
-- otherwise exits with error at command line
flr = tonumber(flr)
print()
print("You've selected: ", flr)
if flr == curflr then
print("Same floor")
flr = 0
return
end
if flr <= curflr then
dir = "up"
end
if flr >= curflr then
dir = "down"
end
if flr <= 1 then
flr = 1
end
-- print(flr)
chgflr(flr,dir)
return
end
function listen(sender, message)
rednet.open(modemside)
sender, message = rednet.receive()
print("Sender: ", sender, " Sent the following message: ",message)
if message == "up" then
colr="red"
bundleAPI.on(outputside,colr)
print("Activated upper")
os.sleep(15)
bundleAPI.off(outputside,colr)
end
if message == "down" then
colr="blue"
bundleAPI.on(outputside,colr)
print("Activated lower")
os.sleep(15)
bundleAPI.off(outputside,colr)
end
return sender, message
end
--- Begin program run
while true do
term.clear()
print("Starting .....")
parallel.waitForAny(scrnmsg, listen)
-- print("next ...") -- testing
-- print(flr) -- testing
-- print("Done") -- testing
end
***********************
Hope it helps!