I actually found the code for the program i did. I was very new to programming when i made this so take it with a grain of salt…. but it does work. Maybe you can improve on it or just use it.
It works by using a computer on each floor to act like a terminal. Then it will send a wireless rednet signal to the computer controlling the motors. Also keep in mind that is was made to work on a 2 floor building only. You need to improve it a bit if you want more.
this is the code for the terminal: Edit:This terminal is for the top floor
Spoiler
--#oooooooooo start oooooooooooo
rednet.open("top")
run = true
term.clear()
w,h = term.getSize()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
xpos = 1
ypos = 1
local floor = 2
--#oooooooooooooooooooooooooooo
function printCent(n)
xpos, ypos = term.getCursorPos()
local length = string.len(n)
term.setCursorPos((w/2)-(length/2),ypos)
term.write(n)
end
function user()
term.clear()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.black)
printCent("Welcome User")
term.setCursorPos(1,2)
for i=1,w do term.write("-") end
term.setCursorPos(1,5)
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
printCent(" UP ")
term.setCursorPos(1,8)
printCent(" DOWN ")
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
event,button, cxpos, cypos = os.pullEvent("mouse_click")
if cxpos >=22 and cxpos <= 27 and cypos == 8 then
if redstone.getInput("left") == true then
term.clear()
term.setCursorPos(1,1)
print(" Already on this Floor")
os.sleep(2)
else
rednet.send(13,"down")
end
elseif cxpos >=22 and cxpos <= 27 and cypos == 5 then
if redstone.getInput("back") == true then
else
rednet.send(13,"up")
print("down")
end
end
end
local stat = true
while stat == true do
user()
end
This the code for the computer controlling the motors:
Spoiler
--#ooooooooooo startup ooooooooooooo
drive = peripheral.wrap("back")
run = true
rednet.open("right")
--#oooooooooooooooooooooooooooooooo
function move(n,d)
for i = 1,n do
redstone.setOutput(d,true)
os.sleep(1)
redstone.setOutput(d,false)
os.sleep(1)
end
redstone.setOutput(d,false)
end
while run == true do
local event, dist , msg = os.pullEvent()
if event == "rednet_message" then
print(event)
if msg == "down"then
move(5,"top")
elseif msg == "up" then
move(5,"bottom")
end
elseif event == "char" and dist == "x" then
print("Ending")
run = false
end
end
I wish got into the habit of adding more comments when i made this but if you have any questions about it you can just ask and I'm sure i can work it out.