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


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Wed Mar 09, 2005 6:52 pm   

#MSS
 
After reading a bit about #MSS and %mss(), I created the following trigger:

Code:
#TR {({@list1})%s(%d)%s(%d)%s(%d)} {
#va inum {%ismember(%1,@list1)}
#if %ismember(%zonename,@list2)<1 {#additem list2 zonename}
#va znum {%ismember(%zonename,@list2)}
#mss {a1[@list1][@list2]=%2:a2[@list1][@list2]=%3:a3[@list1][@list2]=%4}
}

I plan to use an alias later on to access the three VBScript arrays a1, a2, a3 using something like this:

Code:
#loop %numitems(@list1) {
#loop %numitems(@list2) {
#va l1 {%concat(@l1,", ",%mss(a1[%i][%%i])}
#va l2 {%concat(@l2,", ",%mss(a2[%i][%%i])}
#va l3 {%concat(@l3,", ",%mss(a3[%i][%%i])}
}
#echo @l1
#echo @l2
#echo @l3
}


Of course, there will be more formatting and such to make it prettier, but this is the meat of it.

My questions about this are:
    Are there any pitfalls with using #MSS or %mss in this way that I should be aware of?
    Is this likely to consume exorbitant amounts of system resources?
    Is it going to create a substantial performance drain?
    Is there a slicker way to handle multi-dimensional arrays?
    Or - if I click that little VBScript button in the trigger window, can I then combine zscript and VBScript together in the same code?


Thanks for your help!
_________________
Spartacus
rm -rf .*
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Thu Mar 10, 2005 1:47 am   
 
Quote:
Is there a slicker way to handle multi-dimensional arrays?

I wouldnt say this is slicker but if multi-dimensional arrays are what you want
you can do it in zmud.

Code:
#loop %numitems(@list1) {
#loop %numitems(@list2) {
#va l1 {%concat(@l1,", ",%item(%item(@a1,%i),%%i)}
#va l2 {%concat(@l2,", ",%item(%item(@a2,%i),%%i)}
#va l3 {%concat(@l3,", ",%item(%item(@a3,%i),%%i)}
}
#echo @l1
#echo @l2
#echo @l3
}


That should do the same thing as your loop.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Mar 10, 2005 2:03 am   
 
Quote:

Is there a slicker way to handle multi-dimensional arrays?


I don't know about slicker, but it's certainly doable.

A multi-dimensional array in ZMud would look like this:

Code:

Variable
    .line1 = item1|item2|item3|...|itemN
    .line2 = item1|item2|item3|...|itemN
    .line3 = item1|item2|item3|...|itemN
    .lineN = item1|item2|item3|...|itemN


Because there's no sort of easy reference to each individual element, you probably want to maintain a few internal fields for easy validation and location:

Code:

Variable
    .x = M
    .y = N
    .currentx
    .currenty
    .line1 = item1|item2|item3|...|itemN
    .line2 = item1|item2|item3|...|itemN
    .line3 = item1|item2|item3|...|itemN
    .lineM = item1|item2|item3|...|itemN


Now you have the structure, but not necessarily the execution:

#FUNCTION Get {%if((%2 <= @%1.x) and (%3 <= @%1.y),%item(%db(@%1,line%2),%3),%null)}

%1 = variable name (do not include @)
%2 = X coordinate (item1, item2, item3, etc)
%3 = Y coordinate (line1, line2, line3, etc)

This function will return null if the specified location is out of bounds, or the element contents if inbounds

#FUNCTION Set {%if((%2 <= @%1.x) and (%3 <= @%1.y),%replaceitem("%4",%3,@%1.line%2),%null)}

%1 = variable name (do not include @)
%2 = X coordinate (item1, item2, item3, etc)
%3 = Y coordinate (line1, line2, line3, etc)
%4 = new contents

This function will replace the old element contents with the new contents, or return %null if the location was outside boundaries.

I'm not real familiar with functions, so I don't guarantee this will work as shown.
_________________
EDIT: I didn't like my old signature
Reply with quote
Spartacus
Wanderer


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Thu Mar 10, 2005 12:58 pm   
 
So last night I found the pitfall, which is that values stored in VBScript variables do not appear to be retained across sessions. Looks like I'll
have to to use nested lists in zmud or a database in order to maintain this.

What I'm using this for is to maintain current pricing of commodities so that I can quickly see if there is an opportunity to buy for less than I can sell at elsewhere.

Thanks for your responses! =)
_________________
Spartacus
rm -rf .*
Reply with quote
Spartacus
Wanderer


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Thu Mar 10, 2005 1:04 pm   
 
By the by,

Zugg, if you see this, the only feature request I can think of today would be more seamless integration of VBscript and Zscript. What I mean, is maintaining state of script variables across logins and ability to use VBscript right in the middle of Zscript code without calling #MSS or %mss(). Hopefully that doesn't sound too stupid... Very Happy
_________________
Spartacus
rm -rf .*
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Mar 10, 2005 9:28 pm   
 
Some such things may become possible in the next version of zMud. I do not know what developments from eMobius and zApp will be brought into zMud, but the creation of zApp caused Zugg to become seriously involved in the low level guts of the MS scripting host system for a few weeks. I know he has achieved a nearly seamless integration between the script and component data sets and this may lead to a more seamless integration in zMud's future.
_________________
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