Pfap
Member
Lets say you have like 10 rpg characters on a map and after each turn you need to run a script to update each instances position within a grid. Maybe a better way to phrase it is that I have 10 instances doing the same thing and after there done with that thing, I want to run 1 script globally for all instances. But I don't want to call it 10 times, because it only needs to run once.
Are global.flags a good way to handle the above?
With global flag:
Is the above a good way to handle my situation?
Are global.flags a good way to handle the above?
Code:
//10 instances will be running this at the same time
if active_opp{
if point_distance(x, y, targetX, targetY) > 5{
move_towards_point(targetX, targetY, 3);
}
else{
speed = 0;
active_opp = false;
//this will get fired 10 times unless I do something
with(update_obj){
event_user(0);
}
}
}
With global flag:
Code:
if active_opp{
if point_distance(x, y, targetX, targetY) > 5{
move_towards_point(targetX, targetY, 3);
}
else{
speed = 0;
active_opp = false;
//this will get fired 10 times unless I do something
if global.call_control{
global.call_control = false;
with(update_obj){
event_user(0);
}
}
}
}