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
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Thu Jun 14, 2012 4:41 pm   

Help with Zmud to Cmud conversion
 
I made a compass that worked perfectly fine in Zmud, but it does nothing in Cmud.
#REGEX {Visible Exits: (.*)} {
compassdirections = ""
#fo {N|Ne|E|Se|S|Sw|W|Nw|U|D} {#if %regex( "%concat(%1,%2)", "\b%i\b") {#additem compassdirections %i}}
#IF %ismember( D, @compassdirections) {#VAR compassdown 1} {#VAR compassdown 0}
#IF %ismember( E, @compassdirections) {#VAR compasseast 1} {#VAR compasseast 0}
This is just part of it but I think its the #if %regex part that is not compatible.
Thanks for any help.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Jun 14, 2012 5:47 pm   
 
I don't think this could possibly have "worked perfectly fine in Zmud". This bit of code:
Code:
%regex( "%concat(%1,%2)", "\b%i\b")
won't work because %concat(%1,%2) is inside quotation marks. This would not have worked under Zmud either. In addition, your initial #REGEX has only one set of parentheses, so there is no %2 at all. There is no reason for the %concat().

Replace that bit of code with:
Code:
%regex(%1, "\b%i\b")

But this is not very efficient code. There are much better ways of converting a string of directions into a stringlist.

Tell me, is the text after "Visible Exits:" always a space-separated sequence of exit directions? In that case, just replace the following code
Code:

compassdirections = ""
#fo {N|Ne|E|Se|S|Sw|W|Nw|U|D} {#if %regex( "%concat(%1,%2)", "\b%i\b") {#additem compassdirections %i}}

with:
Code:
compassdirections = %list(%1, " ", 1)
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Sun Jun 17, 2012 2:56 pm   
 
The entire code is pasted under Zmud general discusions under compass on the second page. It must be something else because those two examples didnt work (also tried on Zmud and it made it so the compass didnt work).
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Thu Jun 21, 2012 11:58 pm   
 
Ok I still can't get your two examples to work in either Zmud or Cmud. Here is the entire script:
The trigger for this is based off of: Visible Exits: (W) U D Ne Se where (W) is a closed door

