I'm sure those of us who code with Galaxy are quite familiar with some of the constants that exist. The intent of this thread is to come up with a list of the values of all these constants so we can simply type 0, instead of c_blablablablablablabla. It makes coding so much faster see?
Unfortunately there are a hell of a lot of constants in the Galaxy editor and It gets pretty hard to use them without having to use the trigger editor to check them one by one when coding. I won't be able to find them all myself.
This is where I need help from anyone who is interested to help. If there are any constants you would like to see listed here, please post them, when I find the time, I'll update this post with them and hopefully in future we can just use this thread to Ctrl+F find the values we need, making our coding lives much easier.
If there's any mistakes, Please inform me.
Dialogs
Anchors
0 - c_anchorTopLeft
1 - c_anchorTop
2 - c_anchorTopRight
3 - c_anchorLeft
4 - c_anchorCenter
5 - c_anchorRight
6 - c_anchorBottomLeft
7 - c_anchorBottom
8 - c_anchorBottomRight
Now lets cross our fingers and hope this goes well.
If someone could provide me with a list of all the constants that would be great as well, I could just code an algorithm to check all their values so we can post them here directly. But please identify their type.. Because not everything is an integer.
Why would you prefer literals over constants? Glad i don't have to work with your code to put it that way.
Anyhow whatever rocks your boat i suppose, even tho it's a horrible practice.
Well, I can iterate literals. But constants? It's a little hard (maybe impossible?) to do.
Whoops.. I missed that natives page. It looks like it has everything I need. I guess this thread is redundant then.
Care to elaborate as to why it's horrible practice? I'd like to know. Though i can guess it's probably cos it makes it very hard for other people to work with your code.
Well, as for why there are numerous arguments against using literals and i can always think of some for using them.
For example take the following code
Could list a lot of examples, but it all comes down to, primarily, readability (the compiled code is the same, tho some languages support objects as constants which may have different semantics but obviously this does not include Galaxy) .
And yes this thread would be a bit redundant, however the Wiki does not contain most of this information.
Thanks for the enlightenment. I'll keep this in mind when I'm working on my future codes, given that I expect someone else will work with it once I'm done with it.
Totally agree with caspersc.
I even use constants for Wait(0, c_timeGame) or Wait(0, c_timeReal) because I can never remember whether c_timeGame is actually 0 or 1.
When writing own systems its sometimes useful to even write your own constants so you can still identify all that mess after a month or so.
@caspersc: Go
Well, I can iterate literals. But constants? It's a little hard (maybe impossible?) to do.
inti=c_messageAreaSubtitle;while(i<=c_messageAreaChat){UIDisplayMessage(PlayerGroupAll(),i,StringToText("Look, it's message area "+IntToString(i)));i=i+1;}
Not quite what I had in mind. For example I wanted to loop 9 times and have 9 dialogs appear at different anchors.
I could just input the literals directly and it would do it automatically. No extra assignments required, thus removing the need to allocate memory unnecessarily.
Say the literals for arrow key inputs are 73,75,77,79 and we wanted to assign key press trigger events.
Rather than assigning all the constants into an dummy array and iterating through the array. By using literals instead, There is the freedom to just loop it 4 times and use the formula 73+2*i to assign the events. This is the main advantage I see.
Yeah, I'm bought on the idea. It's unfortunate for me that I remember numbers easier than the lengthly constant names. A good example would be dialog control creation. I use them quite a lot so its easy for me to remember 3 = button, 2 = icon, 1 = label as opposed to c_dialogControlButton? etc etc... (can't remember) =/ In the end I suppose it all comes down to familiarity.
So do c_keyUp + 2*i ?
You don't need to use literals or constants for everything.
Just give the programmer a clue to what the number represents so when it breaks it stands out and it's easy to fix.
(Though it's unlikely this would break, ever)
Thanks. And not to get defensive, but if you meant to imply i wasn't searching the site properly for this information by "No comment", please keep note this question was posted about a week before those wiki links were created/updated.
Oh, and great job on the wiki, I notice you've filled in a lot of the missing stuff inside it
Introduction
I'm sure those of us who code with Galaxy are quite familiar with some of the constants that exist. The intent of this thread is to come up with a list of the values of all these constants so we can simply type 0, instead of c_blablablablablablabla. It makes coding so much faster see?
Unfortunately there are a hell of a lot of constants in the Galaxy editor and It gets pretty hard to use them without having to use the trigger editor to check them one by one when coding. I won't be able to find them all myself.
This is where I need help from anyone who is interested to help. If there are any constants you would like to see listed here, please post them, when I find the time, I'll update this post with them and hopefully in future we can just use this thread to Ctrl+F find the values we need, making our coding lives much easier.
Dialogs
Anchors
Now lets cross our fingers and hope this goes well.
If someone could provide me with a list of all the constants that would be great as well, I could just code an algorithm to check all their values so we can post them here directly. But please identify their type.. Because not everything is an integer.
Placeholder
Why would you prefer literals over constants? Glad i don't have to work with your code to put it that way. Anyhow whatever rocks your boat i suppose, even tho it's a horrible practice.
See the old pastes, http://paste.sc2mapster.com/1979/. There is a more recent one on github somewhere, but can't remember by whom.
@caspersc: Go
Well, I can iterate literals. But constants? It's a little hard (maybe impossible?) to do.
Whoops.. I missed that natives page. It looks like it has everything I need. I guess this thread is redundant then.
Care to elaborate as to why it's horrible practice? I'd like to know. Though i can guess it's probably cos it makes it very hard for other people to work with your code.
Well, as for why there are numerous arguments against using literals and i can always think of some for using them. For example take the following code
and tell me which parameter is the key code.
Now using constants that function call is alot more readable and clear.
Could list a lot of examples, but it all comes down to, primarily, readability (the compiled code is the same, tho some languages support objects as constants which may have different semantics but obviously this does not include Galaxy) .
And yes this thread would be a bit redundant, however the Wiki does not contain most of this information.
@caspersc: Go
Thanks for the enlightenment. I'll keep this in mind when I'm working on my future codes, given that I expect someone else will work with it once I'm done with it.
Totally agree with caspersc.
I even use constants for Wait(0, c_timeGame) or Wait(0, c_timeReal) because I can never remember whether c_timeGame is actually 0 or 1.
When writing own systems its sometimes useful to even write your own constants so you can still identify all that mess after a month or so.
@MotiveMe: Go
Not quite what I had in mind. For example I wanted to loop 9 times and have 9 dialogs appear at different anchors. I could just input the literals directly and it would do it automatically. No extra assignments required, thus removing the need to allocate memory unnecessarily.
Say the literals for arrow key inputs are 73,75,77,79 and we wanted to assign key press trigger events. Rather than assigning all the constants into an dummy array and iterating through the array. By using literals instead, There is the freedom to just loop it 4 times and use the formula 73+2*i to assign the events. This is the main advantage I see.
Its too bad its horrible practice.
@s3rius: Go
Yeah, I'm bought on the idea. It's unfortunate for me that I remember numbers easier than the lengthly constant names. A good example would be dialog control creation. I use them quite a lot so its easy for me to remember 3 = button, 2 = icon, 1 = label as opposed to c_dialogControlButton? etc etc... (can't remember) =/ In the end I suppose it all comes down to familiarity.
@FuzzYD: Go
So do c_keyUp + 2*i ?
You don't need to use literals or constants for everything.
Just give the programmer a clue to what the number represents so when it breaks it stands out and it's easy to fix.
(Though it's unlikely this would break, ever)
@MotiveMe: Go
Ok.. guess it's time to start memorizing constant names.
http://wiki.sc2mapster.com/galaxy/triggers/presets/anchor/
http://wiki.sc2mapster.com/galaxy/triggers/presets
No comment
@avogatro: Go
Thanks. And not to get defensive, but if you meant to imply i wasn't searching the site properly for this information by "No comment", please keep note this question was posted about a week before those wiki links were created/updated.
Oh, and great job on the wiki, I notice you've filled in a lot of the missing stuff inside it