Could someone help me with this

Posted by Trpstrife on Mon 24 Oct 2005 06:07 PM — 7 posts, 32,715 views.

#0
I'm trying to convert a script for zmud to mush for a friend of mine but so far I havn't been able to make heads or tails out of the mush clients scripting. the code is as follows

#CLASS {xptimer}
#ALIAS showxp {showxp=1;cost}
#ALIAS startxp {savexp=1;cost}
#VAR minutes {11}
#VAR offsetxp {47361000}
#VAR savexp {0}
#VAR showxp {0}
#VAR totalxp {3712000}
#ALARM "mintimer" {-1:00} {#math minutes (@minutes+1)}
#REGEX {You have ((.+)) to spend on stats, skills or to use to level\.} {#if (@showxp=1) {#math totalxp (%1-@offsetxp);#math perminute (@totalxp/@minutes);#math perhour (@perminute*60);pl You have made @totalxp xp in @minutes minutes (@perhour xp per hour);showxp=0};#if (@savexp=1) {savexp=0;minutes=0;offsetxp=%1;#alarm "mintimer" -1:00 {#math minutes (@minutes+1)};#say XP Timer started}}
#CLASS 0

If anyone can help me with this Id be very grateful.
Amended on Mon 24 Oct 2005 06:08 PM by Trpstrife
Australia Forum Administrator #1
To get you started, there is a post which shows various zMUD things converted to MUSHclient scripts:


http://www.gammon.com.au/forum/?bbsubject_id=3032

#2
Going by the information on the other page this is what I've got so far.

ALIAS
match="showxp *"
enabled="y"
send_to"12"
sequence="100"
EnableTriggerGroup "xptimer", vbTrue
SetVariable "showxp", "1,cost"
send
alias

ALIAS
match="startxp *"
enabled="y"
send_to"12"
sequence="100"
EnableTriggerGroup "xptimer", vbTrue
SetVariable "savexp", "1,cost"
send
alias

SetVariable "minutes"

SetVariable "offsetxp"

SetVariable "savexp", "0"

SetVariable "showxp", "0"

SetVariable "totalxp"
--------------------------------------------------------
From here down im completely lost

#ALARM "mintimer" {-1:00} {#math minutes (@minutes+1)}
#REGEX {You have ((.+)) to spend on stats, skills or to use to level\.} {#if (@showxp=1) {#math totalxp (%1-@offsetxp);#math perminute (@totalxp/@minutes);#math perhour (@perminute*60);pl You have made @totalxp xp in @minutes minutes (@perhour xp per hour);showxp=0};#if (@savexp=1) {savexp=0;minutes=0;offsetxp=%1;#alarm "mintimer" -1:00 {#math minutes (@minutes+1)};#say XP Timer started}}
#CLASS 0

If someone could give me a hand and maybe check what I got done id be very appreciative.
Amended on Tue 25 Oct 2005 04:31 PM by Trpstrife
USA #3
Hmm.

<timers>
  <timer enabled="y"
   minute="1"
   send_to="12"
   one_shot="y"
   name="mintimer"
  >
  <send>setvariable "minutes", getvariable ("minutes") + 1</send>
  </timer>
</timers>

<triggers>
  <trigger
   enabled="y"
   match="You have ((.+)) to spend on stats, skills or to use to level\."
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if getvariable("showxp") = 1 then
  setvariable "totalxp", %1 - getvariable("offsetxp")
  setvariable "perminute", getvariable ("totalxp") / getvariable ("minutes")
  setvariable "perhour" , getvariable ("perminute") * 60
  send "pl You have made " &amp; getvariable ("totalxp") &amp; " xp in " &amp; getvariable("minutes") &amp; " minutes (" &amp; getvariable("perhour") &amp; " xp per hour"
  setvariable "showxp",0
end if
if getvariable("savexp") = 1 then
  setvariable "savexp", 0
  setvariable "minutes", 0
  setvariable "offsetxp", %1
  addtimer "mintimer",0,1,0,"setvariable "minutes", getvariable("minutes")+1" &amp; vbCRLF &amp; "note XP Timer started",1029,""
  settimeroption "mintimer", "send_to", 12
end if</send>
  </trigger>
</triggers>


Though.. I don't swear to this working right... Its my best guess and entirely untested.

BTW Nick. Seems the XML generation for timers is a bit odd and doesn't place all of the parts on seperate lines. The version I actually got of the timer above from 'copy' looked like this: Notice the extra line between </send> and </timer> as well as all the options crammed together on the <timer line.

<timers>
  <timer name="mintimer" enabled="y" minute="1"    send_to="12"
one_shot="y" >
  <send>setvariable "minutes", getvariable ("minutes") + 1</send>

  </timer>
</timers>
Australia Forum Administrator #4
Quote:

Seems the XML generation for timers is a bit odd and doesn't place all of the parts on seperate lines


That was intentional, the stuff about hours, mins, secs took up heaps of lines, so to save space, they are written on the one line.
#5
I'm not quite sure whats wrong with this. It won't import. It says its not in xml format.

<alias
match="showxp *"
enabled="y"
send_to"12"
sequence="100"
>
EnableTriggerGroup "xptimer", vbTrue
SetVariable "showxp", "1,cost"
</send>
</alias>

<alias
match="startxp *"
enabled="y"
send_to"12"
sequence="100"
>
EnableTriggerGroup "xptimer", vbTrue
SetVariable "savexp", "1,cost"
</send>
</alias>

<timers>
<timer enabled="y"
minute="1"
send_to="12"
one_shot="y"
name="mintimer"
>
<send>setvariable "minutes", getvariable ("minutes") + 1</send>
</timer>
</timers>

<triggers>
<trigger
enabled="y"
match="You have ((.+)) to spend on stats, skills or to use to level\."
regexp="y"
send_to="12"
sequence="100"
>
<send>if getvariable("showxp") = 1 then
setvariable "totalxp", %1 - getvariable("offsetxp")
setvariable "perminute", getvariable ("totalxp") / getvariable ("minutes")
setvariable "perhour" , getvariable ("perminute") * 60
send "pl You have made " &amp; getvariable ("totalxp") &amp; " xp in " &amp; getvariable("minutes") &amp; " minutes (" &amp; getvariable("perhour") &amp; " xp per hour"
setvariable "showxp",0
end if
if getvariable("savexp") = 1 then
setvariable "savexp", 0
setvariable "minutes", 0
setvariable "offsetxp", %1
addtimer "mintimer",0,1,0,"setvariable "minutes", getvariable("minutes")+1" &amp; vbCRLF &amp; "note XP Timer started",1029,""
settimeroption "mintimer", "send_to", 12
end if</send>
</trigger>
</triggers>

I feel like with your help I'm getting closer. It's probably just a syntax problem I'm over looking.
Australia Forum Administrator #6
Around the aliases you need:

<aliases>

...

</aliases>


This is similar to what you had for triggers. Copy a single alias the clipboard from the alias list and you will see what I mean.

You shouldn't need to manually type in your aliases in XML anyway, just use the GUI editor to insert them.