Initial upload
Initial upload
This commit is contained in:
78
module/nss/coloritemrandom.nss
Normal file
78
module/nss/coloritemrandom.nss
Normal file
@@ -0,0 +1,78 @@
|
||||
//Script Name: coloritemrandom
|
||||
////////////////////////////////////////////////
|
||||
//Created by: Genisys / Guile
|
||||
//ON: 6/17/08
|
||||
////////////////////////////////////////////////
|
||||
/* **Notes**
|
||||
|
||||
This script goes in the ActionTaken
|
||||
event of the coloritemconv conversation
|
||||
on the line which allow the player to
|
||||
select a random color for their item.
|
||||
*/
|
||||
////////////////////////////////////////////////
|
||||
|
||||
//WARNING: DO NOT TOUCH THE STRINGS BELOW THIS LINE!!!
|
||||
const string COLORTOKEN = " ##################$%&'()*+,-./0123456789:;;==?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[]^_`abcdefghijklmnopqrstuvwxyz{|}~~<7E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
||||
|
||||
// returns a properly color-coded string based on specified RGB values
|
||||
string ColorString(int nRed=255, int nGreen=255, int nBlue=255)
|
||||
{
|
||||
return "<c" + GetSubString(COLORTOKEN, nRed, 1) + GetSubString(COLORTOKEN, nGreen, 1) + GetSubString(COLORTOKEN, nBlue, 1) + ">";
|
||||
}
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
//Main Script//
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
//Define Major Variables
|
||||
object oPC = GetPCSpeaker();
|
||||
string sName = GetLocalString(oPC, "ONNC");
|
||||
string sMod;
|
||||
string sToken;
|
||||
string sNew;
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
|
||||
object oItem;
|
||||
|
||||
//Cycle through thier inventory to find the proper item(s)
|
||||
oItem = GetFirstItemInInventory(oPC);
|
||||
while(GetIsObjectValid(oItem)==TRUE)
|
||||
{
|
||||
//Change all items with the same name to a different color
|
||||
if(GetName(oItem)==sName)
|
||||
{
|
||||
//Let's make sure it doesn't already have a color on it!!!
|
||||
if(GetStringLeft(sName, 2)=="<c")
|
||||
{
|
||||
//Get the original name without the color strings!
|
||||
sMod = GetSubString(sName, 6, 40);
|
||||
}
|
||||
else
|
||||
{
|
||||
sMod = sName;
|
||||
}
|
||||
|
||||
a = Random(255); b = Random(255); c = Random(255);
|
||||
//This color value will change EVERY time an item is selected.
|
||||
sToken = ColorString(a,b,c);
|
||||
|
||||
//The new name of item (Color + Original Name)
|
||||
sNew = sToken + sMod;
|
||||
|
||||
//Change the name to include color..
|
||||
SetName(oItem, sNew);
|
||||
}
|
||||
|
||||
oItem = GetNextItemInInventory(oPC);
|
||||
}
|
||||
|
||||
//Remove the variables from the PC
|
||||
DelayCommand(2.2, DeleteLocalString(oPC, "ONNC"));
|
||||
|
||||
//Main Script End
|
||||
}
|
||||
Reference in New Issue
Block a user