Page 1 of 1
Posted:
Sat Feb 24, 2007 1:57 pm
by Troodon
Ok, thanks.
I don't want to sound idiot, but is the #define making a normal variable?
Posted:
Sat Feb 24, 2007 2:17 pm
by makslane
The #define just create a 'replace' in the code.
If need to use some value, like 3.1416 in your code, you can make a define, like this:
#define PI 3.1416
And just use PI in the code.
Please, refer to some C docs.
Posted:
Sat Feb 24, 2007 2:20 pm
by Troodon
Wow, thanks!
I haven't read any C docs, only the GE documentation. Maybe I should start learning C...
Posted:
Sat Feb 24, 2007 10:43 pm
by Fuzzy
Yes, define is more than storage for values of strings. You can use it to store portions of code. That code will go uncompiled at first..
#define HEAL Hp+amount, MaxHP
then later in code...
amount = rand(10);
hp = min(HEAL);
you can see that it can act somewhat like a function, without the overhead of the function. It stores the formula and nothing more. You dont have to remember what arguments to pass it. You could also wrap the min() around the contents of HEAL.
Note that convention says use capital letters for define labels, and that the line is not normally appended with ; but it is legal.
one interesting use is to shorten key words...
#define GaAiC getAllActorsInCollision
#define EA "Event Actor"
later in code...
GaAiC(EA,&num);
thats kinda silly, but shows how you can compress your code. If you use certain long key words repeatedly, you can actually shorten up your code considerably.
From my experiments, it extends to the compiled program too. however, you might find that it slows things down a bit. Makslane will know better than I.
Posted:
Sun Feb 25, 2007 12:04 am
by Sgt. Sparky
I still like it!
Posted:
Sun Feb 25, 2007 11:52 am
by Troodon
Ok, thanks!
Is there any place (in web) where I could find that kind of C script things?
For example what's the '|' doing?
Posted:
Sun Feb 25, 2007 11:59 pm
by Sgt. Sparky
that is a setance end
Posted:
Mon Feb 26, 2007 1:38 pm
by Troodon
Sentence end?
Posted:
Thu Mar 01, 2007 1:28 pm
by Sgt. Sparky
yup.
that way it does not get glitchy
Posted:
Thu Mar 01, 2007 8:30 pm
by UltimatHedgehog
how do you type '|' it's not on the keyboard
Posted:
Thu Mar 01, 2007 8:41 pm
by Kodo
look at the bottom left of your keyboard, hold down the left shift and press the key next to it (backslash). Least that's what it is on a UK keyboard.
Posted:
Thu Mar 01, 2007 10:08 pm
by UltimatHedgehog
thats capital Z there is one that is 2 lines one on top one on bottom looks just like | but with a space in the middle but thats the right one
its only a | in certain fonts though
Posted:
Thu Mar 01, 2007 10:26 pm
by Kodo
thats capital Z
That'll be why I said "on a UK keyboard", keyboard layouts vary slightly from country to country, on mine the | key is next to the Left Shift
Posted:
Thu Mar 01, 2007 11:39 pm
by Game A Gogo
in Canada keyboard (Should be similar to U.S.A.) English, its Shift and Back slash (Right above the Enter), and for French, its should be Alt Gr and 6
Posted:
Fri Mar 02, 2007 12:39 am
by UltimatHedgehog
what you said about the canadian is on mine so yes youre right its like usa keyboard