mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add on_update event
This commit is contained in:
parent
bb1c0b4b44
commit
982c8b132d
7 changed files with 41 additions and 10 deletions
|
|
@ -40,6 +40,21 @@ return {
|
|||
return entity
|
||||
end,
|
||||
remove_Entity = function(eid)
|
||||
entities[eid] = nil;
|
||||
local entity = entities[eid]
|
||||
if entity then
|
||||
entity.env = nil
|
||||
entities[eid] = nil;
|
||||
end
|
||||
end,
|
||||
update = function()
|
||||
for id,entity in pairs(entities) do
|
||||
local callback = entity.env.on_update
|
||||
if callback then
|
||||
local result, err = pcall(callback)
|
||||
if err then
|
||||
print(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue