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
hodgkinr
Wanderer


Joined: 05 Jan 2002
Posts: 55
Location: United Kingdom

PostPosted: Fri Sep 30, 2011 8:47 am   

Debugging scripts
 
Hi

A few years ago someone wrote me some script to sing songs as a bard for classes on our MUD when i played using ZMUD. I'm just getting back to playing again and I have downloaded CMUD to use on Win 7. The trouble is I have tried to use my old scripts and they don't seem to work anymore. Alas the friend is not around anymore so it looks like I will have to try and sort it.

Is there a way of checking what is stored in variables etc some sort of Debug window?

I need to start with this line I think I use to type "singup rogue playername" and it would sing a package of name to that person.

#ALIAS singup {#UNVAR songoffset;#UNVAR songpackage;#UNVAR songto;#T+ Song/SingUp;#VAR songoffset 0;#IF (%1 and %2) {#VAR songpackage %1;#IF (%2 =~ "%w") {#VAR songto "to %2"}} {#IF (%1) {#VAR songpackage %1} {#VAR songpackage default}};#SAY Singing @songpackage @songto;nextsong}
#ALIAS SetSongstatus {#IF (@DoAction) {#VAR SongStatus %ansi( hi, bold, red)SING} {#VAR SongStatus %ansi( bold, green)Singing}}
#ALIAS nextsong {#VAR currsong %arrget( @songpackage , @songoffset);#SAY;#IF (@currsong != "") {sing @currsong @songto;#MATH songoffset @songoffset+1} {#T- Song/SingUp;#UNVAR songoffset;#UNVAR songpackage;#UNVAR songto}}
any tips on how to chech whats happening would be great.

Thanks Bob
_________________
Bob Hodgkins
Processor: Intel(R) Core(TM) i7 CPU
920 @ 2.67GHz
Memory: 6.00 Gb
Win 7 64 bit operating
Video: ATI 5870 Sapphire
Windows XP
ZMud: Version 7.03
ZMapper: Version 1.22 Beta
Reply with quote
hodgkinr
Wanderer


Joined: 05 Jan 2002
Posts: 55
Location: United Kingdom

PostPosted: Fri Sep 30, 2011 9:13 am   
 
Correction : It would sing a package of songs to that person.
_________________
Bob Hodgkins
Processor: Intel(R) Core(TM) i7 CPU
920 @ 2.67GHz
Memory: 6.00 Gb
Win 7 64 bit operating
Video: ATI 5870 Sapphire
Windows XP
ZMud: Version 7.03
ZMapper: Version 1.22 Beta
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Sep 30, 2011 1:55 pm   
 
You say "they don't seem to work anymore"; it would help if you could be more specific about what does happen.

There is a debugger window, and it can show what is going on, but we probably don't need it here.

There are a couple of obvious issues, and some poor coding practice in that code. The %arrget is a particular problem. Also, there is no reason to be deleting variables and recreating variables all the time--much more efficient to simply set the variables to %null. However, the first question I would ask is: do you actually have the class Song/SingUp, and does it have your songlists?

If you do have that class, you should give us more information about what is actually going on. Include all the code and variables involved.
Reply with quote
hodgkinr
Wanderer


Joined: 05 Jan 2002
Posts: 55
Location: United Kingdom

PostPosted: Fri Sep 30, 2011 4:14 pm   
 
Ok thanks for coming back I did think it may be just a quick syntax issue with the main lines.

These are the program lines I have:

#CLASS {Song|SingUp}
#CLASS {songstatusbar}
#CLASS {Song} {enable}

#VAR fighter {<Array>|of the mule|of agility|of the cobra|of the mule|of the nymph|of the owl|of the rhino|of the rock|of the spider}
#VAR mage {<Array>|of knowledge|of thought|of the hawk|of the rock|of the nymph|of the owl|of the eagle}
#VAR rogue {<Array>|of the mule|of the rock|of agility|of the cobra|of the rhino|of the owl|of the nymph}
#VAR default {<Array>|of agility|of the mule|of the rock|of knowledge|of the cobra|of the rhino}
#VAR sceleton {<Array>|of agility}
#VAR monk {<Array>|of knowledge|of thought|of the mule|of the rock|of agility|of the nymph|of the cobra|of the rhino|of the hawk|of the owl}

#VAR currsong {}
#VAR DoAction {1}
#VAR SongStatus {SING}
#VAR currsong {}
#VAR song {spider}
#VAR SingSong {singsp}
#VAR SongStatus {SING} %ansi( yellow)|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;@DoAction = 1;
#VAR SingSong singspider;SetSongStatus}
#VAR SingSong {singspider} {singspider}

#TRIGGER {^You feel different.} {#SAY %ansi( yellow)-=-=-| %ansi( bold, purple)SPIDER %ansi( yellow)|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-;@DoAction = 1;#VAR SingSong singsp;SetSongStatus}
#TRIGGER {^You sing: We give thee mine.} {nextsong}
#TRIGGER {^You sing: Like a wall.} {nextsong}
#TRIGGER {^You sing: The truth of beauty.} {nextsong}
#TRIGGER {^You sing: Quickness of will.} {nextsong}
#TRIGGER {^You sing: The future is mute.} {nextsong}
#TRIGGER {^You sing: And the parts of the sum.} {nextsong}
#TRIGGER {^You sing: A better attack for your enemy to see.} {nextsong}
#TRIGGER {^You sing: From every harsh blow.} {nextsong}
#TRIGGER {^You sing: And increase he for which this song.} {nextsong}
#TRIGGER {^You sing: Protects him from the falling sky.} {nextsong}
#TRIGGER {^You sing: And over the sea.} {nextsong}
#TRIGGER {^You sing a wonderful song of your own making.} {#SAY You messed up your array there, mate!;#T- Song/SingUp;#UNVAR songoffset;#UNVAR songpackage;#UNVAR songto}
#TRIGGER {Variable songpackage removed.} {#var song spider}
#TRIGGER {You feel different.} {sing song of the spider} "" {disable}


#ALIAS singup {#UNVAR songoffset;#UNVAR songpackage;#UNVAR songto;#T+ Song/SingUp;#VAR songoffset 0;#IF (%1 and %2) {#VAR songpackage %1;#IF (%2 =~ "%w") {#VAR songto "to %2"}} {#IF (%1) {#VAR songpackage %1} {#VAR songpackage default}};#SAY Singing @songpackage @songto;nextsong}
#ALIAS SetSongstatus {#IF (@DoAction) {#VAR SongStatus %ansi( hi, bold, red)SING} {#VAR SongStatus %ansi( bold, green)Singing}}
#ALIAS nextsong {#VAR currsong %arrget( @songpackage , @songoffset);#SAY;#IF (@currsong != "") {sing @currsong @songto;#MATH songoffset @songoffset+1} {#T- Song/SingUp;#UNVAR songoffset;#UNVAR songpackage;#UNVAR songto}}

The Class variables contain what songs I would normally be asked to sing to them.

I would then use the syntax e.g. "singup rogue playername"

The triggers are the last line of the song which then steps it on to the next song in the list for the class.

I'm not to sure whats happening atm but I get

Singing rogue to %2

Variable songoffset removed.
Variable songpackage removed.
Variable songto removed.

then it stops.

I think its not seeing the player name in %2

I'm not sure if this helps. I do appreciate any time you give to help.

Thanks

Bob
_________________
Bob Hodgkins
Processor: Intel(R) Core(TM) i7 CPU
920 @ 2.67GHz
Memory: 6.00 Gb
Win 7 64 bit operating
Video: ATI 5870 Sapphire
Windows XP
ZMud: Version 7.03
ZMapper: Version 1.22 Beta
Reply with quote
hodgkinr
Wanderer


Joined: 05 Jan 2002
Posts: 55
Location: United Kingdom

PostPosted: Sat Oct 01, 2011 9:54 pm   
 
Well I think I may have narrowed it down to this bit of code #IF (%2 =~ "%w") from:

#ALIAS singup {#UNVAR songoffset;#UNVAR songpackage;#UNVAR songto;#T+ Song/SingUp;#VAR songoffset 0;#IF (%1 and %2) {#VAR songpackage %1;#IF (%2 =~ "%w") {#VAR songto "to %2"}} {#IF (%1) {#VAR songpackage %1} {#VAR songpackage default}};#SAY Singing @songpackage @songto;nextsong}

