Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
HollyC
Novice


Joined: 10 Apr 2003
Posts: 45
Location: USA

PostPosted: Fri Oct 08, 2010 2:53 pm   

This USED to work...
 
...but apparently the changes in the scripting engine between zMUD and cMUD made it stop working.

The last known version of zMUD I remember using was I think 7.21. I had the following script for hunting rats in Achaea:

(I have written the script by hand in the old zMUD format because cMUD requires .xml which adds a lot of unnecessary characters)

#class ratting
#alias {"ratreset"} {@ratgold = 0;@rats = 0;@ratkilled = 0;@rathere = 0}
#alias {"e"} {east;@ratkilled = 0}
#alias {"s"} {south;@ratkilled = 0}
#alias {"n"} {north;@ratkilled = 0}
#alias {"w"} {west;@ratkilled = 0}
#alias {"nw"} {northwest;@ratkilled = 0}
#alias {"ne"} {northeast;@ratkilled = 0}
#alias {"sw"} {southwest;@ratkilled = 0}
#alias {"se"} {southeast;@ratkilled = 0}
#var {"ratgold"} {0} {0}
#var {"rats"} {0} {0}
#var {"rathere"} {0} {0}
#var {"ratkilled"} {0} {0}
#trigger {{A|An}%1rat wanders into view, nosing about for food.} {#math rathere (@rathere + 1)}
#trigger {{A|An}%1rat noses its way cautiously out of the shadows.} {#math rathere (@rathere + 1)}
#trigger {Your eyes are drawn to {a|an}%1rat that darts suddenly into view.} {#math rathere (@rathere + 1)}
#trigger {With a squeak, {a|an}%1rat darts into the room, looking about wildly.} {#math rathere (@rathere + 1)}
#trigger {You have slain {a|an}%1rat} {#math rathere (@rathere - 1);#IF (@rathere < 0) {@rathere = 0};#math ratkilled (@ratkilled + 1);#IF (@ratkilled = 4) {#echo Move on. Rats cleared.}}
#trigger {rat has been slain by} {#math rathere (@rathere - 1);#IF (@rathere < 0) {@rathere = 0};#math ratkilled (@ratkilled + 1);#IF (@ratkilled = 4) {#echo Move on. Rats cleared.}}
#trigger {You detect nothing here by that name.} {#IF (@target = rat) {@rathere = 0}}
#trigger {You cannot see that being here.} {#IF (@target = rat) {@rathere = 0}}
#trigger {Nothing can be seen here by that name.} {#IF (@target = rat) {@rathere = 0}}
#trigger {Ah, I am truly sorry,} {#IF (@target = rat) {@rathere = 0}}
#trigger {With a flick of its small whiskers, {a|an}%1rat dashes out of view.} {#math rathere (@rathere - 1);#IF (@rathere < 0) {@rathere = 0}}
#trigger {{A|An}%1rat wanders back into its warren} {#math rathere (@rathere - 1);#IF (@rathere < 0) {@rathere = 0}}
#trigger {{A|An}%1rat darts into the shadows and disappears.} {#math rathere (@rathere - 1);#IF (@rathere < 0) {@rathere = 0}}
#trigger {Hakhim gibbers insanely and mutters, "Foul vermins! A pox on your ancestors!"} {ratreset}
#trigger {Liirup squeals with delight} {ratreset}
#trigger {The ratman thanks you as you hand over} {ratreset}
#trigger {Jorj smiles out of the unparalysed corner of his face as he accepts} {ratreset}
#trigger {You have slain a baby rat, retrieving the corpse.} {#math ratgold (@ratgold + 7);#math rats (@rats + 1)}
#trigger {You have slain a black rat, retrieving the corpse.} {#math ratgold (@ratgold + 35);#math rats (@rats + 1)}
#trigger {You have slain a rat, retrieving the corpse.} {#math ratgold (@ratgold + 21);#math rats (@rats + 1)}
#trigger {You have slain a young rat, retrieving the corpse.} {#math ratgold (@ratgold + 14);#math rats (@rats + 1)}
#trigger {You have slain an old rat, retrieving the corpse.} {#math ratgold (@ratgold + 28);#math rats (@rats + 1)}

#stat {StatBar1} {rats:@rathere-@ratkilled total:@rats gold:@ratgold}

This class folder is set to be disabled so that its properties remain inactive until another trigger, outside the folder, is received, which enables the folder, as shown:

#trigger {You will now notice the movement of rats. Happy Hunting!} {#cla ratting 1}
#trigger {You will no longer take notice of the movement of rats.} {#cla ratting 0}

So the first trigger activates and enables the class folder and makes its properties active; the second trigger disables the folder and makes the properties inactive again. These two triggers continue to work fine.

The triggers and aliases inside the class folder worked fine in zMUD. However, in cMUD, they don't seem to work. The stat bar doesn't update properly as the values in the variables change, and the directional aliases (n, e, s, w, etc.) produce invalid command messages. This was NOT the case in zMUD which parsed the semicolon basically as an "enter" command so that "e;ode" for example would send the alias "e" and then send the alias "ode" on a separate line. My cMUD does not appear to have a different default setting for the semicolon because if I was to type in two commands manually, on one line and separated by a semicolon, both commands go through properly.

So I'm guessing that the slightly different script engine in cMUD is causing the errors I'm getting in this script, whereas it worked fine under zMUD. Can anyone point out what I need to fix/update? Scripting and script programming is my downfall in computer usage and always will be. Good as I am with computers, and as much as I understand the basic concepts behind programming, I can't write program script well.


