I am attempting to make a simple script with a function that requires the entire content of a multi-line trigger. Using %0 only seems to pass the first line and separates the line into several arguments. Is there any way to pass the ENTIRE multiline trigger as ONE argument?
Multiline Triggers & calling functions
Posted by Grounded on Thu 12 Oct 2006 08:29 PM — 3 posts, 13,594 views.
My intention is to use LINE BREAKS and SPACES as split points in order to parse the trigger. This is for a rerolling script for Realms of Despair.
An example of the trigger looks like this:
Strength 17 13
Dexterity 18 15
Intelligence 15 14
Wisdom 10 13
Charisma 13 15
Constitution 12 13
Luck 10 12
My multiline trigger is formated like this:
Strength+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nDexterity+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nIntelligence+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nWisdom+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nCharisma+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nConstitution+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nLuck+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\Z
And here is the code of my VBScript:
'START
basemax=array(18,15,15,16,10,14,14)
basemin=array(16,14,14,15,9,12,12)
Sub evalroll(roll)
stat=Split(roll,"\n",7)
For s=0 to 6
value=Split(stat(s))
stat(s)=value(1)
Next
rollagain = False
For s=0 to 6
If stat(s)<basemin(s) or stat(s)>basemax(s) Then
rollagain = True
End If
Next
If rollagain Then
world.send "gold"
world.send "reroll"
Else
world.note "good stats"
End If
End Sub
'END
An example of the trigger looks like this:
Strength 17 13
Dexterity 18 15
Intelligence 15 14
Wisdom 10 13
Charisma 13 15
Constitution 12 13
Luck 10 12
My multiline trigger is formated like this:
Strength+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nDexterity+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nIntelligence+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nWisdom+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nCharisma+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nConstitution+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\nLuck+( *)(9|(1[0-8]))+( *)(9|(1[0-8]))\Z
And here is the code of my VBScript:
'START
basemax=array(18,15,15,16,10,14,14)
basemin=array(16,14,14,15,9,12,12)
Sub evalroll(roll)
stat=Split(roll,"\n",7)
For s=0 to 6
value=Split(stat(s))
stat(s)=value(1)
Next
rollagain = False
For s=0 to 6
If stat(s)<basemin(s) or stat(s)>basemax(s) Then
rollagain = True
End If
Next
If rollagain Then
world.send "gold"
world.send "reroll"
Else
world.note "good stats"
End If
End Sub
'END
Rather than trying to put the whole matching line somewhere, I would get at the individual numbers, like this:
When I run that on your example I get:
Now you can use the individual items in your calculations.
<triggers>
<trigger
enabled="y"
group="Multi Line"
lines_to_match="7"
keep_evaluating="y"
match="Strength ([0-9]{1,2}) ([0-9]{1,2})\nDexterity ([0-9]{1,2}) ([0-9]{1,2})\nIntelligence ([0-9]{1,2}) ([0-9]{1,2})\nWisdom ([0-9]{1,2}) ([0-9]{1,2})\nCharisma ([0-9]{1,2}) ([0-9]{1,2})\nConstitution ([0-9]{1,2}) ([0-9]{1,2})\nLuck ([0-9]{1,2}) ([0-9]{1,2})\Z"
multi_line="y"
regexp="y"
send_to="2"
sequence="100"
>
<send>Matched!
str1 = %<1>
str2 = %<2>
dex1 = %<3>
dex2 = %<4></send>
</trigger>
</triggers>
When I run that on your example I get:
Matched!
str1 = 17
str2 = 13
dex1 = 18
dex2 = 15
Now you can use the individual items in your calculations.