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


Joined: 29 Apr 2004
Posts: 2
Location: USA

PostPosted: Thu Apr 29, 2004 11:18 pm   

Scripting trouble
 
I'm rather new to scripting using zmud, and all I've really got going for me in the programming department are quickbasic and visualbasic classes I took a few years ago, and the ability to emulate bits of script made by others. I play Aetolia, and got the idea to make a script that keeps detailed track of key numbers and such from a script another player made (his was made for keeping track of guild enemy information).

My idea for the script is that the user can enter the key's item number (items in Aetolia/Achaea show up as this when looking at personal or room inventories: key106798) then what room the key goes to, and then who has (or is supposed to have) that specific key, all in one line. That information would then be stored (either in a created file or maybe in a variable), and the user would be able to see what keys they have information on by entering another command that would bring up the whole list. In the end, the list would look something like this:

===============================================================
KEY NO. GOES TO HOLDER
===============================================================
139876 Sentaari_GM_room Hakhim
100037 Pathways_of_Balance_Stk_Rm. Me

The user would also be able to delete keys too, of course. The only problem is that I'm not sure if what I'm trying to do is even possible. Everything I've thought of involves assigning about fifty different kinds of variables and restricting the list to a certain number. I can't figure out how to store information entered from zmud into a separate file and then display that information when prompted, though I'd think it would be possible. I use version 3.62, by the way, which might be the problem, though I'd like this script to be usable by everyone.

I'll write the script I've got so far down here, and maybe one of you can help me out a little, even if it's just to say that I'm trying the impossible. Go ahead and copy/paste it into a script file and fiddle with it if you feel like it.

#CLASS {Keymaster}
#ALIAS keys {#SH " ";#SH "-=-=-=-=-=-=-=-=-=-=-=-=-=-KEYMASTER-=-=-=-=-=-=-=-=-=-=-=-=-=-";#SH "===============================================================";#SH "KEY NO. GOES TO HOLDER";#SH "===============================================================";#SH}
#ALIAS addkey {#IF (%1 != "?") {#UNALIAS %1msg "Keymaster";#UNTRIGGER %1 "Keymaster"} {#SH " ";#SH ADDKEY ~<keynumber> ~<what_it_goes_to> ~<who has it>;#SH " ";#SH Usage:;#SH " Adds a key";#SH Variables:;#SH " Keynumber: The number of the key (item number).";#SH " What it goes to: Self explanatory.";#SH " Who has it: Self explanatory."}}
#ALIAS delkey {#IF (%1 != "?") {#UNALIAS %1msg "Keymaster";#UNTRIGGER %1 "Keymaster"} {#SH " ";#SH DELKEY ~<keynumber>;#SH " ";#SH Usage:;#SH " Deletes a key.";#SH Variables:;#SH " Keynumber: The number of the key (item number)."} }
#ALIAS listex {#SH " ";#SH "-=-=-=-=-=-=-=-=-=-=THIS IS AN EXAMPLE LIST=-=-=-=-=-=-=-=-=-=-";#SH "===============================================================";#SH "KEY NO. GOES TO HOLDER";#SH "===============================================================";#SH "139876 Sentaari_GM_room Hakhim"}
#ALIAS keymasterhelp {#SH " ";#SH THE KEYMASTER;#SH --------------;#SH "The Keymaster is a script designed for use in the MUDs Aetolia, Achaea, and Imperian to make it easy for you to keep track of key numbers, what keys lock and unlock what, and who is supposed to have each key. With the simple command of KEYS a list of all of the keys you have registered into the system will be displayed, along with where the keys go to and who is supposed to have them.";#SH " ";#SH "The following commands allow you to add or delete keys:";#SH "-------------------------------------------------------";#SH "ADDKEY ~<keynumber> ~<what_it_goes_to> ~<who has it> ..... Adds a key to the Keymaster's list. (NOTE: Replace spaces with underscores ("_") when entering what the key goes to.)";#SH "DELKEY ~<keynumber> .................................... Deletes a key from the Keymaster's list.";#SH " ";#SH "Adding a question mark (?) after one of the above commands will remind you of its usage.";#SH " ";#SH "Additional commands:";#SH "--------------------";#SH "LISTEX ................................................ Displays an example Keymaster list.";#SH KEYS .................................................. Displays your list of keys."}
#CLASS 0
Reply with quote
perturbed
Newbie


Joined: 29 Apr 2004
Posts: 2
Location: USA

PostPosted: Thu Apr 29, 2004 11:25 pm   
 
Grr, sorry. The spacing isn't working properly here. Here's something like it's supposed to look like:

===============================================================
KEY NO.------GOES TO-----------------------HOLDER
===============================================================
139876-------Sentaari_GM_room--------------Hakhim

Just replace those dashes with spaces.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun May 02, 2004 6:35 am   
 
Assuming that version 3.62 supports record-variables (also known as database-variables), you should be able to store this information in two record-variables. One variable would have the keynumbers as its keys and the rooms they go to as its values, the other variable would also have the keynumbers as its keys but would have their Holders as its values.

The syntax is:
#ADDK recordvar key value

#ADDK Holder {139876} {Hakhim}
#ADDK GoesTo {139876} {Sentaari GM room}
#ADDK Holder {100037} {Me}
#ADDK GoesTo {100037} {Pathways of Balance Stk Rm.}

I recommend changing the order so that %1 is the keynumber, %2 is the holder, and %3 (and beyond) is the room. That way, you won't need to replace spaces with underscores.

#AL addkey {#ADDK Holder {%1} {%2};#ADDK GoesTo {%1} {%-3}}
#AL delkey {#DELK Holder {%1};#DELK GoesTo {%1}}
#AL keys {#SAY ===============================================================
#SAY KEY NO. %repeat( " ", 4) HOLDER %repeat( " ", 12) GOES TO
#SAY ===============================================================
#LOOPDB @Holder {#SAY %key %repeat( " ", %eval( 11 - %len( %key))) %val %repeat( " ", %eval( 18 - %len( %val))) %db( @GoesTo, %key)}}

I've never used anything earlier than version 5.55 so you'll have to verify that all these commands and function are available to you or modify the script for any that aren't.

There's not much point trying to write a script which "everyone" will be able to use. Most people quickly recognize the value of zMUD and purchase a license, so there aren't many 3.62 users. With upgrades free to licensed users, there also aren't many people using the versions between 3.62 and the current version. By targeting the handful of users who are on obsolescent versions, you can't take advantage of all the improvements of 4 major upgrades. This will likely make your scripts clumsy by current standards and unattractive to those who are using the current version.
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