Need help with this Script

Posted by Confused on Wed 30 Mar 2005 03:02 AM — 4 posts, 19,557 views.

#0

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, March 29, 2005, 10:36 PM -->
<!-- MuClient version 3.65 -->

<!-- Plugin "Stats" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Stats"
   author="Travis"
   id="4624287bc3c0840692e4e0eb"
   language="JScript"
   save_state="y"
   date_written="2005-03-29 22:34:53"
   requires="3.65"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.js"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   group="Multi Line"
   ignore_case="y"
   lines_to_match="2"
   keep_evaluating="y"
   match="Hit Points:       */*   Practices:      *\nSpell Points:     */*\Z"
   multi_line="y"
   name="tmax"
   regexp="y"
   script="StatsMax"
   send_to="12"
   sequence="100"
  >
  <send>%2 %5</send>    <---- ?
  </trigger>
  <trigger
   enabled="y"
   ignore_case="y"
   keep_evaluating="y"
   match="&lt;*hp *sp *st&gt;"
   name="tprompt"
   script="StatsChanged"
   send_to="12"
   sequence="100"
  >
  <send>%1 %2 %3</send>  <--- ?
  </trigger>
</triggers>

<!--  Script  -->


<script>
<![CDATA[


function StatsChanged (Name, trig_line, wildcards)
{
 
   wildcards = VBArray(wildcards).toarray();
   xhp = wildcards[0]     <---- 
   xsp = wildcards[1]     <---- 
   
   world.Note( hpc  spc );
}

function StatsMax (Name, trig_line, wildcards)
{
   wildcards = VBArray(wildcards2).toarray();
   maxhp = wildcards[1] <---
   maxsp = wildcards[4] <---
}

var maxhp = 0
var maxsp = 0
var xhp = 0
var xsp = 0
var hpc = maxhp - xhp
var spc = maxsp - xsp   

]]>
</script>


</muclient>


Need I a little guidance. Basically I want the numerically difference between my current hp and maxhp. Two triggers that catch current and max hp. Thanks in advance for any assistance.

I wasn't sure where exactly to put the world.Note() command. Is it in the correct place?
Amended on Wed 30 Mar 2005 03:24 AM by Confused
USA #1
You need to have the subtraction in your script somewhere (right now it does it when the file is loaded, but that's it).

So in your changed subroutine, after you've set the values subtract them, and THEN note your values.

You also need to get rid of the big arrows (assuming you didnt add them for this post) and they also needs semicolons. And then for the note you also need to have some sort of string between them or whatnot.

It becomes this:
function StatsChanged (Name, trig_line, wildcards)
{
 
   wildcards = VBArray(wildcards).toarray();
   xhp = wildcards[0];
   xsp = wildcards[1];
   hpc = maxhp - xhp;
   spc = maxsp - spc;
   world.Note( hpc + "  " + spc );
}
#2
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, March 29, 2005, 10:36 PM -->
<!-- MuClient version 3.65 -->

<!-- Plugin "Stats" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Stats"
   author="Travis Hampton"
   id="4624287bc3c0840692e4e0eb"
   language="JScript"
   save_state="y"
   date_written="2005-03-29 22:34:53"
   requires="3.65"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.js"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   group="Multi Line"
   ignore_case="y"
   lines_to_match="2"
   keep_evaluating="y"
   match="Hit Points:       */*   Practices:      *\nSpell Points:     */*\Z"
   multi_line="y"
   name="tmax"
   regexp="y"
   script="StatsMax"
   send_to="12"
   sequence="100"
  >
  <send>%2 %5</send>
  </trigger>
  <trigger
   enabled="y"
   ignore_case="y"
   keep_evaluating="y"
   match="&lt;*hp *sp *st&gt;"
   name="tprompt"
   script="StatsChanged"
   send_to="12"
   sequence="100"
  >
  <send>%1 %2</send>
  </trigger>
</triggers>

<!--  Script  -->


<script>
<![CDATA[

function StatsChanged(Name, trig_line, wildcards)
{
 
   wildcards = VBArray(wildcards).toarray();
   xhp = wildcards[0];
   xsp = wildcards[1]; 
   hpc = maxhp - xhp;
   spc = maxsp - spc;
   world.Note( hpc + " " + spc );
}

function StatsMax(Name, trig_line, wildcards)
{
   wildcards = VBArray(wildcards).toarray();
   maxhp = wildcards[0];
   maxsp = wildcards[1];
}

]]>
</script>
</muclient>


Still doesn't work. Thanks for the help so far see anything else wrong? What about the send_to line in the triggers?
USA #3
You shouldn't be sending anything (delete what you have) and sending to script doesn't override the script function. However, you can go ahead and change send_to to 1 (world). But definately delete the send text (<send></send>).

Your problem (now) is that your variables are all local. You need to declare them outside the subroutines (like you did before).

And actually (if I were you) I would get rid of the script file all together and use these triggers (along with the two appropriate MC Variables):
<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   keep_evaluating="y"
   match="&lt;*hp *sp *st&gt;"
   name="tprompt"
   send_to="12"
   sequence="100"
  >
  <send>changeHP = (getvariable("maxhp") - ParseInt("%1"));
changeSP = (getvariable("maxsp") - ParseInt("%2"));
note(ChangeHP + " " + changeSP);</send>
  </trigger>
  <trigger
   enabled="y"
   group="Multi Line"
   ignore_case="y"
   lines_to_match="2"
   keep_evaluating="y"
   match="Hit Points:       */*   Practices:      *\nSpell Points:     */*\Z"
   multi_line="y"
   name="tmax"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>setvariable("maxhp","%2");
setvariable("maxsp","%5");</send>
  </trigger>
</triggers>