This commit is contained in:
kepler155c@gmail.com
2019-04-16 00:23:37 -04:00
parent f13e56327e
commit a6ddc77b4e
3 changed files with 18 additions and 16 deletions

View File

@@ -3,15 +3,19 @@ local Schematic = require('builder.schematic')
local TableDB = require('core.tableDB') local TableDB = require('core.tableDB')
local Util = require('util') local Util = require('util')
local fs = _G.fs local device = _G.device
local peripheral = _G.peripheral local fs = _G.fs
local n = peripheral.find "neuralInterface" local Syntax = [[Required:
* Neural Interface
if not n then error "run on neural interface" end * Overlay glasses
* Entity sensor
if not n.hasModule "plethora:glasses" then error "needs overlay glasses" end * Introspection module
if not n.hasModule "plethora:sensor" or not n.hasModule "plethora:introspection" or not n.getMetaOwner then error "needs entity sensor + bound introspection module" end ]]
local neural = device['neuralInterface'] or error(Syntax)
assert(neural.hasModule('plethora:glasses'), Syntax)
assert(neural.hasModule("plethora:sensor"), Syntax)
assert(neural.hasModule('plethora:introspection'), Syntax)
local BUILDER_DIR = 'usr/builder' local BUILDER_DIR = 'usr/builder'
@@ -125,9 +129,9 @@ print('Substituting blocks')
Builder.subDB = subDB Builder.subDB = subDB
Builder:substituteBlocks(Util.throttle()) Builder:substituteBlocks(Util.throttle())
local cn = n.canvas3d().create() local cn = neural.canvas3d().create()
local pos = neural.getMetaOwner().withinBlock
local pos = n.getMetaOwner().withinBlock
cn.recenter({-(pos.x + .5), -(pos.y + 2) + .5, -(pos.z + .5) }) cn.recenter({-(pos.x + .5), -(pos.y + 2) + .5, -(pos.z + .5) })
for i = 1, #Builder.schematic.blocks do for i = 1, #Builder.schematic.blocks do
@@ -137,10 +141,10 @@ for i = 1, #Builder.schematic.blocks do
cn.addItem({ b.x, b.y, b.z }, b.id, b.dmg) cn.addItem({ b.x, b.y, b.z }, b.id, b.dmg)
end) end)
if not s and m then if not s and m then
printError(m) _G.printError(m)
end end
end end
end end
pcall(read) pcall(_G.read)
cn.clear() cn.clear()

View File

@@ -1,4 +1,4 @@
local machine = require('neural.state') local machine = require('neural.statemachine')
local device = _G.device local device = _G.device
local os = _G.os local os = _G.os
@@ -45,13 +45,11 @@ local fsm = machine.create({
os.sleep(.5) os.sleep(.5)
local meta = sensor.getMetaByName('unknown') local meta = sensor.getMetaByName('unknown')
depth = meta and meta.y - .5 or depth depth = meta and meta.y - .5 or depth
return true
end, end,
onreel = function() onreel = function()
kinetic.use(.3) kinetic.use(.3)
os.sleep(.5) os.sleep(.5)
return true
end, end,
-- state changes -- state changes
@@ -91,7 +89,7 @@ local function fish()
fsm:rod() fsm:rod()
if not meta then if not meta then
fsm:cast() fsm:cast()
elseif meta and meta.y < depth then elseif meta.y < depth then
fsm:reel() fsm:reel()
end end
os.sleep(.1) os.sleep(.1)