ENIGMA Forums
General fluff => General ENIGMA => Topic started by: RetroX on October 30, 2010, 04:13:21 pm
-
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.
-
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)
-
That works. I personally didn't know how LGM handled it, and assumed that action_if() was just used as an if macro.
-
...
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?
-
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;"
-
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).
-
Don't forget negative numbers.
-
bool(-1) = 0 in GML
-
works for me
-
How are you planning to deal with that in GML? If you directly copy the if over the truth of expressions will be different.
-
For example?
-
variant::operator bool() { return dval > .5; }
-
Can there be an option added to LGM/Enigma to make it x != 0 instead of x <= .5 ?
-
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.
-
variant::operator bool() { return dval > .5; }
Shouldn't that be >=?
-
It is, I just wasn't paying much attention to the thread. :P