BillBodkin

mine controller with advanced peripherals

Sep 13th, 2021 (edited)
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. -- pastebin get hVaGS1K6
  2.  
  3. local distanceWeight = -2
  4. local blockScoreWeight = 1
  5.  
  6. local controllerID = os.getComputerID()
  7.  
  8. local commands = {
  9.     ["default"] = {
  10.         ["minY"] = 2,
  11.         ["maxY"] = 12,
  12.         ["blockScores"] = {
  13.             --["minecraft:andesite"] = 100,
  14.             ["minecraft:diamond_ore"] = 10,
  15.             ["minecraft:gold_ore"] = 8,
  16.             ["minecraft:iron_ore"] = 5,
  17.             ["minecraft:coal_ore"] = 16,
  18.             ["minecraft:redstone_ore"] = 0.1,
  19.             ["minecraft:lapis_ore"] = 0.15,
  20.             ["minecraft:emerald_ore"] = 50,
  21.             ["minecraft:oak_log"] = 9,
  22.             ["minecraft:dark_oak_log"] = 9,
  23.             ["minecraft:birch_log"] = 9,
  24.             ["minecraft:jungle_log"] = 9,
  25.             ["minecraft:acaia_log"] = 9,
  26.             ["minecraft:nether_gold_ore"] = 5,
  27.             ["minecraft:nether_quartz_ore"] = 5,
  28.             ["minecraft:ancient_debris"] = 30,
  29.             ["minecraft:crying_obsidian"] = 31,
  30.             ["minecraft:obsidian"] = 1,
  31.             ["minecraft:glowstone"] = 15,
  32.             ["minecraft:sand"] = 3,
  33.             ["minecraft:soul_sand"] = 3
  34.         }
  35.     },
  36.     ["desertSand"] = {
  37.         ["minY"] = 80,
  38.         ["maxY"] = 120,
  39.         ["blockScores"] = {
  40.             ["minecraft:sand"] = 100
  41.         }
  42.     },
  43.     ["tree"] = {
  44.         ["minY"] = 60,
  45.         ["maxY"] = 100,
  46.         ["blockScores"] = {
  47.             ["minecraft:oak_log"] = 20,
  48.             ["minecraft:dark_oak_log"] = 20,
  49.             ["minecraft:birch_log"] = 20,
  50.             ["minecraft:jungle_log"] = 20,
  51.             ["minecraft:acaia_log"] = 20
  52.         }
  53.     }
  54. }
  55.  
  56. local IDs = {
  57.     [21] = "desertSand",
  58.     [19] = "tree"
  59. }
  60.  
  61. rednet.open("top")
  62.  
  63. local lastSeen = {}
  64.  
  65. print("Started controller")
  66.  
  67. while true do
  68.     local id, message = rednet.receive()
  69.     print("-----------------------------")
  70.     print("[" .. tostring(os.date()) .. "] Message from " .. id .. ": ")--textutils.formatTime
  71.     print(textutils.serialize(message))
  72.     print("-----------------------------")
  73.    
  74.     lastSeen[id] = message
  75.     local file = fs.open("lastSeen", "w")
  76.     file.write(textutils.serialize(lastSeen))
  77.     file.close()
  78.    
  79.     local toSend = commands["default"]
  80.    
  81.     if IDs[id] ~= nil then
  82.         toSend = commands[IDs[id]]
  83.     end
  84.    
  85.     toSend["timestamp"] = os.time()
  86.    
  87.     rednet.send(id, toSend)
  88. end
  89.  
Add Comment
Please, Sign In to add comment