updated to use new canvas features
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
local Builder = require('builder.builder')
|
||||||
|
local Schematic = require('builder.schematic')
|
||||||
|
local TableDB = require('core.tableDB')
|
||||||
|
local Util = require('util')
|
||||||
|
|
||||||
|
local fs = _G.fs
|
||||||
|
local peripheral = _G.peripheral
|
||||||
|
|
||||||
local n = peripheral.find "neuralInterface"
|
local n = peripheral.find "neuralInterface"
|
||||||
|
|
||||||
if not n then error "run on neural interface" end
|
if not n then error "run on neural interface" end
|
||||||
@@ -5,38 +13,8 @@ if not n then error "run on neural interface" end
|
|||||||
if not n.hasModule "plethora:glasses" then error "needs overlay glasses" end
|
if not n.hasModule "plethora:glasses" then error "needs overlay glasses" end
|
||||||
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
|
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 itemDB = require('core.itemDB')
|
|
||||||
local Schematic = require('builder.schematic')
|
|
||||||
local TableDB = require('core.tableDB')
|
|
||||||
local Util = require('util')
|
|
||||||
|
|
||||||
local colors = _G.colors
|
|
||||||
local fs = _G.fs
|
|
||||||
|
|
||||||
local BUILDER_DIR = 'usr/builder'
|
local BUILDER_DIR = 'usr/builder'
|
||||||
|
|
||||||
local Builder = require('builder.builder')
|
|
||||||
|
|
||||||
Builder.schematic = Schematic()
|
|
||||||
|
|
||||||
local function convertSingleBack(item)
|
|
||||||
if item then
|
|
||||||
item.id = item.name
|
|
||||||
item.dmg = item.damage
|
|
||||||
item.qty = item.count
|
|
||||||
item.max_size = item.maxCount
|
|
||||||
item.display_name = item.displayName
|
|
||||||
end
|
|
||||||
return item
|
|
||||||
end
|
|
||||||
|
|
||||||
local function convertBack(t)
|
|
||||||
for _,v in pairs(t) do
|
|
||||||
convertSingleBack(v)
|
|
||||||
end
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[-- SubDB --]]--
|
--[[-- SubDB --]]--
|
||||||
local subDB = TableDB({
|
local subDB = TableDB({
|
||||||
fileName = fs.combine(BUILDER_DIR, 'sub.db'),
|
fileName = fs.combine(BUILDER_DIR, 'sub.db'),
|
||||||
@@ -140,6 +118,7 @@ end
|
|||||||
subDB:load()
|
subDB:load()
|
||||||
|
|
||||||
print('Loading schematic')
|
print('Loading schematic')
|
||||||
|
Builder.schematic = Schematic()
|
||||||
Builder.schematic:load(args[1])
|
Builder.schematic:load(args[1])
|
||||||
print('Substituting blocks')
|
print('Substituting blocks')
|
||||||
|
|
||||||
@@ -149,11 +128,17 @@ Builder:substituteBlocks(Util.throttle())
|
|||||||
local cn = n.canvas3d().create()
|
local cn = n.canvas3d().create()
|
||||||
|
|
||||||
local pos = n.getMetaOwner().withinBlock
|
local pos = n.getMetaOwner().withinBlock
|
||||||
cn.recenter({-pos.x, -pos.y, -pos.z})
|
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
|
||||||
b = Builder.schematic:getComputedBlock(i)
|
local b = Builder.schematic:getComputedBlock(i)
|
||||||
if b.id ~= "minecraft:air" then
|
if b.id ~= "minecraft:air" and b.id ~= 'minecraft:water' then
|
||||||
cn.addBox(b.x, b.y-10, b.z, 0xffffff40).setDepthTested(false)
|
local s, m = pcall(function()
|
||||||
|
cn.addItem({ b.x, b.y, b.z }, b.id, b.dmg)
|
||||||
|
end)
|
||||||
|
if not s and m then
|
||||||
|
printError(m)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -136,11 +136,20 @@ function page.detail:show(blocks, entry)
|
|||||||
for _, b in pairs(blocks) do
|
for _, b in pairs(blocks) do
|
||||||
if not projecting[b.id] then
|
if not projecting[b.id] then
|
||||||
projecting[b.id] = b
|
projecting[b.id] = b
|
||||||
b.box = canvas.addBox(
|
pcall(function()
|
||||||
pos.x - offset.x + b.x + -(pos.x % 1) + .25,
|
b.box = canvas.addItem({
|
||||||
pos.y - offset.y + b.y + -(pos.y % 1) + .25,
|
pos.x - offset.x + b.x + -(pos.x % 1) + .5,
|
||||||
pos.z - offset.z + b.z + -(pos.z % 1) + .25,
|
pos.y - offset.y + b.y + -(pos.y % 1) + .5,
|
||||||
.5, .5, .5)
|
pos.z - offset.z + b.z + -(pos.z % 1) + .5 },
|
||||||
|
b.name, b.damage, .5)
|
||||||
|
end)
|
||||||
|
if not b.box then
|
||||||
|
b.box = canvas.addBox(
|
||||||
|
pos.x - offset.x + b.x + -(pos.x % 1) + .25,
|
||||||
|
pos.y - offset.y + b.y + -(pos.y % 1) + .25,
|
||||||
|
pos.z - offset.z + b.z + -(pos.z % 1) + .25,
|
||||||
|
.5, .5, .5)
|
||||||
|
end
|
||||||
b.box.setDepthTested(false)
|
b.box.setDepthTested(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ local function update()
|
|||||||
for _, b in pairs(blocks) do
|
for _, b in pairs(blocks) do
|
||||||
if not projecting[b.id] then
|
if not projecting[b.id] then
|
||||||
projecting[b.id] = b
|
projecting[b.id] = b
|
||||||
|
--[[
|
||||||
b.box = canvas.addFrame({
|
b.box = canvas.addFrame({
|
||||||
pos.x - offset.x + b.x + -(pos.x % 1) + .5,
|
pos.x - offset.x + b.x + -(pos.x % 1) + .5,
|
||||||
pos.y - offset.y + b.y + -(pos.y % 1) + .5,
|
pos.y - offset.y + b.y + -(pos.y % 1) + .5,
|
||||||
@@ -97,6 +98,14 @@ local function update()
|
|||||||
})
|
})
|
||||||
b.box.setDepthTested(false)
|
b.box.setDepthTested(false)
|
||||||
b.box.addItem({ 0, 0 }, b.name, b.damage, 2)
|
b.box.addItem({ 0, 0 }, b.name, b.damage, 2)
|
||||||
|
--]]
|
||||||
|
|
||||||
|
b.box = canvas.addItem({
|
||||||
|
pos.x - offset.x + b.x + -(pos.x % 1) + .5,
|
||||||
|
pos.y - offset.y + b.y + -(pos.y % 1) + .5,
|
||||||
|
pos.z - offset.z + b.z + -(pos.z % 1) + .5,
|
||||||
|
}, b.name, b.damage, .5)
|
||||||
|
b.box.setDepthTested(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user