robathome

fleet_agent

Oct 9th, 2026
20,371
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1.  
  2. -- FLEET AGENT v1.0
  3. -- CC:Tweaked
  4. -- Install on each turtle.
  5. -- Change SLOT to 1 through 6.
  6.  
  7. local SLOT = 1
  8. local PROTOCOL = "mountain_fleet_v1"
  9. local DEPLOY_DISTANCE = 3
  10. local HOME_FILE = "fleet_home.dat"
  11.  
  12. local id = os.getComputerID()
  13. local state = {
  14. slot = SLOT,
  15. status = "STARTING",
  16. steps = 0,
  17. home = nil,
  18. error = nil
  19. }
  20.  
  21. -- Open wireless modem
  22. local modemName = nil
  23.  
  24. for _, name in ipairs(peripheral.getNames()) do
  25. if peripheral.hasType(name, "modem") then
  26. local modem = peripheral.wrap(name)
  27. if modem.isWireless() then
  28. modemName = name
  29. break
  30. end
  31. end
  32. end
  33.  
  34. if not modemName then
  35. error("Wireless modem not found")
  36. end
  37.  
  38. rednet.open(modemName)
  39.  
  40. -- Persistent state
  41. local function saveHome()
  42. local f = fs.open(HOME_FILE, "w")
  43. f.write(textutils.serialize({
  44. home = state.home,
  45. steps = state.steps
  46. }))
  47. f.close()
  48. end
  49.  
  50. local function loadHome()
  51. if not fs.exists(HOME_FILE) then
  52. return false
  53. end
  54.  
  55. local f = fs.open(HOME_FILE, "r")
  56. local contents = f.readAll()
  57. f.close()
  58.  
  59. local data = textutils.unserialize(contents)
  60.  
  61. if type(data) ~= "table"
  62. or type(data.home) ~= "table"
  63. or type(data.steps) ~= "number" then
  64. return false
  65. end
  66.  
  67. state.home = data.home
  68. state.steps = data.steps
  69. return true
  70. end
  71.  
  72. local function locate()
  73. local x, y, z = gps.locate(2)
  74.  
  75. if not x then
  76. return nil
  77. end
  78.  
  79. return {
  80. x = math.floor(x + 0.5),
  81. y = math.floor(y + 0.5),
  82. z = math.floor(z + 0.5)
  83. }
  84. end
  85.  
  86. local function sendStatus()
  87. local position = locate()
  88.  
  89. rednet.broadcast({
  90. type = "status",
  91. slot = SLOT,
  92. id = id,
  93. status = state.status,
  94. position = position,
  95. home = state.home,
  96. steps = state.steps,
  97. fuel = turtle.getFuelLevel(),
  98. error = state.error
  99. }, PROTOCOL)
  100. end
  101.  
  102. -- Initialize the dock record.
  103. if not loadHome() then
  104. local position = locate()
  105.  
  106. if not position then
  107. error("GPS unavailable. Dock not saved.")
  108. end
  109.  
  110. state.home = position
  111. state.steps = 0
  112. saveHome()
  113. end
  114.  
  115. if state.steps == 0 then
  116. state.status = "DOCKED"
  117. else
  118. state.status = "ACTIVE"
  119. end
  120.  
  121. local function deploy()
  122. if state.steps > 0 then
  123. state.error = "Already deployed"
  124. sendStatus()
  125. return
  126. end
  127.  
  128. local current = locate()
  129.  
  130. if not current or not state.home
  131. or current.x ~= state.home.x
  132. or current.y ~= state.home.y
  133. or current.z ~= state.home.z then
  134. state.status = "ERROR"
  135. state.error = "Dock position mismatch"
  136. sendStatus()
  137. return
  138. end
  139.  
  140. state.status = "DEPLOYING"
  141. state.error = nil
  142. sendStatus()
  143.  
  144. while state.steps < DEPLOY_DISTANCE do
  145. if turtle.forward() then
  146. state.steps = state.steps + 1
  147. saveHome()
  148. sendStatus()
  149. else
  150. state.status = "BLOCKED"
  151. state.error = "Forward path blocked"
  152. sendStatus()
  153. return
  154. end
  155. end
  156.  
  157. state.status = "ACTIVE"
  158. sendStatus()
  159. end
  160.  
  161. local function recall()
  162. state.error = nil
  163.  
  164. if state.steps == 0 then
  165. state.status = "DOCKED"
  166. sendStatus()
  167. return
  168. end
  169.  
  170. state.status = "RETURNING"
  171. sendStatus()
  172.  
  173. while state.steps > 0 do
  174. if turtle.back() then
  175. state.steps = state.steps - 1
  176. saveHome()
  177. sendStatus()
  178. else
  179. state.status = "BLOCKED"
  180. state.error = "Return path blocked"
  181. sendStatus()
  182. return
  183. end
  184. end
  185.  
  186. local current = locate()
  187. local home = state.home
  188.  
  189. if current and home
  190. and current.x == home.x
  191. and current.y == home.y
  192. and current.z == home.z then
  193. state.status = "DOCKED"
  194. else
  195. state.status = "ERROR"
  196. state.error = "Dock GPS verification failed"
  197. end
  198.  
  199. sendStatus()
  200. end
  201.  
  202. -- Start communications
  203. print("Fleet Turtle " .. SLOT)
  204. print("Computer ID: " .. id)
  205. print("Modem: " .. modemName)
  206. print("GPS home registered")
  207.  
  208. sendStatus()
  209.  
  210. local heartbeat = os.startTimer(3)
  211.  
  212. while true do
  213. local event, a, b, c = os.pullEvent()
  214.  
  215. if event == "timer" and a == heartbeat then
  216. sendStatus()
  217. heartbeat = os.startTimer(3)
  218.  
  219. elseif event == "rednet_message" then
  220. local sender = a
  221. local message = b
  222. local protocol = c
  223.  
  224. if protocol == PROTOCOL
  225. and type(message) == "table"
  226. and message.type == "command"
  227. and message.slot == SLOT then
  228.  
  229. if message.action == "deploy" then
  230. deploy()
  231.  
  232. elseif message.action == "recall" then
  233. recall()
  234.  
  235. elseif message.action == "ping" then
  236. sendStatus()
  237. end
  238. end
  239. end
  240. end
  241.  
Advertisement
Comments
  • CEO_Queen
    14 days
    # text 0.03 KB | 0 0
    1. Nice brother, do you have telegram?
  • Monqexni
    6 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=baazahxrfy
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment