Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tardis = peripheral.wrap("top")
- modem = peripheral.wrap("back")
- refueling = false
- local function modemHandler()
- while true do
- modem.open(6407)
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- -- modem handler
- local words = {}
- for word in message:gmatch("%S+") do
- table.insert(words, word)
- print(word)
- end
- if words[1] == "open" then
- tardis.setDoors("BOTH")
- modem.transmit(6408, 6407, "Doors opened")
- elseif words[1] == "close" then
- tardis.setDoors("CLOSED")
- modem.transmit(6408, 6407, "Doors closed")
- end
- if words[1] == "setpos" then
- tardis.setDestination(tonumber(words[2]), tonumber(words[3]), tonumber(words[4]))
- modem.transmit(6408, 6407, "Position set to " .. words[2] .. " " .. words[3] .. " " .. words[4])
- end
- if words[1] == "setdim" then
- tardis.setDimension(tonumber(words[2]))
- modem.transmit(6408, 6407, "Dimension set to " .. words[2])
- end
- if words[1] == "takeoff" then
- tardis.setFlight(1)
- modem.transmit(6408, 6407, "Taking off")
- end
- if words[1] == "getpos" then
- local x, y, z = tardis.getLocation()
- modem.transmit(6408, 6407, "Position is " .. x .. " " .. y .. " " .. z)
- end
- if words[1] == "getdim" then
- modem.transmit(6408, 6407, "Dimension is " .. tardis.getCurrentDimension())
- end
- if words[1] == "sethandbrake" then
- tardis.setHandbrake(true)
- modem.transmit(6408, 6407, "Handbrake set")
- end
- if words[1] == "releasehandbrake" then
- tardis.setHandbrake(false)
- modem.transmit(6408, 6407, "Handbrake released")
- end
- if words[1] == "base" then
- tardis.setDestinationAndDimension(686, 62, -731, 0)
- modem.transmit(6408, 6407, "Base set as destination")
- end
- if words[1] == "mathieu" then
- tardis.setDestinationAndDimension(269, 62, -119, 0)
- modem.transmit(6408, 6407, "Mathieu set as destination")
- end
- if words[1] == "creeper" then
- tardis.setDestinationAndDimension(2240, 78, -1264, 0)
- modem.transmit(6408, 6407, "Creeper set as destination")
- end
- if words[1] == "malik" then
- tardis.setDestinationAndDimension(1126, 64, -4175, 0)
- modem.transmit(6408, 6407, "Malik set as destination")
- end
- if words[1] == "johan" then
- tardis.setDestinationAndDimension(133, 66, -4098, 0)
- modem.transmit(6408, 6407, "Johan set as destination")
- end
- end
- end
- local function tardisHandler()
- while true do
- -- automatic features
- local time, currTick, tickThing = tardis.getTimeLeft()
- if currTick ~= 0 then
- if tardis.getDoors() ~= "CLOSED" then
- tardis.setDoors("CLOSED")
- end
- refueling = false
- else
- if not refueling then
- tardis.setRefuel(true)
- refueling = true
- modem.transmit(6408, 6407, "Landed")
- end
- end
- sleep(0.1)
- end
- end
- parallel.waitForAny(modemHandler, tardisHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement