AGS 3.3.x/3.4.0.0 Developer Discussion

Started by Gurok, Sun 09/02/2014 08:45:13

Previous topic - Next topic

Crimson Wizard

#20
Gurok, I could not find time to check the for/continue/break feature yet.
Maybe you could make a test build and let people try it out meanwhile? You need to distribute only Editor & Engine binaries (dlls and exes), they may be manually copied over 3.3.0 folder.

The code changes in case anyone's interested to review: https://github.com/adventuregamestudio/ags/pull/121/commits

Monsieur OUXX

Quote from: abstauber on Mon 10/02/2014 10:00:18
But pretty pretty please consider fixing the Undo-History :~(

To be honest this is driving me nuts, because at some points I can't remember what I did to break the game. Only that now I can't undo my way out of this mess ;)

Yes, for me this is a no-go for upgrading to 3.3.0. I tend to do tests by changing parts of the code, then undo the changes. If the undo history is gone, I'm done for.

 

monkey0506

You could test your code by doing this:

Code: ags
/*/
// Original code -- COMMENTED OUT
int a = 42;
float b = 3.14;
String c = "blah";
// ...
/*/ // don't mess with this ;)
// New code -- NOT COMMENTED
int a = 314;
float b = 5.7;
String c = "whatever";
// ...
/**/


Code: ags
/**/
// Original code -- NOT COMMENTED
int a = 42;
float b = 3.14;
String c = "blah";
// ...
/*/ // don't mess with this ;)
// New code -- COMMENTED OUT
int a = 314;
float b = 5.7;
String c = "whatever";
// ...
/**/


By changing a single character (the asterisks on the first line) you can toggle between the two blocks of code.

Crimson Wizard

Tzachs is testing the fix in the 3.3.1 branch right now.

Also, have anyone tried to use source control with AGS? There's even a plugin api for that.

Monsieur OUXX

#24
Quote from: monkey_05_06 on Wed 19/02/2014 16:26:30
You could test your code by doing this:

Nope. It's not a matter of replacing an entire section of code with another one. It's a matter of modifying a bunch of small parameters inside the code, and continualy testing what the changes did.
Anyway, just sayin'.  For me it would be disastrous not to be able to revert after I inadvertently broke something at some unknown point. It's only an inconvenience for me, others will do great.

Quote from: Crimson Wizard on Wed 19/02/2014 17:03:33
Have anyone tried to use source control with AGS? There's even a plugin api for that.
I can't wait for that to fully mature. I'm very excited.
 

Crimson Wizard

#25
Quote from: Monsieur OUXX on Wed 19/02/2014 17:49:13
I can't wait for that to fully mature. I'm very excited.
But you can use any version control system right now. For scripts, at least.
BTW Git is good for experiments, because it allows to quickly switch between branches.

Doing what you say with Undo sounds like a wrong thing to me anyway.

Monsieur OUXX

Quote from: Crimson Wizard on Wed 19/02/2014 18:10:46
Doing what you say with Undo sounds like a wrong thing to me anyway.

OK guys, you win, I'll stop being stubborn and switch to 3.3.0. I'm very attracted to source control and re-importing sprites from original source.
 

Crimson Wizard

Quote from: Monsieur OUXX on Thu 20/02/2014 11:13:23
OK guys, you win, I'll stop being stubborn and switch to 3.3.0. I'm very attracted to source control and re-importing sprites from original source.
I was not forcing you to use 3.3.0 :), in fact the non-working undo is something I would be concerned about as well.
Regarding source control, I mean it can be used normally without connection to AGS. You may just make a repository out of the game project folder.
I don't know how source control API works myself.

fireapache

#28
An alternative implementation of version control could be a simple visual interface with Git, using system calls (an API would be a better choise). A version of Git could be placed in the AGS folder on the next release. Each project folder would have a local repository, and may have a pre-configured .gitignore to ignore some files. To support remote repositories the user may enter with a Github URL in the project creation wizard, or set it later in the project settings.

Just a sugestion! :wink:

monkey0506

I worked closely with CJ in designing the current source/version control API for editor plugins, but I could never seem to quite wrap my own head about how to properly implement any of the systems I looked at. I knew less about version control then than I do now (which is still not very much), so I may take a look at it later and see if I could come up with anything.

Monsieur OUXX

Quote from: monkey_05_06 on Sat 22/02/2014 06:23:47
I may take a look at it later and see if I could come up with anything.

Please do it. AGS needs collaborative development.
 

Gurok

Quote from: Monsieur OUXX on Sat 22/02/2014 19:04:08
Please do it. AGS needs collaborative development.

AGS and the AGS Git repository both!
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crosco

I can't say anything to the Direct3D stuff. I'm not enough experienced with it.
The "for()" statement would be a nice-to-have feature. (I can't say why I didn't missed it so much.)

To having pointers as member variables of structs would be fantastic!

Quote from: Crimson Wizard on Thu 20/02/2014 11:26:04
Quote from: Monsieur OUXX on Thu 20/02/2014 11:13:23
OK guys, you win, I'll stop being stubborn and switch to 3.3.0. I'm very attracted to source control and re-importing sprites from original source.
I was not forcing you to use 3.3.0 :), in fact the non-working undo is something I would be concerned about as well.
Regarding source control, I mean it can be used normally without connection to AGS. You may just make a repository out of the game project folder.
I don't know how source control API works myself.

Crimson is right. A version control system will resolve your problem to determine which code lines you changed. And, it will allow you to keep a history of all your changes.
I installed a subversion repository on my machine (using TortoiseSVN) and added the project folder as trunk as Crimson also mentioned.
The repository also allows you to branch and try out another AGS version.

Gurok

#33
Hello all,

I've found some more low-hanging fruit. It's pretty easy to lift the static restrictions on extender functions such that you could do this:

Code: ags

static function DoIt(this Character *, int a)
{
    Display("I did it! %d", a);
}


and then in your module header, this:

Code: ags

import static function DoIt(this Character *, int a);


and then later somewhere in your code, this:

Code: ags

    Character.DoIt(3);


The trouble is that
a) "this" is not defined for a static extender function
b) the syntax is a bit ugly

"This" being undefined is not such a problem because the compiler picks that up anyway. If I were to tidy up the syntax (which I could), do people think this might be useful? Something like this might be possible for the syntax:
Code: ags

static function DoIt(extends Character, int a)

or this (which is the nicest I've thought of so far):
Code: ags

function AbsInt(static Maths, int value)


Though I am open to suggestions.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Gurok

#34
I've also devised an extraordinarily complicated way to do switch() statements if anyone's interested. This:

Code: ags

switch(x)
{
	case 5:
		Display("Five");
	case 6:
		Display("Six");
	default:
		Display("Default");
	case 7:
		Display("Seven");
}


translates into lots of jumps. Pseudo-assembly follows:

Code: ags

# Switch statement
jmp condition1:
exit:
jmp 0
condition1:
evaluate_expression("x == 5");
jz condition2:
code1:
Display("Five");
jmp code2:
condition2:
evaluate_expression("x == 6");
jz condition3:
code2:
Display("Six");
jmp code3:
condition3:
# No jumps or evals
code3:
Display("Default");
jmp code4:
condition4:
evaluate_expression("x == 7");
jz 0
code4:
Display("Seven");
end_of_statement:


With the 0 addresses being filled in as "end_of_statement" after the switch statement is fully parsed
Might need some temporary 0 addresses for lines like "jmp code2:" too
But with this, a break statement just becomes:

Code: ags

# Break statement
jmp exit:


I haven't coded the above yet, but that is what I plan to do. Comments welcome.
AGS script is a single pass compiler, so there are a lot of cases where jmp 0 is used temporarily. A few variables about how things are currently nested (almost to the point of having a second pass) are stored to help fill in the blank addresses later.

Side note: Passing structs as parameters is more complex than I first thought and might take some time.
[img]http://7d4iqnx.gif;rWRLUuw.gi

monkey0506

Static extenders would be great. I've come across several times where I had to resort to some annoying alternatives.

As to switch statements, I don't understand these things well enough to know any better, but you've said that it's a rather complicated solution, might there be a better way?

If you can figure out passing struct instances by reference as well then everyone can finally stop complaining about how horrible AGScript is.


Gurok

#36
Static extender functions

Syntax as follows.

Module:
Code: ags

function AbsInt(static Maths, int value)
{
    if(value < 0)
        value = 0 - value;

    return(value);
}


Header:
Code: ags

import function AbsInt(static Maths, int value);


Example call:
Code: ags

int x = Maths.AbsInt(-3);


https://github.com/gurok/ags/compare/adventuregamestudio:develop-3.3.1...331_static_extender_functions

Better warning for function delcaration inside a struct

https://github.com/gurok/ags/compare/adventuregamestudio:develop-3.3.1...bugtracker_function_in_struct_error_msg

http://www.adventuregamestudio.co.uk/forums/index.php?issue=503.0

--

I should probably listen to CW's advice and stop piling features into this thread. It's just every time I look at the scripting engine (and this weekend I spent some time looking at for/break/continue), I see things which could very easily be made better.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

Quote from: Gurok on Mon 10/03/2014 06:25:49
Side note: Passing structs as parameters is more complex than I first thought and might take some time.

You might need to make a new type of dynamic object manager in the engine that handles user structs.

Gurok

Quote from: Crimson Wizard on Mon 10/03/2014 15:06:51
You might need to make a new type of dynamic object manager in the engine that handles user structs.

Yes, that is what I fear :D. Right now, switch...case seems easier. Also I've been trying to fix general bugs, but I find myself drawn to the script compiler.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

Hmm, no, I mistook dynamic creation with passing reference.
For passing reference you will need just a wrapper which knows the type of data ("user struct reference"), address and size, and you may "simply" use RuntimeScriptValue for that.

Dynamic creation of user structs is different thing. You might have a look at how strings and dynamic arrays are created: there's a special assembly command for that. But this would be a completely new feature.

SMF spam blocked by CleanTalk