<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, November 05, 2002, 5:34 PM -->
<!-- MuClient version 3.30 -->

<!-- Plugin "ScoreChecker" generated by Plugin Wizard -->

<muclient>
<plugin
   name="ScoreChecker"
   author="Nick Gammon"
   id="e5035cb194f55fc466334012"
   language="VBscript"
   purpose="Checks stat rolls"
   date_written="2002-11-05 17:32:55"
   requires="3.27"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This checks your stats (str, dex, wis etc.) and replies "Y" (to accept) if they are OK, and "N" (to reject) if not.

See: 
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1936

for more details.

]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="Your ability scores:"
   script="OnStart"
   sequence="100"
  >
  </trigger>
  <trigger
   custom_colour="3"
   group="scores"
   match="Str: * Dex: * Int: *"
   script="OnLine1"
   sequence="100"
  >
  </trigger>
  <trigger
   custom_colour="4"
   group="scores"
   match="Wis: * Con: * Cha: *"
   script="OnLine2"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Script  -->


<script>
<![CDATA[
sub OnStart (sName, sLine, wildcards)
  world.EnableGroup "scores", 1
end sub

'
' converts a word score into a number
'
function RateIt (score)
 
 select case score
   case "excellent" RateIt = 8
   case "very good" RateIt = 7
   case "good"      RateIt = 6
   case "decent"    RateIt = 5
   case "average"   RateIt = 4
   case "poor"      RateIt = 3
   case "bad"       RateIt = 2
   case "awful"     RateIt = 1
   case else        RateIt = 0
 end select

end function

sub OnLine1 (sName, sLine, wildcards)
'
'  remember str, dex, int for next time
'
  world.SetVariable "str", wildcards (1)
  world.SetVariable "dex", wildcards (2)
  world.SetVariable "int", wildcards (3)
end sub

sub OnLine2 (sName, sLine, wildcards)
  dim str, dex, int, wis, con, cha, ok

  str = world.GetVariable ("str")
  dex = world.GetVariable ("dex")
  int = world.GetVariable ("int")
  wis = wildcards (1)
  con = wildcards (2)
  cha = wildcards (3)

  ok = vbTrue

'
'  see if it OK
'

  if RateIt (str) < 4 then ok = vbFalse
  if RateIt (dex) < 4 then ok = vbFalse
  if RateIt (int) < 4 then ok = vbFalse
  if RateIt (wis) < 4 then ok = vbFalse
  if RateIt (con) < 4 then ok = vbFalse
  if RateIt (cha) < 7 then ok = vbFalse

'
'  accept scores if ok
'    

  if ok then
    world.send "Y"
  else
    world.send "N"
  end if

  world.EnableGroup "scores", 0
end sub


]]>
</script>


</muclient>
