I have some custom scripts within the "custom script" section of a trigger/function. To keep the code clean I need some kind of enum to keep track of int based constants. However when i press ctrl+f11 there's no code of preset definition showing anywhere. Is it possible to use presets within my custom scripts? or is there any language feature can be used like enum?
I'm currently using constants but they're not working as well as enum solution that every programmer got used to.
I wanted 'enum' mostly for code readability reasons, while your solution seems having some trade offs. I need to use irrelevant function names to get this hash-like behavior. I need to think about it carefully before i make my choice.
Presets are a GUI trigger construct, its values are inserted into the map script as literals. So definitely not accessible via script.
While galaxy lacks an enum construct, one may employ constants, arrays, structs, functions, DataTable API, and/or UserType data & UserData API to similar effect. None of the approaches are entirely satisfying as a convenient enum construct, but given the options one ought to find a workable compromise.
AHAH! i should have asked you jade what you CANT do with galaxy!
Jade answered my question very clearly. What I learnt in past 3 weeks of my map making life, I would say you can't do $$$$ with galaxy script. The only model of programming in galaxy is to pre-allocate your data then write global functions to manipulate them. You cant even define any custom type or use pointer (I heard they once support the use of pointer but removed it later on). Blizzard should totally fire the one designed galaxy compiler, this is high school level work of making a language.
Jade answered my question very clearly. What I learnt in past 3 weeks of my map making life, I would say you can't do $$$$ with galaxy script. The only model of programming in galaxy is to pre-allocate your data then write global functions to manipulate them. You cant even define any custom type or use pointer (I heard they once support the use of pointer but removed it later on). Blizzard should totally fire the one designed galaxy compiler, this is high school level work of making a language.
Well, truth of the matter is, pointers are rarely needed nor recommended under a sandboxed environment.
In any case, you have references (with arrayref and structref) and you can use the typedef for your custom definitions.
In any case, while there are a few notable exceptions, for the most part you dont need elaborate constructs for actually getting shit done. What do you intend to do that cant be solved in any other way?
In any case, while there are a few notable exceptions, for the most part you dont need elaborate constructs for actually getting shit done. What do you intend to do that cant be solved in any other way?
<</quote>>
Thanks a lot for the links, much appreciated.
A bit more to language capability problem. Theoretically you can use your nails to scratch trees and eventually build a house. Keep in mind that even ForTran is a Turing complete language that 'capable' of everything, as a language of year 2012 galaxy script really lack of many features to enable project of significant complexity. To have 'work around' on certain task is nothing to be proud of as compiler programmer, this kind of credit should be entitled to user. Just like template meta programming of C++ is really not a language feature, but a lack of reflection abilities of the language itself.
This paste may be helpful, as it provides some usage examples of funcref and structref (didn't include arrayref, since it's used similarly to structref).
I have some custom scripts within the "custom script" section of a trigger/function. To keep the code clean I need some kind of enum to keep track of int based constants. However when i press ctrl+f11 there's no code of preset definition showing anywhere. Is it possible to use presets within my custom scripts? or is there any language feature can be used like enum?
I'm currently using constants but they're not working as well as enum solution that every programmer got used to.
Either UserData or ConversationDataStates Catalogs. There are native functiont to retrieve data from them without using the Catalog native functions.
Cehck the following:
Conversationdata states entries are readonly tho, and are recommendably filled by hand, as the UI in the Data module for it is mediocre. Here is an example I gave to some other guy: http://www.sc2mapster.com/forums/development/galaxy-scripting-and-trigger-lib/34702-import-a-lot-of-data-to-initialize-variables/#p1
I couldnt find the UserData natives, but you can see into the GUI functions. They can be modified (but no new instances can be created)
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
@Alevice: Go
Thanks a lot for your solution.
I wanted 'enum' mostly for code readability reasons, while your solution seems having some trade offs. I need to use irrelevant function names to get this hash-like behavior. I need to think about it carefully before i make my choice.
Presets are a GUI trigger construct, its values are inserted into the map script as literals. So definitely not accessible via script.
While galaxy lacks an enum construct, one may employ constants, arrays, structs, functions, DataTable API, and/or UserType data & UserData API to similar effect. None of the approaches are entirely satisfying as a convenient enum construct, but given the options one ought to find a workable compromise.
AHAH! i should have asked you jade what you CANT do with galaxy!
Jade answered my question very clearly. What I learnt in past 3 weeks of my map making life, I would say you can't do $$$$ with galaxy script. The only model of programming in galaxy is to pre-allocate your data then write global functions to manipulate them. You cant even define any custom type or use pointer (I heard they once support the use of pointer but removed it later on). Blizzard should totally fire the one designed galaxy compiler, this is high school level work of making a language.
@miushock: Go
sorry that was directed at jade, it was off topic to the thread.
Well, truth of the matter is, pointers are rarely needed nor recommended under a sandboxed environment.
In any case, you have references (with arrayref and structref) and you can use the typedef for your custom definitions.
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
@Alevice: Go
can you please elaborate a bit about arrayref and structref?
I feel it's really hard to construct data structure with some level of complication with galaxy script.
Lemme google that for you:
http://www.sc2mapster.com/forums/?scope=tree&search=structref http://www.sc2mapster.com/forums/?scope=tree&search=arrayref
In any case, while there are a few notable exceptions, for the most part you dont need elaborate constructs for actually getting shit done. What do you intend to do that cant be solved in any other way?
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
<<quote 1817902>>
Lemme google that for you:
http://www.sc2mapster.com/forums/?scope=treesearch=structref http://www.sc2mapster.com/forums/?scope=treesearch=arrayref
In any case, while there are a few notable exceptions, for the most part you dont need elaborate constructs for actually getting shit done. What do you intend to do that cant be solved in any other way?
<</quote>>
Thanks a lot for the links, much appreciated.
A bit more to language capability problem. Theoretically you can use your nails to scratch trees and eventually build a house. Keep in mind that even ForTran is a Turing complete language that 'capable' of everything, as a language of year 2012 galaxy script really lack of many features to enable project of significant complexity. To have 'work around' on certain task is nothing to be proud of as compiler programmer, this kind of credit should be entitled to user. Just like template meta programming of C++ is really not a language feature, but a lack of reflection abilities of the language itself.
Theoretically you can use both a fruit fork and a table fork to pinch your steak. In practice you can do the same.
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!
This paste may be helpful, as it provides some usage examples of funcref and structref (didn't include arrayref, since it's used similarly to structref).
For some reason i forgot to mention funcref, even when it is the more valuable for me.
Go play Antioch Chronicles Remastered!
Also, coming soon, Antioch Episode 3: Thoughts in Chaos!
Dont like mapster's ugly white? Try Mapster's Classic Skin!