Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Jscript
➜ Need help with this Script
Need help with this Script
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Confused
(2 posts) Bio
|
Date
| Wed 30 Mar 2005 03:02 AM (UTC) Amended on Wed 30 Mar 2005 03:24 AM (UTC) by Confused
|
Message
|
<?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="<*hp *sp *st>"
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?
| Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Wed 30 Mar 2005 04:36 AM (UTC) |
Message
| 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 );
}
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Confused
(2 posts) Bio
|
Date
| Reply #2 on Wed 30 Mar 2005 06:29 AM (UTC) |
Message
| <?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="<*hp *sp *st>"
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? | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #3 on Wed 30 Mar 2005 06:51 AM (UTC) |
Message
| 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="<*hp *sp *st>"
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>
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
15,009 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top