I have programming experience, nothing professional (amatuer at best and just a hobby), and I know what a function is and what it can do. My question is why would you ever use a function? It seems like almost anything you can do can be done with the functions blizzard provides. What exactly would be the point of using a custom function over one provided by the editor? Is there things you can do with a custom function that the editor's built in functions can't do?
I'm creating a few functions in a test map I have and the way I am writing them I keep asking myself "why am I even making this a function?". I just can't see any reason to use a custom function. Can someone give an example of when a custom function would be better than an editor provided function?
The Team - TnTProductions
TnTProductions latest Project - Docking Bay 13
TnTProductions Epic RPG in the making - Psionics: Chaos Rising
Check out our website on wixx! http://bulletbutter.wix.com/tntproductions
Obviously the reasons for making a custom function are to reduce the amount of code used and simplify the process of doing something that you expect to use in more than one place.
A lot of examples of good use of custom functions are for dialog creation. If you come up with a button design that you like and want to use in multiple dialogs it may require creating a button, getting the icon from an ability or item or something similar, applying that icon to an image, and positioning the image on top of the button. What would normally take several actions can be simplified to 1 with much fewer parameters for use in multiple triggers.
-
Writing code can become extremely fast if using them. Whenever I come along something that I need and expect to use again, I don't just slap it together there, I make it as a new "module" of sorts, with every function I expect to need for it. The result is that I can do things like create a dialog health bar that automatically updates for a specified unit's health using just a single action and a couple of parameters.
MasterWrath is quite right- they are incredibly useful. While they do essential have the same function as an action definition including threading which is usefull enough in its own, their main function is to take in information and return something else thats complete different; which you can then uses within the very action you want the conversion done. For example in one of my own maps i have 6 different types of hero units that i always refer to in order from 1-6. Using functions i can always returns an icon, image, ammo count, etc based on the hero unit type so basically i ask it set the icon of any button according what unit i have put in. Or you could simply return a different number other than what is put in. Like masterwrath said you basically use them like a template when your constructing large maps, so that you only every have the one set of actions ever in your map which you can call from at any place or point in your map.
Rollback Post to RevisionRollBack
When I want your opinion...I'll give it to you!
To post a comment, please login or register a new account.
I have programming experience, nothing professional (amatuer at best and just a hobby), and I know what a function is and what it can do. My question is why would you ever use a function? It seems like almost anything you can do can be done with the functions blizzard provides. What exactly would be the point of using a custom function over one provided by the editor? Is there things you can do with a custom function that the editor's built in functions can't do?
I'm creating a few functions in a test map I have and the way I am writing them I keep asking myself "why am I even making this a function?". I just can't see any reason to use a custom function. Can someone give an example of when a custom function would be better than an editor provided function?
@bulletbutter: Go
Obviously the reasons for making a custom function are to reduce the amount of code used and simplify the process of doing something that you expect to use in more than one place.
A lot of examples of good use of custom functions are for dialog creation. If you come up with a button design that you like and want to use in multiple dialogs it may require creating a button, getting the icon from an ability or item or something similar, applying that icon to an image, and positioning the image on top of the button. What would normally take several actions can be simplified to 1 with much fewer parameters for use in multiple triggers.
-
Writing code can become extremely fast if using them. Whenever I come along something that I need and expect to use again, I don't just slap it together there, I make it as a new "module" of sorts, with every function I expect to need for it. The result is that I can do things like create a dialog health bar that automatically updates for a specified unit's health using just a single action and a couple of parameters.
@bulletbutter: Go
MasterWrath is quite right- they are incredibly useful. While they do essential have the same function as an action definition including threading which is usefull enough in its own, their main function is to take in information and return something else thats complete different; which you can then uses within the very action you want the conversion done. For example in one of my own maps i have 6 different types of hero units that i always refer to in order from 1-6. Using functions i can always returns an icon, image, ammo count, etc based on the hero unit type so basically i ask it set the icon of any button according what unit i have put in. Or you could simply return a different number other than what is put in. Like masterwrath said you basically use them like a template when your constructing large maps, so that you only every have the one set of actions ever in your map which you can call from at any place or point in your map.