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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Tue Dec 24, 2002 9:04 am   

Charbal's Status Window Extender
 
Written in response to this topic, this script allows one to specify row and column numbers for status window items.

Note: This script is for zMUD 6.40 and above. To get it to work properly on 6.16, read my post below.

#CLASS StatusWindowExtender
#VAR TempOutput %null
#VAR StatusElements %null
#VAR Found 0
#STW %null
#ALIAS recalculate {#VAR TempOutput %null;#FORALL @StatusElements {#VAR TempOutput %concat(%expand(@TempOutput,1),%char(27),"[",%repeatnum.Row,"~;",%repeatnum.Column,"f",%expand(%repeatnum.Content, 1))};#EXEC %concat("#STW ",%char(34),%expand(@TempOutput, 1), %char(34))}
#ALIAS addtext {#VAR Found 0;#FORALL @StatusElements {#IF (%repeatnum.ID = "%1") {#VAR Found 1}};#IF (@Found = 0 and %isnumber(%2) and %isnumber(%3) and %2 > 0 and %3 > 0) {#ADDI StatusElements %addkey(%addkey(%addkey(%addkey(%null,"ID","%1"),"Row",%2),"Column",%3),"Content",%literal("%-4"));#SAY New status text ~(ID %1) added at row %2, column %3: %literal("%-4");recalculate} {#SAY Unable to add status text ~(could be due to a duplicate ID or an invalid row and column specification)}}
#ALIAS remtext {#VAR Found %null;#LOOP 1,%numitems(@StatusElements) {#IF (%db(%item(@StatusElements, %repeatnum),"ID") = "%1") {#VAR Found %if(@Found = %null,%repeatnum,%concat(%repeatnum,"|",@Found))}};#IF (@Found <> %null) {#FORALL @Found {#DELNITEM StatusElements %repeatnum};#SAY Status text ID %1 removed from display list;recalculate} {#SAY Unable to find ID %1 in current status elements.;listtexts}}
#ALIAS listtexts {#SAY Currently defined positional status window texts are:;#FORALL @StatusElements {#SHOWDB %repeatnum}}
#CLASS 0

There is no coded limit on the number of status window elements you may define. Internally, the script uses a string list of database records to store the data on defined elements.

Syntax:
addtext ID row column text to put in status window
ID is a unique specifier for the element to add to the status window
Row and column start at 1

remtext ID
Removes the text with the unique identifier ID

listtexts
Displays the IDs, positions and content of all currently defined positional status window elements.

recalculate
Regenerates the status window definition from the list of text positions. This alias is executed internally by the script as needed and shouldn't be necessary unless the status window is overwritten with some other value.

Example usage:
addtext HP 1 1 HP: @HP
addtext MV 1 10 MV: @MV
addtext Opponent 2 1 Current opponent: @Opponent

This will start the HP display at column 1 and the MV display at column 10 of the first row and display your current opponent on line 2 (assuming that you are storing these things in @HP, @MV and @Opponent). Once these elements have been added, any changes in the variables will be reflected in the status window.

Known limitations:
Due to the way zMUD displays text specified after a change in cursor location, you'll want to make sure that if you add multiple elements on the same row, you add them in ascending order of their column numbers. Otherwise, zMUD will display the rightmost one, then go to the location of the other, display the text and then blank out the rest of the line (including the previously displayed element).

What this means is that you should do:
addtext HP 1 1 HP: @HP
addtext MV 1 10 MV: @MV

and not:
addtext MV 1 10 MV: @MV
addtext HP 1 1 HP: @HP

That should be about it...

Enjoy.

Edit: Added tildes to escape parentheses so pretty print would display script properly. Syntax Editor: 1, Charbal: 0

Edit 2: Added version compatibility note.

Edit 3: Updated to work for latest versions of zMUD.

 - Charbal
Reply with quote
seamer
Magician


Joined: 26 Feb 2001
Posts: 358
Location: Australia

PostPosted: Tue Dec 24, 2002 9:48 am   
 
Wow...jeez...hehe

Needed to add some tilde's in the addtext alias for the paranthesis in the #says (at least this way purty print doesnt get upset)

This actually does makes my #stw hacking alot easier :)

Why oh WHY did I have pass door on...
Reply with quote
Edwub
Wanderer


Joined: 21 Nov 2002
Posts: 85
Location: USA

PostPosted: Sat Jan 04, 2003 10:17 am   
 
That's incredible Charbal, it works like a charm.

As Seamer said, its missing two tildes in front of the paranthesis.


Wanted to ask: is this all exportable?
(the addtext lines i add)
If i move from comp to comp, can zmud handle it by exporting, or should i make a backup of all my 'addtext' lines on word?



Edwub the Mage
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Sat Jan 04, 2003 11:49 am   
 
Okay, okay... everyone that has commented so far has told me about the syntax editor "error" that I already knew about so I might as well fix it in my posted code. :P

As for exporting settings, the only necessary component is the @StatusElements variable. You can export/import the entire class en masse but this is really the only essential part (assuming that you have already imported a copy of the class in the receiving setup and just want to transfer your configuration). If you do just do the variable, you'll have to use the recalculate alias manually to initialize the status window definition with the saved texts.



 - Charbal
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Sat Jan 04, 2003 10:20 pm   
 
This script as written is for zMUD 6.40. 6.16's expansion of database variables is a bit buggy so if you put variables into your status text definitions, the window won't be updated when they change.

I'd strongly recommend upgrading to 6.40 (look at all it can do) but if you stick with 6.16 and want this script to work, you'll need to force the updating. This can be done every second with this alarm:

#ALARM *1 {recalculate}


 - Charbal
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Fri Jan 10, 2003 9:37 am   
 
