I think I found a tiny buglike issue:
Faulty code like
if (GetGlobalInt(100==2))
Won't generate any errors, though it could.
I slipped such thing into my code and spent hours to find out what's wrong, because game compiled normally and everything worked, exept that code bug, which AGS simply ignored.
(AGS 2.71b, Don't know if it's fixed in latest version)
Also, which globalints are reserved? I didn't find any info in manual, though debug console shows that there's some for cursor modes and other things? ???
The correct code is:
if (GetGlobalInt(100)==2)
Right?
Are you sure it produced no errors that way, if not, CJ should definately make it. That could really screw your game over in a hearbeat no?
It shouldn't generate any error.
As far as I know those ==, >, etc. comparisons are treated as indicator functions, i.e. they're nothing but integer (boolean) values.
For example the expression:
(x==2)
- returns TRUE (non-zero) if x indeeds equals 2
- returns FALSE (zero) if x!=2
Since (100==2) is always FALSE, your code was just identical to:
if (GetGlobalInt(0)), so that if clause will be carried out if GlobalInt #0 is non-zero.
So you need to check them carefully yourself, as it's not a syntax error.
Quote from: InCreator on Sun 23/10/2005 06:37:40
if (GetGlobalInt(100==2))
This isn't actually faulty code, in the sense that AGS knows exactly what to make of it, even if you don't.
Internally AGS treats bool values interchangeably with int values. This is common for programming languages.
100==2 is false, or 0, so the line is "if (GetGlobalInt(0))" which is true if global int 0 is not zero.
Changing AGS so that it discerns between bool and int would break a lot of old code.
Gilbot beat me to it, but I'll post this anyway as perhaps the alternative info is useful.
Quote
Also, which globalints are reserved? I didn't find any info in manual, though debug console shows that there's some for cursor modes and other things?Ã, ???
None of the global ints are reserved, as far as I know.