Pages: [1] 2
  Print  
Author Topic: DnD Functions  (Read 1845 times)
Offline (Male) RetroX
Posted on: October 30, 2010, 04:13:21 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
Not like anyone here uses DnD, but they might as well be done. :P

#define action_if(x) if(x)
#define action_while(x) while(x)

etc.
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 #1 Posted on: October 31, 2010, 09:00:56 PM

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

View Profile Email
I'm not completely sure, but this might fall apart when the user selects "not". Judging by the way I coded LGM to handle it, I think action_if, when passed "x" and having "not" selected, LGM will generate the following code:

if !action_if(x)

Which would make yours generate the following code after resolving the defines:

if !if(x)

Perhaps a better solution might be

inline boolean action_if(var x) { /* return x != 0 */ }
or
#define action_if(x) (x != 0)
« Last Edit: October 31, 2010, 09:08:38 PM by IsmAvatar » Logged
Offline (Male) RetroX
Reply #2 Posted on: November 01, 2010, 03:55:46 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
That works.  I personally didn't know how LGM handled it, and assumed that action_if() was just used as an if macro.
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) Josh @ Dreamland
Reply #3 Posted on: November 01, 2010, 08:20:16 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2953

View Profile Email
...
LGM should handle action_if itself, without writing action_if.
I am unsure of the function of action_if in a GML script. Can someone verify it?
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
Offline (Female) IsmAvatar
Reply #4 Posted on: November 01, 2010, 09:30:00 PM

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

View Profile Email
The problem is that there are different conditional actions, and action_if is just a function name. For conditional actions, I do already prepend "if" for it, and then handle "not" by also prepending "!". The function then follows, so it's simple enough to just write the code for it, but I can't assume that action_if is necessary the if action, because it could very well be user coded with special conditions, in which case it should simply behave as a "return x != 0;"
Logged
Offline (Male) Josh @ Dreamland
Reply #5 Posted on: November 02, 2010, 12:31:06 AM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2953

View Profile Email
If it's not the case that action_if is a substitute for "if", then it should be defined as inline bool action_if(double x) { return x >= .5; } (bool(x != 0) is redundant, anyway).
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
Offline (Female) IsmAvatar
Reply #6 Posted on: November 02, 2010, 09:27:02 AM

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

View Profile Email
Don't forget negative numbers.
Logged
Offline (Male) Josh @ Dreamland
Reply #7 Posted on: November 02, 2010, 09:33:06 AM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2953

View Profile Email
bool(-1) = 0 in GML
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
Offline (Female) IsmAvatar
Reply #8 Posted on: November 02, 2010, 09:37:28 AM

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

View Profile Email
works for me
Logged
Offline (Male) Rusky
Reply #9 Posted on: November 02, 2010, 11:39:38 AM

Resident Troll
Joined: Feb 2008
Posts: 961
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
How are you planning to deal with that in GML? If you directly copy the if over the truth of expressions will be different.
Logged
Offline (Female) IsmAvatar
Reply #10 Posted on: November 02, 2010, 11:45:42 AM

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

View Profile Email
For example?
Logged
Offline (Male) Josh @ Dreamland
Reply #11 Posted on: November 02, 2010, 12:34:26 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2953

View Profile Email
variant::operator bool() { return dval > .5; }
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
Offline (Male) polygone
Reply #12 Posted on: November 02, 2010, 12:39:38 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 810

View Profile
Can there be an option added to LGM/Enigma to make it x != 0 instead of x <= .5 ?
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Male) Josh @ Dreamland
Reply #13 Posted on: November 02, 2010, 12:41:34 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2953

View Profile Email
Ideally. At this point, options are still a YAML clusterfuck. But after we have it so you're able to switch out APIs, I don't see why not.
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
Offline (Male) RetroX
Reply #14 Posted on: November 03, 2010, 03:28:09 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
variant::operator bool() { return dval > .5; }
Shouldn't that be >=?
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? :(
Pages: [1] 2
  Print