Dagoba
Member
Hello!
I am trying to do something like this:
- Get an ID of an object that is the furthest from goal.x and goal.y
- The object must have a certain variable being a certain string, like "Blue" or "Yellow"
How to do this?
This is inside a script, you use it like this: scr_upgrade_item("Blue");
And the script looks like this:
I think that the problem is with the globalvar color, but I do not know how to do it.
Should I make a global variable instead of globalvar?
Thanks in advance!
I am trying to do something like this:
- Get an ID of an object that is the furthest from goal.x and goal.y
- The object must have a certain variable being a certain string, like "Blue" or "Yellow"
How to do this?
This is inside a script, you use it like this: scr_upgrade_item("Blue");
And the script looks like this:
Code:
globalvar color;
color = argument[0];
globalvar furthest_color;
var cost;
if (instance_exists(par_color)) {
with(par_color) {
if (type == color) {
furthest_color = instance_furthest(obj_goal.x, obj_goal.y, id);
}
}
}
cost = furthest_color.upgrade_cost;
with(furthest_color) {
if (type == "Blue") {
global.AI_cash -= cost;
upgrade_level++;
}
}
Should I make a global variable instead of globalvar?
Thanks in advance!