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

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: Texture dropper screen script
PostPosted: Thu Dec 18, 2008 9:06 am 
Furious Typer
User avatar

Joined: Sat Feb 02, 2008 10:02 pm
Posts: 104
Location: Romania, Bucharest
The screen script is an advanced and configurable script I made for setting up monitors and screens in which everyone can drop textures for displaying them. It allows displaying the name of the posted image and its creator, creators of images to lock / unlock paintings and claim them, easily rename the type of screen you have and other features. You can just configure the first values in the script and place it on a prim or object, allowing anyone to display pictures there whenever they want to.

This is one of the first scripts I made which is so complex, so if you find any glitches or issues in it please post about it here. I'd like to know if I scripted correctly or if I missed any methods or did something wrong from more advanced scripters. I tried to add solutions for all possible glitches but the script is complex enough to miss stuff. Also the code in the changed{ } event was created by Sm0key since I didn't know how to make that one, so the part about getting the inventory entry and setting the image on the prim is his.

{L_CODE}:
// **** Texture Dropper Screen v1.11, by Mircea Kitsune & Sm0key ****

// -------- Settings: --------
// Modify these to adjust the properties of your screen. Unless a specific value is required, use TRUE or FALSE.

integer face = 0; //Primitive face to be used as screen.
integer text = 2; //0 means no text, 1 displays lock status, 2 displays lock status and image + creator names. Selecting 2 clears the image between script restarts.
integer notices = TRUE; //Echo information such as locking / unlocking of the screen and error messages in-world.

integer lockdefault = FALSE; //Set to TRUE if the screen is to be locked by default. Relevant in the case of script restarts and when using the "clear" command.
integer lockonpost = FALSE; //If TRUE the screen is locked once someone posts the first picture in it, useful for 'find and claim' screens.
    integer creatorlock = TRUE; //When lockonpost is also TRUE, this allows the creator of the displayed image to lock / unlock or clear the screen.

string screenname = "screen"; //The name which best describes what your object is, used for info and text display (eg: screen, painting, monitor).
string sound = ""; //A sound to be played each time a new image is posted. Leave this string empty to disable sounds.
    float soundvol = 1; //Volume of the sound specified above, can be anything between 0 and 1.

// -------- Script: --------
// Modify anything below if you are a scripter and want to change something else in the script.

string ScriptName;
string InvName;
string InvCreator;
string Toucher;

string Blank = "5748decc-f629-461c-9a36-a35a221fe21f"; //UUID of the blank texture.
integer CmdChan = 9945; //System channel for llDialog.

default
{
    state_entry()
    {
        ScriptName = llGetScriptName();
        llPreloadSound(sound);
        if(text == 2) //Set texture to blank when names are used to avoid images with no names between script restarts.
        {
            llSetTexture(Blank, face);
            llPlaySound(sound, soundvol);
        }
        else if(text != 1 | text != 2)
        {
            llSetText("", <0,0,0>, 0);
        }
       
        if(lockdefault == TRUE)
        {
            state locked;
        }
        else
        {
            state unlocked;
        }
    }
}

state locked
{
    state_entry()
    {
        llAllowInventoryDrop(0);
        llListen(CmdChan, "", NULL_KEY, "" );
        if(notices == 1)
        {
            llSay(0, "The " + screenname + " is now locked.");
        }
       
        if(text == 2 & InvName != "")
        {
            llSetText("[" + screenname + " locked] - " + InvName + " by " + InvCreator, <1,0.5,0.5>, 1);
        }
        else if(text == 1 | text == 2 & InvName == "")
        {
            llSetText("[" + screenname + " locked]", <1,0.5,0.5>, 1);
        }
    }
   
    touch_start(integer avatar)
    {
        Toucher = llDetectedKey(0);
        llSetTimerEvent(15);
        if (Toucher == llGetOwner())
        {
            llDialog(llDetectedKey(0) , "You are the owner of this screen. What do you wish to do?", ["unlock", "clear"], CmdChan);
        }
        else if(lockonpost == TRUE & creatorlock == TRUE & llKey2Name(Toucher) == InvCreator)
        {
            llDialog(llDetectedKey(0) , "You have been identified as the creator of the currently posted image. What do you wish to do?", ["unlock", "clear"], CmdChan);
        }
        else
        {
            llSay(0, "The " + screenname + " is locked. The owner must first unlock it before you can display new pictures.");
        }
    }
   
    listen(integer channel, string name, key id, string message)
    {
        if(Toucher == llGetOwner() | lockonpost == TRUE & creatorlock == TRUE & llKey2Name(Toucher) == InvCreator)
        {
            Toucher = ""; //Protection so if an owner was the last to touch the object not anyone is able to manually chat an owner-only command on the channel.
            if(llToLower(message) == "unlock")
            {
                state unlocked;
            }
            if(llToLower(message) == "clear")
            {
                llSetTexture(Blank, face);
                llPlaySound(sound, soundvol);
                InvName = "";
                InvCreator = "";
                if(lockdefault == TRUE)
                {
                    llSetText("[" + screenname + " locked]", <1,0.5,0.5>, 1);
                }
                else
                {
                    state unlocked;
                }
            }               
        }
    }
   
    timer()
    {
        Toucher = ""; //Further protection so if an owner ignores the dialog the screen does not remain vulnerable for anyone to chat an owner-only command to.
        llSetTimerEvent(0);
    }
}

