bWolfie 139 Posted April 12, 2016 (edited) 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. Edited April 12, 2016 by True Zeal Quote Share this post Link to post Share on other sites
0 Garr 117 Posted April 12, 2016 (edited) mes (@color?"^00ff00":"^ff0000") + "This text will change color depending if @color is set!^000000"; Edited April 12, 2016 by Garr Quote Share this post Link to post Share on other sites
0 bWolfie 139 Posted April 12, 2016 Thank you for the quick response, really appreciate it. Quote Share this post Link to post Share on other sites
0 Litro 45 Posted April 12, 2016 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 //== 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)); } Quote Share this post Link to post Share on other sites
0 bWolfie 139 Posted April 12, 2016 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. .@selectbuff = select("^777777Return^000000:(@agicolor?"^cc0000":"^cc0000") +Increase Agility^000000:(@blessingcolor?"^cc0000":"^cc0000") +Blessing^000000"); Quote Share this post Link to post Share on other sites
0 Garr 117 Posted April 12, 2016 Because ternary is an operator, and should be outside quotes :3 .@selectbuff = select("^777777Return^000000:" +(@agicolor?"^cc0000":"^cc0000") + "Increase Agility^000000:" +(@blessingcolor?"^cc0000":"^cc0000") + "Blessing^000000"); Quote Share this post Link to post Share on other sites
0 bWolfie 139 Posted April 12, 2016 (edited) 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. Edited April 12, 2016 by True Zeal Quote Share this post Link to post Share on other sites
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.
And then whenever
It will appear in a message box like so:
if color is set to 1,
This text is bright green.
This text is bright green.
Hope I explained it well enough. Any suggestions appreciated. Thank you.
Edited by True ZealShare this post
Link to post
Share on other sites