minor optimization

This commit is contained in:
bgkillas 2025-02-09 10:25:45 -05:00
parent 6de1cd2278
commit 740e5638e5
3 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,7 @@
- `ctx.hook.on_world_initialized()` - called on OnWorldInitialized. - `ctx.hook.on_world_initialized()` - called on OnWorldInitialized.
- `ctx.hook.on_new_entity(ent)` - called on new alive entity. - `ctx.hook.on_new_entity(ent)` - called on new alive entity.
- `ctx.hook.on_world_update()` - called on OnWorldPreUpdate. - `ctx.hook.on_world_update()` - called on OnWorldPreUpdate.
- `ctx.hook.on_world_update_post()` - called on OnWorldPostUpdate.
- `ctx.hook.on_world_update_client()` - called on OnWorldPreUpdate, but only on clients. - `ctx.hook.on_world_update_client()` - called on OnWorldPreUpdate, but only on clients.
- `ctx.hook.on_world_update_host()` - called on OnWorldPreUpdate, but only on host. - `ctx.hook.on_world_update_host()` - called on OnWorldPreUpdate, but only on host.
- `ctx.hook.on_new_player_seen(new_playerdata, player_count)` - called the first time player with this peer_id has entered the world. - `ctx.hook.on_new_player_seen(new_playerdata, player_count)` - called the first time player with this peer_id has entered the world.

View file

@ -79,13 +79,13 @@ end)
local mod = {} local mod = {}
local function bool_to_truefalse(v) --[[local function bool_to_truefalse(v)
if v then if v then
return "true" return "true"
else else
return "false" return "false"
end end
end end]]
function mod.on_world_update_post() function mod.on_world_update_post()
local c_thrown = thrown local c_thrown = thrown

View file

@ -105,6 +105,9 @@ function tele.on_world_update()
ent_to_body[ent] = nil ent_to_body[ent] = nil
else else
ent_to_body[ent] = PhysicsBodyIDGetFromEntity(ent) ent_to_body[ent] = PhysicsBodyIDGetFromEntity(ent)
if ent_to_body[ent] ~= nil and #ent_to_body[ent] == 0 then
ent_to_body[ent] = nil
end
end end
end end
end end