Adventure Game Studio | Forums

AGS Development => Editor Development => Topic started by: Gurok on 11 Mar 2014, 11:25

Title: [ABANDONED] AGS 3.3.1 Alpha 2 Turbo
Post by: Gurok on 11 Mar 2014, 11:25
Hello all,

I invite you to try...

AGS 3.3.1 Alpha 2

Download 3.3.1 alpha 2 as a .zip archive (http://goo.gl/NOu7C6)

Previous alphas:
Spoiler: ShowHide
Download 3.3.1 alpha 1 as a .zip archive (http://goo.gl/TwC0w4)
Download 3.3.1 alpha 1 as a .zip archive (with Linux *building* support) (https://bitbucket.org/monkey0506/ags/downloads/3.3.1%2Blinux.rar)


ACHTUNG!
(http://i.imgur.com/3gHhXIz.png)
This is an early version of AGS 3.3.1.
Use at your own risk. Please back up any games before opening them in this version of AGS.
New settings in this version may make your project files unusable in 3.3.0 after saving with this version.

Last updated: 1st of August, 2014



Engine

Full Screen VSync for Direct3D

This feature was previously available (but always on) in Draconian editions of AGS. With AGS 3.3.1, it has been integrated into the mainline builds. It's now possible to toggle VSync using the "Vertical sync" checkbox in Winsetup.exe. If it's checked, the game starts with vertical sync turned ON. In DirectX 5 mode, you can still toggle this by setting System.VSync to true/false. In DirectX 9 mode, the System.VSync property is now read-only (as opposed to being useless previously).

Bug Fixes



Scripting

For statement

In addition to a while loop, you can now use a for loop in AGS script. The syntax is:
Code: [Select]
for([initialisation];[condition];[increment])
{
    [loop body]
}
Example:
Code: [Select]
for(player.x = 0; player.x < 100; player.x++)
    Wait(1);
Important: You cannot declare a variable inside a for loop's initialisation section. For instance, "for(x = 0; ..." is fine, but "for(int x = 0; ..." is not valid. It might be valid someday.

Break statement

You can now break out of loops using the break statement. For example:
Code: [Select]
i = length - 1;
while(i >= 0)
{
    if(page[i] == target)
        break;
    i--;
}
Will halt the loop when a match is found or leave i as -1 if there was no match.

Continue statement

You can now continue to the next iteration of a loop using the continue statement. For example:
Code: [Select]
for(x = 0; x < 100; x++)
{
    if(x % 2 == 0)
        continue;
    Display("%d", x);
}
Will display only odd numbers between 0 and 100.

Do...While loops

The Do...While loop construct is now supported. For example:
Code: [Select]
x = 1;
do
{
    x++;
    Display("%d", x);
} while(x < 1);
Unlike While, Do...While runs the loop iteration *before* evaluating the condition. The loop above will run once.

Dynamic Arrays in Structs

Dynamic arrays are now permitted inside structs. You can declare a struct like so:
Code: [Select]
struct DieRoll
{
    int BaseModifier;
    int DieCount;
    int Dice[ ];
    import function GetTotalValueOfRoll();
};

function PrepareDice()
{
    DieRoll a;

    a.DieCount = 3;
    a.Dice = new int[a.DieCount];
    a.Dice[0] = 6; // d6
    a.Dice[1] = 6; // d6
    a.Dice[2] = 8; // d8
    ...
}
And the dynamic array "Dice" can be initialised and used like any other dynamic array.

Managed User Structs

In AGS parlance, a managed struct is a struct that can be created dynamically. You must use pointers to refer to them (similar to built-in types like Region or Hotspot). You declare them with the keyword "managed" and construct new instances with "new", like so:
Code: [Select]
managed struct Point
{
    int X;
    int Y;
};

Point *GetPosition()
{
    Point *result;

    result = new Point;
    result.X = 30;
    result.Y = 40;

    return result;
}
Important: Managed structs are currently VERY limited in that they can't contain pointers (including dynamic arrays). It is hoped that this restriction will be lifted in the future.

#define Improvements

#define can now refer to other #define'd constants. Like VC++, #define symbol expansion only needs to make sense at the time of reference. Also like VC++, the order of previously defined constants isn't important, making stuff like this possible:
Code: [Select]
#define RED    GREEN
#define BLUE   456
#define GREEN  BLUE
Display("%d", RED); // Prints 456
#undef BLUE
#define BLUE  123
Display("%d", RED); // Prints 123
Note: To prevent circular references, a #define cannot refer to itself or anything previously used to expand the #define symbol.

Static extender functions

You can now declare the first parameter of a function as a static identifier that corresponds to a struct, e.g.
Code: [Select]
function AbsInt(static Maths, int value)
{
    if(value < 0)
        value = 0 - value;
     
    return(value);
}
This works in the same way as the normal extender method syntax (e.g. this Character *) but for static methods. The above code will define a new method in the static Maths called AbsInt. You can then import it in a header:
Code: [Select]
import function AbsInt(static Maths, int value);And then use it elsewhere in your code just like it were a built-in Maths function:
Code: [Select]
int x = Maths.AbsInt(-3);
Extra Assignment Operators

The following C-style assignment operators are now supported:
*=   (Multiply by and assign)
/=   (Divide by and assign)
&=   (Bitwise AND and assign)
|=   (Bitwise OR and assign)
^=   (Bitwise XOR and assign)
<<=  (Bitshift left and assign)
>>=  (Bitshift right and assign)

Direction parameter for Character.ChangeRoom

This feature was previously available Draconian editions of AGS. The Character.ChangeRoom function now looks like this:
Code: [Select]
Character.ChangeRoom(int room, optional int x, optional int y, optional CharacterDirection direction)Where CharacterDirection is a new built-in enum defined for facings (eDirectionUp, eDirectionUpLeft and so forth).

Character.DestinationX and Character.DestinationY

Two new read-only properties that can be used to determine where a character is currently heading (via a Walk command). If the character is currently stationary, these values are the same as Character.x and Character.y, respectively.

IsInteractionAvailable() for Other Types

This is another feature from Draconian editions of AGS. The IsInteractionAvailable() method can now be called on Hotspots, Objects and Characters.

Audio Clips API

There are two new properties for dealing with audio clips in this version.
Code: [Select]
Game.AudioClipCountRetrieves the number of clips and
Code: [Select]
Game.AudioClips[n]Allows you to access a particular audio clip.

Plugin API

There is now a new function that can be used to detect whether a plugin has been loaded:
Code: [Select]
Game.IsPluginLoaded(const string name)Where name is the filename of the plugin

Dialog Options

The highlight colour for dialog options (default rendering) is no longer hard coded as yellow (14). You can use:
Code: [Select]
game.dialog_options_highlight_color = xxx;And set the dialog options highlight colour to whatever you like. The default is 14.

Code Regions

This was previously available in Draconian editions of AGS. You can define an arbitrary region for code folding in your script like so:
Code: [Select]
#region MyRegion
do stuff;
do stuff;
do stuff;
#endregion MyRegion
The AGS editor will allow you to fold and unfold this region as though it were a code block. This has no effect on compiled code.

Bug Fixes



Common

Extended WFN Font Support

Support was added for extended characters in WFN fonts (those with codes 128 - 255).



Editor

Padding for Text GUI Windows

Text GUI windows now have a padding property which lets you control how much space appears between the border and the text inside a text GUI window. Previously, this value was hardcoded as 3 pixels. It now defaults to 3 pixels.
(http://i.imgur.com/LRa1hv3.png)

Clickable for Objects

The Clickable property of objects is now exposed in the editor so that you can set it at design time. Previously, this value was embedded in the room file format but only toggleable via scripting.
(http://i.imgur.com/QUZzRIX.png)

Bug Fixes



Please enjoy this build and use responsibly.

Contributors
Crimson Wizard
Tzachs
monkey_05_06
salty-horse
Me
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Joseph DiPerla on 11 Mar 2014, 11:55
Nice job!
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Crimson Wizard on 11 Mar 2014, 12:13
  • More settings will now have sensible defaults when they can't be read from the config file (hope I got this right, CW)
No, that just fixed how internal function works. Default values should stay the same.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gurok on 11 Mar 2014, 12:16
Okay, updated. Thanks, CW.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Snarky on 11 Mar 2014, 12:24
Nice! Look forward to trying this out!
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Problem on 11 Mar 2014, 12:44
Great, these are some valuable additions to the scripting language! I'll try it out soon :)
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Dropped Monocle Games on 11 Mar 2014, 13:00
I'm not very good with coding, being more into graphics so a lot of this has gone over my head.. but hell yes to VSync!!! I spend alot of time on the art and then seeing the screen tearing brokes my little heart hehe, nice work! :)
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Radiant on 11 Mar 2014, 13:36
Thanks, this is a breakthrough that I've been expecting for awhile; please continue your work on this :grin:
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gilbert on 11 Mar 2014, 14:08
It's not particularly important for me with for loops adding back as it's been removed for like a decade. It's of course nice to have it back.

But:
Audio Clips API
Sold! :=
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: monkey0506 on 11 Mar 2014, 17:35
Audio Clips API
Sold! :=

I tried a couple times to implement something like this, but I kept over-complicating things (introducing new data types and such) to the point where I felt I couldn't justify all the changes. This is much more elegant and simple, and is a very welcome change. :)
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: tzachs on 11 Mar 2014, 20:06
Running with this version and can confirm the text window padding works. :)

Re the audio clips API: Can you guys explain why you find those additions useful? One use I can maybe see is for playing random sound effects, but other than that, I'm drawing a blank. Is there another reason that got you sold, Iceboty?
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gilbert on 12 Mar 2014, 03:07
It's tremendously useful. In fact I'm all for referring to every thing with numbers, rather than stupid object names. For example, I abuse the sprite numbers heavily for putting in the correct tiles to draw in a tiled engine.

Often times, there are occasions where a certain piece of asset is chosen by means of a formula.
For example (just some randomly made up junk, so don't mind whether this is really practical here), I have an interface with some piano keys(say, for simplicity, 8 keys, or, think the interface of LOOM) and a different sound clip will be played when a different key is clicked. If the clips are numbered #100 to #107, it's easy to code the game to play clip #100 + piano_key, than to assign a different clip by name to each key.

I haven't checked it yet, but will the numbering be changed if a sound file is removed from the project? In that case it's only half-done in the current situation. Ideally we should be able to change manually what number each sound file is assigned to, just like what we have for sprites.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gurok on 12 Mar 2014, 03:21
Re: Audio Clips API

I can't say terribly much about this because I don't have much experience with audio clips. It returns a flattened version of the audio clips tree. That's as much as I know. I would hazard a guess that there's no special numbering going on, but maybe Crimson Wizard can chime in as he'll know more.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Ghost on 12 Mar 2014, 06:18
Very interested in testing this, I especially like the loops. Can't say how often I've wished for those. Well played, Gurok!
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Radiant on 12 Mar 2014, 06:57
Re the audio clips API: Can you guys explain why you find those additions useful?
The old (AGS 2) music/sound system let you address everything by number, but it doesn't work with the new (AGS 3) volume controls; so this should do both. This lets you pull tricks like setting a variable cur_music for each room, then playing music[cur_music] if it's daytime, music[cur_music + 1] if it's night, without having to set up an array of pointers.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: DoorKnobHandle on 12 Mar 2014, 12:21
Break statement

You can now break out of loops using the break statement. For example:
Code: [Select]
i = length - 1;
while(i > 0)
{
    if(page[i] == target)
        break;
    i--;
}
Will halt the loop when a match is found or leave i as -1 if there was no match.

This is really nitpicking but I think there's an error in this example. It halts the loop when a match is found (but it doesn't check the first element in the page[] array) or end up with i being 0 (not -1) if there was no match, right? What you probably wanted is >= instead of > in the second line.

Good work though, can't wait to try this! The for/break/continue stuff is neat but the audio clips are really useful to me as well!
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Snarky on 12 Mar 2014, 12:30
It's better written as a for-loop anyway. :-D
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gurok on 12 Mar 2014, 12:59
This is really nitpicking but I think there's an error in this example. It halts the loop when a match is found (but it doesn't check the first element in the page[] array) or end up with i being 0 (not -1) if there was no match, right? What you probably wanted is >= instead of > in the second line.

Good work though, can't wait to try this! The for/break/continue stuff is neat but the audio clips are really useful to me as well!

Yes, you're right. I'm too used to writing it the "proper" way ( while(i-- > 0) ) which AGS doesn't support yet. I'll update the example. Sorry about that! :-[
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Adeel on 12 Mar 2014, 13:32
Nice going, sir. It's a very fine start. I especially like having the power to manually configure 'padding for Text GUI Windows.' :)
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gurok on 12 Mar 2014, 13:40
Umm... I just want to stress that this is still a collaborative effort. I appreciate the thanks and kind words from people, but Crimson Wizard and Tzachs have been contributing for a lot longer than me and are also contributing to this release. Audio Clips and some of the Draconian porting is CW's work. The undo history + editor crash fixes are Tzachs'.

I have a feeling that we won't get any feedback about the new scripting stuff until someone finds a bug. Regardless, it would be nice to read a "I tried the new version and it ran a for loop fine" from someone so I know that I didn't completely mess things up :).
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Crimson Wizard on 12 Mar 2014, 13:44
I have a feeling that we won't get any feedback about the new scripting stuff until someone finds a bug.
Lol, you need to have patience, such things are usually revealed 1 week before final release :D.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: monkey0506 on 12 Mar 2014, 14:58
I'm too used to writing it the "proper" way ( while(i-- > 0) )

Hmm, that's funny. I've never heard anyone refer to the postfix operator as being "proper" (even if it is an aggregate type in a language with no prefix operator). :cool:

I have a feeling that we won't get any feedback about the new scripting stuff until someone finds a bug.
Lol, you need to have patience, such things are usually revealed 1 week before final release :D.

Or a week after release.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Ryan Timothy B on 12 Mar 2014, 20:32
Code: Adventure Game Studio
  1. Game.AudioClips[n]
In all honesty, it should've been  audio[n]  to keep with AGS's standard (ie object[n], character[n] etc), but this is the better choice. But since I've brought it up, it would've been nice to have things grouped in a more organized and intuitive convention like: Audio.Clips[n]   or something of that sort.


Has anyone thought of adding a do while loop? Not that it's an important addition (neither was the for loop though), it would just be nice to have.

Anyway nice additions everyone!
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gurok on 12 Mar 2014, 23:02
I'm too used to writing it the "proper" way ( while(i-- > 0) )

Hmm, that's funny. I've never heard anyone refer to the postfix operator as being "proper" (even if it is an aggregate type in a language with no prefix operator). :cool:


Hrm... not sure what you mean. Are you saying this because when a postfix operator is used with an aggregate type, it means creating a temporary copy? For the case of ints, --i and i-- generate identical opcodes, just in a different order as far as I know. So for that case, there's no reason to consider the i-- operator as being bad. I primarily use the postfix operator because I am lazy, hence the quotes around the term proper. In C and Javascript (which is my day job), you can get away with: while(i--) which saves keystrokes.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Radiant on 12 Mar 2014, 23:13
The difference is that i++ returns the value of i and then increments it, whereas ++i increments i and then returns the value. This is only relevant if you write wonky code like "j = ++i" or the like.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gurok on 12 Mar 2014, 23:16
Has anyone thought of adding a do while loop? Not that it's an important addition (neither was the for loop though), it would just be nice to have.

That's on my list after switch...case and passing structs as params.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Radiant on 12 Mar 2014, 23:37
That's on my list after switch...case and passing structs as params.
Cool, I would like to have do{}while as well.

Considering we already have +=, would it be a big deal to add *= /= &= |= ^= >>= and <<= ? I'm used to C++ coding and tend to reflexively type those before realizing they don't actually work. Yes, I actually use bitfields in AGS :D

(edit) sorry if that sounds like a lot, I figured they're all pretty much the same in terms of opcodes.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Dualnames on 13 Mar 2014, 06:07
Provided the static extender works properly, this is quite fantastic!! And useful, wonderful job there, Gurok. +1 For several of these to be integrated into the main build.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Radiant on 15 Mar 2014, 10:00
I have a feeling that we won't get any feedback about the new scripting stuff until someone finds a bug. Regardless, it would be nice to read a "I tried the new version and it ran a for loop fine" from someone so I know that I didn't completely mess things up :).

I'd be happy to give you feedback. I've got some rather complicated C++ code that I can try to compile in AGS, and if that works then it's pretty strong evidence that for/break/continue work properly. I'd probably have time for that in a couple of weeks. But the code also uses do{}while and some of the *= type operators, so I'd either have to wait for those to be added, or rewrite the code. Either way, it should be a nice test.
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: tzachs on 15 Mar 2014, 21:32
Regardless, it would be nice to read a "I tried the new version and it ran a for loop fine" from someone so I know that I didn't completely mess things up :).

I tried the new version and it ran a for loop fine.
Well done!
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Crosco on 16 Mar 2014, 14:14
He, the new built-in enum CharacterDirection is very interesting.
When I started to use AGS I began with a game template from Maniac Mansion Mania (http://www.maniac-mansion-mania.com). In this template they defined such an enum: eDirection. They used it at a Character extending function FaceDirection( this Character*, eDirection dir ).

So, maybe a function FaceDirection( CharacterDirection direction, optional BlockingStyle ) is a useful extension to the FaceCharacter, -Object, ... functions and should make it into AGS?

Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: GrogGames on 31 Mar 2014, 06:29
very nice!!! ;-D

When i was a "kid", i learn programation with AGS, with the proskito's templates,
and i remember, thah i was very surprised with the "while-int i=0-i++" conjunction, i tought "oh, what a clever use of while" (i had no-idea of "for", or something like it).
I think, if "for" existed in AGS in that moment, then that no was happen. That was a great moment of my adolescence.

But, yes, is very, very useful for me (now more adult), the "for" sentence. At overall, for better understanding of the code.

I am studing "Informatic Enginering", and i no have idea of "continue" existence . That is very useful too. And i learn something new :)

And, obviulsy, "break" is useful, always that will be used with responsability.

in conclusion, very interesting propose!
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Gurok on 04 May 2014, 11:20
I'm hoping this is not considered presumptuous, but I'd like to bump the build number and the version numbers in the repository and release what we have as "3.3.1 alpha 1". If CrimsonWizard obliges, I'd be happy to update this thread with the changelog. Or if you prefer, CrimsonWizard, you can start a new thread for 3.3.1 alpha 1. What do you think?

Among the changes since this test build are better screen resolution selection, fixed building after moving script folders around and extra operators in scripting (e.g. *=, /=).
Title: Re: AGS 3.3.1 - Scripting Test Build
Post by: Crimson Wizard on 04 May 2014, 14:09
Sure, please do. I am sort of distracted from AGS lately.
Two months ago I asked JJS to give you contributor rights in the ags repository, but JJS hadn't been on forums since February :(. I am not sure if I may do this myself, I haven't found a way to do this yet (github UI is confusing).

I don't remember if I mentioned this before. We are using odd build numbers for development versions (e.g. 1163, 1165 etc) and even numbers for release versions (e.g. 1162, 1164 etc).
Title: Re: AGS 3.3.1 - Alpha 1
Post by: Gurok on 04 May 2014, 15:48
Okay, I've updated the first post.
Title: Re: AGS 3.3.1 - Alpha 1
Post by: Crimson Wizard on 04 May 2014, 17:32
I think you should make a notice which features are from 3.3.0 update, to prevent possible confusion.

Also, I completely forgot, I had to add a fix to extended WFN renderer which lets to load incorrect WFN fonts (already used in Scavenger's "Heatwave", for example). I might do that soon.
Title: Re: AGS 3.3.1 - Alpha 1
Post by: monkey0506 on 04 May 2014, 20:44
I made a combined build of the new 3.3.1 alpha with the Linux compilation. Hope you don't mind me piggybacking this onto your release. (roll)

https://bitbucket.org/monkey0506/ags/downloads/3.3.1%2Blinux.rar
Title: Re: AGS 3.3.1 - Alpha 1
Post by: Radiant on 04 May 2014, 23:19
I'm hoping this is not considered presumptuous, but I'd like to bump the build number and the version numbers in the repository and release what we have as "3.3.1 alpha 1". If CrimsonWizard obliges, I'd be happy to update this thread with the changelog. Or if you prefer, CrimsonWizard, you can start a new thread for 3.3.1 alpha 1. What do you think?

Among the changes since this test build are better screen resolution selection, fixed building after moving script folders around and extra operators in scripting (e.g. *=, /=).

Very good news! Thank you Gurok!
Title: Re: AGS 3.3.1 - Alpha 1
Post by: Gurok on 05 May 2014, 07:23
I think you should make a notice which features are from 3.3.0 update, to prevent possible confusion.

You're absolutely right. For now, to avoid confusion, I've completely removed the sections about upscaling and resolution selection. Are there any other 3.3.0 features I've listed by mistake? I didn't realise upscaling was already present in 3.3.0. I just went through all the commit logs in order. Sorry!

I made a combined build of the new 3.3.1 alpha with the Linux compilation. Hope you don't mind me piggybacking this onto your release. (roll)

https://bitbucket.org/monkey0506/ags/downloads/3.3.1%2Blinux.rar

I have included a link to this in the main post. I don't see why this couldn't be part of 3.3.1 alpha 2. I saw your thread and branch about this feature and was wondering why there wasn't a pull request yet.

I can't test how the builds work because I don't run Linux. They certainly seem like they're being built though! I guess I could try it out in a VM at some point.

The "linux" directory, however, does feel wrong to me somehow. I know that the directory structure of an AGS game isn't great to start with, but it would be nice to organise the directories like so:

Compiled\Windows\
Compiled\Linux\

And then, of course, if "automatically build for all available ports" is unchecked, revert to the old behaviour of dumping the Windows .exe directly into compiled:

Compiled\

But I don't know... would that kind of reorganisation break anything? We might need to update the editor "delete all" code so that it recursively deletes directories inside Compiled\. Having this kind of hierarchy would also ensure Linux files are deleted when the editor rebuilds for Windows only.

Edit: Oh gosh, sorry monkey_05_06, I probably should have posted this in your test thread.
Title: Re: AGS 3.3.1 - Alpha 1
Post by: Crimson Wizard on 05 May 2014, 08:08
I made a combined build of the new 3.3.1 alpha with the Linux compilation. Hope you don't mind me piggybacking this onto your release. (roll)

https://bitbucket.org/monkey0506/ags/downloads/3.3.1%2Blinux.rar

I have included a link to this in the main post. I don't see why this couldn't be part of 3.3.1 alpha 2. I saw your thread and branch about this feature and was wondering why there wasn't a pull request yet.

Maybe people will look at this first and tell if that's ok the way it's done? Just to be sure that it is made conveniently. Just suggesting.

Also, Gurok raised good point about directory structure.
Title: Re: AGS 3.3.1 - Alpha 1
Post by: monkey0506 on 05 May 2014, 17:24
I saw your thread and branch about this feature and was wondering why there wasn't a pull request yet.

Maybe people will look at this first and tell if that's ok the way it's done? Just to be sure that it is made conveniently. Just suggesting.

Also, Gurok raised good point about directory structure.

Yes, this is the reason there's not a pull request yet. (Well that, and I have several intermediary commits that don't need to be part of the main repo's history. Once I get a build that everyone's generally happy with then I'll dump it all into a single "initial" commit and pull that in instead.) ;) Agreed about the points you raised, and yes, to prevent clogging this thread up let's continue discussion about it in this thread (http://www.adventuregamestudio.co.uk/forums/index.php?topic=50421.0). A few items were brought up there that I will be working on.
Title: Re: AGS 3.3.1 - Alpha 1
Post by: Calin Leafshade on 05 May 2014, 19:54
Once I get a build that everyone's generally happy with then I'll dump it all into a single "initial" commit and pull that in instead.) ;)

Look up "rebasing"
Title: Re: AGS 3.3.1 - Alpha 1
Post by: Crimson Wizard on 05 May 2014, 20:46
Once I get a build that everyone's generally happy with then I'll dump it all into a single "initial" commit and pull that in instead.) ;)

It is strongly suggested to not put all the changes you make into one commit without consideration. When reviewing the history of changes it is very important to understand what has changed and why. Also, sometimes when looking for a source of bug we may walk down the history of commits, looking for the one which introduced the error: in this case it really helps when every commit has only task- and thematically related changes.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=50001.msg636481384#msg636481384
;)
Title: Re: AGS 3.3.1 Alpha 2
Post by: Gurok on 31 Jul 2014, 15:01
Hello all,

