mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add on_update, on_render to docs & change entities tps to 20
This commit is contained in:
parent
3f67944cc2
commit
f8907f7db1
10 changed files with 62 additions and 21 deletions
|
|
@ -88,25 +88,29 @@ return {
|
|||
entities[eid] = nil;
|
||||
end
|
||||
end,
|
||||
update = function()
|
||||
for _,entity in pairs(entities) do
|
||||
update = function(tps, parts, part)
|
||||
for uid, entity in pairs(entities) do
|
||||
if uid % parts ~= part then
|
||||
goto continue
|
||||
end
|
||||
for _, component in pairs(entity.components) do
|
||||
local callback = component.on_update
|
||||
if callback then
|
||||
local result, err = pcall(callback)
|
||||
local result, err = pcall(callback, tps)
|
||||
if err then
|
||||
debug.error(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end,
|
||||
render = function()
|
||||
render = function(delta)
|
||||
for _,entity in pairs(entities) do
|
||||
for _, component in pairs(entity.components) do
|
||||
local callback = component.on_render
|
||||
if callback then
|
||||
local result, err = pcall(callback)
|
||||
local result, err = pcall(callback, delta)
|
||||
if err then
|
||||
debug.error(err)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue