Change font size
It is currently Sat Dec 15, 2018 2:16 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: Lucky Chair Script
PostPosted: Mon Nov 22, 2010 1:57 pm 
OSG Elite

Joined: Wed Aug 05, 2009 1:59 am
Posts: 417
Ye Olde Lucky Chair!!
Read the comments in the script for instructions.

{L_CODE}:
//Lucky Chair v2. this is an open source lucky chair script I moded, it is under CC NO SELLING!!!
//Here is the original notice, in the notecard accompanying the original script:
//
//"Creative Commons Attribution-Noncommercial-Share Alike 3.0 License. Read about it here:
//http://creativecommons.org/licenses/by-nc-sa/3.0/
//Thanks, and enjoy your Lucky Seat
//-- Nekow42 Zarf"
//So, you can give it away, but NO SELLING and most of thise script is not mine, it was made by him
//so he has been attributed right here here, do the same when you mod it please!

//Added by Poenald Palen - A menu to control mins, silent or whisper mode, switch on and off.
//Also code to display a pic of the object on link # 2 prim, face 3.
//All this is added under the same liscence, so share, attribute and do not sell this.

//Adapted to work in Opensim by Oddball Otoole


//How to use.

//1. Rez a "chair" or any object to animate with/on/ around.

//2. Check the object has a regular upright prim, not a prim that has been rotated etc. but
//if you want you can make the sit target roated etc., for most applications it is easier to
//start with a "upright" prim.

//3. Add a board prim, made from a box, to the object and you MUST link it as the second prim. So delink the root,
//then link this one and finally the root prim linked will give you the panal as second prim.
//This is the display for whatever product there is as a prize.

//4. This version has a display for products, so organize your pics and rename them to the
//exact same name as the object they are of BUT, add the letters 'PIC' to the end.
//But no the ' ' parts!

//5. Add all the stuff to the lucky objects inventory.

//6. Test it out! Look up above for instructions on linking the display.

//7. Set the sit target and rename al the stuff you need to rename variables like animation
//poofer texture name(if any, you can leave it blank) and all the stuff you wish to change.


//////////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

//Don't mess with the below, not worth it unless you know some lsl.
list letters = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0"];
string currentLetter;
integer countDown;
string InventoryToGive;//Variable for the Prize to be put in.
string ItemPIC;//Variable for teh current prizes picture to load.
string clicker;//Person clicking the menu, this is to compare to llGetOwner, make sure clicker is owner.
integer MenuChan = -99;//Channel the menu buttons chat flies accross back to the listen state to use.
list menu = ["Minutes", "Silent", "Off"];//Default menu.
integer listener;//the listening state is toggled to reduce lag as it turns off when not needed. Stop it form checking ALL chat on that channel.
vector SitVec = <-0.5, 0.0, 0.58>;
rotation SitRot = <0,0,2,0>;

//You can change the stuff below with little trouble
integer Silence = 0;//toggle setting holder for silent running or whisper of prize and letter info.
string OffTextr = "OffLine";//This is your offline texture name. When chair is off this displays.
list RemMenu = menu;//The "memory' variable to store what version of themenu button names where in
//use before state cahnges or whatever.
string PoofTextr = "WinnerPoof";
integer SetTimeT = 10;//Default time, if script resets etc. Yo cahnge by clicking the menu, but
//if there is a problem and teh script resets, this is the default.


updateParticles()//Paarticle poofer to poof a bit of stuff for celebration
{
llParticleSystem([0,256,1,<1.0,1.0,1.0>,2,1.0,5,<1,1,1>,7,8.0,9,2,12,"fractal poof",13,0.1,15,12,17,0.5,18,0.5,19,2.0]);
llSleep(2.5);
llParticleSystem([]);
}

////////////Beow is the actually scripts working stuff, teh states and events. Above is functisn and variables.\\\\\\\\\\\

