Pages: 1 2 »
  Print  
Author Topic: action_move_to  (Read 6361 times)
Offline (Male) polygone
Posted on: February 27, 2011, 08:17:43 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
Code: (C) [Select]
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....
« Last Edit: March 02, 2011, 12:13:39 AM by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) RetroX
Reply #1 Posted on: February 27, 2011, 08:42:46 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
Code: [Select]
inline void action_move_to(double x, double y) { move_towards_point(x, y); }
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Rusky
Reply #2 Posted on: February 27, 2011, 10:40:02 PM

Resident Troll
Joined: Feb 2008
Posts: 955
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
argument_relative
Logged
Offline (Male) RetroX
Reply #3 Posted on: February 27, 2011, 11:02:38 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
Code: [Select]
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;
  }
}
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Female) IsmAvatar
Reply #4 Posted on: February 27, 2011, 11:58:14 PM

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

View Profile Email
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.
Logged
Offline (Male) polygone
Reply #5 Posted on: February 28, 2011, 12:03:54 AM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
I meant when using action_ functions. In gml the relative argument doesn't seem to be used..
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Female) IsmAvatar
Reply #6 Posted on: February 28, 2011, 01:40:15 AM

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

View Profile Email
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.
Logged
Offline (Unknown gender) TGMG
Reply #7 Posted on: February 28, 2011, 10:09:04 AM

Developer
Joined: Jun 2008
Posts: 107

View Profile WWW Email
This is not the best place to report this but before I forget (I was going to investigate further before filing a bug report). but there is a serious problem with the way the enigma plugin writes the action code.
Before it calls any action it writes the code "argument_relative=true; action_whatever()". Which works fine normally but it doesn't work when the if action is used without the block actions! as this happens:
"if (false) argument_relative=true; action_whatever()"
So it still calls action_whatever even although it shouldn't. I think a similar thing happens with the "with" statement.

It might be better to pass argument_relative into the function as a parameter that has a default value (so it is optional incase its used in normal gml).
Logged
me
GMbed 2.0 :: Embed you gm games in websites.
Offline (Male) polygone
Reply #8 Posted on: March 01, 2011, 11:50:28 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
So I see, you would work relative like so EDL:

Code: (EDL) [Select]
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:
Code: (EDL) [Select]
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.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Female) IsmAvatar
Reply #9 Posted on: March 02, 2011, 12:21:40 AM

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

View Profile Email
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:
Code: [Select]
if (blah)
  argument_relative = blah;
action_set_motion(blah);

Even though action_set_motion should belong to the if statement.
Solved by either:
Code: [Select]
if (blah)
  { argument_relative = blah; action_set_motion(blah);
or
Code: [Select]
if (blah)
  action_set_motion(blah,argument_relative_value);
« Last Edit: March 02, 2011, 12:23:16 AM by IsmAvatar » Logged
Offline (Male) polygone
Reply #10 Posted on: March 02, 2011, 01:08:05 AM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
I've just seen in Universal System:
https://enigma-dev.svn.sourceforge.net/svnroot/enigma-dev/trunk/ENIGMAsystem/SHELL/Universal_System/actions.h

I'm presuming this isn't actually called, but will be?
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) TGMG
Reply #11 Posted on: March 02, 2011, 06:05:26 AM

Developer
Joined: Jun 2008
Posts: 107

View Profile WWW Email
@IsmAvatar I initially tried to solve the problem by changing the plugin to add "{" around it. But it causes a problem when using multiple if statements:
{argument relative=false //this argument_relative is part of the action_if_something
if(action_if_something()) { //can't close the '}' for argument_relative until the end
{argument relative=false //this argument_relative is part of the action_if_something
if(action_if_something()) {
{argument relative=false
if(action_if_something()) {
{argument relative=false
action_something();}
}}}}}} //close al the if statements and the argument_relative blocks

So 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.

@polygone: I forgot that file was still in enigma, it isn't included, it provides all the function prototypes so i can easily test out game maker games which use actions without actually implementing each action properly. As you can see its very messy and unoptimised, it was really just a way to quickly test games that otherwise wouldn't convert.
Logged
me
GMbed 2.0 :: Embed you gm games in websites.
Offline (Male) polygone
Reply #12 Posted on: March 02, 2011, 11:40:32 AM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
Quote
So 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?
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) TGMG
Reply #13 Posted on: March 02, 2011, 12:11:57 PM

Developer
Joined: Jun 2008
Posts: 107

View Profile WWW Email
I don't understand what you mean by moving back up into the statements :/
Logged
me
GMbed 2.0 :: Embed you gm games in websites.
Offline (Male) Rusky
Reply #14 Posted on: March 02, 2011, 12:38:15 PM

Resident Troll
Joined: Feb 2008
Posts: 955
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
Keeping track of braces is trivial if you're not doing a find-and-replace parser, which I hope is the case by now.
Logged
Pages: 1 2 »
  Print