Set font color in message box?

bWolfie

I'm the man
Messages
850
Points
0
Location
Alberta, Midgard
Github
bWolfie
Emulator
Hello again Hercules,

I want to set a variable so when it is 1, it can appear in a message box next to writing in a 'mes' box. But I can't figure out how to make it work.

E.g.

I set my variable to 1.

set @color, 1;

And then whenever 

if (.color == 1) {
^00ff00;
}
else {
^ff0000;
}


It will appear in a message box like so:

if color is set to 1,

mes "" + @color + "This text is bright green^000000.";
This text is bright green.

if color is set to 0 (or anything else),
mes "" + @color + "This text is bright green^000000.";
This text is bright green.
Hope I explained it well enough. Any suggestions appreciated. Thank you.

 
Last edited by a moderator:
mes (@color?"^00ff00":"^ff0000") + "This text will change color depending if @color is set!^000000";

 
Last edited by a moderator:
there is function for this
 
https://github.com/HerculesWS/Hercules/blob/master/npc/other/Global_Functions.txt#L360" class="bbc_url" title="External link" rel="nofollow external">https://github.com/HerculesWS/Hercules/blob/master/npc/other/Global_Functions.txt#L360

Code:
//== Function F_MesColor ===================================
// Function to colorize npc dialog without having to memorize the color code
// Examples:
//    mes callfunc("F_MesColor", C_BLUE) +"This message is now in BLUE";
function	script	F_MesColor	{
	return sprintf("^X", min(getarg(0), 0xFFFFFF));
}
 
Sorry I should have explained what I'm trying to do better. I'm trying to make an npc which you can choose which buffs it gives and the buffs it will give you depends on what is active. The activity will be shown in red or green on a menu.

Error log says I am missing a parenthesis/bracket '(' ')' somewhere in this line.

Code:
.@selectbuff = select("^777777Return^000000:(@agicolor?"^cc0000":"^cc0000") +Increase Agility^000000:(@blessingcolor?"^cc0000":"^cc0000") +Blessing^000000");
 
Because ternary is an operator, and should be outside quotes :3

Code:
.@selectbuff = select("^777777Return^000000:" +(@agicolor?"^cc0000":"^cc0000") + "Increase Agility^000000:" +(@blessingcolor?"^cc0000":"^cc0000") + "Blessing^000000");
 
Thank god, I can finally see the light. Thanks for all the replies and taking your time to help me so far. I think I'm almost there.

Edit: Figured it out. 

 
Last edited by a moderator:
Back
Top