polygone
 Joined: Mar 2009
Posts: 794
|
 |
Posted on: February 28, 2011, 01:17:43 AM |
|
|
|
inline void action_move_to(double x, double y) { enigma::object_planar* const inst = ((enigma::object_planar*)enigma::instance_event_iterator->inst); if (argument_relative) { inst->x += x; inst->y += y; } else { inst->x = x; inst->y = y; } } How the fuck does relative work? It isn't specified as an argument in gml....
|
|
|
RetroX
Master of all things Linux
 Joined: Apr 2008
Posts: 1,055
|
 |
Reply #1 Posted on: February 28, 2011, 01:42:46 AM |
|
|
|
inline void action_move_to(double x, double y) { move_towards_point(x, y); }
|
|
|
|
|
RetroX
Master of all things Linux
 Joined: Apr 2008
Posts: 1,055
|
 |
Reply #3 Posted on: February 28, 2011, 04:02:38 AM |
|
|
|
void action_move_to(double x, double y, bool argument_relative) { enigma::object_planar* const inst = ((enigma::object_planar*)enigma::instance_event_iterator->inst); if (argument_relative) { inst->x += x; inst->y += y; } else { inst->x = x; inst->y = y; } }
|
|
|
IsmAvatar
LateralGM Developer
 Joined: Apr 2008
Posts: 877
|
 |
Reply #4 Posted on: February 28, 2011, 04:58:14 AM |
|
|
|
It's codematically generated when The Plugin translates your DND to code. Immediately prior to the code it will set argument_relative to true if it's relative, or false otherwise.
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #5 Posted on: February 28, 2011, 05:03:54 AM |
|
|
|
I meant when using action_ functions. In gml the relative argument doesn't seem to be used..
|
|
|
IsmAvatar
LateralGM Developer
 Joined: Apr 2008
Posts: 877
|
 |
Reply #6 Posted on: February 28, 2011, 06:40:15 AM |
|
|
|
No, I don't think relative is treated as an argument. Instead, it's treated as an internal mechanism, probably not unlike how we've implemented it as a kind of global variable.
|
|
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #8 Posted on: March 02, 2011, 04:50:28 AM |
|
|
|
So I see, you would work relative like so EDL:
argument_relative = true; action_move_to(4, 4); Should use the action relative. This I presume would actually work in gml however it doesn't allow you to set the argument_relative variable.
Calling plain as:
action_move_to(4, 4); Should always use the action not relative. This means that the argument_relative variable should always be set false after an action is called.
|
|
|
IsmAvatar
LateralGM Developer
 Joined: Apr 2008
Posts: 877
|
 |
Reply #9 Posted on: March 02, 2011, 05:21:40 AM |
|
|
|
Yes, that's exactly the way it works. In fact, at one point I had forgotten to reset argument_relative, so we had a bug, but it has since been fixed. Actually, the way we handle it is to *always* set argument_relative prior to any action that allows relative. Maybe not the most efficient, but I don't think DND users are going to complain about an additional variable set before some DND actions.
However, as TGMG has pointed out, using an IF action before a relative action causes a problem with this conversion method: * If Action * Set Motion Relative
gets converted to:
if (blah) argument_relative = blah; action_set_motion(blah);
Even though action_set_motion should belong to the if statement. Solved by either:
if (blah) { argument_relative = blah; action_set_motion(blah); or
if (blah) action_set_motion(blah,argument_relative_value);
|
|
|
|
|
|
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #12 Posted on: March 02, 2011, 04:40:32 PM |
|
|
QuoteSo it needs to keep track of where to actually close the '{' for action_if's (that have the relatvie checkbox) which is much more complex than passing the value in by the argument. Can't you put the closing brace in then move back up into the statements?
|
|
|
|
|
|
|
|