I'm not sure what it did in zmud but I don't think its working for me in cmud.

Thanks

Bob
_________________
Bob Hodgkins
Processor: Intel(R) Core(TM) i7 CPU
920 @ 2.67GHz
Memory: 6.00 Gb
Win 7 64 bit operating
Video: ATI 5870 Sapphire
Windows XP
ZMud: Version 7.03
ZMapper: Version 1.22 Beta
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sat Oct 01, 2011 10:02 pm   
 
Well, you will need to take %2 out of quotes for it to be expanded in CMUD. That's why it's saying singing rogue to %2, not playername. However, even if it gets the name wrong, it should still be trying to sing. I think the main problem is that you're using arrays, as Rahab said above. Try converting them to string list variables.
Reply with quote
hodgkinr
Wanderer


Joined: 05 Jan 2002
Posts: 55
Location: United Kingdom

PostPosted: Sat Oct 01, 2011 10:13 pm   
 
ok thanks for that.... I did notice the variables had not imported correctly, which I have now corrected. I can appreciate the whole thing is a bit of a mess, its mad my brain ache trying to sort it as I'm no programmer :(

Bob
_________________
Bob Hodgkins
Processor: Intel(R) Core(TM) i7 CPU
920 @ 2.67GHz
Memory: 6.00 Gb
Win 7 64 bit operating
Video: ATI 5870 Sapphire
Windows XP
ZMud: Version 7.03
ZMapper: Version 1.22 Beta
Reply with quote
hodgkinr
Wanderer


Joined: 05 Jan 2002
Posts: 55
Location: United Kingdom

PostPosted: Sun Oct 02, 2011 10:29 am   
 
Hi

Ok I thought I better start by going back to basics as I'm getting a bit confused with a lot stuff in the existing program that was written for me.
And i have taken you advice to switch to string lists.


<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<var name="rogue" type="StringList" copy="yes">
<value>of the mule|of the rock|of agility|of the cobra|of the rhino|of the owl|of the nymph</value>
<json>["of the mule","of the rock","of agility","of the cobra","of the rhino","of the owl","of the nymph"]</json>
</var>
</cmud>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<var name="mage" type="StringList" copy="yes">
<value>of the hawk|of thought|of knowledge|of the eagle|of the nymph|of the owl|of the rock</value>
<json>["of the hawk","of thought","of knowledge","of the eagle","of the nymph","of the owl","of the rock"]</json>
</var>
</cmud>

<alias name="test_singup" id="298">
<value>#IF (%1 and %2) {#VAR songpackage %1; #VAR songto %2};#SAY Singing @songpackage @songto;test_nextsong
</value>
</alias>

If i send "test_singup rogue playername" to the MUD using:

<alias name="test_nextsong" id="244">
<value>sing %item(rogue,1) to @songto</value>
</alias>

everything works fine and i get singing song of the mule to playername.

But if i change to my class variable i.e. @songpackage:

<alias name="test_nextsong" id="244">
<value>sing %item(@songpackage,1) to @songto</value>
</alias>

I get sing rogue to playername. Is it possible to use a variable when using the %item function?

thanks

Bob
_________________
Bob Hodgkins
Processor: Intel(R) Core(TM) i7 CPU
920 @ 2.67GHz
Memory: 6.00 Gb
Win 7 64 bit operating
Video: ATI 5870 Sapphire
Windows XP
ZMud: Version 7.03
ZMapper: Version 1.22 Beta
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Sun Oct 02, 2011 12:43 pm   
 
You're telling it to use the first item of the list @songpackage. To use the value stored in the variable as the variable name, use the syntax @{@var}. Thus:
Code:
using %item(@{@songpackage},1) to @songto
_________________
.geniusclown
Reply with quote
hodgkinr
Wanderer


Joined: 05 Jan 2002
Posts: 55
Location: United Kingdom

PostPosted: Sun Oct 02, 2011 1:20 pm   
 
ahah ...super thanks ....works great

Bob
_________________
Bob Hodgkins
Processor: Intel(R) Core(TM) i7 CPU
920 @ 2.67GHz
Memory: 6.00 Gb
Win 7 64 bit operating
Video: ATI 5870 Sapphire
Windows XP
ZMud: Version 7.03
ZMapper: Version 1.22 Beta
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