default
{
state_entry()
{
listener = llListen(MenuChan, "", NULL_KEY, "");///Asigning this so it can be switched!

llListenRemove(listener);//Dont need it yet, so turn it off!
menu = RemMenu;//setting the menu mem for state cahnges to keep buttons right!

countDown = SetTimeT;//The timer is set
llSitTarget(SitVec, SitRot); //Adjust this for different chairs


currentLetter = llList2String(letters, (integer) llFrand (36.0)); //Pick a letter
InventoryToGive = llGetInventoryName(INVENTORY_OBJECT, (integer) llFrand (llGetInventoryNumber(INVENTORY_OBJECT)));
menu = ["Minutes", "Whisper", "Off"];

if(Silence == 1)
{
llWhisper(0,"Now looking for an Avatar with a name that begins with " + currentLetter + " and the prize is: " + InventoryToGive);
menu = ["Minutes", "Silent", "Off"];
}
ItemPIC = InventoryToGive + "PIC";


llSetLinkTexture(2, ItemPIC, 3);

countDown = SetTimeT;
llSetText("Lucky seat!Prize if you have the right names\nLooking for avatar\n with a name starting with " + currentLetter + "\n Letter will change ~" + (string)countDown + " minutes. \n The prize is: " + InventoryToGive, <1,1,1>, 2.5);
llSetTimerEvent(60);

}


touch_start(integer clicked)
{
//open listen
//check owner
llListen(MenuChan, "", NULL_KEY, "");
clicker = (string)llDetectedKey(0);
if(clicker == (string)llGetOwner())
{
llOwnerSay("Main menu should open, owner has clicked this to enable setup mode.");
llDialog(clicker, "Select administrative options by clicking the buttons below. ", menu, MenuChan);

//launch dialog with options and STOP CHAIR and go into set up mode(turn it read and unsit?)
}
}
listen(integer MenuChan, string name, key id, string message)
{

if(message == "Silent")
{
Silence = 0;
menu = ["Minutes", "Whisper", "Off"];
llOwnerSay("Silent Mode enabled");
}
if(message == "Whisper")
{
Silence = 1;
menu = ["Minutes", "Silent", "Off"];
llOwnerSay("Whisper Mode enabled");
}

if(message == "Off")
{
RemMenu = menu;
state Off;

}

if(message == "Minutes")
{


if(id == (key)llGetOwner())
{

state SetTime;
}

}
}




changed(integer change) {
if (change & CHANGED_LINK) {
key sitter = llAvatarOnSitTarget();
if (sitter != NULL_KEY) //If sat on...
{
if (llToUpper(llGetSubString(llKey2Name(sitter),0,0)) == currentLetter) //And if the name is the same...
{
llGiveInventory(sitter, InventoryToGive); //Give a random inventory item
llWhisper(0,"Congratulations! " + llKey2Name(sitter) + " just won a " + InventoryToGive);
updateParticles();
currentLetter = llList2String(letters, (integer) llFrand (36.0)); //Pick a letter
InventoryToGive = llGetInventoryName(INVENTORY_OBJECT, (integer) llFrand (llGetInventoryNumber(INVENTORY_OBJECT)));



if(Silence == 1)
{
llWhisper(0,"Now looking for an Avatar with a name that begins with " + currentLetter + " and the prize is: " + InventoryToGive);
}

ItemPIC = InventoryToGive + "PIC";

llSetLinkTexture(2, ItemPIC, 3);
llSetText("Lucky seat!Prize if you have the right names\nLooking for avatar\n with a name starting with " + currentLetter + "\n Letter will change ~" + (string)countDown + " minutes. \n The prize is: " + InventoryToGive, <1,1,1>, 1.5);
}
else
{
llWhisper(0,"Your name does not begin with " + currentLetter);
}
llSleep(3);
llUnSit(sitter);
}
}
}


timer()
{
countDown = countDown - 1;
if (countDown <= 0)
{
countDown = SetTimeT;
currentLetter = llList2String(letters, (integer) llFrand (36.0)); //Pick a letter
InventoryToGive = llGetInventoryName(INVENTORY_OBJECT, (integer) llFrand (llGetInventoryNumber(INVENTORY_OBJECT)));


if(Silence == 1)
{
llWhisper(0,"Now looking for an Avatar with a name that begins with " + currentLetter + " and the prize is: " + InventoryToGive);
}


ItemPIC = InventoryToGive + "PIC";

llSetLinkTexture(2, ItemPIC, 3);

llSetText("Lucky seat!Prize if you have the right names\nLooking for avatar\n with a name starting with " + currentLetter + "\n Letter will change ~" + (string)countDown + " minutes. \n The prize is: " + InventoryToGive, <1,1,1>, 1.5);

}
}
}


state SetTime
{
state_entry()
{
llSay(0, "Just type in the number of minutes, no partial/fractions/decimals please.");
llSetLinkTexture(2, OffTextr, 3);
listener = llListen(0, "", NULL_KEY, "");

llSetText("Off Until you type in the number of minutes you want.", <1,0,0>, 1.5);



}



listen(integer channel, string name, key id, string message)
{
if(id == llGetOwner())
{

if((integer)message < 1){message = "1";}
SetTimeT = (integer)message;
countDown = SetTimeT;

llSay(0, "you set the time between gift change to " +message + " .");
llListenRemove(listener);
state default;
}
}
}


state Off
{
state_entry()
{
llSetLinkTexture(2, OffTextr, 3);
integer listener = llListen(MenuChan, "", NULL_KEY, "");

llListenRemove(listener);


llSetText("Sorry, this is turned Off.", <1,0,0>, 1.5);
menu = ["On"];

}
touch_start(integer clicked)
{
llListen(MenuChan, "", NULL_KEY, "");
clicker = (string)llDetectedKey(0);
llDialog(clicker, "Select administrative options by clicking the buttons below. ", menu, MenuChan);
if(clicker == (string)llGetOwner())
{
llOwnerSay("Main menu should open, owner has clicked this to enable setup mode.");

}
}


listen(integer MenuChan, string name, key id, string message)
{
if(message == "On")
{
state default;
}

}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]


Who is online

Users browsing this forum: legacy_google [bot] and 2 guests


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 post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net