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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Tue Jun 13, 2006 7:11 pm   

Figuring out Literal
 
ZMUD CODE

Code:

%literal("%-4")


Shows %-4

If i change it to just %-4 it shows NAME: Tamlin with right colors
If i change it to %literal(%-4) it shows %-4

Can someone play with this and see if they can get it to show the following

SHOULD BE %ansi(bold,white)Name: %ansi(bold,green) @Name

Anyone got a clue how to make it show the Ansi String Literally. I have tried a bunch of things.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Tue Jun 13, 2006 8:01 pm   
 
So, you're passing in a parameter to be evaluated and you want to display it as the raw, unexpanded value, but not as the actual parameter name?

I'm not saying this is what works. I'm trying to understand what you're doing. It's more like pseudo-code than real code.
Code:
#ALIAS test {#show %-1}

Code:
test %ansi(bold,white)Name: %ansi(bold,green) @Name

And you want to see if output the string "%ansi(bold,white)Name: %ansi(bold,green) @Name" exactly like that?

You'd likely have to figure out what combination of {}, (), or "" you need to get it passed and shown properly.
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Tue Jun 13, 2006 8:08 pm   
 
YOu have it correct i want it not to show the NAME: Tamlin in colors i want to see %ANSI ETC. I am currently in the middle of trying to figure this out myself so any help would be wonderful. Its a key element to one of my most used scripts

What confuses me is this is exactly the point of the %literal command. Instead now it doesnt expand the variable and process it literally it processes the command between the () literally

#VAR PASSED
#ECHO %LITERAL(@TEST)

Will show
@TEST instead of PASSED

Its not just complex functions its even simple ones lol
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Tue Jun 13, 2006 8:29 pm   
 
It may not help you, depending on all that you're doing with this, but I found that if you just put double quotes around the argument you pass into your alias it will prevent expansion. Putting the quotes on it inside the alias is too late because it will prevent expansion of the %-1 instead.
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Tue Jun 13, 2006 9:10 pm   
 
Im trying the same thing now its just a painful script to migrate as that problem is creating other problems lol im gonna end up rewriting the whole thing from scratch i can see it.
_________________
Confucious say "Bugs in Programs need Hammer"
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jun 14, 2006 1:45 am   
 
I am pretty sure Zugg said that the %[b]-/[b]xx syntax was being removed in CMud. Try using the %params function that was designed to replace the older method.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Wed Jun 14, 2006 2:04 am   
 
#VAR PASSED
#ECHO %LITERAL(@TEST)

Will show
@TEST instead of PASSED


I dont think this has anoything to do with that vigilante but i might be wrong :)
_________________
Confucious say "Bugs in Programs need Hammer"
Reply with quote
Rainchild
Wizard


Joined: 10 Oct 2000
Posts: 1551
Location: Australia

PostPosted: Wed Jun 14, 2006 2:16 am   
 
The definition of %literal() is: Return the parameters untouched by any expansion or evaluation.

Maybe you want %expand() or am I reading this wrong?
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Wed Jun 14, 2006 2:20 am   
 
Yeah in ZMUD
it would have shown passed not @test

Heres the thing in MY variable its this
#VAR HP %ANSI(green)HP:
IN ZMUD
%literal(@HP) --> %ansi(green)HP:
IN CMUD
%literal(@HP) --> @HP
if i do what was suggested with the "" it works but it shows HP: in green instead of the ansi code which is what literal was supposed to do. Show the variable without parsing it.

In any case i have gotten past that point. I am about to make a post with the script cause im having a few other problems and need another set of eyes.
_________________
Confucious say "Bugs in Programs need Hammer"
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jun 14, 2006 2:30 am   
 
Actually "#ECHO %literal(@Test)" should display "@Test" in both CMud and zMud. It would seem that CMud corrected some sort of old hidden bug in the scripting engine.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Wed Jun 14, 2006 2:38 am   
 
First you need to assign the variable with either inverted comas surrounding the definition or using the %literal() function:
Code:
#var HP "%ansi(green)HP:"
or
#var HP %literal(%ansi(green)HP:)
otherwise it seems that CMUD will evaluate the variable before defining it even if you use curling brackets. Secondly instead of using %literal() you need to place { } around the variable name to allow expansion but prevent evaluation
Code:
{@HP}
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Wed Jun 14, 2006 2:55 am   
 
I will test that out ceres thank you.

It also seems that even if i get %ansi(green)HP: into a variable that way
The status window cant properly play with it. Putting %ANSI(GREEN)HP: into the status window leaves it as %ansi(green) HP: instead of parsing it in the status window.

I am going to have to think of another way to play with my status windows quite possibly. Lol this is the part i LOVE. I knew i was going to have to redo a bunch and now i have challenges WHEE. Might be time to convert it to MXP commands which i have been dreading for quite a while :P
Reply with quote
Ceres
Wanderer


Joined: 25 May 2006
Posts: 88

PostPosted: Wed Jun 14, 2006 2:58 am   
 
I think you will have to leave the status window for now as I recall another post which stated that the status window was not currently working as it should be .. no colour or expansion of variables.
Reply with quote
Rainchild
Wizard


Joined: 10 Oct 2000
Posts: 1551
Location: Australia

PostPosted: Wed Jun 14, 2006 2:59 am   
 
I think the status window is just displaying text 'as is', at least I couldn't get it to expand any of the text I threw at it so just put it on the 'will figure this out after Zugg gets back' list :)
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Wed Jun 14, 2006 3:00 am   
 
Yeah well i have color i figured out how to make it work using expand and a variable containing the ESCAPE ANSI CODES>

However this worked also

#STWIN {%ansi(Green)HP:}

which i have been trying all day and finally i musta got something right cause it took straight away. Go Figure

As did this wth :P now its working

#STWIN {+} {~<Color Red~>Level:<~/COLOR~>}
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Wed Jun 14, 2006 3:02 am   
 
I am going to post up some script for you guys to look at its a conversion of the charbal status window extender as i use it in my scripts i am in the middle of rewriting it though so please bear with me.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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