Can you give the status window a name in the blue line? I alredy know I can put one in the status window itself.
Oh and thanks I use this for alot of different stuff.
Is there a way to make more than one status window appere for the same character?

megamog75
Reply with quote
Auren
Newbie


Joined: 12 Jan 2003
Posts: 7

PostPosted: Sun Jan 12, 2003 4:55 pm   
 
Question: I'm using the Status Window Extender and I'm having a spot of trouble with colors. I'm using %ansi to change the color of a certain variable being displayed depending on it's status. The problem is, when I change the color to anything but the default, everything beyond that item changes too. Now, I originally added everything in the proper order, but when I update, the color change spills over. How can i fix/workaround this?
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Sun Jan 12, 2003 5:14 pm   
 
In response to megamog75, I'm not aware of any way to use zMUD to add a title to the status window nor how to make more than one status window appear for a character.

And, Auren, if you use %ansi to change the color of an item, be sure to use %ansi(default) at the end of it to restore the default color.

Like:
addtext ID1 1 1 %ansi(red)This is red text%ansi(default)


 - Charbal
Reply with quote
rsbomar
Newbie


Joined: 10 Feb 2003
Posts: 5
Location: USA

PostPosted: Mon Feb 10, 2003 7:22 am   
 
I'm sorry for being stupid, but I haven't used ZMud for about 7 years and just downloaded and started playing again. Anyway I've tried to get this Status Window to work and am currently stumped.

Does this script go in as a new Status Window? And then paste the script in the window section? If so this is what I've done, but when I go to save it I get a syntax error on the #EXEC line.

Like I said I apologize ahead of time if this is a stupid question but I've been messing around with this for about 4 hours.

Oh, BTW I have ver. 6.55 beta.
Reply with quote
rsbomar
Newbie


Joined: 10 Feb 2003
Posts: 5
Location: USA

PostPosted: Mon Feb 10, 2003 7:23 am   
 
Make that 6.53 beta.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Feb 10, 2003 7:52 am   
 
Like most scripts on this site, this one should be pasted into the command line.

LightBulb
Advanced Member
Reply with quote
rsbomar
Newbie


Joined: 10 Feb 2003
Posts: 5
Location: USA

PostPosted: Thu Feb 13, 2003 3:50 am   
 
Thanks for the response. I copied and pasted the script into the command line and got a blank status window. I did the addtext but changed to the variables that I have set. The status window stay's blank. *Shrug*

When I do a listtexts it shows up that I should have something in row 1 column 1 and row 1 column 10 as well as row 2 column 1 but the window is still blank.

Any suggestions will be greatly apprecieated.
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Feb 13, 2003 10:13 am   
 
You might try going through your settings and looking for any status bar/status window definitions. Delete any you find (saving any information you need to recreate them if you need them) and then use #STW %null at the command line.


 - Charbal
Reply with quote
moksha
Novice


Joined: 13 Oct 2002
Posts: 37
Location: United Kingdom

PostPosted: Thu Feb 13, 2003 6:31 pm   
 
Charbal

I'm an having the same problem as rsbomor.
This script worked perfectly in 6.40 and many thanks for it :) but when I used it to create a new #stw for a character in 6.53 I found a syntax error in the recalculate alias which I don't think was there before.

Could you have a look see if this is the problem please as I don't know much about scripting and this one is well above me atm.

The error is:

#EXEC %concat("#STW ",%char(34),%expand(@TempOutput, 1), %char(34))
^ syntax error

Many thanks

Moksha
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Feb 13, 2003 10:07 pm   
 
This script probably doesn't work in version 6.53 because of a possible bug discussed in the Beta Forum. When Zugg gets back, the bug will probably be fixed for the nexy version.

Kjata
Reply with quote
moksha
Novice


Joined: 13 Oct 2002
Posts: 37
Location: United Kingdom

PostPosted: Wed Feb 19, 2003 5:19 pm   
 
Thank you Kjata

Moksha
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Tue Feb 10, 2004 11:06 pm   
 
I've updated this script so it should work for all versions of zMUD from 6.40 to present (6.67). There was a change in the way %i is used in zMUD that had affected this script.
Reply with quote
blkno1
Novice


Joined: 26 May 2002
Posts: 30
Location: USA

PostPosted: Thu Apr 08, 2004 3:59 pm   
 
I made this little help alias for the window extender so I didnt have to find the post everytime I wanted to change things. I named mine wehelp.[8D]



Code:

#SAY {%char( 10)@ansi(bYellow)Help for @ansi(bGreen)Status Window Extender}
#SAY {@ansi(bYellow)%repeat( "-", 30)}
#SAY {@ansi(bGreen)addtext ID row column text@ansi(byellow) ID is a unique specifier for the element to add to the status window Row and column start at 1}
#SAY {@ansi(bGreen)remtext ID @ansi(byellow) Removes the text with the unique identifier ID}
#SAY {@ansi(bGreen)listtexts @ansi(byellow) Displays the IDs, positions and content of all currently defined positional status window elements.
}
#SAY {@ansi(bGreen)recalculate @ansi(byellow) Regenerates the status window definition from the list of text positions. This alias is executed internally by the script as needed and shouldn't be necessary unless the status window is overwritten with some other value.
}
#SAY {@ansi(bgreen)wehelp @ansi(byellow) This file.}
#SAY {@ansi(bGreen)Example Usage:}
#SAY {@ansi(bGreen)addtext HP 1 1 HP: ~@HP}
#SAY {@ansi(bgreen)addtext MV 1 10 MV: ~@MV}
#SAY {@ansi(bgreen)addtext Opponent 2 1 Current opponent: ~@Opponent}
#SAY {@ansi(bYellow)%repeat( "-", 30)}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts 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