AGS 3.3.1 Alpha 2 is out. You can download it here:

Download 3.3.1 alpha 2 as a .zip archive (http://goo.gl/NOu7C6)



Changes from 3.3.1 Alpha 1:



Engine

Bug Fixes



Scripting

Do...While loops

The Do...While loop construct is now supported. For example:
Code: [Select]
x = 1;
do
{
    x++;
    Display("%d", x);
} while(x < 1);
Unlike While, Do...While runs the loop iteration *before* evaluating the condition. The loop above will run once.

Dynamic Arrays in Structs

Dynamic arrays are now permitted inside structs. You can declare a struct like so:
Code: [Select]
struct DieRoll
{
    int BaseModifier;
    int DieCount;
    int Dice[ ];
    import function GetTotalValueOfRoll();
};

function PrepareDice()
{
    DieRoll a;

    a.DieCount = 3;
    a.Dice = new int[a.DieCount];
    a.Dice[0] = 6; // d6
    a.Dice[1] = 6; // d6
    a.Dice[2] = 8; // d8
    ...
}
And the dynamic array "Dice" can be initialised and used like any other dynamic array.

Managed User Structs

In AGS parlance, a managed struct is a struct that can be created dynamically. You must use pointers to refer to them (similar to built-in types like Region or Hotspot). You declare them with the keyword "managed" and construct new instances with "new", like so:
Code: [Select]
managed struct Point
{
    int X;
    int Y;
};

Point *GetPosition()
{
    Point *result;

    result = new Point;
    result.X = 30;
    result.Y = 40;

    return result;
}
Important: Managed structs are currently VERY limited in that they can't contain pointers (including dynamic arrays). It is hoped that this restriction will be lifted in the future.

#define Improvements

#define can now refer to other #define'd constants. Like VC++, #define symbol expansion only needs to make sense at the time of reference. Also like VC++, the order of previously defined constants isn't important, making stuff like this possible:
Code: [Select]
#define RED    GREEN
#define BLUE   456
#define GREEN  BLUE
Display("%d", RED); // Prints 456
#undef BLUE
#define BLUE  123
Display("%d", RED); // Prints 123
Note: To prevent circular references, a #define cannot refer to itself or anything previously used to expand the #define symbol.

Character.DestinationX and Character.DestinationY

Two new read-only properties that can be used to determine where a character is currently heading (via a Walk command). If the character is currently stationary, these values are the same as Character.x and Character.y, respectively.



Editor

Clickable for Objects

The Clickable property of objects is now exposed in the editor so that you can set it at design time. Previously, this value was embedded in the room file format but only toggleable via scripting.
(http://i.imgur.com/QUZzRIX.png)


This build also includes everything in AGS 3.3.0 Hotfix 3 (including the updated templates).
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Crimson Wizard on 31 Jul 2014, 15:12
Gurok, I just found a compiler bug: it does not restrict dynamic arrays in managed structs (although that's too a pointer).
Guess I forgot to check that particular case.


E: elaborating to users: it actually will work, but will cause memory leaks in program (which may result in various problems).
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Gurok on 31 Jul 2014, 15:32
Gurok, I just found a compiler bug: it does not restrict dynamic arrays in managed structs (although that's too a pointer).
Guess I forgot to check that particular case.

Sorry! I quickly patched it locally and updated the link (a bit cowboy, I know). Should be better now. I will make a pull request for the extra compiler warning soon (tomorrow).
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Crimson Wizard on 31 Jul 2014, 15:34
Sorry! I quickly patched it locally and updated the link (a bit cowboy, I know). Should be better now. I will make a pull request for the extra compiler warning soon (tomorrow).
You may simply send me a patch and I'll apply it right into main branch.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Sslaxx on 02 Aug 2014, 18:14
This isn't exactly a major feature request, but allowing "... } do" at the end of a while loop (to provide syntactic symmetry with the "do while" loop) would be nice.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Crimson Wizard on 02 Aug 2014, 18:51
Post deleted :tongue:, sry nevermind.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Alberth on 02 Aug 2014, 19:16
But the "do" is a prefix for the statements ("do x = 1;" rather than "x = 1; do"), just like "while" a prefix is for the condition. (Technically the "while" is thus not at the end of the "do while" since the condition follows).

The only somewhat feasible alternative is probably "while ... do { ... }", like Pascal had. The parentheses around the condition after the "while" make the "do" unneeded in this case.

In all cases, the syntax would be different from what the zillion C/C++/Java programmers are used to, which seems to be a major source of inspiration for the AGS language. That makes it highly unlikely to happen.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Calin Leafshade on 02 Aug 2014, 19:29
agreed. while() {} do; is not correct form basically everywhere.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: deltamatrix on 10 Aug 2014, 17:38
Wow great job!

One thing I'd like to ask for. I noticed ages ago that when you assign the function names for interactions (i.e: for Hotspots), you were limited to use only functions in the room script and not global script functions - this caused for me a lot of duplicated code across the room scripts.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Crimson Wizard on 10 Aug 2014, 18:36
One thing I'd like to ask for. I noticed ages ago that when you assign the function names for interactions (i.e: for Hotspots), you were limited to use only functions in the room script and not global script functions - this caused for me a lot of duplicated code across the room scripts.
Not that I am principally against this suggestion, but there are numerous ways to reduce code duplication, such as intercepting mouse clicks on hotspot in global script, or calling other, "generic", functions from room event handlers.
It is even possible to not having a room script at all.
Perhaps if you'd give some example of duplicated code you have, we could find a solution for you.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: deltamatrix on 11 Aug 2014, 14:06
Thats very true. I envision good programming practice within AGS using jQuery-like event detection (lambda expressions/Closures 4 AGS?? :cheesy::cheesy::cheesy:)

The example was Look at Bush which calls a global function with random descriptions. This game was Hero6 which had a lot of forest screens each with bush hotspots. Therefore the duplication was in the repeated calling of the global function in each room.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Crimson Wizard on 11 Aug 2014, 14:20
The example was Look at Bush which calls a global function with random descriptions. This game was Hero6 which had a lot of forest screens each with bush hotspots. Therefore the duplication was in the repeated calling of the global function in each room.

Code: Adventure Game Studio
  1. function on_mouse_click(MouseButton button)
  2. {
  3.     if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot &&
  4.         Game.GetLocationName(mouse.x, mouse.y) == "bush")
  5.     {
  6.         ProcessBushInteraction(mouse.Mode);
  7.     }
  8. }
  9.  

:=

EDIT: You could use "unhandled_event" function, that would be more logical, but it won't work properly if interaction was triggered not by mouse.
Code: Adventure Game Studio
  1. function unhandled_event(int what, int type)
  2. {
  3.    if (what == 1 && type == 1) // look at hotspot
  4.    {
  5.        if (Game.GetLocationName(mouse.x, mouse.y) == "bush")
  6.        {
  7.            LookAtRandomBush();
  8.        }
  9.    }
  10. }
  11.  
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Billbis on 11 Aug 2014, 19:21
Great works!
I'm a bit late, but I would like to make a couple of comments about the new CharacterDirection enum.
- It would be nice to have a build-in FaceDirection function. Sure, it is easy to code with some AGSscript, but the very first things I'm doing in every AGS project I start is recode it, because I found it so useful. I should probably be able to implement it myself, if only I knew how to compile a C++ program on Windows platform. :-D
- Would it make some sense to have a eDirectionNone in the enum? That way you can make some functions that use it as an optional parameter:
Code: Adventure Game Studio
  1. // header
  2. import void Use(this Character*, CharacterDirection = eDirectionNone);
  3.  
  4. // script
  5. void Use(this Character*, CharacterDirection Dir)
  6. {
  7.     int view;
  8.     if (this == cEgo) {
  9.         view = 10; //La view Utilise de Ego
  10.     } else if (this == cRoger) {
  11.         view = 15; //La view Utilise de Roger
  12.     } else {
  13.         return;
  14.     }
  15.     this.FaceDirection(Dir, eBlock);
  16.     this.LockView(view);
  17.     this.Animate(this.Loop, 5, eOnce, eBlock);
  18.     this.UnlockView();
  19. }
But maybe I'm missing something. It seems I can't set my optional parameters to null (compiling error), so a eDirectionNone would be (relatively) useful.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Crimson Wizard on 11 Aug 2014, 22:28
I should probably be able to implement it myself, if only I knew how to compile a C++ program on Windows platform.
If you may build it on Linux, for instance, you could do that too, because both versions share nearly same code.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Crimson Wizard on 22 Aug 2014, 17:49
Any plans on checking out why AGS does not allow to put non-managed structs into structs?
I don't think it needs any breaking changes, it's just inserting nested data chunk; in engine memory it will be just the seamless array of data, just like any simple struct.
Probably compiler is not taught to track nested offsets.
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Gurok on 22 Aug 2014, 18:06
I haven't thought about it, but I'll put it on my list of things to investigate.

Current priorities are:
 -- Investigate destruction of stack struct variables that contain pointers to user objects (something seemed weird about the way they were cleaned up)
 -- Modify the script format to support writing out parts of the symbol table for RTTI
 -- Implement switch...case
 -- Function pointers, type coercion for floats<->ints, etc (these are more things I'd like to put up for discussion before even attempting)

eDirectionNone would be (relatively) useful.

I meant to comment on this a while ago. I think both this and the FaceDirection suggestion are worthy of inclusion in the standard library, but I don't know how others feel. I also implement this in most projects. I tend to call it "eDirectionUnknown" because you aren't facing none, you're just not specifying the direction faced. Right now, I think all the directions in the direction enumeration have a 1:1 mapping with loops. Not sure if we need to consider that when adding eDirectionNone.

Also, regarding the standard library of functions, there's one that seems peculiar to me:

Code: [Select]
GetRoomProperty(const string property);
No idea why this is a global function and not a static function on the room (like Room.GetTextProperty). Would anyone object to tidying that up?
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Crimson Wizard on 22 Aug 2014, 18:32
I meant to comment on this a while ago. I think both this and the FaceDirection suggestion are worthy of inclusion in the standard library, but I don't know how others feel. I also implement this in most projects.
We already have optional direction argument to Character.ChangeRoom, so I don't see a reason not to.

I tend to call it "eDirectionUnknown" because you aren't facing none, you're just not specifying the direction faced.
Hmm, I'd rather vote for "eDirectionNone" to comply with other similar constants (e.g. eKeyNone).
Its value should probably be "SCR_NO_VALUE".

No idea why this is a global function and not a static function on the room (like Room.GetTextProperty). Would anyone object to tidying that up?
Its global because 100% of old AGS script API was global. OO-style was introduced around 2.7, and still not complete.
Just leave existing one under #ifndef STRICT for backwards compatibility (there are many examples around the header).
Title: Re: AGS 3.3.1 Alpha 2 Turbo
Post by: Gurok on 22 Aug 2014, 19:03
Hmm, I'd rather vote for "eDirectionNone" to comply with other similar constants (e.g. eKeyNone).
Its value should probably be "SCR_NO_VALUE".

Of course! I'm totally on board with that and the other comments you made. I just wanted to check that I wasn't randomly adding features when these possibly show up as pull requests in the future.