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._running = true
@ -9,7 +8,7 @@ _G.canvas3d_src.clear()
_G.canvas3d = canvas3d_src.create()
_G.player = nil
_G.entities = {}
_G.nearbyEntities = {}
local function run_wrapped(func, filename)
return function()
@ -72,7 +71,7 @@ function() -- Neural Interface coroutine
print("NI routine started")
while _G._running do
_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()
os.sleep(0.05)
end

View File

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

View File

@ -1,23 +1,29 @@
-- x-run: cd .. && scp -r ./* pneumatic-pump:htdocs/cc/augment/
return function()
local cubes = {}
local cache = {}
while _G._running do
local el = entities
for i, cube in ipairs(cubes) do
local el = _G.nearbyEntities
for i, entry in ipairs(cache) do
if el[i] == nil then
cube.setSize(0.0, 0.0, 0.0)
print("entity box "..tostring(i).." unused")
entry.cube.setSize(0.0, 0.0, 0.0)
entry.frame.setAlpha(0x00)
end
end
for i, entity in ipairs(entities) do
if cubes[i] == nil then
cubes[i] = canvas3d.addBox(0, 0, 0)
cubes[i].setDepthTested(false)
print("Created cube for entity "..entity.name)
for i, entity in ipairs(nearbyEntities) do
if cache[i] == nil then
cache[i] = {}
cache[i].cube = canvas3d.addBox(0, 0, 0)
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
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
os.sleep(0.05)
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 files = textutils.unserializeJSON(http.get(repository).readAll())