state unlocked
{
    state_entry()
    {
        llAllowInventoryDrop(1);
        llListen(CmdChan, "", NULL_KEY, "" );
        if(notices == 1)
        {
            llSay(0, "The " + screenname + " is now unlocked.");
        }
       
        if(text == 2 & InvName != "")
        {
            llSetText("[" + screenname + " unlocked] - " + InvName + " by " + InvCreator, <0.5,1,0.5>, 1);
        }
        else if(text == 1 | text == 2 & InvName == "")
        {
            llSetText("[" + screenname + " unlocked]", <0.5,1,0.5>, 1);
        }
    }
   
    changed(integer mask)
    {
        if(mask & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
        {
            if(llGetInventoryNumber(0)) //Texture dropped
            {
                InvName = llGetInventoryName(INVENTORY_TEXTURE, 0);
                key InvKey = llGetInventoryKey(InvName);
                InvCreator = llKey2Name(llGetInventoryCreator(InvName));
                llRemoveInventory(InvName);
                llSetTexture(InvKey, face);
                llPlaySound(sound, soundvol);
                if(lockonpost == TRUE)
                {
                    state locked;
                }
                else if(text == 2)
                {
                    llSetText("[" + screenname + " unlocked] - " + InvName + " by " + InvCreator, <0.5,1,0.5>, 1);
                }
            }
            else //Something else dropped
            {
                integer Items = llGetInventoryNumber(-1);
                do
                {
                    string InvName = llGetInventoryName(INVENTORY_ALL, --Items);
                    if (InvName != ScriptName & InvName != sound)
                    {
                        llRemoveInventory(InvName);
                        if(notices == 1)
                        {
                            llSay(0, "Error - Only textures may be dropped inside the " + screenname + ".");
                        }
                    }
                }
                while(Items);
            }
        }
    }
   
    touch_start(integer avatar)
    {
        Toucher = llDetectedKey(0);
        llSetTimerEvent(15);
        if (Toucher == llGetOwner())
        {
            llDialog(llDetectedKey(0) , "You are the owner of this screen. What do you wish to do?", ["lock", "clear"], CmdChan);
        }
        else if(lockonpost == TRUE & creatorlock == TRUE & llKey2Name(Toucher) == InvCreator)
        {
            llDialog(llDetectedKey(0) , "You have been identified as the creator of the currently posted image. What do you wish to do?", ["lock", "clear"], CmdChan);
        }
        else
        {
            llSay(0, "The " + screenname + " is unlocked. Control + drag textures onto it to display them.");
        }
    }
   
    listen(integer channel, string name, key id, string message)
    {
        if(Toucher == llGetOwner() | lockonpost == TRUE & creatorlock == TRUE & llKey2Name(Toucher) == InvCreator)
        {
            Toucher = ""; //Protection so if an owner was the last to touch the object not anyone is able to manually chat an owner-only command on the channel.
            if(llToLower(message) == "lock")
            {
                state locked;
            }
            if(llToLower(message) == "clear")
            {
                llSetTexture(Blank, face);
                llPlaySound(sound, soundvol);
                InvName = "";
                InvCreator = "";
                if(lockdefault == TRUE)
                {
                    state locked;
                }
                else
                {
                    llSetText("[" + screenname + " unlocked]", <0.5,1,0.5>, 1);
                }
            }               
        }
    }
   
    timer()
    {
        Toucher = ""; //Further protection so if an owner ignores the dialog the screen does not remain vulnerable for anyone to chat an owner-only command to.
        llSetTimerEvent(0);
    }
}


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