mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Fix linting errors from debug.info
Some checks failed
Analysis / Run Luau Analyze (push) Has been cancelled
Deploy VitePress site to Pages / build (push) Has been cancelled
Styling / Run Stylua (push) Has been cancelled
Unit Testing / Run Luau Tests (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
Some checks failed
Analysis / Run Luau Analyze (push) Has been cancelled
Deploy VitePress site to Pages / build (push) Has been cancelled
Styling / Run Stylua (push) Has been cancelled
Unit Testing / Run Luau Tests (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
This commit is contained in:
parent
02cb4ad7a2
commit
7c025a3782
1 changed files with 21 additions and 16 deletions
37
jecs.luau
37
jecs.luau
|
@ -1606,13 +1606,15 @@ World.each = world_each
|
||||||
World.children = world_children
|
World.children = world_children
|
||||||
|
|
||||||
if _G.__JECS_DEBUG then
|
if _G.__JECS_DEBUG then
|
||||||
-- taken from https://github.com/centau/ecr/blob/main/src/ecr.luau
|
local function dbg_info(n: number): any
|
||||||
-- error but stack trace always starts at first callsite outside of this file
|
return debug.info(n, "s")
|
||||||
|
end
|
||||||
local function throw(msg: string)
|
local function throw(msg: string)
|
||||||
local s = 1
|
local s = 1
|
||||||
|
local root = dbg_info(1)
|
||||||
repeat
|
repeat
|
||||||
s += 1
|
s += 1
|
||||||
until debug.info(s, "s") ~= debug.info(1, "s")
|
until dbg_info(s) ~= root
|
||||||
if warn then
|
if warn then
|
||||||
error(msg, s)
|
error(msg, s)
|
||||||
else
|
else
|
||||||
|
@ -1627,15 +1629,18 @@ if _G.__JECS_DEBUG then
|
||||||
throw(msg)
|
throw(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_name(world, id): string
|
local function get_name(world, id)
|
||||||
local name: string | nil
|
return world_get_one_inline(world, id, EcsName)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function bname(world: World, id): string
|
||||||
|
local name: string
|
||||||
if ECS_IS_PAIR(id) then
|
if ECS_IS_PAIR(id) then
|
||||||
name = `pair({get_name(world, ECS_ENTITY_T_HI(id))}, {get_name(world, ECS_ENTITY_T_LO(id))})`
|
local first = get_name(world, ecs_pair_first(world, id))
|
||||||
|
local second = get_name(world, ecs_pair_second(world, id))
|
||||||
|
name = `pair({first}, {second})`
|
||||||
else
|
else
|
||||||
local _1 = world_get_one_inline(world, id, EcsName)
|
return get_name(world, id)
|
||||||
if _1 then
|
|
||||||
name = `${_1}`
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if name then
|
if name then
|
||||||
return name
|
return name
|
||||||
|
@ -1659,14 +1664,14 @@ if _G.__JECS_DEBUG then
|
||||||
World.set = function(world: World, entity: i53, id: i53, value: any): ()
|
World.set = function(world: World, entity: i53, id: i53, value: any): ()
|
||||||
local is_tag = ID_IS_TAG(world, id)
|
local is_tag = ID_IS_TAG(world, id)
|
||||||
if is_tag and value == nil then
|
if is_tag and value == nil then
|
||||||
local _1 = get_name(world, entity)
|
local _1 = bname(world, entity)
|
||||||
local _2 = get_name(world, id)
|
local _2 = bname(world, id)
|
||||||
local why = "cannot set component value to nil"
|
local why = "cannot set component value to nil"
|
||||||
throw(why)
|
throw(why)
|
||||||
return
|
return
|
||||||
elseif value ~= nil and is_tag then
|
elseif value ~= nil and is_tag then
|
||||||
local _1 = get_name(world, entity)
|
local _1 = bname(world, entity)
|
||||||
local _2 = get_name(world, id)
|
local _2 = bname(world, id)
|
||||||
local why = `cannot set a component value because {_2} is a tag`
|
local why = `cannot set a component value because {_2} is a tag`
|
||||||
why ..= `\n[jecs] note: consider using "world:add({_1}, {_2})" instead`
|
why ..= `\n[jecs] note: consider using "world:add({_1}, {_2})" instead`
|
||||||
throw(why)
|
throw(why)
|
||||||
|
@ -1678,8 +1683,8 @@ if _G.__JECS_DEBUG then
|
||||||
|
|
||||||
World.add = function(world: World, entity: i53, id: i53, value: any)
|
World.add = function(world: World, entity: i53, id: i53, value: any)
|
||||||
if value ~= nil then
|
if value ~= nil then
|
||||||
local _1 = get_name(world, entity)
|
local _1 = bname(world, entity)
|
||||||
local _2 = get_name(world, id)
|
local _2 = bname(world, id)
|
||||||
throw("You provided a value when none was expected. " .. `Did you mean to use "world:add({_1}, {_2})"`)
|
throw("You provided a value when none was expected. " .. `Did you mean to use "world:add({_1}, {_2})"`)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue