1
0
mirror of https://github.com/kepler155c/opus synced 2025-05-04 16:34:13 +00:00

builder improvements

This commit is contained in:
kepler155c@gmail.com 2017-06-09 17:41:03 -04:00
parent b618246679
commit 71cbf34ade
3 changed files with 27 additions and 17 deletions

View File

@ -1,7 +1,7 @@
local bootOptions = { local bootOptions = {
{ prompt = 'Default Shell', file = '/sys/boot/default.boot' }, { prompt = 'Default Shell', file = '/sys/boot/default.boot' },
{ prompt = 'Multishell' , file = '/sys/boot/multishell.boot' }, { prompt = 'Opus' , file = '/sys/boot/multishell.boot' },
{ prompt = 'TLCO' , file = '/sys/boot/tlco.boot' }, -- { prompt = 'TLCO' , file = '/sys/boot/tlco.boot' },
} }
local bootOption = 2 local bootOption = 2

View File

@ -24,13 +24,15 @@ function MEProvider:init(args)
end end
end end
if self.side then local sides = {
local sides = { top = 'down',
top = 'down', bottom = 'up',
bottom = 'up', east = 'west',
} west = 'east',
self.oside = sides[self.side] north = 'south',
end south = 'north',
}
self.oside = sides[self.direction or self.side]
end end
function MEProvider:isValid() function MEProvider:isValid()

View File

@ -198,7 +198,7 @@ function Builder:finish()
Builder.resupplying = true Builder.resupplying = true
Builder.ready = false Builder.ready = false
if turtle.gotoLocation('supplies') then if turtle.gotoLocation('supplies') then
turtle.setHeading(0) turtle.setHeading(1)
os.sleep(.1) -- random 'Computer is not connected' error... os.sleep(.1) -- random 'Computer is not connected' error...
Builder:dumpInventory() Builder:dumpInventory()
Event.exitPullEvents() Event.exitPullEvents()
@ -274,6 +274,7 @@ Message.addHandler('supplyList',
self.ready = false self.ready = false
Event.exitPullEvents() Event.exitPullEvents()
end end
turtle.setHeading(1)
os.sleep(.2) -- random 'Computer is not connected' error... os.sleep(.2) -- random 'Computer is not connected' error...
Builder:dumpInventoryWithCheck() Builder:dumpInventoryWithCheck()
Builder:refuel() Builder:refuel()
@ -283,7 +284,6 @@ Message.addHandler('supplyList',
if #supplies == 0 then if #supplies == 0 then
break break
end end
turtle.setHeading(0)
Builder:autocraft(supplies) Builder:autocraft(supplies)
turtle.status = 'waiting' turtle.status = 'waiting'
os.sleep(5) os.sleep(5)
@ -319,9 +319,10 @@ Message.addHandler('needSupplies',
os.sleep(0) os.sleep(0)
if not turtle.gotoLocation('supplies') then if not turtle.gotoLocation('supplies') then
Builder:log('failed to go to supply location') Builder:log('failed to go to supply location')
self.ready = false --self.ready = false
Event.exitPullEvents() Event.exitPullEvents()
end end
turtle.setHeading(1)
return return
end end
pt.y = pt.y - 2 -- location where builder should go for the chest to be above pt.y = pt.y - 2 -- location where builder should go for the chest to be above
@ -379,24 +380,31 @@ local function onTheWay() -- parallel routine
end end
local args = {...} local args = {...}
if #args < 1 then if #args < 2 then
error('Supply id for builder') error('syntax: <builder id> <facing>')
end end
__BUILDER_ID = tonumber(args[1]) __BUILDER_ID = tonumber(args[1])
maxStackDB:load() maxStackDB:load()
Builder.itemProvider = MEProvider() Builder.itemProvider = MEProvider({ direction = args[2] })
if not Builder.itemProvider:isValid() then if not Builder.itemProvider:isValid() then
Builder.itemProvider = ChestProvider() local sides = {
east = 'west',
west = 'east',
north = 'south',
south = 'north',
}
Builder.itemProvider = ChestProvider({ direction = sides[args[2]], wrapSide = args[2] })
if not Builder.itemProvider:isValid() then if not Builder.itemProvider:isValid() then
error('A chest or ME interface must be below turtle') error('A chest or ME interface must be below turtle')
end end
end end
turtle.run(function() turtle.run(function()
turtle.setPoint({ x = -1, z = -2, y = 0, heading = 0 }) turtle.setPoint({ x = -1, z = -2, y = -1, heading = 1 })
turtle.getState().coordSystem = 'relative' turtle.getState().coordSystem = 'relative'
turtle.saveLocation('supplies') turtle.saveLocation('supplies')