Noob help please :) - SLUniverse Forums
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » Noob help please :)


Scripting Discuss scripting and programming for SL and other platforms

 
Reply
 
LinkBack Thread Tools Display Modes
Old 01-10-2012, 07:38 PM   #1 (permalink)
Junior Member
Sleepy
 
Join Date: Jan 2012
Location: Illinois
Posts: 2
My Mood:
Business: The Artificers Workshoppe
Client: Phoenix and Firestorm
Noob help please :)

I have this script

Code:
list Access = ["player name, player name"]; 

vector scale = <1,1,1>;//scale of the texture
vector offset = <0,0,0>;//offset of the texture
float rot = 0;//rotation of the texture
string gCard;
integer gLine;
key gLineKey;
integer numberoftextures;//number of textures in inventory
integer currenttexture;//inventory number of current texture

changetexture()//user fucntion to change texture;
{
    string texture = llGetInventoryName(INVENTORY_TEXTURE,currenttexture);//gets texture key
    //PRIM_TEXTURE:integer face, string name, vector repeats, vector offsets, float rotation
    llSetLinkPrimitiveParams(LINK_SET,[PRIM_TEXTURE,ALL_SIDES, texture, scale, offset, rot]);
}

default
{
    state_entry()
    {
        if (llGetInventoryNumber(INVENTORY_NOTECARD))
        {
            Access = []; // Clears internal Access list, prepares for external list
            gCard = llGetInventoryName(INVENTORY_NOTECARD,0); // Read from the first notecard in inventory
            gLine = 0; // Start with the first line
            gLineKey = llGetNotecardLine(gCard,gLine); // Queue a "read" request for the dataserver event
        }
        else
        {
            llOwnerSay("There's no configuration notecard in inventory. Using internal access list as default.");
            // Access will be read from the list at the top of this script
        }            
    }

    dataserver(key qID, string data)
    {
        if(qID == gLineKey) // If this really is a request from this script
        {
            if(data != EOF) // And if there's a line to read
            {
                Access += [data]; // Add the data from this line to the Access list
                ++gLine; // Advance to the next line
                gLineKey = llGetNotecardLine(gCard,gLine); // And queue a new "read" request for the dataserver
            }
        }
    }

    changed (integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            llResetScript();
        }
    }

    touch_start(integer total_number)
    {
        numberoftextures = llGetInventoryNumber(INVENTORY_TEXTURE);
        ++currenttexture;
        if(currenttexture == numberoftextures)
            currenttexture = 0;
        if (llDetectedKey(0) == llGetOwner() || ~llListFindList(Access, [llDetectedName(0)]))
            changetexture();
        else
            llSay(0,"Only those on the list can change me.");
    }
}
I love this script but was wondering if there was an easy way to add in a drop down menu to select the textures instead of clicking on the prim and having it randomly cycle through them. (Found this script in the forums a while ago curtsey of Rolig Loon)

Thank you in advance
Jenelle is offline   Reply With Quote
Old 01-11-2012, 12:58 AM   #2 (permalink)
That Bitch

*SLU Supporter*
 
Void's Avatar
Innocent as far as you know
 
Join Date: Nov 2011
Location: Online
Posts: 8,820
My Mood:
SL Join Date: late 04 original account, mid 05 current
easy? depends on how you feel about building a list of all the textures in contents, and then updating it as needed. also depends on if you want to use just numbers or name in contents (requires santization) or some sort of friendly names.

something like this would need to be in the state_entry to build the texture list
Code:
integer vIntCnt = llGetInventoryNumber( INVENTORY_TEXTURE );
while (vIntCnt--){
    vLstMnu = [llGetSubString( llGetInventoryName( INVENTORY_TEXTURE, --vIntCnt ), 0, 24 )] + vLstMnu;
}
then you could add in the dialog pagination code found here and use the index you get back in the listen to select the texture to use
__________________
- These eyes can do more than see
Quote:
Originally Posted by Cajsa Lilliehook View Post
It's not enough to care about liberty if the only liberty you care about is your own.
Quote:
Originally Posted by Jupiter Firelyte View Post
Why doesn't anyone ever ask, "What is the real meaning of the winter solstice?"
Quote:
Originally Posted by Eboni Khan View Post
Thanks for being passive agressive.
Void is offline   Reply With Quote
Old 01-13-2012, 08:51 AM   #3 (permalink)
Not as dumb as I look
 
Rolig Loon's Avatar
More coffee, please
 
Join Date: Sep 2009
Location: In a TP
Posts: 226
SL Join Date: March 2007
If you want to look at a script that uses Void's dialog pagination code to do the sort of job you are asking about, see Dialog Choices from Numbered Buttons - Second Life . The dialog lists in that one are built from data read off notecards, but could as easily be built in exactly the way Void described.

/me waves at Void
__________________
I'm awake ... I think.

Look for my scripted tools and my mesh items for the home and garden in SL's Marketplace at https://marketplace.secondlife.com/stores/12305
Rolig Loon is offline   Reply With Quote
Old 01-13-2012, 10:13 AM   #4 (permalink)
That Bitch

*SLU Supporter*
 
Void's Avatar
Innocent as far as you know
 
Join Date: Nov 2011
Location: Online
Posts: 8,820
My Mood:
SL Join Date: late 04 original account, mid 05 current
:: waves back ::
Void is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On