Open
Description
Problem
I'd like to be able to pass Entity
around in Lua, and I can with Val<Entity>
, but I'd also like to be able to call tostring()
on that value, but what happens currently is this.
Example for tostring
For this code:
world.info("entity "..tostring(e))
2025-04-02T07:56:25.127878Z ERROR bevy_mod_scripting_core::handler: error in script `main.lua`: Could not find function: display_ref for type: bevy_mod_scripting_core::bindings::reference::ReflectReference.
Context:
stack traceback:
[C]: in ?
[C]: in function 'tostring'
[string "/Users/shane/Projects/bevy_mod_scripting/crat..."]:93: in function '_update'
Event handling for: Language: Lua
Example for concatenation
And for concatenation I get this.
world.info("entity "..e)
2025-04-02T08:01:09.663853Z ERROR bevy_mod_scripting_core::handler: error in script `main.lua`: runtime error: [string "/Users/shane/Projects/bevy_mod_scripting/crat..."]:94: attempt to concatenate a LuaReflectReference value (local 'e')
stack traceback:
[C]: in metamethod 'concat'
[string "/Users/shane/Projects/bevy_mod_scripting/crat..."]:94: in function '_update'.
Context:
Event handling for: Language: Lua
I'm happy to wrap this value in a custom time struct MyEntity(Entity)
.
Solution
I'd like for either Debug
or Display
to be available in Lua's tostring()
and concatenate functionality.
Alternative Solution
I can pass the value to myself, and register a entity_tostring()
method implemented in Rust do what I want, but that feels off.
Metadata
Metadata
Assignees
Labels
No labels