I have the following situation: I want a button that adds selects one object from a predetermined set and adds it to a list. If all objects already have been added to a list, it generates a new UI-object, which displays all the objects. If the player selects one of the objects from that display, then it gets removed from whatever list it is in and added to the list dependend on the originally clicked button.
To make this happen, when the button is pressed and no objects are free, another ui-object gets created which also creates a button for each of the objects. Each of those buttons also gets the object_index of the original button. When the new button gets pressed it uses with on the original button, adds it's selected object id to the variables of the original button and then tells it to run it's script again.
But with the "script_execute" within the with bracket it somehow creates an endless loop where it just keeps running that script. Anyone know what I can do about that?
Original Button commit - script:
New button commit-script:
To make this happen, when the button is pressed and no objects are free, another ui-object gets created which also creates a button for each of the objects. Each of those buttons also gets the object_index of the original button. When the new button gets pressed it uses with on the original button, adds it's selected object id to the variables of the original button and then tells it to run it's script again.
But with the "script_execute" within the with bracket it somehow creates an endless loop where it just keeps running that script. Anyone know what I can do about that?
Original Button commit - script:
GML:
function commit_add_agent_general() {
if(subjectId == noone) subjectId = get_free_agent();
if(subjectId != noone) {
if(subjectPicker != noone) instance_destroy(subjectPicker);
add_agent(agent_assignment_type.GENERAL, buttonId, subjectId);
object.update = true;
object.assignedAgents = get_assigned_agent_Ids(agent_assignment_type.GENERAL, buttonId);
} else if(subjectId == noone) {
subjectPicker = new_agent_selector(x2, x2 + AGENT_SELECTOR_WIDTH, y2, y2 + AGENT_SELECTOR_HEIGHT, object_index, get_general_local(gen_local.AGENT_SELECTOR), UI_LAYER_2);
}
}
GML:
function commit_agent_selection() {
var _subjectId = buttonId;
with(object) {
subjectId = _subjectId;
script_execute(script);
}
}