builder starting point
This commit is contained in:
@@ -39,7 +39,6 @@ local supplyPage, substitutionPage
|
|||||||
local pistonFacings
|
local pistonFacings
|
||||||
|
|
||||||
local Builder = {
|
local Builder = {
|
||||||
version = '1.71',
|
|
||||||
isCommandComputer = not turtle,
|
isCommandComputer = not turtle,
|
||||||
slots = { },
|
slots = { },
|
||||||
loc = { },
|
loc = { },
|
||||||
@@ -214,18 +213,17 @@ function Builder:getBlockCounts()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
for k,b in ipairs(schematic.blocks) do
|
for k = self.index, #schematic.blocks do
|
||||||
if k >= self.index then
|
local b = schematic.blocks[k]
|
||||||
local key = tostring(b.id) .. ':' .. b.dmg
|
local key = tostring(b.id) .. ':' .. b.dmg
|
||||||
local block = blocks[key]
|
local block = blocks[key]
|
||||||
if not block then
|
if not block then
|
||||||
block = Util.shallowCopy(b)
|
block = Util.shallowCopy(b)
|
||||||
block.qty = 0
|
block.qty = 0
|
||||||
block.need = 0
|
block.need = 0
|
||||||
blocks[key] = block
|
blocks[key] = block
|
||||||
end
|
|
||||||
block.need = block.need + 1
|
|
||||||
end
|
end
|
||||||
|
block.need = block.need + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
return blocks
|
return blocks
|
||||||
@@ -472,7 +470,7 @@ Event.on('build', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function Builder:refuel()
|
function Builder:refuel()
|
||||||
while turtle.getFuelLevel() < 4000 and self.fuelItem do
|
while turtle.getFuelLevel() < 4000 do
|
||||||
print('Refueling')
|
print('Refueling')
|
||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
|
|
||||||
@@ -953,7 +951,6 @@ function Builder:placeDirectionalBlock(b, slot, travelPlane)
|
|||||||
[ 'west-up' ] = 'east'
|
[ 'west-up' ] = 'east'
|
||||||
}
|
}
|
||||||
if stairUpDirections[d] then
|
if stairUpDirections[d] then
|
||||||
|
|
||||||
local isSouth = (turtle.getHeadingInfo(Builder.facing).heading +
|
local isSouth = (turtle.getHeadingInfo(Builder.facing).heading +
|
||||||
turtle.getHeadingInfo(stairUpDirections[d]).heading) % 4 == 1
|
turtle.getHeadingInfo(stairUpDirections[d]).heading) % 4 == 1
|
||||||
|
|
||||||
@@ -1141,7 +1138,7 @@ function Builder:loadProgress(filename)
|
|||||||
Builder.index = 1
|
Builder.index = 1
|
||||||
end
|
end
|
||||||
Builder.facing = progress.facing or 'south'
|
Builder.facing = progress.facing or 'south'
|
||||||
Builder.loc = progress.loc
|
Builder.loc = progress.loc or { }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2052,10 +2049,17 @@ function startPage:eventHandler(event)
|
|||||||
Builder.supplyPoint = { x = -1, y = 0, z = -1 }
|
Builder.supplyPoint = { x = -1, y = 0, z = -1 }
|
||||||
end
|
end
|
||||||
|
|
||||||
turtle.setPoint(Builder.supplyPoint)
|
|
||||||
Builder:dumpInventory()
|
Builder:dumpInventory()
|
||||||
Builder:refuel()
|
Builder:refuel()
|
||||||
|
|
||||||
|
if Builder.mode == 'build' then
|
||||||
|
Builder:getTurtleFacing()
|
||||||
|
end
|
||||||
|
|
||||||
|
local facing = turtle.getHeadingInfo(Builder.facing).heading
|
||||||
|
Point.rotate(Builder.supplyPoint, facing)
|
||||||
|
turtle.setPoint(Builder.supplyPoint)
|
||||||
|
|
||||||
-- reset piston cache in case wrench was substituted
|
-- reset piston cache in case wrench was substituted
|
||||||
pistonFacings = {
|
pistonFacings = {
|
||||||
down = { },
|
down = { },
|
||||||
@@ -2070,7 +2074,6 @@ function startPage:eventHandler(event)
|
|||||||
Builder:build()
|
Builder:build()
|
||||||
else
|
else
|
||||||
print('Starting build')
|
print('Starting build')
|
||||||
Builder:getTurtleFacing()
|
|
||||||
Builder:resupply()
|
Builder:resupply()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2129,7 +2132,7 @@ if commands then
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Builder v' .. Builder.version)
|
multishell.setTitle(multishell.getCurrent(), 'Builder')
|
||||||
|
|
||||||
maxStackDB:load()
|
maxStackDB:load()
|
||||||
subDB:load()
|
subDB:load()
|
||||||
@@ -2161,7 +2164,7 @@ if Builder.isCommandComputer then
|
|||||||
UI:pullEvents()
|
UI:pullEvents()
|
||||||
else
|
else
|
||||||
turtle.run(function()
|
turtle.run(function()
|
||||||
turtle.heading = 0
|
turtle.point.heading = 0
|
||||||
UI:pullEvents()
|
UI:pullEvents()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
_G.requireInjector()
|
_G.requireInjector()
|
||||||
|
|
||||||
local ChestAdapter = require('chestAdapter18')
|
local ChestAdapter = require('chestAdapter18')
|
||||||
|
local Config = require('config')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local itemDB = require('itemDB')
|
local itemDB = require('itemDB')
|
||||||
local Peripheral = require('peripheral')
|
local Peripheral = require('peripheral')
|
||||||
@@ -14,8 +15,13 @@ local turtle = _G.turtle
|
|||||||
|
|
||||||
multishell.setTitle(multishell.getCurrent(), 'Crafter')
|
multishell.setTitle(multishell.getCurrent(), 'Crafter')
|
||||||
|
|
||||||
|
local config = {
|
||||||
|
inventory = { direction = 'north', wrapSide = 'front' },
|
||||||
|
}
|
||||||
|
Config.load('crafter', config)
|
||||||
|
|
||||||
repeat until not turtle.forward()
|
repeat until not turtle.forward()
|
||||||
local inventoryAdapter = ChestAdapter({ wrapSide = 'bottom', direction = 'up' })
|
local inventoryAdapter = ChestAdapter(config.inventory)
|
||||||
|
|
||||||
local RESOURCE_FILE = 'usr/config/resources.db'
|
local RESOURCE_FILE = 'usr/config/resources.db'
|
||||||
local RECIPES_FILE = 'usr/etc/recipes2.db'
|
local RECIPES_FILE = 'usr/etc/recipes2.db'
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ local function follow(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- check if gps is inaccurate (player moving too fast)
|
-- check if gps is inaccurate (player moving too fast)
|
||||||
if d < Point.pythagoreanDistance(turtle.point, pt) + 10 then
|
if d < Point.distance(turtle.point, pt) + 10 then
|
||||||
lastPoint = Point.copy(pt)
|
lastPoint = Point.copy(pt)
|
||||||
following = true
|
following = true
|
||||||
os.queueEvent('turtle_follow', pt)
|
os.queueEvent('turtle_follow', pt)
|
||||||
|
|||||||
Reference in New Issue
Block a user