Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pos_modem
- local up
- local down
- local call
- local stage
- local height
- function getData()
- write("Position des Modems: ")
- pos_modem=io.read()
- write("Seite des Redstone-Signals 'Hoch': ")
- up=io.read()
- write("Seite des Redstone-Signals 'Runter': ")
- down=io.read()
- write("Seite des Redstone-Signals 'Rufen': ")
- call=io.read()
- write("Stockwerk dieses Clients: ")
- stage=io.read()
- write("Hoehe (y-Wert) dieses Stockwerks: ")
- height=io.read()
- end
- function checkData()
- if(fs.exists("client.cfg")) then
- config=fs.open("client.cfg", "r")
- pos_modem=config.readLine()
- stage=config.readLine()
- up=config.readLine()
- down=config.readLine()
- call=config.readLine()
- height=tonumber(config.readLine())
- config.close()
- print("Alte Konfiguration eingelesen!")
- else
- getData()
- saveData()
- end
- end
- function saveData()
- config=fs.open("client.cfg", "w")
- config.writeLine(pos_modem)
- config.writeLine(stage)
- config.writeLine(up)
- config.writeLine(down)
- config.writeLine(call)
- config.writeLine(height)
- config.close()
- end
- function receiveRedstone()
- while (true) do
- os.pullEvent("redstone")
- if(redstone.getInput(up)) then
- rednet.broadcast("move,"..stage+1)
- elseif(redstone.getInput(down)) then
- rednet.broadcast("move,"..stage-1)
- elseif(redstone.getInput(call)) then
- rednet.broadcast("move,"..stage)
- end
- end
- end
- function logon()
- rednet.broadcast("logon,"..stage..","..height)
- sleep(1)
- id, message, distance = rednet.receive()
- print(message)
- end
- function split(str, pat)
- local t = {}
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- checkData()
- rednet.open(pos_modem)
- logon()
- receiveRedstone()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement