Hello! I have a script with an attribute with an array of entites with the button component and I need to assign the click event to all of them. Normally, a for loop would work, but that makes it so all events activate the same function but I need the script to give different results depending on the button. Thanks in advance.
Try using a boolean and an if statement
Don’t really understand sorry.
My code goes a bit like this
script.attributes.add("buttonEntity",{type:"entity",array:"true"});
script.prototype.intiatilize = function () {
for (i = 0; i<this.buttonEntity.length; i++){
this.buttonEntity[i].on("click",doSomething,this);
}
};
The issue is i need to generate a different function for each button entity and i dont want to hardcode each individual function.
I think you would need to hardcode its function anyway. Perhaps create an attribute that is a number, then check what the number is and do something from that.