My experience with using other outside the scope of with() or collisions, is that it behaves as the current instance.Just remember though, if you call that script that uses the other variable, and you are not in a with(){} statement or collision event, you will get either some kind of error, or possibly get wrong behavior, but more likely the error.
a = 1;
b = 1;
with (other) {
a++;
}
other.b++;
draw_text(10, 10, string(a));
draw_text(10, 30, string(b));
draw_text(10, 50, string(id));
draw_text(10, 70, string(other.id));
I'm guessing they have some kind of failsafe in there then. They should really shoot out an error instead. I would count that as wrong/undefined behavior as I mentioned. Neat to know though.My experience with using other outside the scope of with() or collisions, is that it behaves as the current instance.
Nobody said that. All I said was that you needed to be sure that the script is being called from within a with statement(){}. Then, the otherkeyword will be applicable. If you are referring to calling a script, and then that script having the with(){} statement(which then uses other[/], there is no reason that won't work either. Scripts/Functions generally work as if you simply copy/pasted the code in(there is even a pre-compiler flag to force this literal thing to happen when using the YYC).Sooo in the script, I know Im able to access instance variables of the with(obj). However 'other' wont work from there?
I would have felt more comfortable with it having the value of noone outside with or collisions if not aborting with an error. But I'm not losing sleep over the current behavior.I'm guessing they have some kind of failsafe in there then. They should really shoot out an error instead. I would count that as wrong/undefined behavior as I mentioned. Neat to know though.
noone would have been acceptable, I like the actual error better so it's more clear what's going on instead of undefined stuff, but yeah, I never do it so it doesn't really affect me.I would have felt more comfortable with it having the value of noone outside with or collisions if not aborting with an error. But I'm not losing sleep over the current behavior.
Given object A and object B, these two sets of code should function identically.Sooo in the script, I know Im able to access instance variables of the with(obj). However 'other' wont work from there?
script();
with B {
if ++x > room_width {
x = 0;
other.y += 16;
}
}
with B
script();
if ++x > room_width {
x = 0;
other.y += 16;
}