Custom Tokens
#1
Posté 03 juin 2011 - 05:24
#2
Posté 03 juin 2011 - 06:55
OnModuleLoad
#include "mod_color"
void main()
{
string sDesc = ""; //
GiveGoldToCreature(GetFirstPC(), 1); // //
int r=0,g=0,b=0;
while (r+g+b != 27)
{
sDesc += ColorString("XXXXXX\\n", r*25+30, g*25+30, b*25+30, 1); //
SetCustomToken(6000 + r*100 + g*10 + b*1, ColorString("", r*25+30, g*25+30, b*25+30));
if ((g == 9) && (b == 9)) {r++; g=0; b=0;}
else if ((b == 9)) { g++; b=0;}
else { b++;}
}
GiveGoldToCreature(GetFirstPC(), 2); // //
SetCustomToken(7000, "</c>");
SetDescription(GetObjectByTag("thechest"), sDesc); //
}mod_color
const string COLORTOKEN = " ##################$%&'()*+,-./0123456789:;;==?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[]^_`abcdefghijklmnopqrstuvwxyz{|}~~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¡¢£¤¥¦§¨©ª«¬¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþþ";
// returns a properly color-coded sText string based on specified RGB values
// ends color mode after sText if iEnd = 1
string ColorString(string sText, int nRed=255, int nGreen=255, int nBlue=255, int iEnd = 0);
string ColorString(string sText, int nRed=255, int nGreen=255, int nBlue=255, int iEnd = 0)
{
string sEnd = "";
if (iEnd = 1) {sEnd = "</c>";}
return "<c" + GetSubString(COLORTOKEN, nRed, 1) + GetSubString(COLORTOKEN, nGreen, 1) + GetSubString(COLORTOKEN, nBlue, 1) + ">" + sText + sEnd;
}Im not getting the 1 or 2 gold I put in the script for testing.
Modifié par Xardex, 03 juin 2011 - 06:59 .
#3
Posté 03 juin 2011 - 08:35
Funky
#4
Posté 04 juin 2011 - 04:38
FunkySwerve wrote...
GetFirstPC won't return OBJECT_INVALID on modload - there are no pcs.
Funky
fixed.. =D
#5
Posté 04 juin 2011 - 04:51
FunkySwerve wrote...
GetFirstPC won't return valid on modload - there are no pcs.
Funky
_Guile wrote...
FunkySwerve wrote...
GetFirstPC won't return OBJECT_INVALID on modload - there are no pcs.
Funky
fixed.. =D
I do not know what you think you fixed _Guile. Funky's ststment is correct. GetFirstPC will not return valid object on mod load.
Your fix of his statment is 100% incorrect. Since it will return OBJECT_INVALID every time in the on mod load event.
#6
Posté 04 juin 2011 - 08:12
To make it easier to grasp ill explain what it is supposed to do...
Basically go through 1000 colors, set tokens 6000-6999, so custom token 6900 would be brightred, 6040 dark green... (6RGB)
void SetColors()
{
string sDesc = ""; //
int r=0,g=0,b=0,n=0;
while (n != 1000)
{
sDesc += ColorString("XXXXXX\\n", r*25+30, g*25+30, b*25+30, 1); //
SetCustomToken(6000 + r*100 + g*10 + b*1, ColorString("", r*25+30, g*25+30, b*25+30));
if ((g == 9) && (b == 9)) {r++; g=0; b=0;}
else if ((b == 9)) { g++; b=0;}
else { b++;}
n++;
}
SetCustomToken(7000, "</c>");
SetDescription(GetObjectByTag("thechest"), sDesc); //
}Color string is the same as above... Cant figure it out.
Also about the performance of having lots of custom tokens..?
Modifié par Xardex, 04 juin 2011 - 08:14 .
#7
Posté 04 juin 2011 - 08:20
n++ -> n+=10and it works. Too bad its not enough...
1000 loops? seriously?
#8
Posté 04 juin 2011 - 08:35
So I reduced the amount of color intensities to 3 per color, which makes a total of 27 colors. And what is this? Exactly same amount of lag.
Switched back to 1000 varieties AND NO LAG?
What the hell?
but this is just ... IMPOSSIBLE!
It seems that it randomly lags like there is no tomorrow, or not at all.
#9
Posté 04 juin 2011 - 08:52
// FILE: x3_inc_string FUNCTION: StringToRGBString()
//
// This function will make sString be the specified color
// as specified in sRGB. RGB is the Red, Green, and Blue
// components of the color. Each color can have a value from
// 0 to 7.
// Ex: red == "700"
// green == "070"
// blue == "007"
// white == "777"
// black == "000"
// The STRING_COLOR_* constants may be used for sRGB.
string StringToRGBString(string sString, string sRGB);
Or is there a perpose here that I am missing.
As far as setting the tokens I do not see a performance problem with setting them one time on ModLoad.
The To Many Instructions error does not really care about how many loops there are in the script. It is how many instructions are executed. The limit is around 16000 if what I havew heard is right. But then again I do not know if that is machine instructions or number of instructions being fed to the script interperter. Or where the blocking for the count is.
I just do not know what you need to set all the tokens for that the above function will not handle.
#10
Posté 04 juin 2011 - 09:19
The script works now, and it does actually lag if I set 1000 tokens. (Not just momentarily, it persists)
Im going with the 27 colors, it doesn't lag at all and the reason it lagged earlier was propably because I forgot to compile my stuff.
I might have used that nwn's own thingy but I didn't even know it existed. Anyhow, im good with the one I got from... somewhere... + It offers a wider spectrum of colors.
Thanks though, you are most helpful as usual.
Modifié par Xardex, 04 juin 2011 - 09:19 .





Retour en haut






