Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Trent R on Thu 06/11/2008 07:46:58

Title: += and -= missing from manual? [MODS-PLEASE MOVE TO TECH]
Post by: Trent R on Thu 06/11/2008 07:46:58
At first I wasn't sure if the += and -= operators wouldn't work, so I checked in the manual. But they're not there!

However, they do work (because they didn't show a compile error and I used Display checks). So how come they're not a part of the manuals entry on all of the other operators? There's even the bitwise ones included.


~Trent
PS-This seems like a Beginner question, so I posted here.
[Edit]: Requesting that this gets moved to the tech to become an official suggestion.
Title: Re: += and -= missing from manual?
Post by: monkey0506 on Thu 06/11/2008 08:00:04
I can't say for sure why the += and -= shortcut operators aren't included in the documentation (but yet, as you say, the binary operators are...).

Definitely I'd say it would be useful for new members to know about.

It is notable that at the moment there are no *=, /=, or %= operators however.

As for the forum, I'd say that as a "suggestion" maybe the Tech Forum would've been a better fit? I'd say it's a toss-up, but don't cross-post. If needed the moderators can make sure it's in the right place. ;)
Title: Re: += and -= missing from manual?
Post by: DoorKnobHandle on Thu 06/11/2008 10:30:56
While we're talking about these, I have often noticed the lack of *= and /* respectively and thus would welcome their addition. Can't imagine it can be much of a time investment to implement them?
Title: Re: += and -= missing from manual?
Post by: Buckethead on Thu 06/11/2008 11:18:34
They do get explained in the manual: scripting turorial 1  ;)
Title: Re: += and -= missing from manual?
Post by: beomoud on Tue 11/11/2008 16:08:01
what do *=, /=, or %= operators do? i've never seen them before
Title: Re: += and -= missing from manual?
Post by: DoorKnobHandle on Tue 11/11/2008 16:13:29

int a, b;

a += b; // is the same as a = a + b

a -= b; // is the same as a = a - b

a *= b; // is the same as a = a * b

a /= b; // is the same as a = a / b;

a %= b; // is the same as a = a % b;


I personally never saw a use for %= though.
Title: Re: += and -= missing from manual?
Post by: SSH on Tue 11/11/2008 17:06:24
Quote from: dkh on Tue 11/11/2008 16:13:29
I personally never saw a use for %= though.


// Make x position wrap around at screen edge
x++;
x%=System.Viewport_Width;

Title: Re: += and -= missing from manual?
Post by: DoorKnobHandle on Tue 11/11/2008 17:45:51
I should have phrased that better, I know what it does and when it's useful, it's just that I really use the remainder operator % so rarely that it's not a big hassle to type in the few more characters. I use *= and /= often though!

Of course, if Chris implements *= and /=, it wouldn't be a problem (I suspect this should be pretty easy to get into AGS) to just add the %= as well, at the very least for consistency's sake!