Skip to content

🐛 Vec input in wrong order when used as input for a script binding #430

Open
@Peepo-Juice

Description

@Peepo-Juice

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions