I have a Sprite object called "Weapons" with many animations named things like "Pistol", "Revolver", etc. How do I get the names of every "Weapon" object animation using an event sheet script or script file?
Currently, I'm hard-coding the animation names into an array, but I'd like to not need to update the array whenever I add new animations. Here's an example:
// This is a function block inside an event sheet called "GetRandomWeaponName".
// It returns a random "Weapon" animation name that isn't the name of the currently wielded weapon.
const weaponWielder = runtime.objects.WeaponWielder.getFirstPickedInstance();
const currentWeaponName = weaponWielder.instVars.WeaponName;
// This is the relevant part where I hard-code
// all of the "Weapon" animation names.
const otherWeaponNames = [
"Pistol",
"Revolver",
"Shotgun",
// All other names...
].filter(name => name !== currentWeaponName);
const randomIndex = Math.floor(Math.random() * otherWeaponNames.length);
runtime.setReturnValue(otherWeaponNames[randomIndex]);