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
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Tue Mar 24, 2009 6:00 pm   

MXP foreground background with functions
 
I have tried a number of methods to use color, but now it seems that I must use MXP if I am to duplicate the BG I chose. Could anyone tell me how to structure the MXP for the 2 db calls below. There are 4 db calls really as it is a conditional, but I don't know if I can just use one MXP statement, or much about modes and expansion here.

ty



#if (@totalspell_h > 0) {
Code:
#MXP


I am unsure what to put for mxp here

Code:
<color %db( @AllPref, col_alert) %db( @AllPref, col_bg)>


and that these are all functions and variables I'd like to color

Code:
%proper( %replace( @spellfoci, "start", "")) @naysay elasped: @totalspell_h @totalspell_m @totalspell_s :elasped @naysay %proper( %replace( @spellfoci, "start", ""))


Code:
</color>


} {

and that this is a conditional like the other

#MXP
<color %db( @AllPref, col_alert) %db( @AllPref, col_bg)>%proper( %replace( @spellfoci, "start", "")) @naysay elasped: @totalspell_m @totalspell_s :elasped @naysay %proper( %replace( @spellfoci, "start", ""))

</color>
}
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Tue Mar 24, 2009 6:51 pm   
 
Are you sure you need the #MXP? May be you'll start with something simple like #PRINT (or #SHOW)? All what I see in your sample code is plain text output.
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Tue Mar 24, 2009 10:05 pm   
 
thanks for the help, you are very kind

(btw that is sarcasm)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Mar 24, 2009 10:26 pm   
 
No need for sarcasm. Actually, I believe he's correct. Why not do something like this.

Code:
#show test <color fore="blue" back="red"> red</color>


Since you're not starting with a function you should be able to just do
Code:
#PRINT <color %db( @AllPref, col_alert) %db( @AllPref, col_bg)>%proper( %replace( @spellfoci, "start", "")) @naysay elasped: @totalspell_h @totalspell_m @totalspell_s :elasped @naysay %proper( %replace( @spellfoci, "start", ""))</color>


If you're certain you want to use #MXP and may start it with a function in the future then
Code:
#MXP 1 {<color %db( @AllPref, col_alert) %db( @AllPref, col_bg)>%proper( %replace( @spellfoci, "start", "")) @naysay elasped: @totalspell_h @totalspell_m @totalspell_s :elasped @naysay %proper( %replace( @spellfoci, "start", ""))</color>}



If Ive completely missed what you're getting at, please elaborate or post the variables in XML so we can recreate it properly. I'm assuming you're not using the 3.05 beta version.
_________________
Asati di tempari!
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Wed Mar 25, 2009 2:11 am   
 
Your answer Tech was very apt, as I said I had tried a number of methods, and asked what would work. Trying show may work as your example differs from that I had used, and now I see that I wasn't taking the help file literally.

I would have accepted the first without sarcasm except since the code I displayed 'would' need to be expanded, how could I consider it text? Then I felt just %proper() was a leading function. Anyway.

I feel your example will fix my problem.

I would be happy to post the context of what I had with it's error, though just to accommodate after the fact.

And I apologize for assuming it must require MXP. I don't have a standard background color and that is difficult to work with but appealing otherwise. Nothing I have done was working. I had tried the obvious, however badly. Sorry, really.

This failed in v3.05:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="tm_reporttime">
    <value><![CDATA[#if (@totalspell_h > 0) {#sh {<color %db( @AllPref, col_alert) %db( @AllPref, col_bg)>%proper( %replace( @spellfoci, "start", "")) @naysay elasped: @totalspell_h @totalspell_m @totalspell_s :elasped @naysay %proper( %replace( @spellfoci, "start", ""))</color>}} {#sh {<color %db( @AllPref, col_alert) %db( @AllPref, col_bg)>%proper( %replace( @spellfoci, "start", "")) @naysay elasped: @totalspell_m @totalspell_s :elasped @naysay %proper( %replace( @spellfoci, "start", ""))</color>}}]]></value>
  </alias>
</cmud>


This is the context of the entire script, the last is just a print which differs as I was trying to work with it. I am sure anyone could do better, as I can't understand the principals I needed and used very well. Still I am proud to have done this.

Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="SpellReport" autoappend="true">
    <value><![CDATA[#class SpellDuration
#sh " "
#var startspell_h %item( %db( @SpellDura, @spellfoci), 1)
#var endspell_h %item( %db( @SpellDura, @spellterm), 1)
#var startspell_m %item( %db( @SpellDura, @spellfoci), 2)
#var endspell_m %item( %db( @SpellDura, @spellterm), 2)
#var startspell_s %item( %db( @SpellDura, @spellfoci), 3)
#var endspell_s %item( %db( @SpellDura, @spellterm), 3)
#if (@endspell_h < @startspell_h) {#add endspell_h 24}
#var totalspell_h %eval( (@endspell_h * 1) - (@startspell_h * 1))
#if (@endspell_m < @startspell_m) {#add endspell_m 60}
#var totalspell_m %eval( (@endspell_m * 1) - (@startspell_m * 1))
#if (@endspell_s < @startspell_s) {#add endspell_s 60}
#var totalspell_s %eval( (@endspell_s * 1) - (@startspell_s * 1))
#var totalspell_h %mod( @totalspell_h, 24)
#var totalspell_m %mod( @totalspell_m, 60)
#var totalspell_s %mod( @totalspell_s, 60)
#var naysay ""
#if (@SpellDura.spellshort == 1) {#var naysay REFRESH} {#if (@SpellDura.spellshort == 2) {
    #var naysay DOWN
    #var %concat( "ref", %replace( @spellfoci, "start", "")) -1
    } {
    #sh skipping
    #var naysay SKIP
    }}
#if (@naysay != "DOWN") {
  #var refspellvalue %eval( ((@totalspell_h * 60) + (@totalspell_m) + (@totalspell_s + 30) / 60))
  #sh refspellvalue: @refspellvalue
  #sh spellfoci: @spellfoci
  #var tm_avgnamekey %concat( "ref", %replace( @spellfoci, "start", ""), "timer")
  #var tm_maxnamekey %concat( "ref", %replace( @spellfoci, "start", ""), "max")
  #var tm_nameforvar %concat( "ref", %replace( @spellfoci, "start", ""))
  #if (%db( @SpellDura, keep_average) == 1) {#if (%db( @SpellDura, @tm_avgnamekey) > 0) {#addkey SpellDura %concat( "averaged", "_", %replace( @spellfoci, "start", "")) %eval( (@refspellvalue + %db( @SpellDura, @tm_avgnamekey)) / 2)}}
  #if (@naysay == "REFRESH") {
    #sh testing refresh
    #if (%db( @SpellDura, @tm_avgnamekey) > 0) {#var refspellvalue %db( @SpellDura, @tm_avgnamekey)}
    }
  #if (@refspellvalue > %db( @SpellDura, @tm_maxnamekey)) {#if (%db( @SpellDura, @tm_avgnamekey) < %db( @SpellDura, @tm_maxnamekey) && %db( @SpellDura, @tm_avgnamekey) > 1)  {
      #sh max value as avg key follows:
      #var refspellvalue %db( @SpellDura, @tm_avgnamekey)
      } {
      #sh max value as max key follows:
      #var refspellvalue %db( @SpellDura, @tm_maxnamekey)
      }}
  #sh refspellvalue is now @refspellvalue
  #var %expand( @tm_nameforvar, 1) ""
  #var %expand( @tm_nameforvar, 1) @refspellvalue
  #addkey SpellDura @tm_avgnamekey @refspellvalue
  #addkey SpellDura @spellfoci ""
  #addkey SpellDura @spellfoci %concat( %time( hh), "|", %time( nn), "|", %time( ss))
  }
; is the print
#if (@naysay != "SKIP") {#if (@totalspell_h > 0) {#sh {<color %db( @AllPref, col_alert) %db( @AllPref, col_bg)>%proper( %replace( @spellfoci, "start", "")) @naysay elasped: @totalspell_h @totalspell_m @totalspell_s :elasped @naysay %proper( %replace( @spellfoci, "start", ""))</color>}} {#sh {<color %db( @AllPref, col_alert) %db( @AllPref, col_bg)>%proper( %replace( @spellfoci, "start", "")) @naysay elasped: @totalspell_m @totalspell_s :elasped @naysay %proper( %replace( @spellfoci, "start", ""))</color>}}}
  #delkey SpellDura spellshort
  #unvar naysay
  #unvar spellfoci
  #unvar spellterm
  #unvar startspell_h
  #unvar startspell_m
  #unvar startspell_s
  #unvar endspell_h
  #unvar endspell_m
  #unvar endspell_s
  #unvar totalspell_h
  #unvar totalspell_m
  #unvar totalspell_s
  #sh " "
#class 0]]></value>
  </alias>
</cmud>


