Entities in frames now?

This commit is contained in:
Casey 2023-10-12 21:25:20 +03:00
parent 81cc518e0d
commit 22f0d73184
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
4 changed files with 22 additions and 21 deletions

View File

@ -1,4 +1,3 @@
-- x-run: scp -r ./* pneumatic-pump:htdocs/cc/augment/
_G.NI = peripheral.wrap("back") _G.NI = peripheral.wrap("back")
_G._running = true _G._running = true
@ -9,7 +8,7 @@ _G.canvas3d_src.clear()
_G.canvas3d = canvas3d_src.create() _G.canvas3d = canvas3d_src.create()
_G.player = nil _G.player = nil
_G.entities = {} _G.nearbyEntities = {}
local function run_wrapped(func, filename) local function run_wrapped(func, filename)
return function() return function()
@ -72,7 +71,7 @@ function() -- Neural Interface coroutine
print("NI routine started") print("NI routine started")
while _G._running do while _G._running do
_G.player = safeset(NI.getMetaOwner, "getMetaOwner()", _G.player) _G.player = safeset(NI.getMetaOwner, "getMetaOwner()", _G.player)
_G.entities = safeset(NI.sense, "sense()", _G.entities) _G.nearbyEntities = safeset(NI.sense, "sense()", _G.entities)
_G.canvas3d.recenter() _G.canvas3d.recenter()
os.sleep(0.05) os.sleep(0.05)
end end

View File

@ -1,5 +1,3 @@
-- x-run: cd .. && scp -r ./* pneumatic-pump:htdocs/cc/augment/
return function() return function()
while _G._running do while _G._running do
local ev = { os.pullEvent() } local ev = { os.pullEvent() }

View File

@ -1,23 +1,29 @@
-- x-run: cd .. && scp -r ./* pneumatic-pump:htdocs/cc/augment/
return function() return function()
local cubes = {} local cache = {}
while _G._running do while _G._running do
local el = entities local el = _G.nearbyEntities
for i, cube in ipairs(cubes) do for i, entry in ipairs(cache) do
if el[i] == nil then if el[i] == nil then
cube.setSize(0.0, 0.0, 0.0) entry.cube.setSize(0.0, 0.0, 0.0)
print("entity box "..tostring(i).." unused") entry.frame.setAlpha(0x00)
end end
end end
for i, entity in ipairs(entities) do for i, entity in ipairs(nearbyEntities) do
if cubes[i] == nil then if cache[i] == nil then
cubes[i] = canvas3d.addBox(0, 0, 0) cache[i] = {}
cubes[i].setDepthTested(false) cache[i].cube = canvas3d.addBox(0, 0, 0)
print("Created cube for entity "..entity.name) cache[i].frame = canvas3d.addFrame(0, 0, 0)
cache[i].text = cache[i].frame.addText({ 0, 0 }, "")
cache[i].cube.setDepthTested(false)
cache[i].frame.setDepthTested(false)
end end
cubes[i].setPosition(entity.x, entity.y, entity.z)
cubes[i].setSize(0.25, 0.25, 0.25) cache[i].cube.setPosition(entity.x, entity.y, entity.z)
cache[i].frame.setPosition(entity.x, entity.y, entity.z)
cache[i].frame.setAlpha(0xFF)
cache[i].text.setText(entity.name)
cache[i].text.setColor(0xFF0000FF)
end end
os.sleep(0.05) os.sleep(0.05)
end end

View File

@ -1,5 +1,3 @@
-- x-run: scp ./* pneumatic-pump:htdocs/cc/augment/
local repository = "https://git.salushnes.solutions/hkc/cc-stuff/raw/branch/master/augment/files.json" local repository = "https://git.salushnes.solutions/hkc/cc-stuff/raw/branch/master/augment/files.json"
local files = textutils.unserializeJSON(http.get(repository).readAll()) local files = textutils.unserializeJSON(http.get(repository).readAll())