Optimizing and Events

Post Reply
Xikue
Posts: 6
Joined: Sun Jul 05, 2009 4:24 am

Optimizing and Events

Post by Xikue »

Q1. I have some aliases which start off with the same pattern. Will they go through faster if I collapse it into one alias?
db (command: drink bromide)
df (command: drink fire)
...
dm (command: drink mana)
collapse into
alias: d(b|f|...|m)
script: --if statement to send correct command

Q2. What is an event? Can an event only have one handler?
I was thinking of having an OnEquilibrium event to be handled differently depending on the situation--fighting, debating, or influencing. Could I have three event handlers each in it's own script and enable the script corresponding to the situation? Or do I have to use one event handler and use an if statement inside to respond according to the situation?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Optimizing and Events

Post by Heiko »

Q1:
Due to the nature of alias, there is no need whatsoever to worry about alias optimization - even if you plan on defining several thousand aliases. Trigger sets, by contrast, should be designed with speed criteria in mind (chosing the fastest possible trigger pattern type).

Q2:
a) http://en.wikipedia.org/wiki/Event-driven_programming
b) Yes, an event may have many handlers in different scripts. When an event is raised all event handler functions for this event will be called.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: Optimizing and Events

Post by Caled »

Xikue wrote: alias: d(b|f|...|m)
script: --if statement to send correct command
Instead of an elseif statement, consider a list

In a script object:

drinkables={
f = "fire",
b = "bromide"
}

In the alias:
send("drink " .. drinkables[ matches[2] ])

Post Reply