Advertisement
RedoverPlayer

Tardis main v2

Nov 27th, 2022 (edited)
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.50 KB | None | 0 0
  1. tardis = peripheral.wrap("top")
  2. modem = peripheral.wrap("back")
  3.  
  4. refueling = false
  5.  
  6. local function modemHandler()
  7.     while true do
  8.         modem.open(6407)
  9.         local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  10.    
  11.         -- modem handler
  12.         local words = {}
  13.         for word in message:gmatch("%S+") do
  14.             table.insert(words, word)
  15.             print(word)
  16.         end
  17.    
  18.         if words[1] == "open" then
  19.             tardis.setDoors("BOTH")
  20.             modem.transmit(6408, 6407, "Doors opened")
  21.         elseif words[1] == "close" then
  22.             tardis.setDoors("CLOSED")
  23.             modem.transmit(6408, 6407, "Doors closed")
  24.         end
  25.  
  26.         if words[1] == "setpos" then
  27.             tardis.setDestination(tonumber(words[2]), tonumber(words[3]), tonumber(words[4]))
  28.             modem.transmit(6408, 6407, "Position set to " .. words[2] .. " " .. words[3] .. " " .. words[4])
  29.         end
  30.  
  31.         if words[1] == "setdim" then
  32.             tardis.setDimension(tonumber(words[2]))
  33.             modem.transmit(6408, 6407, "Dimension set to " .. words[2])
  34.         end
  35.  
  36.         if words[1] == "takeoff" then
  37.             tardis.setFlight(1)
  38.             modem.transmit(6408, 6407, "Taking off")
  39.         end
  40.        
  41.         if words[1] == "getpos" then
  42.             local x, y, z = tardis.getLocation()
  43.             modem.transmit(6408, 6407, "Position is " .. x .. " " .. y .. " " .. z)
  44.         end
  45.  
  46.         if words[1] == "getdim" then
  47.             modem.transmit(6408, 6407, "Dimension is " .. tardis.getCurrentDimension())
  48.         end
  49.  
  50.         if words[1] == "sethandbrake" then
  51.             tardis.setHandbrake(true)
  52.             modem.transmit(6408, 6407, "Handbrake set")
  53.         end
  54.  
  55.         if words[1] == "releasehandbrake" then
  56.             tardis.setHandbrake(false)
  57.             modem.transmit(6408, 6407, "Handbrake released")
  58.         end
  59.  
  60.         if words[1] == "base" then
  61.             tardis.setDestinationAndDimension(686, 62, -731, 0)
  62.             modem.transmit(6408, 6407, "Base set as destination")
  63.         end
  64.        
  65.         if words[1] == "mathieu" then
  66.             tardis.setDestinationAndDimension(269, 62, -119, 0)
  67.             modem.transmit(6408, 6407, "Mathieu set as destination")
  68.         end
  69.  
  70.         if words[1] == "creeper" then
  71.             tardis.setDestinationAndDimension(2240, 78, -1264, 0)
  72.             modem.transmit(6408, 6407, "Creeper set as destination")
  73.         end
  74.  
  75.         if words[1] == "malik" then
  76.             tardis.setDestinationAndDimension(1126, 64, -4175, 0)
  77.             modem.transmit(6408, 6407, "Malik set as destination")
  78.         end
  79.  
  80.         if words[1] == "johan" then
  81.             tardis.setDestinationAndDimension(133, 66, -4098, 0)
  82.             modem.transmit(6408, 6407, "Johan set as destination")
  83.         end
  84.     end
  85. end
  86.  
  87. local function tardisHandler()
  88.     while true do
  89.         -- automatic features
  90.         local time, currTick, tickThing = tardis.getTimeLeft()
  91.         if currTick ~= 0 then
  92.             if tardis.getDoors() ~= "CLOSED" then
  93.                 tardis.setDoors("CLOSED")
  94.             end
  95.             refueling = false
  96.         else
  97.             if not refueling then
  98.                 tardis.setRefuel(true)
  99.                 refueling = true
  100.                 modem.transmit(6408, 6407, "Landed")
  101.             end
  102.         end
  103.            
  104.         sleep(0.1)
  105.     end
  106. end
  107.  
  108. parallel.waitForAny(modemHandler, tardisHandler)
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement