Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Hive Maintenance
- -- ----------------------------------------------------------
- -- Tries to keep my barrels stocked with "real" resources, so's
- -- I don't have to worry about converting combs etc myself.
- -- ----------------------------------------------------------
- -- Initialise important values:
- -- ----------------------------------------------------------
- -- Number of inventory servers (that should be) online:
- local invServerCount = 2
- -- Job timer IDs. [1] = furnace, [2] = centrifuge, [3] = pulveriser, [4] = casings, [5] = panels, [6] = pearls, [7] = magma.
- local worktimer = {}
- for i=1,7 do worktimer[i] = 0 end
- -- Misc stuff.
- local facing = {"north","east","south","west"}
- local invServer, job = {}, {}
- local direction, curnode, x, y, z, pathList, report
- -- First three indexes are co-ords. All thereafter are linked nodes.
- local node = {{241,422,58, 2,3}, -- 1, barrel central.
- {244,422,57, 1,3,4}, -- 2, processed resource dropoff.
- {244,419,57, 1,2}, -- 3, machine central.
- {242,430,57, 2}} -- 4, chopper programming point.
- -- Basic machine tasks.
- local machine = {
- -- Centrifuge:
- {["waypoint"] = {{245,417,58}}, ["time"] = 5.25, ["task"] = "centrifuge",
- {"Simmering Comb (13360:2)",{"Phosphor (13324:0)","Refractory Wax (13325:0)"}},
- {"Seedy Comb (8776:9)",{"Honey Drop (13283:0)","Nutdew (8786:7)"}},
- {"Dripping Comb (13360:5)",{"Honey Drop (13283:0)","Honeydew (13289:0)"}},
- {"Earthy Comb (26090:14)",{"Magic Wax (26091:0)","Clay (337:0)"}},
- {"Energetic Comb (8776:12)",{"Honey Drop (13283:0)","Beeswax (13285:0)","Redstone (331:0)"}},
- {"Mysterious Comb (13360:8)",{"Honey Drop (13283:0)","Pulsating Propolis (13287:2)"}},
- {"Iron Comb (8776:15)",{"Honey Drop (13283:0)","Beeswax (13285:0)","Iron Grains (8829:6)"}},
- {"Copper Comb (8776:17)",{"Honey Drop (13283:0)","Beeswax (13285:0)","Copper Grains (8829:10)"}},
- {"Tin Comb (8776:18)",{"Honey Drop (13283:0)","Beeswax (13285:0)","Tin Grains (8829:11)"}},
- {"Golden Comb (8776:16)",{"Honey Drop (13283:0)","Beeswax (13285:0)","Gold Grains (8829:7)"}},
- {"Lapis Comb (8776:46)",{"Honey Drop (13283:0)","Beeswax (13285:0)","Lapis Lazuli (351:4)"}},
- {"Diamond Comb (8776:56)",{"Honey Drop (13283:0)","Beeswax (13285:0)","Diamond Fragment (8829:1)"}},
- {"Emerald Comb (8776:52)",{"Honey Drop (13283:0)","Beeswax (13285:0)","Emerald Fragment (8829:2)"}},
- {"Uranium Comb (8776:21)",{"Honey Drop (13283:0)","Beeswax (13285:0)","ic2.itemCrushedUranOre (30064:4)"}},
- {"Mellow Comb (13360:16)",{"Honeydew (13289:0)","Beeswax (13285:0)","Nether Quartz (406:0)"}}},
- -- Furnace:
- {["waypoint"] = {{246,417,58}}, ["time"] = 4, ["task"] = "furnace",
- {"ic2.itemDustIron (30066:5)","Iron Ingot (265:0)"},
- {"ic2.itemDustCopper (30066:3)","Copper Ingot (20264:64)"},
- {"ic2.itemDustTin (30066:7)","Tin Ingot (20264:65)"},
- {"ic2.itemDustGold (30066:4)","Gold Ingot (266:0)"},
- {"Block of Quartz (155:0)","tile.extrautils:decorativeBlock1.2.name (2523:2)"},
- {"Wheat Flour (12660:2)","Bread (297:0)"},
- {"Sand (12:0)","Glass (20:0)"},
- {"Clay (337:0)","Brick (336:0)"},
- {"Clay (82:0)","Hardened Clay (172:0)"}},
- -- Pulverisor:
- {["waypoint"] = {{249,418,58},{249,417,58}}, ["time"] = 4, ["task"] = "pulverise",
- {"Cobblestone (4:0)",{"Sand (12:0)","Gravel (13:0)"}}}}
- for i=1,#machine do machine[i].current = 1 end
- -- Carpenter specifics.
- local carpenter = {
- {["making"] = "Impregnated Casing (13380:0)", ["max"] = 4096,
- ["sX"] = 247, ["sY"] = 418, ["sZ"] = 57, ["sContent"] = {"Seeds (295:0)","Nutdew (8786:7)"},
- ["cX"] = 248, ["cY"] = 418, ["cZ"] = 57, ["cContent"] =
- {"Oak Wood (17:0)","Oak Wood (17:0)","Oak Wood (17:0)","Oak Wood (17:0)",
- "Oak Wood (17:0)","Oak Wood (17:0)","Oak Wood (17:0)","Oak Wood (17:0)",
- "Oak Wood (17:0)","Oak Wood (17:0)","Oak Wood (17:0)","Oak Wood (17:0)",
- "Oak Wood (17:0)","Oak Wood (17:0)","Oak Wood (17:0)","Oak Wood (17:0)"}},
- {["making"] = "Scented Paneling (13354:6)", ["max"] = 4096,
- ["sX"] = 250, ["sY"] = 418, ["sZ"] = 57, ["sContent"] = {"Honey Drop (13283:0)","Honeydew (13289:0)"},
- ["cX"] = 251, ["cY"] = 418, ["cZ"] = 57, ["cContent"] =
- {"Jungle Wood Planks (5:3)","Jungle Wood Planks (5:3)","Jungle Wood Planks (5:3)",
- "Jungle Wood Planks (5:3)","Jungle Wood Planks (5:3)","Jungle Wood Planks (5:3)",
- "Beeswax (13285:0)","Beeswax (13285:0)","Beeswax (13285:0)","Beeswax (13285:0)",
- "Pollen (13286:0)","Pollen (13286:0)","Royal Jelly (13288:0)","Royal Jelly (13288:0)"}},
- {["making"] = "Ender Pearl (368:0)", ["max"] = 1024,
- ["cX"] = 252, ["cY"] = 418, ["cZ"] = 57, ["cContent"] =
- {"Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)",
- "Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)",
- "Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)",
- "Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)","Pulsating Mesh (13354:1)"}}}
- -- Stuff to craft.
- local craft = {["current"] = 1,
- {"tile.alveary.0 (1382:0)",
- {{"Scented Paneling (13354:6)","Scented Paneling (13354:6)","Scented Paneling (13354:6)"},
- {"Scented Paneling (13354:6)","Impregnated Casing (13380:0)","Scented Paneling (13354:6)"},
- {"Scented Paneling (13354:6)","Scented Paneling (13354:6)","Scented Paneling (13354:6)"}}},
- {"Wheat Flour (12660:2)",
- {{"Wheat (296:0)"}}},
- {"Block of Redstone (152:0)",
- {{"Redstone (331:0)","Redstone (331:0)","Redstone (331:0)"},
- {"Redstone (331:0)","Redstone (331:0)","Redstone (331:0)"},
- {"Redstone (331:0)","Redstone (331:0)","Redstone (331:0)"}}},
- {"Glowstone (89:0)",
- {{"Glowstone Dust (348:0)","Glowstone Dust (348:0)"},
- {"Glowstone Dust (348:0)","Glowstone Dust (348:0)"}}},
- {"ic2.itemDustIron (30066:5)",
- {{"Iron Grains (8829:6)","Iron Grains (8829:6)"},
- {"Iron Grains (8829:6)","Iron Grains (8829:6)"}}},
- {"ic2.itemDustCopper (30066:3)",
- {{"Copper Grains (8829:10)","Copper Grains (8829:10)"},
- {"Copper Grains (8829:10)","Copper Grains (8829:10)"}}},
- {"ic2.itemDustTin (30066:7)",
- {{"Tin Grains (8829:11)","Tin Grains (8829:11)"},
- {"Tin Grains (8829:11)","Tin Grains (8829:11)"}}},
- {"ic2.itemDustGold (30066:4)",
- {{"Gold Grains (8829:7)","Gold Grains (8829:7)"},
- {"Gold Grains (8829:7)","Gold Grains (8829:7)"}}},
- {"Lapis Lazuli Block (22:0)",
- {{"Lapis Lazuli (351:4)","Lapis Lazuli (351:4)","Lapis Lazuli (351:4)"},
- {"Lapis Lazuli (351:4)","Lapis Lazuli (351:4)","Lapis Lazuli (351:4)"},
- {"Lapis Lazuli (351:4)","Lapis Lazuli (351:4)","Lapis Lazuli (351:4)"}}},
- {"Emerald (388:0)",
- {{"Emerald Fragment (8829:2)","Emerald Fragment (8829:2)","Emerald Fragment (8829:2)"},
- {"Emerald Fragment (8829:2)","Emerald Fragment (8829:2)","Emerald Fragment (8829:2)"},
- {"Emerald Fragment (8829:2)","Emerald Fragment (8829:2)","Emerald Fragment (8829:2)"}}},
- {"Apatite",
- {{"Apatite Shard (26120:7)","Apatite Shard (26120:7)","Apatite Shard (26120:7)"},
- {"Apatite Shard (26120:7)","Apatite Shard (26120:7)","Apatite Shard (26120:7)"},
- {"Apatite Shard (26120:7)","Apatite Shard (26120:7)","Apatite Shard (26120:7)"}}},
- {"Block of Quartz (155:0)",
- {{"Nether Quartz (406:0)","Nether Quartz (406:0)"},
- {"Nether Quartz (406:0)","Nether Quartz (406:0)"}}},
- {"Smokey Quartz (22406:0)",
- {{"Nether Quartz (406:0)","Nether Quartz (406:0)","Nether Quartz (406:0)"},
- {"Nether Quartz (406:0)","Charcoal (263:1)","Nether Quartz (406:0)"},
- {"Nether Quartz (406:0)","Nether Quartz (406:0)","Nether Quartz (406:0)"}},8},
- {"Block of Smokey Quartz (2615:0)",
- {{"Smokey Quartz (22406:0)","Smokey Quartz (22406:0)"},
- {"Smokey Quartz (22406:0)","Smokey Quartz (22406:0)"}}},
- {"ic2.itemPartIndustrialDiamond (30135:0)",
- {{"Diamond Fragment (8829:1)","Diamond Fragment (8829:1)","Diamond Fragment (8829:1)"},
- {"Diamond Fragment (8829:1)","Diamond Fragment (8829:1)","Diamond Fragment (8829:1)"},
- {"Diamond Fragment (8829:1)","Diamond Fragment (8829:1)","Diamond Fragment (8829:1)"}}},
- {"Diamond (264:0)",
- {{"ic2.itemPartIndustrialDiamond (30135:0)"}}},
- {"Stone Bricks (98:0)",
- {{"Stone (1:0)","Stone (1:0)"},
- {"Stone (1:0)","Stone (1:0)"}},4},
- {"Chiseled Stone Bricks (98:3)",
- {{"Stone Bricks (98:0)","Stone Bricks (98:0)"},
- {"Stone Bricks (98:0)","Stone Bricks (98:0)"}}},
- {"Stone Slab (44:0)",
- {{"Stone (1:0)","Stone (1:0)","Stone (1:0)"}},6},
- {"Stone Slab (43:0)",
- {{"Stone Slab (44:0)"},
- {"Stone Slab (44:0)"}}},
- {"Stone Slab (43:8)",
- {{"Stone Slab (43:0)","Stone Slab (43:0)"},
- {"Stone Slab (43:0)","Stone Slab (43:0)"}},4},
- {"tile.extrautils:decorativeBlock1.0.name (2523:0)",
- {{"Stone (1:0)","Stone Bricks (98:0)","Stone (1:0)"},
- {"Stone Bricks (98:0)","Stone Bricks (98:0)","Stone Bricks (98:0)"},
- {"Stone (1:0)","Stone Bricks (98:0)","Stone (1:0)"}},9},
- {"tile.extrautils:decorativeBlock1.4.name (2523:4)",
- {{"tile.extrautils:decorativeBlock1.0.name (2523:0)","tile.extrautils:decorativeBlock1.0.name (2523:0)"},
- {"tile.extrautils:decorativeBlock1.0.name (2523:0)","tile.extrautils:decorativeBlock1.0.name (2523:0)"}},4},
- {"tile.extrautils:decorativeBlock1.7.name (2523:7)",
- {{"tile.extrautils:decorativeBlock1.4.name (2523:4)","tile.extrautils:decorativeBlock1.4.name (2523:4)"},
- {"tile.extrautils:decorativeBlock1.4.name (2523:4)","tile.extrautils:decorativeBlock1.4.name (2523:4)"}},4},
- {"Pillar Quartz Block (155:2)",
- {{"Block of Quartz (155:0)"},
- {"Block of Quartz (155:0)"}},2},
- {"Quartz Slab (44:7)",
- {{"Block of Quartz (155:0)","Block of Quartz (155:0)","Block of Quartz (155:0)"}},6},
- {"Chiseled Quartz Block (155:1)",
- {{"Quartz Slab (44:7)"},
- {"Quartz Slab (44:7)"}}},
- {"Pillar Smokey Quartz Block (2615:2)",
- {{"Block of Smokey Quartz (2615:0)"},
- {"Block of Smokey Quartz (2615:0)"}},2},
- {"Smokey Quartz Slab (2616:0)",
- {{"Block of Smokey Quartz (2615:0)","Block of Smokey Quartz (2615:0)","Block of Smokey Quartz (2615:0)"}},6},
- {"Chiseled Smokey Quartz Block (2615:1)",
- {{"Smokey Quartz Slab (2616:0)"},
- {"Smokey Quartz Slab (2616:0)"}}},
- {"Wax Capsule (13290:0)",
- {{"Beeswax (13285:0)","Beeswax (13285:0)","Beeswax (13285:0)"}},4},
- {"Ambrosia (13293:0)",
- {{"Honeydew (13289:0)","Wax Capsule (13290:0)","Honeydew (13289:0)"},
- {"Royal Jelly (13288:0)","Royal Jelly (13288:0)","Royal Jelly (13288:0)"},
- {"Honeydew (13289:0)","Honeydew (13289:0)","Honeydew (13289:0)"}}},
- {"Honeyed Slice (13291:0)",
- {{"Honey Drop (13283:0)","Honey Drop (13283:0)","Honey Drop (13283:0)"},
- {"Honey Drop (13283:0)","Bread (297:0)","Honey Drop (13283:0)"},
- {"Honey Drop (13283:0)","Honey Drop (13283:0)","Honey Drop (13283:0)"}},4},
- {"ic2.itemFuelPlantBall (30224:0)",
- {{"Wheat (296:0)","Wheat (296:0)","Wheat (296:0)"},
- {"Wheat (296:0)","","Wheat (296:0)"},
- {"Wheat (296:0)","Wheat (296:0)","Wheat (296:0)"}},4},
- {"Oak Wood Planks (5:0)",
- {{"Oak Wood (17:0)"}},4},
- {"Oak Wood Slab (126:0)",
- {{"Oak Wood Planks (5:0)","Oak Wood Planks (5:0)","Oak Wood Planks (5:0)"}},6},
- {"Jungle Wood Planks (5:3)",
- {{"tile.mfr.rubberwood.log.name (3122:0)"}},3},
- {"Jungle Wood Slab (126:3)",
- {{"Jungle Wood Planks (5:3)","Jungle Wood Planks (5:3)","Jungle Wood Planks (5:3)"}},6},
- {"Cherry Wood Planks (1947:1)",
- {{"Cherry Wood (1933:1)"}},4},
- {"Cherry Wood Slab (1949:1)",
- {{"Cherry Wood Planks (1947:1)","Cherry Wood Planks (1947:1)","Cherry Wood Planks (1947:1)"}},6},
- {"Stick (280:0)",
- {{"Cherry Wood Planks (1947:1)"},
- {"Cherry Wood Planks (1947:1)"}},4},
- {"Fence (85:0)",
- {{"Stick (280:0)","Stick (280:0)","Stick (280:0)"},
- {"Stick (280:0)","Stick (280:0)","Stick (280:0)"}},2},
- {"Ladder (65:0)",
- {{"Stick (280:0)","","Stick (280:0)"},
- {"Stick (280:0)","Stick (280:0)","Stick (280:0)"},
- {"Stick (280:0)","","Stick (280:0)"}},3},
- {"Glass Pane (102:0)",
- {{"Glass (20:0)","Glass (20:0)","Glass (20:0)"},
- {"Glass (20:0)","Glass (20:0)","Glass (20:0)"}},16},
- {"Sandstone (24:0)",
- {{"Sand (12:0)","Sand (12:0)"},
- {"Sand (12:0)","Sand (12:0)"}}},
- {"Smooth Sandstone (24:2)",
- {{"Sandstone (24:0)","Sandstone (24:0)"},
- {"Sandstone (24:0)","Sandstone (24:0)"}},4},
- {"Sandstone Slab (44:1)",
- {{"Sandstone (24:0)","Sandstone (24:0)","Sandstone (24:0)"}},6},
- {"Chiseled Sandstone (24:1)",
- {{"Sandstone Slab (44:1)"},
- {"Sandstone Slab (44:1)"}}},
- {"Stone Bricks Slab (44:5)",
- {{"Stone Bricks (98:0)","Stone Bricks (98:0)","Stone Bricks (98:0)"}},6},
- {"tile.extrautils:decorativeBlock1.6.name (2523:6)",
- {{"Gravel (13:0)","Gravel (13:0)"},
- {"Gravel (13:0)","Gravel (13:0)"}}},
- {"tile.extrautils:decorativeBlock1.10.name (2523:10)",
- {{"Stone Bricks Slab (44:5)","tile.extrautils:decorativeBlock1.6.name (2523:6)","Stone Bricks Slab (44:5)"},
- {"tile.extrautils:decorativeBlock1.6.name (2523:6)","tile.extrautils:decorativeBlock1.6.name (2523:6)","tile.extrautils:decorativeBlock1.6.name (2523:6)"},
- {"Stone Bricks Slab (44:5)","tile.extrautils:decorativeBlock1.6.name (2523:6)","Stone Bricks Slab (44:5)"}},8},
- {"Pulsating Mesh (13354:1)",
- {{"Pulsating Propolis (13287:2)","","Pulsating Propolis (13287:2)"},
- {"","Pulsating Propolis (13287:2)",""},
- {"Pulsating Propolis (13287:2)","","Pulsating Propolis (13287:2)"}}},
- {"item.ccwirelessmodem.name (1226:1)",
- {{"Stone (1:0)","Stone (1:0)","Stone (1:0)"},
- {"Stone (1:0)","Ender Pearl (368:0)","Stone (1:0)"},
- {"Stone (1:0)","Stone (1:0)","Stone (1:0)"}}},
- {"Chest (54:0)",
- {{"Oak Wood Planks (5:0)","Oak Wood Planks (5:0)","Oak Wood Planks (5:0)"},
- {"Oak Wood Planks (5:0)","","Oak Wood Planks (5:0)"},
- {"Oak Wood Planks (5:0)","Oak Wood Planks (5:0)","Oak Wood Planks (5:0)"}}},
- {"item.computer.name (1225:0)",
- {{"Stone (1:0)","Stone (1:0)","Stone (1:0)"},
- {"Stone (1:0)","Redstone (331:0)","Stone (1:0)"},
- {"Stone (1:0)","Glass Pane (102:0)","Stone (1:0)"}}},
- {"Turtle (1227:0)",
- {{"Iron Ingot (265:0)","Iron Ingot (265:0)","Iron Ingot (265:0)"},
- {"Iron Ingot (265:0)","item.computer.name (1225:0)","Iron Ingot (265:0)"},
- {"Iron Ingot (265:0)","Chest (54:0)","Iron Ingot (265:0)"}}},
- {"Stone Tool Rod (14277:1)",
- {{"Stone (1:0)"},
- {"Stone (1:0)"}},4},
- {"Torch (1484:0)",
- {{"item.mfr.rubber.raw.name (12258:0)"},
- {"Stone Tool Rod (14277:1)"}},4},
- {"Clay (82:0)",
- {{"Clay (337:0)","Clay (337:0)"},
- {"Clay (337:0)","Clay (337:0)"}}},
- {"Bricks (45:0)",
- {{"Brick (336:0)","Brick (336:0)"},
- {"Brick (336:0)","Brick (336:0)"}}},
- {"tile.mfr.decorativebrick.pavedstone.name (3133:4)",
- {{"Stone Slab (44:0)","","Stone Slab (44:0)"},
- {"","Bricks (45:0)",""},
- {"Stone Slab (44:0)","","Stone Slab (44:0)"}},8},
- {"tile.mfr.decorativebrick.glowstone.name (3133:1)",
- {{"Glowstone (89:0)","","Glowstone (89:0)"},
- {"","Bricks (45:0)",""},
- {"Glowstone (89:0)","","Glowstone (89:0)"}},8}}
- local barrel = {
- ["Honey Drop (13283:0)"] = {["x"] = 239, ["y"] = 427, ["z"] = 58},
- ["Honeydew (13289:0)"] = {["x"] = 238, ["y"] = 427, ["z"] = 58},
- ["Beeswax (13285:0)"] = {["x"] = 237, ["y"] = 427, ["z"] = 58},
- ["Royal Jelly (13288:0)"] = {["x"] = 236, ["y"] = 427, ["z"] = 58},
- ["Pollen (13286:0)"] = {["x"] = 235, ["y"] = 427, ["z"] = 58},
- ["Glowstone Dust (348:0)"] = {["x"] = 234, ["y"] = 427, ["z"] = 58},
- ["Glowstone (89:0)"] = {["x"] = 233, ["y"] = 427, ["z"] = 58},
- ["Refractory Wax (13325:0)"] = {["x"] = 232, ["y"] = 427, ["z"] = 58},
- ["ic2.itemCrushedUranOre (30064:4)"] = {["x"] = 231, ["y"] = 427, ["z"] = 58},
- ["Redstone (331:0)"] = {["x"] = 230, ["y"] = 427, ["z"] = 58},
- ["Block of Redstone (152:0)"] = {["x"] = 229, ["y"] = 427, ["z"] = 58},
- ["Propolis (13287:0)"] = {["x"] = 228, ["y"] = 427, ["z"] = 58},
- ["Iron Grains (8829:6)"] = {["x"] = 227, ["y"] = 427, ["z"] = 58},
- ["ic2.itemDustIron (30066:5)"] = {["x"] = 226, ["y"] = 427, ["z"] = 58},
- ["Iron Ingot (265:0)"] = {["x"] = 225, ["y"] = 427, ["z"] = 58},
- ["Copper Grains (8829:10)"] = {["x"] = 224, ["y"] = 427, ["z"] = 58},
- ["ic2.itemDustCopper (30066:3)"] = {["x"] = 223, ["y"] = 427, ["z"] = 58},
- ["Copper Ingot (20264:64)"] = {["x"] = 222, ["y"] = 427, ["z"] = 58},
- ["Tin Grains (8829:11)"] = {["x"] = 221, ["y"] = 427, ["z"] = 58},
- ["ic2.itemDustTin (30066:7)"] = {["x"] = 220, ["y"] = 427, ["z"] = 58},
- ["Tin Ingot (20264:65)"] = {["x"] = 219, ["y"] = 427, ["z"] = 58},
- ["Gold Grains (8829:7)"] = {["x"] = 218, ["y"] = 427, ["z"] = 58},
- ["ic2.itemDustGold (30066:4)"] = {["x"] = 217, ["y"] = 427, ["z"] = 58},
- ["Gold Ingot (266:0)"] = {["x"] = 216, ["y"] = 427, ["z"] = 58},
- ["Lapis Lazuli (351:4)"] = {["x"] = 215, ["y"] = 427, ["z"] = 58},
- ["Lapis Lazuli Block (22:0)"] = {["x"] = 214, ["y"] = 427, ["z"] = 58},
- ["Emerald Fragment (8829:2)"] = {["x"] = 213, ["y"] = 427, ["z"] = 58},
- ["Emerald (388:0)"] = {["x"] = 212, ["y"] = 427, ["z"] = 58},
- ["Apatite Shard (26120:7)"] = {["x"] = 211, ["y"] = 427, ["z"] = 58},
- ["Nether Quartz (406:0)"] = {["x"] = 210, ["y"] = 427, ["z"] = 58},
- ["Diamond Fragment (8829:1)"] = {["x"] = 209, ["y"] = 427, ["z"] = 58},
- ["ic2.itemPartIndustrialDiamond (30135:0)"] = {["x"] = 208, ["y"] = 427, ["z"] = 58},
- ["Diamond (264:0)"] = {["x"] = 208, ["y"] = 427, ["z"] = 60},
- ["Ender Pearl (368:0)"] = {["x"] = 209, ["y"] = 427, ["z"] = 60},
- ["Pulsating Mesh (13354:1)"] = {["x"] = 210, ["y"] = 427, ["z"] = 60},
- ["Pulsating Propolis (13287:2)"] = {["x"] = 211, ["y"] = 427, ["z"] = 60},
- ["Chest (54:0)"] = {["x"] = 212, ["y"] = 427, ["z"] = 60},
- ["item.ccwirelessmodem.name (1226:1)"] = {["x"] = 213, ["y"] = 427, ["z"] = 60},
- ["Turtle (1227:0)"] = {["x"] = 214, ["y"] = 427, ["z"] = 60},
- ["item.computer.name (1225:0)"] = {["x"] = 215, ["y"] = 427, ["z"] = 60},
- ["Nutdew (8786:7)"] = {["x"] = 216, ["y"] = 427, ["z"] = 60},
- ["tile.mfr.decorativebrick.glowstone.name (3133:1)"] = {["x"] = 217, ["y"] = 427, ["z"] = 60},
- ["tile.mfr.decorativebrick.pavedstone.name (3133:4)"] = {["x"] = 218, ["y"] = 427, ["z"] = 60},
- ["Bricks (45:0)"] = {["x"] = 219, ["y"] = 427, ["z"] = 60},
- ["Brick (336:0)"] = {["x"] = 220, ["y"] = 427, ["z"] = 60},
- ["Hardened Clay (172:0)"] = {["x"] = 221, ["y"] = 427, ["z"] = 60},
- ["Clay (82:0)"] = {["x"] = 222, ["y"] = 427, ["z"] = 60},
- ["Clay (337:0)"] = {["x"] = 223, ["y"] = 427, ["z"] = 60},
- ["Magic Wax (26091:0)"] = {["x"] = 224, ["y"] = 427, ["z"] = 60},
- ["Mellow Comb (13360:16)"] = {["x"] = 225, ["y"] = 427, ["z"] = 60},
- ["Uranium Comb (8776:21)"] = {["x"] = 226, ["y"] = 427, ["z"] = 60},
- ["Emerald Comb (8776:52)"] = {["x"] = 227, ["y"] = 427, ["z"] = 60},
- ["Diamond Comb (8776:56)"] = {["x"] = 228, ["y"] = 427, ["z"] = 60},
- ["Lapis Comb (8776:46)"] = {["x"] = 229, ["y"] = 427, ["z"] = 60},
- ["Golden Comb (8776:16)"] = {["x"] = 230, ["y"] = 427, ["z"] = 60},
- ["Tin Comb (8776:18)"] = {["x"] = 231, ["y"] = 427, ["z"] = 60},
- ["Copper Comb (8776:17)"] = {["x"] = 232, ["y"] = 427, ["z"] = 60},
- ["Iron Comb (8776:15)"] = {["x"] = 233, ["y"] = 427, ["z"] = 60},
- ["Mysterious Comb (13360:8)"] = {["x"] = 234, ["y"] = 427, ["z"] = 60},
- ["Energetic Comb (8776:12)"] = {["x"] = 235, ["y"] = 427, ["z"] = 60},
- ["Simmering Comb (13360:2)"] = {["x"] = 236, ["y"] = 427, ["z"] = 60},
- ["Earthy Comb (26090:14)"] = {["x"] = 237, ["y"] = 427, ["z"] = 60},
- ["Dripping Comb (13360:5)"] = {["x"] = 238, ["y"] = 427, ["z"] = 60},
- ["Seedy Comb (8776:9)"] = {["x"] = 239, ["y"] = 427, ["z"] = 60},
- ["Cobblestone (4:0)"] = {["x"] = 239, ["y"] = 420, ["z"] = 60},
- ["Stone (1:0)"] = {["x"] = 238, ["y"] = 420, ["z"] = 60},
- ["Stone Bricks (98:0)"] = {["x"] = 237, ["y"] = 420, ["z"] = 60},
- ["Chiseled Stone Bricks (98:3)"] = {["x"] = 236, ["y"] = 420, ["z"] = 60},
- ["Stone Slab (44:0)"] = {["x"] = 235, ["y"] = 420, ["z"] = 60},
- ["Stone Slab (43:0)"] = {["x"] = 234, ["y"] = 420, ["z"] = 60},
- ["Stone Slab (43:8)"] = {["x"] = 233, ["y"] = 420, ["z"] = 60},
- ["tile.extrautils:decorativeBlock1.0.name (2523:0)"] = {["x"] = 232, ["y"] = 420, ["z"] = 60},
- ["tile.extrautils:decorativeBlock1.4.name (2523:4)"] = {["x"] = 231, ["y"] = 420, ["z"] = 60},
- ["tile.extrautils:decorativeBlock1.7.name (2523:7)"] = {["x"] = 230, ["y"] = 420, ["z"] = 60},
- ["tile.extrautils:decorativeBlock1.2.name (2523:2)"] = {["x"] = 229, ["y"] = 420, ["z"] = 60},
- ["Block of Quartz (155:0)"] = {["x"] = 228, ["y"] = 420, ["z"] = 60},
- ["Pillar Quartz Block (155:2)"] = {["x"] = 227, ["y"] = 420, ["z"] = 60},
- ["Quartz Slab (44:7)"] = {["x"] = 226, ["y"] = 420, ["z"] = 60},
- ["Chiseled Quartz Block (155:1)"] = {["x"] = 225, ["y"] = 420, ["z"] = 60},
- ["Block of Smokey Quartz (2615:0)"] = {["x"] = 224, ["y"] = 420, ["z"] = 60},
- ["Pillar Smokey Quartz Block (2615:2)"] = {["x"] = 223, ["y"] = 420, ["z"] = 60},
- ["Smokey Quartz Slab (2616:0)"] = {["x"] = 222, ["y"] = 420, ["z"] = 60},
- ["Chiseled Smokey Quartz Block (2615:1)"] = {["x"] = 221, ["y"] = 420, ["z"] = 60},
- ["Smokey Quartz (22406:0)"] = {["x"] = 220, ["y"] = 420, ["z"] = 60},
- ["tile.alveary.0 (1382:0)"] = {["x"] = 219, ["y"] = 420, ["z"] = 60},
- ["Scented Paneling (13354:6)"] = {["x"] = 218, ["y"] = 420, ["z"] = 60},
- ["Impregnated Casing (13380:0)"] = {["x"] = 217, ["y"] = 420, ["z"] = 60},
- ["ic2.itemFuelPlantBall (30224:0)"] = {["x"] = 216, ["y"] = 420, ["z"] = 60},
- ["Apple (260:0)"] = {["x"] = 215, ["y"] = 420, ["z"] = 60},
- ["Ambrosia (13293:0)"] = {["x"] = 214, ["y"] = 420, ["z"] = 60},
- ["Wax Capsule (13290:0)"] = {["x"] = 213, ["y"] = 420, ["z"] = 60},
- ["Honeyed Slice (13291:0)"] = {["x"] = 212, ["y"] = 420, ["z"] = 60},
- ["Bread (297:0)"] = {["x"] = 211, ["y"] = 420, ["z"] = 60},
- ["Wheat Flour (12660:2)"] = {["x"] = 210, ["y"] = 420, ["z"] = 60},
- ["Wheat (296:0)"] = {["x"] = 209, ["y"] = 420, ["z"] = 60},
- ["Seeds (295:0)"] = {["x"] = 208, ["y"] = 420, ["z"] = 60},
- ["Oak Sapling (6:0)"] = {["x"] = 208, ["y"] = 420, ["z"] = 58},
- ["Oak Wood (17:0)"] = {["x"] = 209, ["y"] = 420, ["z"] = 58},
- ["Oak Wood Planks (5:0)"] = {["x"] = 210, ["y"] = 420, ["z"] = 58},
- ["Oak Wood Slab (126:0)"] = {["x"] = 211, ["y"] = 420, ["z"] = 58},
- ["tile.mfr.rubberwood.sapling.name (3124:0)"] = {["x"] = 212, ["y"] = 420, ["z"] = 58},
- ["tile.mfr.rubberwood.log.name (3122:0)"] = {["x"] = 213, ["y"] = 420, ["z"] = 58},
- ["Jungle Wood Planks (5:3)"] = {["x"] = 214, ["y"] = 420, ["z"] = 58},
- ["Jungle Wood Slab (126:3)"] = {["x"] = 215, ["y"] = 420, ["z"] = 58},
- ["Pink Cherry Sapling (1937:10)"] = {["x"] = 216, ["y"] = 420, ["z"] = 58},
- ["Cherry Wood (1933:1)"] = {["x"] = 217, ["y"] = 420, ["z"] = 58},
- ["Cherry Wood Planks (1947:1)"] = {["x"] = 218, ["y"] = 420, ["z"] = 58},
- ["Cherry Wood Slab (1949:1)"] = {["x"] = 219, ["y"] = 420, ["z"] = 58},
- ["Stick (280:0)"] = {["x"] = 220, ["y"] = 420, ["z"] = 58},
- ["item.mfr.rubber.raw.name (12258:0)"] = {["x"] = 221, ["y"] = 420, ["z"] = 58},
- ["Charcoal (263:1)"] = {["x"] = 222, ["y"] = 420, ["z"] = 58},
- ["Ladder (65:0)"] = {["x"] = 223, ["y"] = 420, ["z"] = 58},
- ["Fence (85:0)"] = {["x"] = 224, ["y"] = 420, ["z"] = 58},
- ["Stone Tool Rod (14277:1)"] = {["x"] = 225, ["y"] = 420, ["z"] = 58},
- ["Torch (1484:0)"] = {["x"] = 226, ["y"] = 420, ["z"] = 58},
- ["Glass Pane (102:0)"] = {["x"] = 227, ["y"] = 420, ["z"] = 58},
- ["Glass (20:0)"] = {["x"] = 228, ["y"] = 420, ["z"] = 58},
- ["Chiseled Sandstone (24:1)"] = {["x"] = 229, ["y"] = 420, ["z"] = 58},
- ["Smooth Sandstone (24:2)"] = {["x"] = 230, ["y"] = 420, ["z"] = 58},
- ["Sandstone Slab (44:1)"] = {["x"] = 231, ["y"] = 420, ["z"] = 58},
- ["Sandstone (24:0)"] = {["x"] = 232, ["y"] = 420, ["z"] = 58},
- ["Sand (12:0)"] = {["x"] = 233, ["y"] = 420, ["z"] = 58},
- ["Stone Bricks Slab (44:5)"] = {["x"] = 234, ["y"] = 420, ["z"] = 58},
- ["tile.extrautils:decorativeBlock1.10.name (2523:10)"] = {["x"] = 235, ["y"] = 420, ["z"] = 58},
- ["tile.extrautils:decorativeBlock1.6.name (2523:6)"] = {["x"] = 236, ["y"] = 420, ["z"] = 58},
- ["Gravel (13:0)"] = {["x"] = 237, ["y"] = 420, ["z"] = 58},
- ["Dirt (3:0)"] = {["x"] = 238, ["y"] = 420, ["z"] = 58},
- ["Phosphor (13324:0)"] = {["x"] = 239, ["y"] = 420, ["z"] = 58}}
- -- ----------------------------------------------------------
- -- Functions and stuff:
- -- ----------------------------------------------------------
- -- Tell the turtle server I'm alive.
- local function doTurtleServerReport()
- rednet.send(report,{"Hello TurtleServer",os.getComputerLabel()})
- report = nil
- end
- -- Returns true if the turtle is carrying anything.
- local function carrying()
- for i=1,16 do if turtle.getItemCount(i) ~= 0 then return true end end
- return false
- end
- -- Poll the inventory servers re a given barrel.
- local function getAmountOf(barreltype)
- local myMessage
- for i=1,3 do
- for i=1,invServerCount do rednet.send(invServer[i],barreltype) end
- myMessage = {rednet.receive(3)}
- if myMessage and tonumber(myMessage[2]) then break end
- end
- if not tonumber(myMessage[2]) then
- print("Warning: Could not get reading for amount of "..barreltype..".")
- return 0
- else return tonumber(myMessage[2]) end
- end
- -- Returns true if the turtle is at the specified node.
- local function atNode(tnode) return (x == node[tnode][1] and y == node[tnode][2] and z == node[tnode][3]) end
- -- Accepts strings representing compass-facings to turn the turtle.
- local function faceDirection(targetdirection)
- local tardir
- for i=1,4 do if targetdirection == facing[i] then
- tardir = i
- break
- end end
- if tardir < direction then
- if tardir == 1 and direction == 4 then while not turtle.turnRight() do end
- else for i=1,direction-tardir do while not turtle.turnLeft() do end end end
- elseif tardir > direction then
- if tardir == 4 and direction == 1 then while not turtle.turnLeft() do end
- else for i=1,tardir-direction do while not turtle.turnRight() do end end end
- end
- direction = tardir
- end
- -- Travel to a co-ordinate.
- local function goToPos(targetx,targety,targetz)
- while x ~= targetx or y ~= targety or z ~= targetz do
- if z > targetz then if turtle.down() then z = z - 1 end
- elseif z < targetz then if turtle.up() then z = z + 1 end end
- if x > targetx then
- if direction ~= 4 then faceDirection("west") end
- if turtle.forward() then x = x - 1 end
- elseif x < targetx then
- if direction ~= 2 then faceDirection("east") end
- if turtle.forward() then x = x + 1 end
- end
- if y > targety then
- if direction ~= 1 then faceDirection("north") end
- if turtle.forward() then y = y - 1 end
- elseif y < targety then
- if direction ~= 3 then faceDirection("south") end
- if turtle.forward() then y = y + 1 end
- end
- end
- end
- -- Travel directly to a node and update the node tracker.
- local function goToNode(desnode)
- goToPos(node[desnode][1],node[desnode][2],node[desnode][3])
- curnode = desnode
- end
- -- Used by the next function to determine the cheapest route to a given destination.
- local function checkNode(thisNode, desnode)
- -- Do a quick search in case the target is right next to us:
- for i=1,#node[thisNode]-3 do if node[thisNode][i+3] == desnode then
- return math.abs(node[thisNode][1] - node[desnode][1]) + math.abs(node[thisNode][2] - node[desnode][2]) + math.abs(node[thisNode][3] - node[desnode][3])
- end end
- -- Do a long search, checking the validity of all attached nodes:
- local linkedNodes = {}
- for i=1,#node[thisNode]-3 do
- local alreadyChecked = false
- for j=1,#pathList do if pathList[j] == node[thisNode][i+3] then
- alreadyChecked = true
- break
- end end
- if not alreadyChecked then linkedNodes[#linkedNodes+1] = node[thisNode][i+3] end
- end
- -- This is a dead end:
- if #linkedNodes == 0 then return 3000 end
- -- Tracking can continue from this point:
- local maxDistance, checkingNode, bestNode = 2000
- pathList[#pathList+1] = thisNode
- for i=1,#linkedNodes do
- checkingNode = checkNode(linkedNodes[i],desnode)
- if checkingNode < maxDistance then
- maxDistance = checkingNode
- bestNode = linkedNodes[i]
- end
- end
- pathList[#pathList] = nil
- return maxDistance + math.abs(node[thisNode][1] - node[bestNode][1]) + math.abs(node[thisNode][2] - node[bestNode][2]) + math.abs(node[thisNode][3] - node[bestNode][3])
- end
- -- Travels to a given node, pathing from the current node.
- local function pathToNode(desnode)
- if report then doTurtleServerReport() end
- goToNode(curnode)
- while true do
- -- Quick checks:
- for i=1,#node[curnode]-3 do if node[curnode][i+3] == desnode then
- goToNode(desnode)
- return
- end end
- -- Long check:
- local bestNode, maxDistance, checkingNode = {}, 2000
- pathList = {curnode}
- for i=1,#node[curnode]-3 do
- checkingNode = checkNode(node[curnode][3+i],desnode)
- if checkingNode < maxDistance then
- maxDistance = checkingNode
- bestNode = node[curnode][3+i]
- end
- end
- goToNode(bestNode)
- end
- end
- -- Collect a given number of items from a barrel into a given turtle slot.
- local function fetch(item, slot, amount)
- if not amount then amount = 64 end
- turtle.select(slot)
- if x > 239 or x < 208 or y > 427 or y < 420 or z > 60 or z < 58 then
- pathToNode(1)
- elseif barrel[item].z ~= z then
- if y==427 then goToPos(x, 426, z)
- elseif y==420 then goToPos(x, 421, z) end
- end
- if not (x == barrel[item].x and y == barrel[item].y and z == barrel[item].z) then
- goToPos(barrel[item].x,barrel[item].y,barrel[item].z)
- faceDirection(y==427 and "south" or "north")
- sleep(1)
- elseif (y==427 and direction~=3) or (y==420 and direction~=1) then
- faceDirection(y==427 and "south" or "north")
- sleep(1)
- end
- peripheral.call("front", "pushItemIntoSlot", y==427 and "north" or "south", 2, amount, slot)
- end
- -- Refuel the turtle itself.
- local function goGetFuel()
- print("I'm hungry. Off to eat some EU...")
- fetch("Charcoal (263:1)",1)
- print("OMNOMNOM")
- turtle.refuel()
- print("Ah, that hit the spot!")
- print("")
- end
- -- Dumps the turtle's inventory into the dropoff chest.
- local function dropOff()
- print("Dropping off loot...")
- pathToNode(2)
- for i=1,16 do if turtle.getItemCount(i) ~= 0 then
- turtle.select(i)
- turtle.dropDown()
- end end
- turtle.select(1)
- print("")
- end
- local function fuelMagmaticEngines()
- print("Let's check the magma boiler.")
- if getAmountOf("Phosphor (13324:0)") < 2 then
- print("Hey, we're out of phosphor!!")
- print("")
- curcombbarrel = 1
- return
- end
- pathToNode(3)
- goToPos(244,418,57)
- faceDirection("north")
- sleep(1)
- local magmaTable,needsMore,inSqueezer = {},false
- for i=1,9 do
- inSqueezer = peripheral.call("front", "getStackInSlot", i)
- magmaTable[i] = 64 - (inSqueezer and inSqueezer.qty or 0)
- if magmaTable[i] > 0 then needsMore = true end
- end
- if not needsMore then
- print("Looks like she's already filled to the brim.")
- worktimer[7] = os.startTimer(480)
- return
- end
- for i=1,6 do if magmaTable[i] > 0 then fetch("Phosphor (13324:0)",i,magmaTable[i]) end end
- for i=7,9 do if magmaTable[i] > 0 then fetch("Cobblestone (4:0)",i,magmaTable[i]) end end
- pathToNode(3)
- goToPos(244,418,57)
- faceDirection("north")
- sleep(1)
- for i=1,9 do peripheral.call("front", "pullItemIntoSlot", "south", i, turtle.getItemCount(i), i) end
- print("Lava production restocked.")
- if carrying() then dropOff() else print("") end
- worktimer[7] = os.startTimer(480)
- end
- -- Clump things together.
- local function craftStuff()
- local thiscraft = craft.current
- craft.current = craft.current + 1
- if craft.current > #craft then craft.current = 1 end
- if barrel[craft[thiscraft][1]] and getAmountOf(craft[thiscraft][1]) == 4096 then return false end
- -- Check we have the required ingredients on hand:
- local needed = {}
- for i=1,#craft[thiscraft][2] do for j=1,#craft[thiscraft][2][1] do if needed[craft[thiscraft][2][i][j]] then
- needed[craft[thiscraft][2][i][j]] = needed[craft[thiscraft][2][i][j]] + 1
- elseif craft[thiscraft][2][i][j] ~= "" then needed[craft[thiscraft][2][i][j]] = 1 end end end
- for thing,required in pairs(needed) do if getAmountOf(thing) < required then return false end end
- -- Looks like we're all set, go get some resources.
- for thing,required in pairs(needed) do
- local slotx,sloty,gotten,slot,maxPerSlot = 0,1,0,{},craft[thiscraft][3] and math.floor(64/craft[thiscraft][3]) or 64
- for i=1,required do
- repeat
- slotx = slotx + 1
- if slotx > #craft[thiscraft][2][sloty] then
- slotx = 1
- sloty = sloty + 1
- end
- until craft[thiscraft][2][sloty][slotx] == thing
- slot[i] = (sloty-1)*4+slotx
- fetch(craft[thiscraft][2][sloty][slotx],slot[i],maxPerSlot)
- gotten = gotten + turtle.getItemCount(slot[i])
- end
- -- We should've had enough, but somehow don't?
- if gotten < required then
- dropOff()
- return false
- end
- -- We got enough, now divide it between the relevant slots evenly.
- local perSlot = math.floor(gotten / required)
- for i=required,1,-1 do if turtle.getItemCount(slot[i]) < perSlot then for j=1,required do if turtle.getItemCount(slot[j]) - perSlot > 0 then
- turtle.select(slot[j])
- turtle.transferTo(slot[i],math.min(perSlot - turtle.getItemCount(slot[i]),turtle.getItemCount(slot[j]) - perSlot))
- if turtle.getItemCount(slot[i]) >= perSlot then break end
- end end end end
- end
- turtle.craft()
- print("Crafted "..craft[thiscraft][1].."!")
- dropOff()
- return true
- end
- -- Relay stuff to a basic resource processing machine.
- local function feedMachine(curmachine)
- local thisresource = machine[curmachine].current
- machine[curmachine].current = machine[curmachine].current + 1
- if machine[curmachine].current > #machine[curmachine] then machine[curmachine].current = 1 end
- -- Skip this stack if the input barrel is too low on resources...
- if getAmountOf(machine[curmachine][thisresource][1]) < 64 then return false end
- -- ... or if all the output barrels are full.
- if type(machine[curmachine][thisresource][2]) == "table" then
- local barrelsFull = true
- for i=1,#machine[curmachine][thisresource][2] do if getAmountOf(machine[curmachine][thisresource][2][i]) < 4096 then
- barrelsFull = false
- break
- end end
- if barrelsFull then return false end
- elseif barrel[machine[curmachine][thisresource][2]] and getAmountOf(machine[curmachine][thisresource][2]) == 4096 then return false end
- fetch(machine[curmachine][thisresource][1],1)
- pathToNode(3)
- for i=1,#machine[curmachine].waypoint do goToPos(machine[curmachine].waypoint[i][1],machine[curmachine].waypoint[i][2],machine[curmachine].waypoint[i][3]) end
- sleep(1)
- if peripheral.call("bottom", "getStackInSlot", 1) then peripheral.call("bottom", "pushItemIntoSlot", "up", 1, 64, 2) end
- worktimer[curmachine] = os.startTimer(turtle.getItemCount(1) * machine[curmachine].time)
- turtle.dropDown()
- print("Processing "..machine[curmachine][thisresource][1].." in progress.")
- if carrying() then dropOff() end
- return true
- end
- -- Restock the carpenters and their attached squeezers:
- local function feedCarpenter(curcarpenter)
- print("Let's check on "..carpenter[curcarpenter].making.." production.")
- pathToNode(3)
- if carpenter[curcarpenter].sX then
- goToPos(carpenter[curcarpenter].sX,carpenter[curcarpenter].sY,carpenter[curcarpenter].sZ)
- faceDirection("north")
- sleep(1)
- local curFluidResource, bestFluidResource, thisFluidResource = 0
- for i=1,#carpenter[curcarpenter].sContent do
- thisFluidResource = getAmountOf(carpenter[curcarpenter].sContent[i])
- if thisFluidResource > curFluidResource then
- curFluidResource = thisFluidResource
- bestFluidResource = carpenter[curcarpenter].sContent[i]
- end
- end
- if bestFluidResource then
- local squeezerTable,needsMore,inSqueezer = {},false
- for i=1,9 do
- inSqueezer = peripheral.call("front", "getStackInSlot", i)
- if inSqueezer then squeezerTable[i] = {64 - inSqueezer.qty, inSqueezer.name.." ("..inSqueezer.id..":"..inSqueezer.dmg..")"}
- else squeezerTable[i] = {64, bestFluidResource} end
- if squeezerTable[i][1] > 0 then needsMore = true end
- end
- if needsMore then
- for i=1,9 do if squeezerTable[i][1] > 0 then fetch(squeezerTable[i][2],i,squeezerTable[i][1]) end end
- pathToNode(3)
- goToPos(carpenter[curcarpenter].sX,carpenter[curcarpenter].sY,carpenter[curcarpenter].sZ)
- faceDirection("north")
- sleep(1)
- for i=1,9 do peripheral.call("front", "pullItemIntoSlot", "south", i, turtle.getItemCount(i), i) end
- print("Squeezer restocked.")
- else print("Looks like the squeezer's full.") end
- else print("Warning: We're out of squeezables for this carpenter.") end
- if carrying() then
- dropOff()
- pathToNode(3)
- end
- end
- goToPos(carpenter[curcarpenter].cX,carpenter[curcarpenter].cY,carpenter[curcarpenter].cZ)
- faceDirection("north")
- sleep(1)
- local carpenterTable,needsMore,inCarpenter = {}, false
- for i=1,#carpenter[curcarpenter].cContent do
- inCarpenter = peripheral.call("front", "getStackInSlot", 12+i)
- carpenterTable[i] = 64 - (inCarpenter and inCarpenter.qty or 0)
- if carpenterTable[i] > 0 then needsMore = true end
- end
- if needsMore then
- for i=1,#carpenter[curcarpenter].cContent do if carpenterTable[i] > 0 then fetch(carpenter[curcarpenter].cContent[i],i,carpenterTable[i]) end end
- pathToNode(3)
- goToPos(carpenter[curcarpenter].cX,carpenter[curcarpenter].cY,carpenter[curcarpenter].cZ)
- faceDirection("north")
- sleep(1)
- for i=1,#carpenter[curcarpenter].cContent do peripheral.call("front", "pullItemIntoSlot", "south", i, turtle.getItemCount(i), 12+i) end
- print("Carpenter restocked.")
- else print("Looks like the carpenter's full.") end
- if carrying() then dropOff() else print("") end
- end
- -- Perform a server-assigned task.
- local function doJob()
- if job[1][1] == "New turtle" then
- print("Seems I need to replace "..job[1][2]..".")
- if getAmountOf("Diamond (264:0)") < 3 or getAmountOf("Stick (280:0)") < 2 or getAmountOf("Turtle (1227:0)") < 1 or getAmountOf("item.ccwirelessmodem.name (1226:1)") < 1 then
- print("... but I don't have the parts. Maybe some other time.")
- print("")
- table.remove(job,1)
- return
- end
- fetch("Diamond (264:0)",1,1)
- fetch("Diamond (264:0)",2,1)
- fetch("Diamond (264:0)",5,1)
- fetch("Stick (280:0)",6,1)
- fetch("Stick (280:0)",10,1)
- turtle.craft()
- for i=1,16 do if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.transferTo(1)
- break
- end end
- fetch("Turtle (1227:0)",2,1)
- fetch("item.ccwirelessmodem.name (1226:1)",3,1)
- turtle.craft()
- for i=1,16 do if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.transferTo(1)
- break
- end end
- fetch("Charcoal (263:1)",2)
- pathToNode(4)
- faceDirection("west")
- sleep(1)
- local myFile = fs.open("\\disk\\id","w")
- myFile.writeLine(job[1][2]:sub(10))
- myFile.close()
- while not turtle.back() do end
- turtle.select(1)
- while not turtle.place() do end
- turtle.select(2)
- turtle.drop()
- peripheral.call("front","turnOn")
- while not turtle.forward() do end
- table.remove(job,1)
- print("Success!")
- print("")
- end -- More tasks to go here.
- end
- -- ----------------------------------------------------------
- -- Primary functions:
- -- ----------------------------------------------------------
- -- Deal with timers and rednet.
- local function catchTimers()
- local turtleServerTimeOut, myEvent = os.startTimer(0)
- while true do
- myEvent = {os.pullEvent()}
- if myEvent[1] == "timer" then
- if myEvent[2] == turtleServerTimeOut then
- report = 65535
- turtleServerTimeOut = os.startTimer(600)
- else for i=1,table.getn(worktimer) do if worktimer[i] == myEvent[2] then
- worktimer[i] = 0
- break
- end end end
- elseif myEvent[1] == "rednet_message" and myEvent[3] == "Hey, you still there?" then
- report = myEvent[2]
- turtleServerTimeOut = os.startTimer(600)
- elseif myEvent[1] == "rednet_message" and type(myEvent[3]) == "table" then
- if myEvent[3][1] == "We need a new turtle." then
- job[#job+1] = {"New turtle",myEvent[3][2]}
- end -- More tasks to go here later.
- end
- end
- end
- -- Primary work loop.
- local function main()
- while true do
- if turtle.getFuelLevel() < 1000 then goGetFuel() end
- if carrying() then dropOff() end
- if worktimer[7] == 0 then fuelMagmaticEngines() end
- while #job > 0 do doJob() end
- print("Let's try to craft something!")
- local firstDo = craft.current
- repeat until craftStuff() or firstDo == craft.current
- print("")
- while #job > 0 do doJob() end
- for i=1,#machine do if worktimer[i] == 0 then
- print("Checking for resources to "..machine[i].task.."...")
- firstDo = machine[i].current
- repeat until feedMachine(i) or firstDo == machine[i].current
- print("")
- end end
- while #job > 0 do doJob() end
- for i=1,#carpenter do if worktimer[3+i] == 0 then
- if getAmountOf(carpenter[i].making) < carpenter[i].max then feedCarpenter(i) end
- worktimer[3+i] = os.startTimer(600)
- end end
- while #job > 0 do doJob() end
- end
- end
- -- ----------------------------------------------------------
- -- I've just booted up. Where am I? Who am I? etc...
- -- ----------------------------------------------------------
- -- Ping the GPS servers until I get a valid reading, then determine the nearest node:
- do
- local tempx, tempy, tempz
- while tempx == nil or tempy == nil or tempz == nil do
- tempx, tempy, tempz = gps.locate(5)
- sleep(5)
- end
- while not turtle.forward() do while not turtle.turnLeft() do end end
- x,y,z = gps.locate(5)
- if x < tempx then direction = 4
- elseif x > tempx then direction = 2
- elseif y < tempy then direction = 1
- else direction = 3 end
- local temp1, temp2 = 255, 0
- for i=1,table.getn(node) do
- temp2 = math.sqrt(math.pow(x - node[i][1],2) + math.pow(y - node[i][2],2))
- temp2 = math.sqrt(math.pow(temp2,2) + math.pow(z - node[i][3],2))
- if temp2 < temp1 then
- temp1 = temp2
- curnode = i
- end
- end
- end
- -- Broadcast until all inventory servers are identified.
- rednet.open("right")
- while #invServer < invServerCount do
- rednet.broadcast("Hello InvServer")
- local myTimer = os.startTimer(5)
- while true do
- local myEvent = {os.pullEvent()}
- if myEvent[1] == "timer" and myEvent[2] == myTimer then
- break
- elseif myEvent[1] == "rednet_message" and myEvent[3] == "Hello, InvServerClient!" then
- invServer[#invServer+1] = myEvent[2]
- for i=1,#invServer-1 do if invServer[i] == invServer[#invServer] then invServer[#invServer] = nil end end
- if #invServer == invServerCount then break end
- end
- end
- end
- print("I'm at "..x..","..y..","..z..", I have "..turtle.getFuelLevel().." fuel and I'm facing "..facing[direction]..".")
- print("")
- parallel.waitForAny(main, catchTimers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement