Improve debug message

This commit is contained in:
Ukendio 2024-09-21 21:28:06 +02:00
parent 5d6c2e8d42
commit 74ca305600

View file

@ -1666,16 +1666,14 @@ if _G.__JECS_DEBUG then
return
end
if world_has_one_inline(world, entity, id) then
if invoked_hook then
local file, line = debug.info(2, "sl")
local hook_fn = `{file}::{line}`
throw(
([[cannot call world:set within the
This world:set function invokes a structural change because %s doesn't exist on the entity.\n
call world:add when the hook %s is in process]]):format(get_name(world, id), hook_fn))
local why = `cannot call world:set inside {hook_fn} because it adds the component {get_name(world, id)}`
why ..= `\n[jecs note]: consider handling this logic inside of a system`
throw(why)
return
end
end