Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hostIDs = {32, 72, 95}
- local teleports = {}
- local textScale = 0.9
- function startOperations()
- local file = fs.open("list.txt", "r")
- local text = file.readAll()
- file.close()
- for pairText in string.gmatch(text, "([^;]+)") do
- local pair = {}
- for textInPair in string.gmatch(pairText, "([^-]+)") do
- table.insert(pair, textInPair)
- end
- table.insert(teleports, pair)
- end
- for k, v in pairs(teleports) do
- print(k, v[1], v[2])
- end
- rednet.open("right")
- print("rednet opened")
- end
- function display()
- monit = peripheral.wrap("top")
- monit.setTextScale(textScale)
- monit.setBackgroundColour(colors.black)
- monit.clear()
- monit.setCursorPos(1, 1)
- local function dispNewLine()
- local x, y = monit.getCursorPos()
- monit.setCursorPos(1, y + 1)
- end
- local function displayLine()
- local width = monit.getSize()
- for i = 1, width do
- monit.write("-")
- end
- dispNewLine()
- end
- for k, v in pairs(teleports) do
- displayLine()
- monit.write(k .. " " .. v[1] .. " " .. v[2])
- dispNewLine()
- displayLine()
- end
- end
- function work()
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- local btnClicked = math.ceil(y / 3)
- print(event.."; x="..x.."; y="..y)
- print("Button clicked = "..btnClicked)
- if btnClicked <= #teleports and btnClicked > 0 then
- print(teleports[btnClicked][1] .. " -> " .. teleports[btnClicked][2])
- local hostIndex = math.ceil(btnClicked / 5)
- local targetHostID = hostIDs[hostIndex]
- print("try to send side to host")
- local result = rednet.send(targetHostID, teleports[btnClicked][1], "teleportSystem1")
- print("Is it successful? -> "..tostring(result))
- else
- print("This is not button")
- end
- print("end of operation")
- print("")
- end
- end
- function start()
- startOperations()
- display()
- work()
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement