I presume you want to react automatically to the stats offered when you create a new character? To do this I would make a trigger that matches on the appropriate line (post an example from your mud, to make it easier to describe it exactly).
The trigger would call a script routine that (using wildcards for each stat) would decide whether or not to accept the roll and reply accordingly (using the script routine world.send).
Here is an example to get you started ...
Taking the character generation from the Dawn Of Time server as an example:
Rerolling please wait.
-====================== CHARACTER ATTRIBUTES SELECTION ======================-
Strength (ST): 30( 77) Constitution (CO): 33( 53)
Quickness(QU): 40( 40) Agility (AG): 52( 52)
Presence (PR): 24( 84) Self-Discipline(SD): 29( 39)
Empathy (EM): 20( 68) Memory (ME): 40( 40)
Intuition(IN): 26( 47) Reasoning (RE): 29( 39)
green is starting value, (blue) is potential with training.
Are you happy with these attributes?
|
You could match on the above with 5 triggers (one for each attribute line), or make a more complex regular expression. Let's make a regular expression because it lets us skip spaces more easily:
Trigger (one long line):
^\s*(Strength|Quickness|Presence|Empathy|Intuition)\s*\((ST|QU|PR|EM|IN)\):\s*(\d+)\(\s*(\d+)\)\s*(Constitution|Agility|Self-Discipline|Memory|Reasoning)\s*\((CO|AG|SD|ME|RE)\):\s*(\d+)\(\s*(\d+)\)$
- Enabled: checked
- Regular expression: checked
- Label: Stats
- Script: OnStats
This regular expression might look a little daunting, so let's break it up to explain what each bit does ...
^ |
Start of line |
\s* |
Zero or more spaces |
(Strength|Quickness|Presence|Empathy|Intuition) |
One of those words (wildcard 1) |
\s* |
Zero or more spaces |
\( |
The "(" character literally |
(ST|QU|PR|EM|IN) |
One of those words (wildcard 2) |
\) |
The ")" character literally |
:\s* |
A colon followed by zero or more spaces |
(\d+) |
One or more digits (0 to 9) (wildcard 3) |
\( |
The "(" character literally |
(\d+) |
One or more digits (0 to 9) (wildcard 4) |
\) |
The ")" character literally |
\s* |
Zero or more spaces |
(Constitution|Agility|Self-Discipline|Memory|Reasoning) |
One of those words (wildcard 5) |
\s* |
Zero or more spaces |
\( |
The "(" character literally |
(CO|AG|SD|ME|RE) |
One of those words (wildcard 6) |
\) |
The ")" character literally |
:\s* |
A colon followed by zero or more spaces |
(\d+) |
One or more digits (0 to 9) (wildcard 7) |
\( |
The "(" character literally |
(\d+) |
One or more digits (0 to 9) (wildcard 8) |
\) |
The ")" character literally |
$ |
End of line |
Parts of the regular expression in round brackets are "output" as wildcards, thus the expression above sets up 8 widcards, which we can retrieve in the script.
We add to the script file (this example is in VBscript) the "OnStats" handler:
sub OnStats (strName, strLine, aryWildcards)
dim stat, start, potential
' get first stat (wildcards 2, 3, 4)
stat = aryWildcards (2)
start = aryWildcards (3)
potential = aryWildcards (4)
world.setvariable "stat_" & stat & "_start", start
world.setvariable "stat_" & stat & "_potential", potential
' get second stat (wildcards 6, 7, 8)
stat = aryWildcards (6)
start = aryWildcards (7)
potential = aryWildcards (8)
world.setvariable "stat_" & stat & "_start", start
world.setvariable "stat_" & stat & "_potential", potential
end sub
After setting up this wildcard and testing it we can look at the "variables" window in the configuration dialog, to see that various variables have been set up to "remember" the rolls for each attribute.
stat_ag_potential = 52
stat_ag_start = 52
stat_co_potential = 53
stat_co_start = 33
stat_em_potential = 68
stat_em_start = 20
stat_in_potential = 47
stat_in_start = 26
stat_me_potential = 40
stat_me_start = 40
stat_pr_potential = 84
stat_pr_start = 24
stat_qu_potential = 40
stat_qu_start = 40
stat_re_potential = 39
stat_re_start = 29
stat_sd_potential = 39
stat_sd_start = 29
stat_st_potential = 77
stat_st_start = 30
Now what we need to do is reply to the question "Are you happy with these attributes?". The logical thing to do here is make a trigger that matches that line, retrieve each of the stats we saved in the earlier trigger, and make a decision. I don't know your criteria, so I'll do a simple example that tests that each stat exceeds a minimum value. You may want to do something more complex.
- Trigger: Are you happy with these attributes?
- Enabled: checked
- Label: AreYouHappy
- Script: OnAreYouHappy
Now we make the script "OnAreYouHappy" that makes the decision:
sub OnAreYouHappy (strName, strLine, aryWildcards)
dim ST, CO, QU, AG, PR, SD, EMP, MEM, INT, RE
ST = cint (world.getvariable ("stat_st_start"))
CO = cint (world.getvariable ("stat_co_start"))
QU = cint (world.getvariable ("stat_qu_start"))
AG = cint (world.getvariable ("stat_ag_start"))
PR = cint (world.getvariable ("stat_pr_start"))
SD = cint (world.getvariable ("stat_sd_start"))
EMP = cint (world.getvariable ("stat_em_start"))
MEM = cint (world.getvariable ("stat_me_start"))
INT = cint (world.getvariable ("stat_in_start"))
RE = cint (world.getvariable ("stat_re_start"))
' see if we accept these stats
if ST > 30 and _
CO > 50 and _
QU > 25 and _
AG > 40 and _
PR > 30 and _
SD > 22 and _
EMP > 33 and _
MEM > 47 and _
INT > 21 and _
RE > 13 then
world.send "yes"
else
world.send "no"
end if
end sub
Notice that this script sends "yes" or "no" to the world depending on the decision about each stat.
I hope this helps.
|