ENIGMA Forums

Outsourcing saves money => Issues Help Desk => Topic started by: TacoBot on September 27, 2016, 12:46:52 pm

Title: Function essentially asking for 1.5 arguments?
Post by: TacoBot on September 27, 2016, 12:46:52 pm
So here's the code in question:

Code: [Select]
image_speed = 0.1;
moveSpeed = 3;

weapon = "pistol";
facing = "down";

key_moveUp = keyboard_check(ord('W'));
key_moveDown = keyboard_check(ord('S'));
key_moveLeft = keyboard_check(ord('A'));
key_moveRight = keyboard_check(ord('D'));

key_shootUp = keyboard_check(ord('I'));
key_shootDown = keyboard_check(ord('K'));
key_shootLeft = keyboard_check(ord('J'));
key_shootRight = keyboard_check(ord('L'));

And if I compile that, I get the error:

Code: [Select]
Check `obj_player::create...Syntax error in object `obj_player', Create event:0:
Line 7, position 36 (absolute 114): Too few arguments to function `ord': provided 1, required 2.

It's
Now, not only am I 100% sure ord() should take one (and only one) argument, but if I add an additional argument to the function:

Code: [Select]
In file included from SHELLmain.cpp:109:0:
/home/taco/.enigma/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h: In member function ‘virtual variant enigma::OBJ_obj_player::myevent_create()’:
/home/taco/.enigma/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:46:45: error: too many arguments to function ‘int enigma_user::ord(std::__cxx11::string)’
     key_moveUp = keyboard_check(ord("W", "W"));
                                             ^

I'm using the latest version off of Github, and I'm quite confused and frustrated. A little help?
Title: Re: Function essentially asking for 1.5 arguments?
Post by: Goombert on September 27, 2016, 05:27:05 pm
First, I can not reproduce this on the latest master version on Windows 10 with the above code. This must be specific to Linux and may be more of our string problems.

Don't be confused, the issue is actually very simple. So recently I noticed min/max argument counts was incorrect in the syntax checker. Believe it or not, I actually did fix it.
https://github.com/enigma-dev/enigma-dev/pull/1016
The reason it now appears broke in this case is due to our incompatibilities with C++11 strings. Because ord actually takes std::string in ENIGMA it is causing issues.

To work around this until I figure out more about your problem, you can go into the following file and set the variable to 0 instead of SIZE_MAX. Then save the file and reopen ENIGMA. However, after this the minimum argument count will be screwed up for other functions, but it will at least let you compile.
https://github.com/RobertBColton/enigma-dev/blob/36e73c0f056cf4637f758224e3e8750f1bc5ff1b/CompilerSource/compiler/jdi_utility.cpp#L61