Hi! I’m making a Roguelike game and one of its component is to show different skills every time. I have 2 arrays. One has all the skills and one will store the selected skills using a random function. I can easily bring back the skills for the skill select array to the all skill array by just using their index when they’re selected. But my problem is some of the skills can be selected only once so it must removed from the all skill list array after it’s selected so that it will never appear again on the selection. Is there a way to remove a variable on an array using it’s name so I can specifically remove it from the all skill array list.
Hi, is your array a global variable, a scene variable or an object variable?
Would this extension help?
I’m using scene variable. Does this one allows me to find a specific variable using its name and remove it to that array? For example: [attack, health, speed] I want to remove “attack” on the array. (I’m using strings)
An array of named elements is a structure, so your variable is a structure, right?
Honestly I don’t know how you could remove an element from an array nor a structure via events. If this extension doesn’t allow you to do that (and quite honestly I’ve never tried it myself), then maybe you could try these workarounds:
Imagine you have an array of the possible strings you can retrieve: “allKeys = [attack, health, speed]” and you also have two other arrays: “usedKeys = ” and “availableKeys = ”. Empty by default. You then store the key of what you used in the array “usedKeys” and, each time, you will empty/delete “availableKeys” and re-populate it with all the keys that are not contained in “usedKeys”. It’s… complicated. Maybe you can do this without using an extension, but the extension I mentioned might help.
[Just for context and not knowing your experience. Also, apologies if I don’t use the proper terms. Program languages vary and arrays and structures are very similar]
Arrays and structures are very similar. The main difference is arrays are numbered elements. Like variableName while structures are variableName.childName or variableName[“childName”]
You can delete array elements by index (number) and structure children by name (string)
I’m not sure if that helps.
I feel like I’m missing something obvious and if I am, I apologize.
The problem with a structure is that I can’t think of a way to easily pick a random child like you can with an array. But then with an array there’s no obvious easy way to delete a specific value. Maybe you need to use both or create a cross reference somehow.
If I didn’t solve it, I hope I at least added some context or a look into the mechanism. I still think I’m missing something obvious. I’m not an expert.