This works to copy the list and connect it to the user, but the issue is I need to figure out a way from here for it to check whether or not the player currently has an inventory item, and if it does not to update that item. Right now if I reload the page it adds all of the items again. I want there to be no duplicates.
If there is a way to do this I haven’t been able to figure it out. Maybe I’m missing something in the copy list function. If there is an easier way to create a default set up items that can be placed on each player (and updated) I’d love the insight.
Thanks for any help, I’ve been beating my head against a wall on the best way to do inventories for weeks.
Ok…now it isn’t connecting to my user haha. It is copying the list correctly, but I’m not exactly sure the best way to connect this to my player. Back to the drawing board but I think I’m on the right track.
I think it’s considering the stock inventory different from the ones in my inventory, since my inventory items contain a “player” field making them different. This is making my advanced filter not work correctly since they aren’t technically the same.
I’m also a touch worried that “copy a list” isn’t going to work long term since it won’t allow me to build more than 100 items to copy. If I end up building more than 100 items this method becomes moot… hmm
Hi there, @snarec… if I understand your post correctly, I wouldn’t copy a list of things, but instead, I would use a recursive backend workflow that loops through a list of the default inventory items and creates a new item for a player for each item in the default list. I would probably also have a field that links each item for a player back to its default item. With that field in place, you could define the list of things that need to be created for the player (which you will pass as a parameter to the backend workflow) as the default list minus a list of items where the player is the current user and the item’s associated default item field contains an item in the default list.
So, any of that make sense and seem like it could work for you?
Yeah, you would need to be on at least the first paid plan (Personal) in order to use backend workflows. If you can swing it (no offense there, of course), I would highly recommend it because backend workflows will change your life (well, your Bubble life, at least). To be honest, you almost can’t build an app “the right way” without backend workflows, so you are probably going to have to go that route at some point anyway.
Note that I used a yes/no field (set to yes) to define an inventory item as a default item instead of looking for an empty player field, and I probably wouldn’t have the player field at all because the built-in Created by field will associate an item with a player.
The constraint on the second search is the same as the constraint on the first search, and the advanced filter looks like this.
I can’t actually test that stuff because my sandbox app is not on a paid plan, but even if it doesn’t fully work, it should help you understand some of the concepts you will need to keep in mind, such as putting a condition on the second step of the backend workflow to stop it from looping at some point.
Without being able to see exactly how you have everything set up from end to end, I don’t know what’s going on. If you want to share a read-only link to your editor, I’d be happy to poke around under the hood.