Pages: 1 2
Author Topic: action_move_to  (126,799 Views)
Offline (Unknown gender) TGMG

Developer
Joined: Jun 2008
Posts: 107
View profile WWW
Reply #15 Posted on: March 02, 2011, 05:45:58 PM
Implementing a parser just for writing the action code to gml would be overkill and be very unnecessary unless their is a reason to not pass the argument_relative in as an argument, which only requires changes 2 or 3 lines of code in the plugin compared to writing a parser or implementing code to keep track of the closing braces.
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Reply #16 Posted on: March 02, 2011, 07:01:35 PM
Personally I'm a fan of passing an argument, as long as it doesn't introduce problems with variable arguments or such. It makes sense that way, since relative is kind of an 'argument' to the DND action, and not intended as a global variable. It saves the trouble of keeping it global. And, the conversion process is intended to mostly reflect the DND look, so introducing brackets muddies it up, since that's really only supposed to be introduced by the Begin and End (resp. up and down triangle) actions.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #17 Posted on: March 02, 2011, 07:36:36 PM
I'm failing to see how it will work without overcomplicating things since when the gml action_* functions don't take the relative argument.
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Reply #18 Posted on: March 02, 2011, 08:56:50 PM
polygone: Function overloading is possible in C++ (the language ENIGMA is written in).

action_single_argument(var arg1)
action_single_argument(var arg1, bool argument_relative)

Or, sometimes this is written:
action_single_argument(var arg1, bool argument_relative = false)
To indicate a default value if none is provided.
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #19 Posted on: March 02, 2011, 09:22:46 PM
Oh using a default parameter is fine then?

Code (C++) Select
inline void action_move_to(double x, double y, bool argument_relative = false)
{
  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;
  }
}

You won't need argument_relative as a global variable then. Why wasn't this just used to start with?
Offline (Unknown gender) IsmAvatar

LateralGM Developer
LGM Developer
Joined: Apr 2008
Posts: 877
View profile
Reply #20 Posted on: March 02, 2011, 09:55:26 PM
I come from a C background, where functions cannot be overloaded. The action_* functions included in GM do not have these arguments.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #21 Posted on: March 03, 2011, 05:04:05 AM
You can use that for now. Until TGMG commits his changes, which include an argument_relative. See the discussion in this thread.
Pages: 1 2