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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
appleeater
Beginner


Joined: 05 Apr 2003
Posts: 19

PostPosted: Sun Apr 06, 2003 9:27 am   

Room Cost / Color Query
 
Evening,

I have created a nice little map, but now I want to get some more information into it in regards to room types.

Each room has the room type next to the room name in brackets [].

Has anyone written a macro somewhere the will go through my map database, and set the roomcost and color of the room in mapper to my specifications.

Regards
Reply with quote
appleeater
Beginner


Joined: 05 Apr 2003
Posts: 19

PostPosted: Sun Apr 06, 2003 11:57 am   
 
Was just doing a bit of thinking about this and vaguley remembered something about a spreadsheet. I thought I could export the data into an excel spreadshhet and and do this resonably easy. Unfortunately it doesnt apear to be possible?
Reply with quote
scobie
Beginner


Joined: 01 Nov 2002
Posts: 24
Location: Sweden

PostPosted: Mon Apr 07, 2003 1:12 pm   
 
Can you post a room with colors (ie. what it looks like when you mud?

zMUD 6.16 - scobie@linux.se
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Apr 08, 2003 1:47 am   
 
I see you found that old post. I your particular case I thought it best to answer the question in this thread as a particular of your problem requires further explanation.

Your rooms have brackets [] in them which by default is a shortcut for evaluation. You will have to turn this off in your preferences prior to running the script, the option is named 'Allow [] for evaluation' and can be found on the Script Parser page. I have included a test for this that should work.

#CLASS MapColors
#VAR RoomCosts {}
#VAR RoomColors {}
#VAR MapState {}
#VAR RoomType {}
#ALIAS Recolor {#IF (%quote([1+1])="[1+1]") {MapState=%maplocked;#NOOP %maplocked(0);#LOOP 1,%numrooms {RoomType=%roomname(%mapvnum(%i));#WHILE ((@RoomType)&(%copy(@RoomType,1,1)!="[")) {RoomType=%trim(%remove(%word(@RoomType,1),@RoomType))};#IF (@RoomType) {RoomType=%delete(%delete(@RoomType,%pos("]",@RoomType),255),1,1);#IF (%db(@RoomCosts,@RoomType)="") {#ADDKEY RoomCosts {@RoomType} {%pick(%concat("p:Cost for rooms of type-",@RoomType),"o:1","1|2|3|4|5|6|7|8|9|10|11|12|13|14|15")}};#NOOP %roomcost(%mapvnum(%i),%db(@RoomCosts,@RoomType));#IF (%db(@RoomColors,@RoomType)="") {#ADDKEY RoomColors {@RoomType} {%pick(%concat("p:Color for rooms of type-",@RoomType),"o:1","red|blue|brown|green|gray|black|cyan|beige|yellow|teal|aquamarine|magenta|violet|orange|mauve")}};#NOOP %roomcol(%mapvnum(%i),%db(@RoomColors,@RoomType))}};#NOOP %maplocked(@MapState)} {#ECHO "Please turn off the [] evaluation shortcut in Preferences|Script Parser"}}
#CLASS 0

Hopefully no typos, I didn't test it and wrote it directly in the forums so there is no guarantee that I am not missing a ), }, or ".
Reply with quote
appleeater
Beginner


Joined: 05 Apr 2003
Posts: 19

PostPosted: Tue Apr 08, 2003 11:21 am   
 
Thnc very much for the reply, but WHen I put it in a macro, I ended up getting syntax error in the "alias recolor section"

Unfortunately I am not yet cluey enough to debug these things


Cheers
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Apr 08, 2003 12:58 pm   
 
No need to put it in a macro, just copy an paste everything into the zMUD command line and then press Enter. Afterwards, all you need to do is to call the Recolor alias.

Kjata
Reply with quote
appleeater
Beginner


Joined: 05 Apr 2003
Posts: 19

PostPosted: Tue Apr 08, 2003 8:52 pm   
 
Good Morning,

Thanks very much for your help on this matter, but I still appear to have issues.

I put it in the command line and created an Alias, and went into the script parser aera and turned of the "allow[] for evaluation" so it is not checked.

It appears that the script is looping because when i go into the aliases page the refresh button if flashing yellow for a while. However I get a syntax error on the part

#IF (%quote([1+1])="[1+1]")
^ syntax error

If the above doesnt line up properly bucause of font - the ^ points to the firstleft hand "[".

I sthere perhaps any other settings that I have to adjust in the preferences page?

BTW I am using version 6.55a if it makes any difference


Thanks in advance


Cheers
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Apr 08, 2003 11:10 pm   
 
The syntax checker is not perfect, even in public versions. As long as the alias is working correctly you can ignore the syntax error. That particular #IF was the only thing I tested to make sure I could actually detect the state of that preference, and keep everything else from running.

If the alias is running correctly it should pop up pick lists every time it encounters a tag it doesn't know, and you will have to select what you want those rooms to be set to. You only have to make that selection once for each type of room and field of data, after that it will remember what you wanted. If it isn't doing that then it needs debugging.
Reply with quote
appleeater
Beginner


Joined: 05 Apr 2003
Posts: 19

PostPosted: Wed Apr 09, 2003 11:54 am   
 
Evening Again,


I had a little look through the script, and started to seperate the commands to get more of an understanding as to what is going on in the alias.


I think I may have misled you slightly, and made you think that the room name only contained the phrase in brackets []

In fact there is a room name, and a room type that is enclosed in brackets (see below). It is the room type (In this case "Tunnel", enclosed in brackets), that I am trying to pick up.


An example of walking around in Brief mode is as follows:

You walk west.
Clouded Tunnel [Tunnel]
[Exits: east west ]

450h 182mv 53ma (998804) >


Does the section below pick up the room type?

WIth my rough interepretation, it

-checks if the 1st char in room name is a "["
-trims off spaces
-takes first word

But im not sure if I read it correctly, or if it will pick up the room syntax detailed above as there will never be a "[" starting the room name?, instead it should alway be at the end of a room name.

;#WHILE ((@RoomType)&(%copy(@RoomType,1,1)!="["))
{RoomType=%trim(%remove(%word(@RoomType,1),@RoomType))}


I am still a newbie with this stuff , and should have given an example previously, so could you please provide an example how i could fix this?

Once again, many thnx in advance
Cheers Guru
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Apr 09, 2003 11:29 pm   
 
In English that loop says, "As long as the variable RoomType contains something and the first character is not an open baracket do the following: take the contents of the RoomType variable, remove the first word and any spaces at the beginning or end, then put that into the RoomType variable."

So in your example RoomType is set to "Clouded Tunnel [Tunnel]". Then after the first pass it is "Tunnel [Tunnel]", then again "[Tunnel]", and stops because the firsy character is now an open bracket.
Reply with quote
appleeater
Beginner


Joined: 05 Apr 2003
Posts: 19

PostPosted: Sat Apr 12, 2003 3:57 am   
 
Afternoon,

I have mucked around with the following, and ended up getting it to work reasonably well.

The command below

-sets up a loop based on number of rooms
-finds what the room type is by seeing where the first "[" is and then uses pos/leftback/rightback to isolate the roomtype/area
-then compares it to whatever is in the brackets, and colors appropriately

#loop %numrooms {RoomType=%roomname(%roomvnum(%i));area=%leftback(%rightback(@roomtype,%len(@roomtype) - %pos([,@roomtype)),1);#echo @area;#if (@area="Gates") {#noop %roomcol(%mapvnum(%i),yellow)}}


However, not all rooms get colored for some reason. I thought it might be to do with the roomnums interger not being high enough, but room number 2109 and 2111 can be colored, but not 2110. Is it a result of commands going to fast for the mapper to keep up?


Any suggestions?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Apr 12, 2003 6:07 am   
 
Is it possible that you have 2 rooms with the same vnum? If you never changed a vnum manually then you shouldn't, but that is the only reason I can see that would cause what you describe.
Reply with quote
appleeater
Beginner


Joined: 05 Apr 2003
Posts: 19

PostPosted: Wed Apr 16, 2003 11:09 am   
 
Hmm I think I may have a problem with the little command macro that I have looping above.

#loop %numrooms {RoomType=%roomname(%roomvnum(%i));area=%leftback(%rightback(@roomtype,%len(@roomtype) - %pos([,@roomtype)),1);#echo @area;#if (@area="Gates") {#noop %roomcol(%mapvnum(%i),yellow)}}

It is set up to loop as many times as there are rooms in the map. Then each loop makes the mapper look in the room and colour it.

But I now have room that are numbered >5000, but I only have a total numbers of rooms at 4300.

Hence I think the loop is not working correctly.

Now the loop appears not to be creating %i numbers correctly. And does not cycle through the rooms. Instead all that is being echoed by the #echo @area section is alot of blanks - ie several thousand of them.

Any suggestions on how to improve my little bit of code, or what is causing it? I have tried uninstalling and reinstalling zmud and cleared all settings


Cheers
Me
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Apr 16, 2003 10:34 pm   
 
Change this line:area=%leftback(%rightback(@roomtype,%len(@roomtype) - %pos([,@roomtype)),1)
To:
area=%leftback(%copy(@roomtype,%eval(%pos("[",@roomtype)+1),255),1)

Even though the argument type for %copy and %rightback are expression, and should preform evaluation on arguments, I prefer to explicitly put in the %eval.

As to haveing only 4300 rooms but numbers being over 5000, that is what the mapvnum/roomvnum functions are for.
Reply with quote
appleeater
Beginner


Joined: 05 Apr 2003
Posts: 19

PostPosted: Thu Apr 17, 2003 12:12 pm   
 
Eureka !


err kinda, anyway, I figured out what the problem was. Previously I was using the Beta version 6.56, which crashed for some unkown reason, and I had some kind of a macro bug, so I decided to uninstalling and reinstall off a newly downloaded version. However what I dowloaded was version 6.40, which does not appear to have the command %roomvnum in it, just %roomnum, hence the %roomvnum part of it did not work. Once I figured this out I uninstalled, dowloaded 6.56 beta, and restarted it. Now it works. Thanks Vigi, I got the idea from you mentioning exactly what the commands were, and then me trying to investigate them further. - and gues what - it wasnt there !


Everthing seems to wark as before now -

Cheers
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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