Pages: « 1 2
  Print  
Author Topic: action_move_to  (Read 24878 times)
Offline (Unknown gender) TGMG
Reply #15 Posted on: March 02, 2011, 12:45:58 pm

Developer
Joined: Jun 2008
Posts: 107

View Profile WWW Email
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.
Logged
me
GMbed 2.0 :: Embed you gm games in websites.
Offline (Female) IsmAvatar
Reply #16 Posted on: March 02, 2011, 02:01:35 pm

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 877

View Profile Email
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.
Logged
Offline (Male) polygone
Reply #17 Posted on: March 02, 2011, 02:36:36 pm

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
I'm failing to see how it will work without overcomplicating things since when the gml action_* functions don't take the relative argument.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Female) IsmAvatar
Reply #18 Posted on: March 02, 2011, 03:56:50 pm

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 877

View Profile Email
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.
Logged
Offline (Male) polygone
Reply #19 Posted on: March 02, 2011, 04:22:46 pm

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
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?
« Last Edit: March 02, 2011, 04:24:24 pm by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Female) IsmAvatar
Reply #20 Posted on: March 02, 2011, 04:55:26 pm

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 877

View Profile Email
I come from a C background, where functions cannot be overloaded. The action_* functions included in GM do not have these arguments.
Logged
Offline (Male) Josh @ Dreamland
Reply #21 Posted on: March 03, 2011, 12:04:05 am

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
You can use that for now. Until TGMG commits his changes, which include an argument_relative. See the discussion in this thread.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Pages: « 1 2
  Print