RetroX
|
|
Posted on: August 25, 2010, 10:37:28 am |
|
|
Master of all things Linux
Location: US Joined: Apr 2008
Posts: 1055
|
Considering how it's been asked, I figured that I'd make a topic about it. If a function is not implemented, you can post a C++ or GML (preferably C++) equivalent here for others to use. Before you do, please check out the latest version of ENIGMA from the SVN to ensure that it is not already implemented. If it shows up in the list under ENIGMA > Keywords > Functions, try running "grep function_name $(find)" in the ENIGMA directory (bash-only). It might take a few seconds, but once it's done, it will direct you to the file that the function is defined in.
Anything that involves actual game resources (sprites, sounds, etc.) shouldn't be worked on and the actual ENIGMA devs should handle it. But other than that, go ahead. Anything that isn't actually implemented in GM but might be useful should also be posted.
Note that the current graphics/audio systems run on OpenGL/OpenAL and that the current window managers are a giant mess because we have six completely different versions that will be used. Eventually, Direct3D/DirectAudio will likely be implemented for Windows simply because Intel sucks cocks.
|
|
« Last Edit: August 25, 2010, 10:54:30 am by RetroX »
|
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)Why do all the pro-Microsoft people have troll avatars?
|
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #4 Posted on: August 25, 2010, 03:21:41 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
RetroX:
In whitespace: #define action_if(x) if (x) #define action_draw_arrow draw_arrow #define create_object instance_create int action_draw_life(int x, int y, int spr) { for (int i = 0; i < life; i++) draw_sprite(spr,0,x + i*sprite_get_width(spr), y); } etc.
Note: that draw_life one won't work as-is; it's just a demonstration. Let me set up an API to make that easy for typical users, and I'll update this with 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
|
|
|
|
|
IsmAvatar
|
|
Reply #7 Posted on: August 26, 2010, 10:34:16 am |
|
|
LateralGM Developer
Location: Pennsylvania/USA Joined: Apr 2008
Posts: 877
|
r383
I just corrected a bug where the last argument is written as a Java Object, rather than the argument value.
Resources should now write their name, or default to the number if they don't have a name for some reason. Colors should output as hex: #bbggrr (can be left as integer, if desired). Arguments that are guaranteed to be string will have "" around them. action_show_message is not one of these. Boolean "0" and non-zero will be replaced with false and true respectively.
action_show_message and other D&D actions which can take either strings or expressions (for instance, action_show_message) will be left alone for now because I'm not sure of their behavior. Test each of these lines individually, for instance: string(x) Hello World
A possible workaround could be special surrounding characters, such as ``, which ENIGMA would have to handle explicitly. `string(x)` would become "0" `Hello World` would become "Hello World"
|
|
« Last Edit: August 26, 2010, 10:47:56 am by IsmAvatar »
|
Logged
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #9 Posted on: August 26, 2010, 11:23:00 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
That much isn't actually my responsibility. Someone would have to be gravely stupid to type action_if(); instead of if(). DND caters to novices. Real programmers learn when to semicolon.
However, what does action_if(false); show_message("weee"); do in GM?
|
|
|
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
|
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #13 Posted on: August 30, 2010, 01:50:18 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
r9k: Indeed, I've been looking for the best way to provide unlimited arguments to the function. It seems my only choice is to parse it that way.
|
|
|
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
|
|
|
luiscubal
|
|
Reply #14 Posted on: August 31, 2010, 05:23:56 am |
|
|
Joined: Jun 2009
Posts: 452
|
If ENIGMA is going to be single-threaded, then there is at least one way.
Mark the function as __ENIGMA_VARARGS, like this:
var min(__ENIGMA_VARARGS);
The parser would see that, and deal with that function differently. It would define two implicit parameters: a size_t with the number of arguments and an array of variables with the actual arguments. The parser would make this transparent, so that when calling min(1, 2, 3), that would be turned to:
::argcount = 3; delete argarray; argarray = new var[3]; argarray[0] = 1; argarray[1] = 2; argarray[2] = 3; min();
It adds *some* overhead, but not a lot. My real concern would be the complexity this adds to your parser. You can also re-use the C varargs system instead of this, but remember varargs doesn't keep track of the number of variables, so you'd still need an extra-argument.
|
|
|
Logged
|
|
|
|
|