Holly
_________________
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Oct 08, 2010 3:08 pm   
 
Code:

{A|An}%1rat wanders into view, nosing about for food.


How does this line appear in the game?

An old rat wanders into view, nosing about for food.

?

If so, replace all of the %1s in your patterns with:
%w and put spaces between the {A|An} %w rat
so that it appears as I have just typed it.

Your ratkilled variable won't be properly set to 0 in many instances because you're using the following syntax:
@var = value

This is actually incorrect, though it might feel as though it should be correct (I've made the same mistake many a time). We attach the @ only in reference to the variable to access the value, such as in #send @var. Generally, if we're changing the value and we're not inside a function, we leave the @ symbol off. So the proper syntax would be:
var = value

You can also more efficiently write all of your #math rathere (@rathere + 1) as:
#ADD rathere 1

If all you're doing is addition, the #ADD command will cover all of your needs better than #math as you don't need to reference the variable a second time or type the + sign, #ADD simply takes its two parameters and adds them together, putting them in the value of its first parameter.

We'll also probably want to put a lot of your stuff into #say and #send commands as opposed to leaving them freely sitting in the editor. This causes the editor to spend extra time parsing them, to make sure that they aren't aliases, etc... so, for instance:
Code:

#alias {"e"} {east;@ratkilled = 0}


becomes

Code:

#alias {"e"} {#send "east";ratkilled = 0}


After you make those changes, we can see what other errors you're still having.

Also, many of us prefer to see the XML that is outputted as CMUD is intended to import the XML of scripts, the old zMUD command-line method is supported but less desirable. If you wish to highlight a portion of the script for us to look at, you can get it's normal script version from the editor box and paste that as well. If you place your scripts between [*code*] [/*code*] boxes (without the asterisks *) then it will retain much of its formatting and appear separates from the rest of the text for easier viewing.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
HollyC
Novice


Joined: 10 Apr 2003
Posts: 45
Location: USA

PostPosted: Fri Oct 08, 2010 4:55 pm   
 
Okie, I've made the following adjustments to the script based on your suggestions and in .xml format it now looks like this:


<class name="ratting" initdisable="true" enabled="false">
<alias name="ratreset" autoappend="true">
<value>ratgold = 0;rats = 0;ratkilled = 0;rathere = 0</value>
</alias>
<alias name="e" autoappend="true">
<value>#send "east";ratkilled = 0</value>
</alias>
<alias name="s" autoappend="true">
<value>#send "south";ratkilled = 0</value>
</alias>
<alias name="n" autoappend="true">
<value>#send "north";ratkilled = 0</value>
</alias>
<alias name="w" autoappend="true">
<value>#send "west";ratkilled = 0</value>
</alias>
<alias name="nw" autoappend="true">
<value>#send "northwest";ratkilled = 0</value>
</alias>
<alias name="ne" autoappend="true">
<value>#send "northeast";ratkilled = 0</value>
</alias>
<alias name="sw" autoappend="true">
<value>#send "southwest";ratkilled = 0</value>
</alias>
<alias name="se" autoappend="true">
<value>#send "southeast";ratkilled = 0</value>
</alias>
<var name="ratgold" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="rats" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="rathere" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="ratkilled" usedef="true">
<value>0</value>
<default>0</default>
</var>
<trigger priority="7290">
<pattern>With a squeak, {a|an}%w rat darts into the room, looking about wildly.</pattern>
<value>#add rathere 1</value>
</trigger>
<trigger priority="7400">
<pattern>You have slain a baby rat, retrieving the corpse.</pattern>
<value>#math ratgold (@ratgold + 7);#add rats 1</value>
</trigger>
<stat name="StatBar1" priority="16800">
<value>Rats:@rathere - @ratkilled || Total:@rats || Gold:@ratgold</value>
</stat>
<trigger priority="7180">
<pattern>Hakhim gibbers insanely and mutters, "Foul vermin! A pox on your ancestors!"</pattern>
<value>ratreset</value>
</trigger>
<trigger priority="7190">
<pattern>{A|An} %w rat wanders into view, nosing about for food.</pattern>
<value>#add rathere 1</value>
</trigger>
<trigger priority="7200">
<pattern>{A|An} %w rat noses its way cautiously out of the shadows.</pattern>
<value>#add rathere 1</value>
</trigger>
<trigger priority="7210">
<pattern>Your eyes are drawn to {a|an} %w rat that darts suddenly into view.</pattern>
<value>#add rathere 1</value>
</trigger>
<trigger priority="7270">
<pattern>Liirup squeals with delight</pattern>
<value>ratreset</value>
</trigger>
<trigger priority="7280">
<pattern>You have slain {a|an} %w rat</pattern>
<value>#math rathere (@rathere - 1);#IF (rathere &lt; 0) {rathere = 0};#add ratkilled 1;#IF (ratkilled &gt; 4) {#echo Move on. Rats cleared.}</value>
</trigger>
<trigger priority="7300">
<pattern>rat has been slain by</pattern>
<value>#math rathere (@rathere - 1);#IF (rathere &lt; 0) {rathere = 0};#add ratkilled 1;#IF (ratkilled &gt; 4) {#echo Move on. Rats cleared.}</value>
</trigger>
<trigger priority="7310">
<pattern>With a flick of its small whiskers, {a|an} %w rat dashes out of view.</pattern>
<value>#math rathere (@rathere - 1);#IF (rathere &lt; 0) {rathere = 0}</value>
</trigger>
<trigger priority="7320">
<pattern>You detect nothing here by that name.</pattern>
<value>#IF (target = rat) {rathere = 0}</value>
</trigger>
<trigger priority="7330">
<pattern>You cannot see that being here.</pattern>
<value>#IF (target = rat) {rathere = 0}</value>
</trigger>
<trigger priority="7340">
<pattern>Nothing can be seen here by that name.</pattern>
<value>#IF (target = rat) {rathere = 0}</value>
</trigger>
<trigger priority="7350">
<pattern>Ah, I am truly sorry,</pattern>
<value>#IF (target = rat) {rathere = 0}</value>
</trigger>
<trigger priority="7360">
<pattern>{A|An} %w rat wanders back into its warren</pattern>
<value>#math rathere (@rathere - 1);#IF (rathere &lt; 0) {rathere = 0}</value>
</trigger>
<trigger priority="7370">
<pattern>The ratman thanks you as you hand over</pattern>
<value>ratreset</value>
</trigger>
<trigger priority="7380">
<pattern>{A|An} %w rat darts into the shadows and disappears.</pattern>
<value>#math rathere (@rathere - 1);#IF (rathere &lt; 0) {rathere = 0}</value>
</trigger>
<trigger priority="7390">
<pattern>Jorj smiles out of the unparalysed corner of his face as he accepts</pattern>
<value>ratreset</value>
</trigger>
<trigger priority="7410">
<pattern>You have slain a black rat, retrieving the corpse.</pattern>
<value>#math ratgold (@ratgold + 35);#add rats 1</value>
</trigger>
<trigger priority="7420">
<pattern>You have slain a rat, retrieving the corpse.</pattern>
<value>#math ratgold (@ratgold + 21);#add rats 1</value>
</trigger>
<trigger priority="7430">
<pattern>You have slain a young rat, retrieving the corpse.</pattern>
<value>#math ratgold (@ratgold + 14);#add rats 1</value>
</trigger>
<trigger priority="7440">
<pattern>You have slain an old rat, retrieving the corpse.</pattern>
<value>#math ratgold (@ratgold + 28);#add rats 1</value>
</trigger>
</class>



And the functionality is as follows:

--#send worked like a charm. Thanks.
--Taking out ALL of the @ symbols for the variables didn't work, I figured out where to leave them in.
--The Hakhim trigger didn't fire, but I noticed they finally corrected the typo of "vermins" into the correct spelling "vermin" so I updated the trigger pattern accordingly.
--The ratgold and rats variables came out correct.

--The rathere and ratkilled variables didn't show correctly in the stat bar. I think the reason is as follows:

I am NOT only adding to the rathere variable; therefore I DO have to use the MATH command. Any time I kill a rat, or whenever a rat runs back into its den, the value of the rathere variable goes DOWN by 1. To use the ADD command whenever the variable increases and then the MATH command when it goes down, seems to be the cause of the inconsistency. I will have to change #add rathere 1 back to #math rathere (@rathere+1).

The ratkilled variable should correct itself when the rathere variable is fixed.

I will test this out later in the day and report back with updated results.


Holly
_________________
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Oct 08, 2010 6:21 pm   
 
Make sure to wrap the XML and any other script posted here in [*code*][/*code*] tags (minus the asterisks) it will give you something like:

Code:

<class name="ratting" initdisable="true" enabled="false" id="163">
  <alias name="ratreset" autoappend="true" id="164">
    <value>ratgold = 0;rats = 0;ratkilled = 0;rathere = 0</value>
  </alias>
  <alias name="e" autoappend="true" id="165">
    <value>#send "east";ratkilled = 0</value>
  </alias>
  <alias name="s" autoappend="true" id="166">
    <value>#send "south";ratkilled = 0</value>
  </alias>
  <alias name="n" autoappend="true" id="167">
    <value>#send "north";ratkilled = 0</value>
  </alias>
  <alias name="w" autoappend="true" id="168">
    <value>#send "west";ratkilled = 0</value>
  </alias>
  <alias name="nw" autoappend="true" id="169">
    <value>#send "northwest";ratkilled = 0</value>
  </alias>
  <alias name="ne" autoappend="true" id="170">
    <value>#send "northeast";ratkilled = 0</value>
  </alias>
  <alias name="sw" autoappend="true" id="171">
    <value>#send "southwest";ratkilled = 0</value>
  </alias>
  <alias name="se" autoappend="true" id="172">
    <value>#send "southeast";ratkilled = 0</value>
  </alias>
  <var name="ratgold" usedef="true" id="173">
    <value>0</value>
    <default>0</default>
  </var>
  <var name="rats" usedef="true" id="174">
    <value>0</value>
    <default>0</default>
  </var>
  <var name="rathere" usedef="true" id="175">
    <value>0</value>
    <default>0</default>
  </var>
  <var name="ratkilled" usedef="true" id="176">
    <value>0</value>
    <default>0</default>
  </var>
  <trigger priority="7290" id="177">
    <pattern>With a squeak, {a|an}%w rat darts into the room, looking about wildly.</pattern>
    <value>#add rathere 1</value>
  </trigger>
  <trigger priority="7400" id="178">
    <pattern>You have slain a baby rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 7);#add rats 1</value>
  </trigger>
  <stat name="StatBar1" priority="16800" id="179">
    <value>Rats:@rathere - @ratkilled || Total:@rats || Gold:@ratgold</value>
  </stat>
  <trigger priority="7180" id="180">
    <pattern>Hakhim gibbers insanely and mutters, "Foul vermin! A pox on your ancestors!"</pattern>
    <value>ratreset</value>
  </trigger>
  <trigger priority="7190" id="181">
    <pattern>{A|An} %w rat wanders into view, nosing about for food.</pattern>
    <value>#add rathere 1</value>
  </trigger>
  <trigger priority="7200" id="182">
    <pattern>{A|An} %w rat noses its way cautiously out of the shadows.</pattern>
    <value>#add rathere 1</value>
  </trigger>
  <trigger priority="7210" id="183">
    <pattern>Your eyes are drawn to {a|an} %w rat that darts suddenly into view.</pattern>
    <value>#add rathere 1</value>
  </trigger>
  <trigger priority="7270" id="184">
    <pattern>Liirup squeals with delight</pattern>
    <value>ratreset</value>
  </trigger>
  <trigger priority="7280" id="185">
    <pattern>You have slain {a|an} %w rat</pattern>
    <value>#math rathere (@rathere - 1);#IF (rathere < 0) {rathere = 0};#add ratkilled 1;#IF (ratkilled > 4) {#echo Move on. Rats cleared.}</value>
  </trigger>
  <trigger priority="7300" id="186">
    <pattern>rat has been slain by</pattern>
    <value>#math rathere (@rathere - 1);#IF (rathere < 0) {rathere = 0};#add ratkilled 1;#IF (ratkilled > 4) {#echo Move on. Rats cleared.}</value>
  </trigger>
  <trigger priority="7310" id="187">
    <pattern>With a flick of its small whiskers, {a|an} %w rat dashes out of view.</pattern>
    <value>#math rathere (@rathere - 1);#IF (rathere < 0) {rathere = 0}</value>
  </trigger>
  <trigger priority="7320" id="188">
    <pattern>You detect nothing here by that name.</pattern>
    <value>#IF (target = rat) {rathere = 0}</value>
  </trigger>
  <trigger priority="7330" id="189">
    <pattern>You cannot see that being here.</pattern>
    <value>#IF (target = rat) {rathere = 0}</value>
  </trigger>
  <trigger priority="7340" id="190">
    <pattern>Nothing can be seen here by that name.</pattern>
    <value>#IF (target = rat) {rathere = 0}</value>
  </trigger>
  <trigger priority="7350" id="191">
    <pattern>Ah, I am truly sorry,</pattern>
    <value>#IF (target = rat) {rathere = 0}</value>
  </trigger>
  <trigger priority="7360" id="192">
    <pattern>{A|An} %w rat wanders back into its warren</pattern>
    <value>#math rathere (@rathere - 1);#IF (rathere < 0) {rathere = 0}</value>
  </trigger>
  <trigger priority="7370" id="193">
    <pattern>The ratman thanks you as you hand over</pattern>
    <value>ratreset</value>
  </trigger>
  <trigger priority="7380" id="194">
    <pattern>{A|An} %w rat darts into the shadows and disappears.</pattern>
    <value>#math rathere (@rathere - 1);#IF (rathere < 0) {rathere = 0}</value>
  </trigger>
  <trigger priority="7390" id="195">
    <pattern>Jorj smiles out of the unparalysed corner of his face as he accepts</pattern>
    <value>ratreset</value>
  </trigger>
  <trigger priority="7410" id="196">
    <pattern>You have slain a black rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 35);#add rats 1</value>
  </trigger>
  <trigger priority="7420" id="197">
    <pattern>You have slain a rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 21);#add rats 1</value>
  </trigger>
  <trigger priority="7430" id="198">
    <pattern>You have slain a young rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 14);#add rats 1</value>
  </trigger>
  <trigger priority="7440" id="199">
    <pattern>You have slain an old rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 28);#add rats 1</value>
  </trigger>
</class>


Which is a bit easier to read.

You only want to remove the @ symbol if you're doing something like
ratkill = X

If it's in an IF statement or a Function, then you will, in most circumstances, still need to refer to it via @ as in @ratkill.

For subtracting, just use:
ratkill = @ratkill - 1

or
ratkill = (@ratkill - 1)

It's less typing and does the same thing. Only use:
#ADD ratkill 1

Wherever you would have otherwise used:
#MATH ratkill (@ratkill + 1)
Or whatever the number is. If it's addition, #ADD will work better.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Oct 08, 2010 6:50 pm   
 
You can "add" negative values as well, Holly, so where you have:

#MATH whatever (@var - 1)

You can do:

#ADD @var -1

Charneus
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Oct 08, 2010 6:51 pm   
 
Also check the Changes For Zmud Users documents: http://forums.zuggsoft.com/modules/mx_kb/kb.php?page=3&mode=doc&k=2622. All of these things are mentioned there, along with many more.
Reply with quote
HollyC
Novice


Joined: 10 Apr 2003
Posts: 45
Location: USA

PostPosted: Fri Oct 08, 2010 11:40 pm   
 
Call me impatient, I did some more fiddling and figured out where I'd taken out required @ symbols :D

Putting the #MATH command back in made the whole script work properly except for one thing. I'll keep the adding of negative values in mind for my next tweaks.

The one thing that still produces inconsistencies in the rathere variable is the %w in the various patterns such as

Code:

{A|An} %w rat wanders into view, nosing about for food.


The %w is apparently 'word' or 'wordstring' and assumes there is a word or string of letters between {A|An} and rat, and this works fine for:

"A baby rat"
"A young rat"
"An old rat"
"A black rat"

But when the string is simply,

"A rat"

there is no word or wordstring in between, and the pattern is not recognized. The trigger expects that wordstring and isn't finding one so it considers the pattern a non-match.

I'm going to have to try the original %1 again, unless there is another alternative that is 'cleaner.'

Will give another update later.

(EDIT: Rahab, I'll have to bookmark that link later. I understand the basic concepts behind programming but writing actual code is still my downfall, so looking through a help directory of script code is unfortunately, a pretty daunting task for me *laugh* )


Holly
_________________
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Oct 09, 2010 12:12 am   
 
Use a range pattern:

{A|An}[%w%s] rat
_________________
EDIT: I didn't like my old signature
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Oct 09, 2010 2:23 am   
 
Yup, that will work to, %s will match any number of spaces OR you can match any number of alpha characters (aka a word), range classes are very useful additions in pattern matching.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
HollyC
Novice


Joined: 10 Apr 2003
Posts: 45
Location: USA

PostPosted: Sat Oct 09, 2010 8:19 am   
 
When I changd it to

Code:

{A|An}%1 rat


The rathere variable went up properly, it just didn't go down when I killed rats, nor did the ratkilled variable go up accordingly.

When I used the ranged pattern you suggested Matt, both the rathere and ratkilled variables stopped changing completely. I tried all of the following tiny tweaks:

Code:

{A|An}[%w%s]rat
{A|An} [%w%s] rat
{A|An}[%s]rat
{A|An} [%s] rat
{A|An}%w%srat
{A|An} %w%s rat
{A|An}%srat
{A|An} %s rat


All patterns for all types of rats entering the room, none of them made either variable go up or down in my stat bar.

I have the following in the class folder, copied and pasted directly from the package editor:

Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="e" autoappend="true" copy="yes">
    <value>#send "east";rathere = 0;ratkilled = 0</value>
  </alias>
  <alias name="n" autoappend="true" copy="yes">
    <value>#send "north";rathere = 0;ratkilled = 0</value>
  </alias>
  <alias name="ne" autoappend="true" copy="yes">
    <value>#send "northeast";rathere = 0;ratkilled = 0</value>
  </alias>
  <alias name="nw" autoappend="true" copy="yes">
    <value>#send "northwest";rathere = 0;ratkilled = 0</value>
  </alias>
  <alias name="ratreset" autoappend="true" copy="yes">
    <value>ratgold = 0;rats = 0;ratkilled = 0;rathere = 0</value>
  </alias>
  <alias name="s" autoappend="true" copy="yes">
    <value>#send "south";rathere = 0;ratkilled = 0</value>
  </alias>
  <alias name="se" autoappend="true" copy="yes">
    <value>#send "southeast";rathere = 0;ratkilled = 0</value>
  </alias>
  <alias name="sw" autoappend="true" copy="yes">
    <value>#send "southwest";rathere = 0;ratkilled = 0</value>
  </alias>
  <alias name="w" autoappend="true" copy="yes">
    <value>#send "west";rathere = 0;ratkilled = 0</value>
  </alias>
  <var name="ratgold" usedef="true" copy="yes">
    <value>0</value>
    <default>0</default>
  </var>
  <var name="rathere" usedef="true" copy="yes">
    <value>0</value>
    <default>0</default>
  </var>
  <var name="ratkilled" usedef="true" copy="yes">
    <value>0</value>
    <default>0</default>
  </var>
  <var name="rats" usedef="true" copy="yes">
    <value>0</value>
    <default>0</default>
  </var>
  <trigger priority="7350" copy="yes">
    <pattern>Ah, I am truly sorry,</pattern>
    <value>#IF (@t = rat) {rathere = 0}</value>
  </trigger>
  <trigger priority="7180" copy="yes">
    <pattern>Hakhim gibbers insanely and mutters, "Foul vermin! A pox on your ancestors!"</pattern>
    <value>ratreset</value>
  </trigger>
  <trigger priority="7390" copy="yes">
    <pattern>Jorj smiles out of the unparalysed corner of his face as he accepts</pattern>
    <value>ratreset</value>
  </trigger>
  <trigger priority="7270" copy="yes">
    <pattern>Liirup squeals with delight</pattern>
    <value>ratreset</value>
  </trigger>
  <trigger priority="7340" copy="yes">
    <pattern>Nothing can be seen here by that name.</pattern>
    <value>#IF (@t = rat) {rathere = 0}</value>
  </trigger>
  <trigger priority="7300" copy="yes">
    <pattern>rat has been slain by</pattern>
    <value>#add rathere - 1;#IF (@rathere < 0) {rathere = 0};#add ratkilled - 1;#IF (@ratkilled > 4) {#echo Move on. Rats cleared.}</value>
  </trigger>
  <trigger priority="7370" copy="yes">
    <pattern>The ratman thanks you as you hand over</pattern>
    <value>ratreset</value>
  </trigger>
  <trigger priority="7310" copy="yes">
    <pattern>With a flick of its small whiskers, {a|an} [%w%s] rat dashes out of view.</pattern>
    <value>#add rathere - 1;#IF (@rathere < 0) {rathere = 0}</value>
  </trigger>
  <trigger priority="7290" copy="yes">
    <pattern>With a squeak, {a|an} [%w%s] rat darts into the room, looking about wildly.</pattern>
    <value>#add rathere 1</value>
  </trigger>
  <trigger priority="7330" copy="yes">
    <pattern>You cannot see that being here.</pattern>
    <value>#IF (@t = rat) {rathere = 0}</value>
  </trigger>
  <trigger priority="7320" copy="yes">
    <pattern>You detect nothing here by that name.</pattern>
    <value>#IF (@t = rat) {rathere = 0}</value>
  </trigger>
  <trigger priority="7400" copy="yes">
    <pattern>You have slain a baby rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 7);#add rats 1</value>
  </trigger>
  <trigger priority="7410" copy="yes">
    <pattern>You have slain a black rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 35);#add rats 1</value>
  </trigger>
  <trigger priority="7420" copy="yes">
    <pattern>You have slain a rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 21);#add rats 1</value>
  </trigger>
  <trigger priority="7430" copy="yes">
    <pattern>You have slain a young rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 14);#add rats 1</value>
  </trigger>
  <trigger priority="7440" copy="yes">
    <pattern>You have slain an old rat, retrieving the corpse.</pattern>
    <value>#math ratgold (@ratgold + 28);#add rats 1</value>
  </trigger>
  <trigger priority="7280" copy="yes">
    <pattern>You have slain {a|an} [%w%s] rat</pattern>
    <value>#add rathere - 1;#IF (@rathere < 0) {rathere = 0};#add ratkilled - 1#IF (@ratkilled > 4) {#echo Move on. Rats cleared.}</value>
  </trigger>
  <trigger priority="7210" copy="yes">
    <pattern>Your eyes are drawn to {a|an} [%w%s] rat that darts suddenly into view.</pattern>
    <value>#add rathere 1</value>
  </trigger>
  <trigger priority="7380" copy="yes">
    <pattern>{A|An} [%w%s] rat darts into the shadows and disappears.</pattern>
    <value>#add rathere - 1;#IF (@rathere < 0) {rathere = 0}</value>
  </trigger>
  <trigger priority="7200" copy="yes">
    <pattern>{A|An} [%w%s] rat noses its way cautiously out of the shadows.</pattern>
    <value>#add rathere 1</value>
  </trigger>
  <trigger priority="7360" copy="yes">
    <pattern>{A|An} [%w%s] rat wanders back into its warren</pattern>
    <value>#add rathere - 1;#IF (@rathere < 0) {rathere = 0}</value>
  </trigger>
  <trigger priority="7190" copy="yes">
    <pattern>{A|An} [%w%s] rat wanders into view, nosing about for food.</pattern>
    <value>#add rathere 1</value>
  </trigger>
  <stat name="StatBar1" priority="16800" copy="yes">
    <value>Rats:@rathere - @ratkilled || Total:@rats || Gold:@ratgold</value>
  </stat>
</cmud>


And the script works fine except for the rathere and ratkilled variables showing proper increases and decreases in my statbar.

Maybe I did a typo of some sort. Brackets and braces I have to lean very close to the screen and squint; this standard font size is a bit small for me. I'll try some more tweaks as I think of them. At the moment I'm considering just stopping keeping track of how many rats have entered and escaped from each room, and how many I've killed in each room (the purpose of the rathere and ratkilled variables).


Holly
_________________
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sun Oct 10, 2010 4:07 am   
 
I'll take a look at this tomorrow if no one has by then. Sorry about the slow response.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
HollyC
Novice


Joined: 10 Apr 2003
Posts: 45
Location: USA

PostPosted: Sun Oct 10, 2010 6:10 am   
 
Hehe no rush Chamenas. You've done more than I could ask of anyone here.

An update:

I tried putting the range finder in separate brackets, that is, [%w][%s]. It produced a curious effect. The trigger would fire and increase the rathere variable, ONLY for baby rats. And when said baby rats were allowed to escape unharmed, I got an error message that the trigger fired but didn't compile. Makes me think I'm on the right track but one tiny detail or another is still a monkey wrench in the cogs. I know how utterly unforgiving computer coding can be so this doesn't surprise me. :)


Holly
_________________
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Oct 10, 2010 3:58 pm   
 
One minor problem I see is that you're add commands usually look like this

Code:
#add rathere - 1;


Which will prevent the trigger from compiling (and therefore executing in CMUD. They should look like this.

Code:
#add rathere -1;


Note the space is gone.

I didn't see any test text, but I'm going assume that was the primary problem.
_________________
Asati di tempari!
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sun Oct 10, 2010 5:17 pm   
 
I'm getting errors importing the XML. It would likely help if you put all of it into a class and copied and pasted the XML from the class folder so I could import it that way. Classes make everything neater and more organized :)
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
HollyC
Novice


Joined: 10 Apr 2003
Posts: 45
Location: USA

PostPosted: Sun Oct 10, 2010 10:43 pm   
 
I took out the space in the -1 modifier. I am also going to try reversing the order of the %w and the %s strings in some of the commands.

The script therefore now looks like this (I did have it in a class before Chamenas, but didn't copy the folder itself, just all the settings inside it, that's why the class and /class tags didn't show :p )

Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="ratting" initdisable="false" enabled="true" copy="yes">
    <alias name="ratreset" autoappend="true" copy="yes">
      <value>ratgold = 0;rats = 0;ratkilled = 0;rathere = 0</value>
    </alias>
    <alias name="e" autoappend="true" copy="yes">
      <value>#send "east";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="s" autoappend="true" copy="yes">
      <value>#send "south";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="n" autoappend="true" copy="yes">
      <value>#send "north";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="w" autoappend="true" copy="yes">
      <value>#send "west";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="nw" autoappend="true" copy="yes">
      <value>#send "northwest";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="ne" autoappend="true" copy="yes">
      <value>#send "northeast";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="sw" autoappend="true" copy="yes">
      <value>#send "southwest";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="se" autoappend="true" copy="yes">
      <value>#send "southeast";rathere = 0;ratkilled = 0</value>
    </alias>
    <var name="ratgold" copy="yes">
      <default>0</default>
    </var>
    <var name="rats" copy="yes">
      <default>0</default>
    </var>
    <var name="rathere" copy="yes">
      <default>0</default>
    </var>
    <var name="ratkilled" copy="yes">
      <default>0</default>
    </var>
    <trigger priority="7290" copy="yes">
      <pattern>With a squeak, {a|an}[%s%w]rat darts into the room, looking about wildly.</pattern>
      <value>#add rathere 1</value>
    </trigger>
    <trigger priority="7400" copy="yes">
      <pattern>You have slain a baby rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 7);#add rats 1</value>
    </trigger>
    <stat name="StatBar1" priority="16800" copy="yes">
      <value>Rats:@rathere - @ratkilled || Total:@rats || Gold:@ratgold</value>
    </stat>
    <trigger priority="7180" copy="yes">
      <pattern>Hakhim gibbers insanely and mutters, "Foul vermin! A pox on your ancestors!"</pattern>
      <value>ratreset</value>
    </trigger>
    <trigger priority="7190" copy="yes">
      <pattern>{A|An}[%s%w]rat wanders into view, nosing about for food.</pattern>
      <value>#add rathere 1</value>
    </trigger>
    <trigger priority="7200" copy="yes">
      <pattern>{A|An}[%s%w]rat noses its way cautiously out of the shadows.</pattern>
      <value>#add rathere 1</value>
    </trigger>
    <trigger priority="7210" copy="yes">
      <pattern>Your eyes are drawn to {a|an}[%s%w]rat that darts suddenly into view.</pattern>
      <value>#add rathere 1</value>
    </trigger>
    <trigger priority="7270" copy="yes">
      <pattern>Liirup squeals with delight</pattern>
      <value>ratreset</value>
    </trigger>
    <trigger priority="7280" copy="yes">
      <pattern>You have slain {a|an}[%s%w]rat</pattern>
      <value>#add rathere - 1;#IF (@rathere < 0) {rathere = 0};#add ratkilled 1;#IF (@ratkilled > 4) {#echo Move on. Rats cleared.}</value>
    </trigger>
    <trigger priority="7300" copy="yes">
      <pattern>rat has been slain by</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0};#add ratkilled 1;#IF (@ratkilled > 4) {#echo Move on. Rats cleared.}</value>
    </trigger>
    <trigger priority="7310" copy="yes">
      <pattern>With a flick of its small whiskers, {a|an}[%w%s]rat dashes out of view.</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0}</value>
    </trigger>
    <trigger priority="7320" copy="yes">
      <pattern>You detect nothing here by that name.</pattern>
      <value>#IF (@t = rat) {rathere = 0}</value>
    </trigger>
    <trigger priority="7330" copy="yes">
      <pattern>You cannot see that being here.</pattern>
      <value>#IF (@t = rat) {rathere = 0}</value>
    </trigger>
    <trigger priority="7340" copy="yes">
      <pattern>Nothing can be seen here by that name.</pattern>
      <value>#IF (@t = rat) {rathere = 0}</value>
    </trigger>
    <trigger priority="7350" copy="yes">
      <pattern>Ah, I am truly sorry,</pattern>
      <value>#IF (@t = rat) {rathere = 0}</value>
    </trigger>
    <trigger priority="7360" copy="yes">
      <pattern>{A|An}[%w%s]rat wanders back into its warren</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0}</value>
    </trigger>
    <trigger priority="7370" copy="yes">
      <pattern>The ratman thanks you as you hand over</pattern>
      <value>ratreset</value>
    </trigger>
    <trigger priority="7380" copy="yes">
      <pattern>{A|An}[%w%s]rat darts into the shadows and disappears.</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0}</value>
    </trigger>
    <trigger priority="7390" copy="yes">
      <pattern>Jorj smiles out of the unparalysed corner of his face as he accepts</pattern>
      <value>ratreset</value>
    </trigger>
    <trigger priority="7410" copy="yes">
      <pattern>You have slain a black rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 35);#add rats 1</value>
    </trigger>
    <trigger priority="7420" copy="yes">
      <pattern>You have slain a rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 21);#add rats 1</value>
    </trigger>
    <trigger priority="7430" copy="yes">
      <pattern>You have slain a young rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 14);#add rats 1</value>
    </trigger>
    <trigger priority="7440" copy="yes">
      <pattern>You have slain an old rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 28);#add rats 1</value>
    </trigger>
  </class>
</cmud>


Note that I changed the class tag to be enabled instead of initially disabled. I keep it disabled until I execute an in-game command to enable it. I also have another in-game command to disable it again. These two commands have not been an issue this whole thread. *laugh*

Will give updates as I get them.

Holly

UPDATE 1: the pattern: Your eyes are drawn to .... still had the [%w][%s] string. I changed it to [%s%w] and now all three strings where any type of rat ENTERS the room fires and woriks. Also, all three patterns where a rat LEAVES the room works. THe one string still not working is where I kill a rat. Will reverse the %w and %s and update again.

UPDATE 2: The trigger for my killing a rat now reduces the rathere variable but doesn't increase the ratkilled variable. Will tweak again and update.
_________________
Reply with quote
HollyC
Novice


Joined: 10 Apr 2003
Posts: 45
Location: USA

PostPosted: Sun Oct 10, 2010 11:15 pm   
 
Bingo. Somehow the necessary dividing semicolon was the culprit with the ratkilled variable; it had gotten taken out just before the #IF statement.

The script now appears to work completely on all counts. For those who are interested, here is a copy:

Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="ratting" initdisable="true" copy="yes">
    <alias name="ratreset" autoappend="true" copy="yes">
      <value>ratgold = 0;rats = 0;ratkilled = 0;rathere = 0</value>
    </alias>
    <alias name="e" autoappend="true" copy="yes">
      <value>#send "east";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="s" autoappend="true" copy="yes">
      <value>#send "south";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="n" autoappend="true" copy="yes">
      <value>#send "north";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="w" autoappend="true" copy="yes">
      <value>#send "west";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="nw" autoappend="true" copy="yes">
      <value>#send "northwest";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="ne" autoappend="true" copy="yes">
      <value>#send "northeast";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="sw" autoappend="true" copy="yes">
      <value>#send "southwest";rathere = 0;ratkilled = 0</value>
    </alias>
    <alias name="se" autoappend="true" copy="yes">
      <value>#send "southeast";rathere = 0;ratkilled = 0</value>
    </alias>
    <var name="ratgold" copy="yes">
      <default>0</default>
    </var>
    <var name="rats" copy="yes">
      <default>0</default>
    </var>
    <var name="rathere" copy="yes">
      <default>0</default>
    </var>
    <var name="ratkilled" copy="yes">
      <default>0</default>
    </var>
    <trigger priority="7290" copy="yes">
      <pattern>With a squeak, {a|an}[%s%w]rat darts into the room, looking about wildly.</pattern>
      <value>#add rathere 1</value>
    </trigger>
    <trigger priority="7400" copy="yes">
      <pattern>You have slain a baby rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 7);#add rats 1</value>
    </trigger>
    <stat name="StatBar1" priority="16800" copy="yes">
      <value>Rats:@rathere - @ratkilled || Total:@rats || Gold:@ratgold</value>
    </stat>
    <trigger priority="7180" copy="yes">
      <pattern>Hakhim gibbers insanely and mutters, "Foul vermin! A pox on your ancestors!"</pattern>
      <value>ratreset</value>
    </trigger>
    <trigger priority="7190" copy="yes">
      <pattern>{A|An}[%s%w]rat wanders into view, nosing about for food.</pattern>
      <value>#add rathere 1</value>
    </trigger>
    <trigger priority="7200" copy="yes">
      <pattern>{A|An}[%s%w]rat noses its way cautiously out of the shadows.</pattern>
      <value>#add rathere 1</value>
    </trigger>
    <trigger priority="7210" copy="yes">
      <pattern>Your eyes are drawn to {a|an}[%s%w]rat that darts suddenly into view.</pattern>
      <value>#add rathere 1</value>
    </trigger>
    <trigger priority="7270" copy="yes">
      <pattern>Liirup squeals with delight</pattern>
      <value>ratreset</value>
    </trigger>
    <trigger priority="7280" copy="yes">
      <pattern>You have slain {a|an}[%s%w]rat</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0};#add ratkilled 1;#IF (@ratkilled > 4) {#echo Move on. Rats cleared.}</value>
    </trigger>
    <trigger priority="7300" copy="yes">
      <pattern>rat has been slain by</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0};#add ratkilled 1;#IF (@ratkilled > 4) {#echo Move on. Rats cleared.}</value>
    </trigger>
    <trigger priority="7310" copy="yes">
      <pattern>With a flick of its small whiskers, {a|an}[%w%s]rat dashes out of view.</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0}</value>
    </trigger>
    <trigger priority="7320" copy="yes">
      <pattern>You detect nothing here by that name.</pattern>
      <value>#IF (@t = rat) {rathere = 0}</value>
    </trigger>
    <trigger priority="7330" copy="yes">
      <pattern>You cannot see that being here.</pattern>
      <value>#IF (@t = rat) {rathere = 0}</value>
    </trigger>
    <trigger priority="7340" copy="yes">
      <pattern>Nothing can be seen here by that name.</pattern>
      <value>#IF (@t = rat) {rathere = 0}</value>
    </trigger>
    <trigger priority="7350" copy="yes">
      <pattern>Ah, I am truly sorry,</pattern>
      <value>#IF (@t = rat) {rathere = 0}</value>
    </trigger>
    <trigger priority="7360" copy="yes">
      <pattern>{A|An}[%w%s]rat wanders back into its warren</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0}</value>
    </trigger>
    <trigger priority="7370" copy="yes">
      <pattern>The ratman thanks you as you hand over</pattern>
      <value>ratreset</value>
    </trigger>
    <trigger priority="7380" copy="yes">
      <pattern>{A|An}[%w%s]rat darts into the shadows and disappears.</pattern>
      <value>#add rathere -1;#IF (@rathere < 0) {rathere = 0}</value>
    </trigger>
    <trigger priority="7390" copy="yes">
      <pattern>Jorj smiles out of the unparalysed corner of his face as he accepts</pattern>
      <value>ratreset</value>
    </trigger>
    <trigger priority="7410" copy="yes">
      <pattern>You have slain a black rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 35);#add rats 1</value>
    </trigger>
    <trigger priority="7420" copy="yes">
      <pattern>You have slain a rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 21);#add rats 1</value>
    </trigger>
    <trigger priority="7430" copy="yes">
      <pattern>You have slain a young rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 14);#add rats 1</value>
    </trigger>
    <trigger priority="7440" copy="yes">
      <pattern>You have slain an old rat, retrieving the corpse.</pattern>
      <value>#math ratgold (@ratgold + 28);#add rats 1</value>
    </trigger>
  </class>
</cmud>


My heartfelt thanks to everyone who butted their heads against this wall alongside me. I'll send you all some extra-strength Excedrin soon as I figure out how to send the pills via electronic internet signals, LOL.


Holly
_________________
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Oct 11, 2010 12:58 am   
 
Sorry I couldn't help more. It's been a long day, but at least you got it all working, and, hopefully, learned some new stuff in the process. :)
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net