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


Joined: 22 Oct 2000
Posts: 90
Location: Sweden

PostPosted: Wed Sep 11, 2002 3:00 am   

Setting roomcolor in runtime
 
I created my own "path-maker", that works with my previous notes. Now, I want to do two things... when I create my path, I temporarily change the functions of my numeric keyboard to move on the map and add the direction to the array of steps I want in my path for later use, without sending the actual step to the MUD. Now, what I want to do is the following:

  • With each step I want to color the room on the map, say RED, so I know exactly what rooms I already was in.

  • With each step I ALSO want to create an array with the roomnumber and the color the room had BEFORE coloring it red.

  • AFTER creating the path, I want either an alias, or a final touch that restores all the room in the array to the color they were before.


I tried to create an array like this:
#va testarray %array(233=23343,122=2343,2353=2343}
but it creates an array with quotes and the final "}" is included in the array also for some weird reason, the last instance in the array looks like "2353=2343}" (I did not add the quotes).
I managed to do the coloring of the rooms using
%roomcol(,red)
but it also sends "255" to the MUD, returning the room color. I don't want that.

I guess I am doing something wrong here. But if someone could point me in the general direction, I would appreciate that.


"May the Force be with you"
[url]peeweesweden@bredband.net[/url]
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Sep 11, 2002 4:41 am   
 
try using #NOOP. I'm not really sure, but I think the %room functions all work like %btncol(), %btnimage(), etc.

li'l shmoe of Dragon's Gate MUD
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Sep 11, 2002 5:30 am   
 
Being brief:

1)
Change:
#va testarray %array(233=23343,122=2343,2353=2343}
to:
#va testarray %array(233=23343,122=2343,2353=2343)

2)
As Matt Lofton points out use:
#NOOP %roomcol(,red)

Addendum:
You could store the room's original color maybe in a different field?
Simply things with: %roomcost( room, [i])?

My brain is toast but you could then play around with something like:
#LOOP 1,%numrooms() {#NOOP %roomcol(%mapvnum(%i),%roomcost(%mapvnum(%i),%i))}
* untested above %_% * This is someting that you could do when safe and can take the lag hit perhaps.


Ton Diening
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Sep 11, 2002 4:36 pm   
 
Why use %array? It seems like a database (record) variable would be better.

#VAR testarray {233=23343|122=2343|2353=2343}

This should give you a record variable with 3 value-pairs. The first value in each pair (the key) would be the room number, and the second value (the value) would be the room color. New value-pairs can be added using #ADDKEY.

LightBulb
Senior Member
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Sep 11, 2002 7:11 pm   
 
The syntax of:
#VAR {key1=value|key2=value2|key3=value3|etc}

doesn't work to create datbase variables. The problem is that even though zMUD displays the key-value separator character as an equal sign, this is not the way it is internally stored. This is contrary to what happens with stringlist where the separator character is a normal, printable ASCII character (|).

You must always use the #ADDKEY command to create database variables.

Kjata
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Sep 12, 2002 12:04 am   
 
Oops. And I got that straight out of "Database Variables" under "Introduction to the Database". This syntax does work, I checked:
#ADDKEY testarray {233=23343|122=2343|2353=2343}



LightBulb
Senior Member
Reply with quote
peewee
Wanderer


Joined: 22 Oct 2000
Posts: 90
Location: Sweden

PostPosted: Thu Sep 12, 2002 3:18 am   
 
Ok, I got this far... with every room, I now do
#addkey RoomColors {%roomnum=%roomcol}

#NOOP %roomcol( ,red)
%arrset( @path_name, @steps, "s")
#add steps 1
and to reset the colors I tried
#loopdb {@RoomColors} {%roomcol(%key,%val)}

Looks all nifty, doesn't it? Well, setting the rooms red works great, and the DataBase with the roomnumbers and roomcolors is also working. Now, here comes the problem... I can do
#loopdb {@RoomColors} {#SHOW Room Number: %key, color %val}
returns:

Room Number: 434, color 12632256
Room Number: 435, color 12632256
Room Number: 436, color 12632256

But it seems that
#loopdb {@RoomColors} {%roomcol(%key,%val)}
did nothing... No colors set, nothing happened... Maybe I shouldn't do this at 4 am...


"May the Force be with you"
[url]peeweesweden@bredband.net[/url]
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Sep 12, 2002 1:56 pm   
 
Sorry, Peewee. I don't see anything wrong with what you have. Obviously #LOOPDB is working, as is %key and %value. You might need to put the %roomcol function into a command? You could just use #NOOP again. That's the only thing I can come up with.

#loopdb {@RoomColors} {#NOOP %roomcol(%key,%val)}

LightBulb
Senior Member
Reply with quote
peewee
Wanderer


Joined: 22 Oct 2000
Posts: 90
Location: Sweden

PostPosted: Thu Sep 12, 2002 2:49 pm   
 
Ok, I give up....
#loopdb {@RoomColors} {#SHOW %int(%key)}
returns:
0
0
0
0
0
0

while
#loopdb {@RoomColors} {#SHOW %key}
returns:
438
436
439
437
435
434

Is there some simple parenthesis I'm missing? Or mayhap I missed a syntax rule somewhere... *sigh* I'm off to work now, anyways...


"May the Force be with you"
[url]peeweesweden@bredband.net[/url]
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Sep 13, 2002 5:54 am   
 
%int? What's that, something to do with the beta versions perhaps? If you are using a beta version, you might want to post this on the beta forum. It may be something to do with the new mapper.

It looks like %key and %val aren't being converted when they are inside the %roomcol function. You might try:
#loopdb {@RoomColors} {#VAR temp1 %key;#VAR temp2 %val;#NOOP %roomcol(@temp1,@temp2)}

I hope this works, because I'm pretty much baffled.

LightBulb
Senior Member
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Sep 14, 2002 12:10 am   
 
%int is indeed a beta function, it is part of the newer support for floating point numbers. Since you mentioned it we know your using a beta version.

Now on to the meat of the topic:

First your %roomcol within the #LOOPDB should be behind a #NOOP, otherwise you will endup sending odd things to the mud.

Second zMud is generally very open about typing between numbers and strings correctly without any scripter effort. You can try to use %number to surround either/both the %key and %value in the loop to force the correct type.
#loopdb {@RoomColors} {#NOOP %roomcol(%number(%key),%number(%val))}

Whether it works or not you should report it to the beta forum, as any problem with type assignments will cause headaches for many people.
Reply with quote
peewee
Wanderer


Joined: 22 Oct 2000
Posts: 90
Location: Sweden

PostPosted: Sat Sep 14, 2002 8:46 am   
 
%number(%key)also returns 0... I did
 #loopdb {@RoomColors} {#NOOP %roomcol(%number(%key),%number(%val));#SH %number(%key)}
to try it out, and all I get is a list of zeroes, but removing the %number gives me a list of the roomnumbers. I will report this in the beta forum.


"May the Force be with you"
[url]peeweesweden@bredband.net[/url]
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