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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Kalie
Beginner


Joined: 23 Jun 2008
Posts: 22

PostPosted: Wed Jul 23, 2008 3:37 am   

SETPROMPT - Non numberical capture?
 
The prompt in the mud I play looks like this:

* R HP:Healthy SP:Fading MV:Strong >

I would love to trigger off of it - the first time it shows up, or at least capture the text as variables (so I can then convert them, roughly, into numbers).

Is there a way to do that? Also, I have a lot of visual cues set up to help me out - mostly color changes on that line. Since I have to trigger off of the line I don't see any color changes until it has moved up (a new line has passed).

Thanks guys.

-Kalie
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Wed Jul 23, 2008 8:47 am   Re: SETPROMPT - Non numberical capture?
 
Sure.

Code:
<trigger priority="1" prompt="true" id="939">
  <pattern>~* R HP:(%w) SP:(%w) MV:(%w) ></pattern>
  <value>#RAISEEVENT onPrompt %1 %2 %3</value>
</trigger>

Note: At this point you could store those values from the prompt directly to variables, but instead I have raised an event instead. The reason I do this is because later on, as you get better and better with CMUD, having the onPrompt event could be very useful to you. Also, this is a good way and chance to learn about events and what they do.

Code:
<event event="onPrompt" priority="10" id="1524">
  <value>HP=$HP
SP=$SP
MV=$MV
</value>
  <arglist>$HP,$SP,$MV</arglist>
</event>


So there you see, that the first trigger matches the prompt, and captures the words from the prompt that mean something to you. It raises the onPrompt event, and sends those words to it. These words are stored directly to the local variables (temporary variables) which are marked by the $ in front of them. You could also use %1, %2, %3 for this, but the 'named argument' system is apparently better for several reasons, one being that it makes things easier to read when they get more complex.

Then, you simply set your permanent variables (@HP etc) with those values.

---------------------------------
To change the colour of the prompt, you would be better off trying to do it all from that first prompt trigger. I assume you mean that you do things like colouring the word that refers to your HP (health?) something bright and dangerous looking (crimson?) when you are hurt, etc.

#SUBSTITUTE seems to be the most efficient and reliable way of modifying the look of your prompt. I would put something like the following in your prompt trigger (that first one) as the very first command.

Code:
$h=%1
$s=%2
$m=%3
#sub {~* R HP:%ansi( %switch( $h="healthy", 10, $h="completely mashed", 12))$h %ansi( white)SP:%ansi( %switch( $s="full", 10, $s="fading", 13))$s %ansi( white)MV: (( another %ansi+%switch here.. you should have the gist of it now)>}

That looks complex, but its not particularly. Not once you figure out whats going on.

%ansi is how you set the colour. 12= red, 10 = bright green, 13=bright purple, etc.
%switch is a bit like %if, only you can have as many words/colours as you like. Just keep adding commas. You're saying that if the word is "suchandsuch" then colour with this number. Then you do the same for the next alternative.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Kalie
Beginner


Joined: 23 Jun 2008
Posts: 22

PostPosted: Wed Jul 23, 2008 3:11 pm   
 
Awesome!! You kick ass Caled. Smile

I think I follow all of that. Thanks for laying it out cleanly and explaining it all. Hopefully I'll get a chance to try it out later today.

Thanks again!
Reply with quote
Kalie
Beginner


Joined: 23 Jun 2008
Posts: 22

PostPosted: Wed Jul 23, 2008 11:22 pm   
 
I am trying to find a table of the color codes and having a really hard time. Is there a place I can find this information? (e.g. 12=red)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Jul 24, 2008 1:31 am   
 
Easy way -

#ALIAS colorfind {#LOOP 1,128 {#show %ansi(%i)Color %i}}

Then just do colorfind, and it'll show you all the colors based on ansi value.

Charneus
Reply with quote
Kalie
Beginner


Joined: 23 Jun 2008
Posts: 22

PostPosted: Thu Jul 24, 2008 1:43 am   
 
Thanks!

I ended up doing a version of that myself (although only to 100).

I was kind of hoping I could take advantage of all the other colors available - I think they are html colors. They are listed in the help section under colorname.

e.g.:

'aliceblue',
'antiquewhite',
'aqua',
'aquamarine',
'azure',
'beige',
'bisque',
'black',
'blanchedalmond',
'blue',
'blueviolet',
'brown',
'burlywood',
'cadetblue',
'chartreuse',
'chocolate',
'coral', ....
(and many more)

But I haven't figure out how to make that work with the scripts above. It's not critical but it would be nice. :)
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Thu Jul 24, 2008 9:16 am   
 
You can., with an mxp tag rather than %ansi. I'm not familiar with it off-hand, but it would be something like

<color aliceblue>blah blah</color>



Perhaps try:
Code:

#sub {~* R:<color %switch($h="healthy","azure",$h="completely knackered","chocolate")> $h </color> SP: <color %switch(etc)> $s MV: etc}

If you're having trouble using the mxp tag <color colourname> text </color> there, let us know and I or someone else will look up the correct syntax. I think it will work, but to be honest I so rarely use anything to do with mxp that its only a guess based on what I remember from a couple of years ago.

I should use it more, actually. I print a lot of messages to myself on the screen and ansi colours are pretty boring in the end.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Thu Jul 24, 2008 9:38 am   
 
Kalie:
you may want download the ColorWheel package from the Library. Then you'll be able to see how colors are looks like and what syntax you should use for coloring with mxp tags.
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Sun Aug 17, 2008 5:16 am   
 
Arde wrote:
Kalie:
you may want download the ColorWheel package from the Library. Then you'll be able to see how colors are looks like and what syntax you should use for coloring with mxp tags.


I've been trying to find this package myself. I can't seem to search by package name, and without knowing the author or category its basically impossible.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sun Aug 17, 2008 7:46 pm   
 
Caled wrote:
Arde wrote:
Kalie:
you may want download the ColorWheel package from the Library. Then you'll be able to see how colors are looks like and what syntax you should use for coloring with mxp tags.


I've been trying to find this package myself. I can't seem to search by package name, and without knowing the author or category its basically impossible.


??? Ah, the new Library interface... Let's see... Mud:All (it is a generic package, not MUD-specific), Package: Colour Wheel by Fang (it is the 1st package in the list! Very easy to find.)
Btw, I can suggest you replace original package' alias with the following one:

Code:
<alias name="ColourTest" id="2">
  <value><![CDATA[#FORALL @Colours {#SAYPROMPT {<color %i>%i</color> }};#cr;
#FORALL @Colours {#SAYPROMPT {<color black %i>%i</color> }};#cr;
#FORALL @Colours {#SAYPROMPT {<color white %i>%i</color> }};#cr;]]></value>
</alias>
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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