makspll / makspll/bevy_mod_scripting
:bug: Vec input in wrong order when used as input for a script binding
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 649
- Forks
- 59
- PR merge metrics
- No merged PRs in 30d
Description
Summary
If i have a list of Entities and i provide it as input for a script binding, the last item in the list becomes the first item. This only happens if there is an even number of items (i only tested up to a size of 4).
Reproducing
Rust binding:
#[derive(Component, Default, Clone, Reflect)]
#[reflect(Component, Default)]
pub struct MyStruct {
list: Vec<Entity>,
}
#[script_bindings(name = "my_struct")]
impl MyStruct {
pub fn set_list(mut _self: Mut<MyStruct>, input: Vec<Val<Entity>>) {
// if u check the input at this point, the order will be wrong if it has 2 or 4 items (maybe even on 6+?)
// this other stuff doesnt matter
let unwrapped: Vec<Entity> = input.into_iter().map(|a| *a).collect();
_self.list = unwrapped;
}
}
Then in lua, i just query for the component and call :set_list() and pass in a table of Entities.
Additional Data
I have not tested this in a minimal reproduction scenario. If u can't reproduce easily, then I will need to make the time to create a repo that does.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Rust script binding with a Lua table of two and four Entity values, then inspect the Vec conversion path used by script bindings. Confirm that the resulting input preserves table order for even and odd lengths, and add or run a regression test covering those cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100