|
phujitsu Newbie
Joined: 20 Apr 2009 Posts: 1
|
Posted: Mon Apr 20, 2009 2:03 am
Your two cents and suggestions wanted on this wouldbe code.. |
Okay Tried to write my own stat reviewer/possible reroller and ran across a snag here is my pattern.
Choose from any of the following groups of abilities...
Group: 1 2 3 4 5
Str: 15 13 13 15 12
Dex: 9 17 13 14 12
Con: 14 16 14 12 13
Int: 14 15 12 15 11
Wis: 12 9 12 12 11
And here is my script/code etc
#VAR Vstr1 %1
#VAR Vint1 %2
#VAR Vwis1 %3
#VAR Vdex1 %4
#VAR Vcon1 %5
#VAR Vstr2 %6
#VAR Vint2 %7
#VAR Vwis2 %8
#VAR Vdex2 %9
#VAR Vcon2 %10
#VAR Vstr3 %11
#VAR Vint3 %12
#VAR Vwis3 %13
#VAR Vdex3 %14
#VAR Vcon3 %15
#VAR Vstr4 %16
#VAR Vint4 %17
#VAR Vwis4 %18
#VAR Vdex4 %19
#VAR Vcon4 %20
#VAR Vstr4 %21
#VAR Vint4 %22
#VAR Vwis4 %23
#VAR Vdex4 %24
#VAR Vcon4 %25
#if ((@Vstr1 > 16) and (@Vint1 > 16) and (@Vwis1 > 16)) {#echo Check Out The RolL!!}
#if ((@Vstr2 > 16) and (@Vint2 > 16) and (@Vwis2 > 16)) {#echo Check Out The RolL!!}
#if ((@Vstr3 > 16) and (@Vint3 > 16) and (@Vwis3 > 16)) {#echo Check Out The RolL!!}
#if ((@Vstr4 > 16) and (@Vint4 > 16) and (@Vwis4 > 16)) {#echo Check Out The RolL!!}
#if ((@Vstr5 > 16) and (@Vint5 > 16) and (@Vwis5 > 16)) {#echo Check Out The RolL!!}
This is where I get lost, I don't know how to make a trigger set the variable?
Here's a half thought theory...
#trigger {Str: %1 %6 %11 %16 %12}
#trigger {Dex: %4 %9 %14 %19 %24}
#trigger {Con: %5 %10 %15 %20 %25}
#trigger {Int: %2 %7 %12 %17 %22}
#trigger {Wis: %3 %8 %13 %18 %23}
...
If anyone cane improve, offer better script/code
Zmud 7.21
Windoze Xp Pro..
Thanks in advance |
|
|
|
Scirkhan Apprentice
Joined: 14 Sep 2007 Posts: 167 Location: aztx
|
Posted: Mon Apr 20, 2009 8:12 am |
Code: |
#trigger {Str: &Vstr1 &Vstr2 &Vstr3 &Vstr4 Vstr5} {} |
Something like that should work. It has been awhile for me but it'll work. I am guessing you don't want a 5th set, so:
Code: |
#trigger {Str: &Vstr1 &Vstr2 &Vstr3 &Vstr4 (%d)} {} |
Code: |
#trigger {Str: &Vstr1 &Vstr2 &Vstr3 &Vstr4 %5} {} |
Code: |
#trigger {Str: %1 %2 %3 %4 %5} {#var Vstr1 %1;#var Vstr2 %2;#var Vstr3 %3;#var Vstr4 %4} |
Any one of the above Triggers should work. Test out using Triggers like this.
--
Not bad it looks like you did pretty good. Also I may not have correctly understood your question, please correct me if I did not.
Let me know how it goes. |
|
|
|
Thrillhouse8 Beginner
Joined: 21 Sep 2004 Posts: 18
|
Posted: Mon Apr 20, 2009 10:27 am |
When a trigger fires, it reads the parameters just as it reads the text--from left to right(and with multi-line triggers, left to right, THEN top to bottom). I'd recommend reading the pattern matching section in help. For a trigger to recognize some sort of variable input, you'll need to tell it what type of input to look for(numbers, letters, both, spaces, and so on), with each type having a different pattern. In this case, the Strength trigger pattern would look like so:
Code: |
#TRIGGER {Str: (%d) (%d) (%d) (%d) (%d)} {[i]commands[/i]} |
or
Code: |
#REGEX {Str: (\d+) (\d+) (\d+) (\d+) (\d+)} {[i]commands[/i]} |
The %d tells the trigger to look for any numbers, and the parenthesis around %d tell the trigger to save each number as a parameter. The regular expression is similiar, \d tells the trigger to look for digits, + means there is at least one digit to match, and the parenthesis mean to store the matched digits as a parameter.
So, referring to all the stats read in at once(ie., with one trigger), Str would be parameters %1 through %5, Int would be %16 through %20 and Wis %21 through %25. If there's irregular spacing between the digits, I'd recommend using %s or \s+, without parenthesis. For instance, this would match all the given stats, regardless of how they're spaced:
Code: |
#REGEX {Str:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\nDex:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\nCon:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\nInt:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\nWis:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$} {} |
\s+ = at least one space,
(\d+) = at least one digit, saved as a parameter
\n = new line
$ = end of line
And putting that into a code...
Defining the highest unacceptable stat:
Code: |
#VAR cutoffStr 16
#VAR cutoffInt 16
#VAR cutoffWis 16 |
@compare(str, int, wis) == 1 if str, int, and wis are all above their respective highest unacceptable numbers,
@compare(str, int, wis) == 0 if str, int, or wis are equal to or below their respective highest unacceptable numbers:
Code: |
#FUNCTION compare {%if(%1 > @cutoffStr, %if(%2 > @cutoffInt, %if(%3 > @cutoffWis, 1, 0), 0), 0)} |
Matching the block of stats, and passing the parameters to the @compare() function:
Code: |
#REGEX {Str:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\nDex:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\nCon:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\nInt:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\nWis:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$} {#LOOP 5 {#IF (@compare(%param(%i), %param(%eval(%i + 15)), %param(%eval(%i + 20)))) {#ECHO Check Out Roll!! - Group %i}}} |
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|