#VAR compassdirections {}
#TRIGGER {Visible Exits: *$} {#gag}
#REGEX {Visible Exits: (.*)} {
compassdirections = ""
#fo {N|Ne|E|Se|S|Sw|W|Nw|U|D} {#if %regex( "%concat(%1,%2)", "\b%i\b") {#additem compassdirections %i}}
#IF %ismember( D, @compassdirections) {#VAR compassdown 1} {#VAR compassdown 0}
#IF %ismember( E, @compassdirections) {#VAR compasseast 1} {#VAR compasseast 0}
#IF %ismember( W, @compassdirections) {#VAR compasswest 1} {#VAR compasswest 0}
#IF %ismember( N, @compassdirections) {#VAR compassnorth 1} {#VAR compassnorth 0}
#IF %ismember( S, @compassdirections) {#VAR compasssouth 1} {#VAR compasssouth 0}
#IF %ismember( Se, @compassdirections) {#VAR compasssoutheast 1} {#VAR compasssoutheast 0}
#IF %ismember( Sw, @compassdirections) {#VAR compasssouthwest 1} {#VAR compasssouthwest 0}
#IF %ismember( Ne, @compassdirections) {#VAR compassnortheast 1} {#VAR compassnortheast 0}
#IF %ismember( Nw, @compassdirections) {#VAR compassnorthwest 1} {#VAR compassnorthwest 0}
#IF %ismember( U, @compassdirections) {#VAR compassup 1} {#VAR compassup 0}
}
#BUTTON 4 {---} {} {NE} {} {} {compassnortheast} {} {Size} {27} {24} {Pos} {106} {99} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 5 {---} {} {S} {} {} {compasssouth} {} {Size} {27} {24} {Pos} {154} {50} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 6 {---} {} {NW} {} {} {compassnorthwest} {} {Size} {27} {24} {Pos} {106} {1} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 8 {---} {} {SE} {} {} {compasssoutheast} {} {Size} {27} {24} {Pos} {154} {99} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 9 {---} {} {SW} {} {} {compasssouthwest} {} {Size} {27} {24} {Pos} {154} {1} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 10 {---} {} {E} {} {} {compasseast} {} {Size} {27} {24} {Pos} {130} {99} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 11 {|---} {} {U} {} {} {compassup} {} {Size} {22} {24} {Pos} {130} {28} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 12 {---|} {} {D} {} {} {compassdown} {} {Size} {22} {24} {Pos} {130} {77} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 13 {---} {} {N} {} {} {compassnorth} {} {Size} {27} {24} {Pos} {106} {50} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 14 {---} {} {W} {} {} {compasswest} {} {Size} {27} {24} {Pos} {130} {1} {9} {14} {} {} "" {} {} {} {3}
#BUTTON 256 {M} {} {M} {} {} {1} {} {Size} {27} {24} {Pos} {130} {50} {13} {15} {} {} "" {} {} {} {3}
#BUTTON 257 {---} {} {} {} {} {} {} {Size} {22} {24} {Pos} {106} {27} {} {} {Gauge||0|||0} {5} "" {Explore|Inset} {} {} {3}
#BUTTON 258 {---} {} {} {} {} {} {} {Size} {22} {22} {Pos} {154} {27} {} {} {Gauge||0|||0} {10} "" {Explore|Inset} {} {} {3}
#BUTTON 259 {---} {} {D} {} {} {1} {} {Size} {21} {24} {Pos} {106} {77} {} {14} {Gauge||0|||0} {5} "" {Explore|Inset} {} {} {3}
#BUTTON 260 {---} {} {D} {} {} {1} {} {Size} {21} {22} {Pos} {154} {77} {} {14} {Gauge||0|||0} {10} "" {Explore|Inset} {} {} {3}
#BUTTON 261 {} {} {D} {} {} {1} {} {Size} {126} {15} {Pos} {176} {0} {} {14} {Gauge||0|||0} {} "" {Explore|Inset} {} {} {3}
#BUTTON 262 {} {} {D} {} {} {1} {} {Size} {126} {15} {Pos} {91} {0} {} {14} {Gauge||0|||0} {} "" {Explore|Inset} {} {} {3}
#CLASS 0

Maybe its the on off button part? And beats me why this works in Zmud!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Jun 22, 2012 12:38 am   
 
Well, one problem is that you didn't tell us before that your exits could have parentheses around them. The code you are trying to adapt does not account for that. What do you want to happen for closed doors? Do you want the button active or not?

I don't know whether the #BUTTON commands will work. Not all of the options to #BUTTON were ever documented, and this appears to be using some of the undocumented Zmud options. Buttons have undergone quite a few changes in Cmud.

Did you check whether it was at least making @compassdirections correctly? Are the buttons being created at all?
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Fri Jun 22, 2012 6:06 pm   
 
The compass on Zmud does not account for closed doors, but it does show the exit (which is annoying). I would like it to show the exit with some sort of indication that its closed.
As far as Cmud, the buttons are not being created. I had some problems with other button scripts that I imported not toggling also.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Jun 22, 2012 6:27 pm   
 
If the buttons aren't even being created, the problem is in the #BUTTON commands. I'll take a look again at this later this afternoon, but I suspect the best way to deal with the buttons is to create them manually.
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Fri Jul 06, 2012 7:57 pm   
 
I believe the only thing wrong with the buttons is the colors didnt import. After fixing that, Ive tested the buttons and they do work so it must be the trigger. Maybe you have another idea? Thanks for all your help so far.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Fri Jul 06, 2012 8:44 pm   
 
No, your trigger will not work. Rahab already explained why, and gave you much better code to do what you're trying to do, but it appears you didn't change anything, judging by your later post...
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