|
bebamedo Novice
Joined: 02 Aug 2006 Posts: 32
|
Posted: Wed Apr 23, 2008 3:11 pm
what is quicker? |
I think i heard a discussions once on what is faster:
To make alias or simply write actions in response to trigger?
example:
#TRIGGER {A} {do a;do b;do c;#VAR blabla 1}
or
#ALIAS alias {do a;do b;do c;#VAR blabla 1}
#TRIGGER {A} {alias} |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed Apr 23, 2008 3:51 pm |
The speed difference will be minute in this case. If you get into doing a lot of nesting of aliases/functions down several levels deep, it gets a little slower. I'd advise you to use aliases when you're going to be doing the same sorts of things over and over again, just to save your own sanity when building and maintaining your scripts.
|
|
|
|
Leyline Wanderer
Joined: 03 Feb 2007 Posts: 64
|
Posted: Wed Apr 23, 2008 5:09 pm |
A general rule of programming is,
if you use it more than once, write a function
or in this case an alias.
If you are going to have 2 or more triggers do the same thing, I would write an alias,
and then have each of the triggers call the alias.
For example, I have multiple versions of "you are hungry"
"you are getting hungry"
"you feel stomach pains from hunger"
"you could use a bitew to eat"
and then I made an alias called doEat
which opens my bag,
tastes the food (to see if it is spoiled)
then eats the food if it is not. (spoiled food is discarded when tasted)
then it closes my bag (so mages cannot freeze or burn my potions / scrolls)
so instead of writing that out 5 different times for each trigger, each trigger just calls doEat
(that and if I get a new bag, or food, or want to change how much food I eat at a time, I only edit 1 alias) |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Apr 23, 2008 5:31 pm |
That's only peripherally relevant to the discussion, though, Leyline. The point is that using an alias within any trigger will be marginally quicker, even if you're only using that code once. And that's true, I believe because of a problem in the way zMUD interprets the scripts - a search of the forums would yield more information.
Of course, having boatloads of aliases around will be an arse to upkeep, so it's up to you if you want that headache.
Oh, and this problem doesn't exist in CMUD. |
|
|
|
Leyline Wanderer
Joined: 03 Feb 2007 Posts: 64
|
Posted: Wed Apr 23, 2008 5:38 pm |
Well Larkin said the speed difference will only be minute,
but he did not say in favor of which way,
So I was just saying aside from the speed difference (if any)
another reason / general rule that could be followed. |
|
|
|
|
|