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
Meznev
Newbie


Joined: 22 Sep 2005
Posts: 6

PostPosted: Tue Sep 27, 2005 8:13 pm   

Magically Dissapearing Array vars?
 
Its me again. I'm playing on a mud in which you have to visit a place and then remember it in order to portal/gate there later on. So I devised this ingenious system of aliases and triggers to allow me to add comments to the output from the mud that shows me the locations I have memorized.

It works really well, actually. Until I log out and close zmud. Then somehow *all* my arrays dissapear. The really bizzare thing is that my normal variables are still there and with the same values they had when I logged out.

Is there something in zmud that flushes arrays? Should I not attempt to use them for long term storage? I don't know how easily I could change it to work on a normal string var system. I suppose I could use a data record var, but anyways.. Here's the code in case anyone's wondering:

use:
rlset ## comment

Code:

#class Spells
remember set "%1" "%-2"
#if ("%2" =~ "%a") {rcomment = "%-2"} {rcomment = "Blank. Try using rset num comment"}
 #if ("%1" =~ "%d") {
  rnum = "%1"
  #if ((@rnum < 10) and (@rnum >=0)) {
    #NOOP %arrset( rloc1, @rnum, @rcomment)
    #show %ansi( white)Slot @rnum Comment added as:%ansi( under, White)%arrget( rloc1, @rnum)
    remember
    }
  }
rnum = ""
rcomment = ""

use:
rlshow ##

code:
Code:

#class Spells
rnum = ""
#if ("%1" =~ "%d") {
  rnum = "%1"
  #if ((@rnum < 10) and (@rnum >= 0)) {#show Comment: %arrget( rloc1, @rnum)} {#echo %ansi( white)Use: rlshow 0-9, You typed: @rnum}
  } {remember}
rnum = ""


trigger:
patter, command 'remember' (raw zmud output):
Code:

#ONINPUT {remember} {} "Spells" {notrig}
#COND {~ ~ 0~ ~| (*)} {#echo %ansi( white) ~ 0 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 0)}
#COND {~ ~ 1~ ~| (*)} {#echo %ansi( white) ~ 1 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 1)}
#COND {~ ~ 2~ ~| (*)} {#echo %ansi( white) ~ 2 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 2)}
#COND {~ ~ 3~ ~| (*)} {#echo %ansi( white) ~ 3 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 3)}
#COND {~ ~ 4~ ~| (*)} {#echo %ansi( white) ~ 4 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 4)}
#COND {~ ~ 5~ ~| (*)} {#echo %ansi( white) ~ 5 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 5)}
#COND {~ ~ 6~ ~| (*)} {#echo %ansi( white) ~ 6 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 6)}
#COND {~ ~ 7~ ~| (*)} {#echo %ansi( white) ~ 7 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 7)}
#COND {~ ~ 8~ ~| (*)} {#echo %ansi( white) ~ 8 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 8)}
#COND {~ ~ 9~ ~| (*)} {#echo %ansi( white) ~ 9 %ansi( high, Red)| %ansi( under, white)%arrget( rloc1, 9)}


I can't see what would cause this. It runs perfectly as I use rlset/rlshow and the trigger while playing with the mud (have to re-init the array every session, grrr...). Any ideas? Thanks in advace :)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Sep 27, 2005 8:31 pm   
 
This is why we don't use arrays except for when dealing with COM objects. Arrays are not saved beyond the session they were created in, and it's intentional (I dunno why, but it is). If you want it to save, use stringlists. Stringlists have about 50 times more support, they save to the settings files, and they look exactly the same as arrays.
_________________
EDIT: I didn't like my old signature
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Sep 27, 2005 9:06 pm   
 
Record variable is the way to go since you have a 2 dimensional array. The change over is quite simple and I will do it on one section, and let you figure out the rest.

#class Spells
remember set "%1" "%-2"
#if ("%2" =~ "%a") {rcomment = "%-2"} {rcomment = "Blank. Try using rset num comment"}
#if ("%1" =~ "%d") {
rnum = "%1"
#if ((@rnum < 10) and (@rnum >=0)) {
#ADDKEY rloc1 {@rnum} {@rcomment}
#show %ansi( white)Slot @rnum Comment added as:%ansi( under, White)%db(@rloc1, @rnum)
remember
}
}
rnum = ""
rcomment = ""
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Meznev
Newbie


Joined: 22 Sep 2005
Posts: 6

PostPosted: Wed Sep 28, 2005 7:11 am   
 
Hey, thanks again guys. And thanks Vijil for your code bit. That actually helped me hopefully as much as you figured it would. :D

Now that I understand that zmud's db thing is almost exactly like perl's hashes I can finally toss all my vars into them. Just for the heck of it I tossed together a proper a speedwalk manager thing, works well. Almost wanna add a field for extra info. Wonder how fun the databases are to play with :)

Now, can I create a data record of string lists (perl HoA/Hash of Arrays)? That would be add lots of fun to my eclectic collection of scriptybits. :)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Sep 28, 2005 8:42 am   
 
Record variables can contain string lists, I suggest not using the . notation with most complex record variables. Although I have never really thought of a use for it you can even structure the record to have lists in the key names.

The actual database is a bit different to work with. Zugg wrote it himself very early in zMud's creation. There simply were no good database solutions at the time. You can do many similar things with indirect references. For example my script to ID equipment checks to see if the database is active and available. When it isn't it it creates a variable with a name based on a time stamp, stores the entire ID record there and records the variable name in a list. Later they are retrieved by using @{%item(@PendingIDs,1)} so it is possible to create mini-databases without actually using the database.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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