This is the database:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <var name="SpellDura" type="Record" sorted="true">averaged_bless=35|endarmour="13|10|30"|endbless="13|29|21"|endbob="10|41|31"|endsanct="13|08|50"|endsense="10|41|24"|endshield="13|08|32"|endstrength="13|04|06"|refarmourmax=35|refarmourtimer=4|refblessmax=12|refblesstimer=4|refbobmax=8|refbobtimer=4|refsanctmax=16|refsancttimer=4|refsensemax=60|refsensetimer=55|refshieldmax=35|refshieldtimer=5|refstrengthmax=55|refstrengthtimer=4|spellshort=2|startarmour="12|43|07"|startbless="12|42|42"|startbob="11|03|57"|startsanct="06|49|32"|startsense="06|49|29"|startshield="12|45|16"|startstrength="12|43|53"|use_average=0</var>
</cmud>


The main script is unfinished.


added this;

This is the second DB called in the color parts:


Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <var name="AllPref" type="Record">col_bg=#1E2510|col_nag=peru|current_wep=ranged|autofol=1|col_ditto=darkslategray|type_gold=lauren|col_info=coral|col_alert=gold|col_warn=firebrick|light=o|mount=Naggy|mounttype=Trained|wimpy=45</var>
</cmud>



OH, Big Thank You
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Mar 25, 2009 6:50 am   
 
Hi Letitia,

I thought about this some more. Why don't you just set the window styles to have the background color you want instead of setting the background on the text you output?
_________________
Asati di tempari!
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Wed Mar 25, 2009 12:48 pm   
 
I changed the session window background to $1E2510 because I felt the default gray on black had an almost sharp contrast that could be improved.

Now when I change the foreground with a color, CMud does not recognize the new background, the results are a voided looking band that commands undesired attention. I wanted to make my own table of colors but have had only a little success.

http://home.comcast.net/~shibeka/CmudScreen.jpg

I like this olive BG as it is darker then the presets. Is there another way to avoid the black bands?

The color scheme here is off and designed for 'green hi' or 'chartuse' in ZMud.

As an aside, I just noticed my on-button color changed too since I used the beta yesterday morning. It may not be the beta though I think so at this point.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Mar 25, 2009 2:29 pm   
 
How exactly were you displaying the text that ended up in black bands?
It could be a Cmud bug, or it could be a problem in your code.
If you are simply defining a foreground color, the background color should not be changing.
So it may be more useful to track down this problem than play with resetting the background color yourself.
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Wed Mar 25, 2009 3:53 pm   
 
I'm not simply setting a foreground color, but a foreground on a background chosen from the 'pick other colors scheme'. I suppose you know this, so I will look for a problem.

entered on the command line:


Code:
#sh Test this simply;#co blue


And I got a black band, I'm pretty sure I tried a lot of things and concluded it was because I used the 'pick other colors scheme' and not the drop down. The dark colors in the drop down were not dark enough for me. I don't say I am right here, I would much rather there be no issue and a fix, and still I would be making a color scheme of my own.

My 'user styles' option is blank. I assume it is not implemented and have no real clue what should be there or is planned for that option.

Using foreground background is ok with me, btw, hopefully from a global db. I think I will use my DB at run time to make variables instead. Maybe alias would be good. Larkin did those I remember in ACP LE.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Mar 25, 2009 5:26 pm   
 
Ok.. i see what you mean. I would argue this is a bug in the #COLOR command because it's not respecting the chosen background color. If you were to do
Code:
#sh <color darkblue>Test this simply</color>

It works as expected.

[edit] I posted a bug report in the beta forums.
_________________
Asati di tempari!

Last edited by Tech on Wed Mar 25, 2009 5:34 pm; edited 1 time in total
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Wed Mar 25, 2009 5:30 pm   
 
#PRINT prints. :D

I get an error with
Code:
#sh <color darkblue>Test this simply</color>


It shows as code in the def text
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Wed Mar 25, 2009 5:41 pm   
 
Perhaps mine toggled something when the previous use of color failed, though I will reload the XML and then try the experiment from a blank session.

I am going with PRINT regardless
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Mar 25, 2009 6:05 pm   
 
Not sure what you mean... #PRINT works just fine for me. If you are using 3.05 make sure you have force Remote MXP enabled.
_________________
Asati di tempari!
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Wed Mar 25, 2009 8:03 pm   
 
That test:

Code:
#sh <color darkblue>Test this simply</color>


returned the same error that prompted this thread, #sh <color anything> would be output literally.

while

Code:
#print <color darkblue>Test this simply</color>


worked fine.

Force Remote MXP was not enabled, but I checked it. I also ran chkdsk

Now, what was that Force Remote MXP thing about please?
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Mar 25, 2009 10:07 pm   
 
That's why it's important to post your version as well.

#SHOW treats test as if it came directly from the MUD. And Force Remote MXP says you'll allow MXP commands/tags from the MUD. So this option needs to be set for it work with #SHOW.
_________________
Asati di tempari!
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Thu Mar 26, 2009 2:34 am   
 
Neat, TY
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