Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- mobile_gui.lua
- local basalt = require("/basalt")
- local main = basalt.createFrame()
- local modem = peripheral.find("modem") or error("No modem found")
- rednet.open(peripheral.getName(modem))
- local x, y, z = gps.locate(5)
- if not x then error("GPS not available.") end
- local statusLabel = main:addLabel()
- :setText("Ready to send task")
- :setPosition(2, 2)
- main:addLabel():setText("Task Type:"):setPosition(2, 4)
- local taskType = main:addInput()
- :setPosition(14, 4)
- :setSize(15, 1)
- :setValue("digHole")
- main:addLabel():setText("Size X:"):setPosition(2, 6)
- local sizeX = main:addInput():setPosition(14, 6):setSize(5, 1):setValue("5")
- main:addLabel():setText("Size Z:"):setPosition(2, 8)
- local sizeZ = main:addInput():setPosition(14, 8):setSize(5, 1):setValue("5")
- main:addLabel():setText("Depth:"):setPosition(2, 10)
- local depth = main:addInput():setPosition(14, 10):setSize(5, 1):setValue("3")
- main:addButton():setText("Send Task")
- :setPosition(2, 12)
- :onClick(function()
- local task = {
- task = taskType:getValue(),
- location = { x = x, y = y, z = z },
- size = {
- x = tonumber(sizeX:getValue()),
- z = tonumber(sizeZ:getValue()),
- depth = tonumber(depth:getValue())
- }
- }
- rednet.broadcast(textutils.serialize(task))
- statusLabel:setText("Sent. Waiting...")
- local _, response = rednet.receive(3)
- if response then
- statusLabel:setText("✓ " .. response)
- else
- statusLabel:setText("✗ No response from base")
- end
- end)
- basalt.autoUpdate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement