Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help from the script gods

Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
08-04-2004 10:51
Hi all,

I'm wanting to do a script that, on voice command, changes the texture of a list of prims but have no idea where to start.

I know texture change is possible as all the store vendors use that method to switch their displayed items when you click the arrows below their sales display.

The trick here is that I want to create a list, notecard, whatever, that has the list of prim names, and what texture they're supposed to have, then read from that and apply it when the proper voice command is issued.

This will allow me to use my store as my house when I need it (for entertaining ;) by saying something to the effect of "Store Closed" and all store items turn to blank alpha textures and the house item's textures go from invisible to what they are on the notecard. The reverse would happen when I said "Store Open".

Any ideas for a script newb?

Thanks!
Syn
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
08-04-2004 11:26
Make a pair of lists, one of commands, one of the textures you wish to set.

Use something like this:

CODE
integer command_position = llListFindList(command_list,[chat_message]);
if (command_position > -1)
{
llSetTexture(llList2String(texture_list, command_position);
}


This will set the texture to the corresponding entry in the texture list.
(So in a command list of ["foo","bar"], the corresponding texture list might look like ["foo_texture","bar_pic"]. See?
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
08-04-2004 11:42
yes, thank you Catherine.

One problem I've thought of though is that even though these objects will be invisible people will still bump into them & not know what's going on. So i either have to:
1) Set them for phantom dynamically

or

2) Scratch the whole idea & figure out a way to just drop them from inventory in particular positions when I need them, and then on voice command, put them back into inv. when the store opens.
Siobhan Taylor
Nemesis
Join date: 13 Aug 2003
Posts: 5,476
08-04-2004 11:58
to make them phantom ...

llSetStatus(STATUS_PHANTOM)

to make them appear at will

llRezObject()

to make them disappear ..

llDie()

look up the parameters in the Wiki... and have fun...
_____________________
http://siobhantaylor.wordpress.com/
Zak Escher
Builder and Scripter
Join date: 3 Aug 2003
Posts: 181
08-04-2004 12:03
Synergy, I'll have to say, this sounds like a very cool idea. Good luck getting it to work. It definitely sounds like it will be worth the effort.
_____________________
Zak Escher
Unity Shapes
http://slurl.com/secondlife/Hatteras%20Island/125/46/31
http://unityshapes.blogspot.com/
See what I have for sale at SLExchange
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
08-04-2004 12:14
Zak, thank you, wish me luck lol

Siobhan - some of these objects were store bought (like my bed) and not created by myself. So the permissions will be different depending on the object.

Will llDie() destroy objects permanently? I dont want to lose anything thats no-copy.
Siobhan Taylor
Nemesis
Join date: 13 Aug 2003
Posts: 5,476
08-04-2004 12:17
From: someone
Originally posted by Synergy Belvedere
Will llDie() destroy objects permanently? I dont want to lose anything thats no-copy.


Unfortunately, yes... don't use on no-copy objects.
_____________________
http://siobhantaylor.wordpress.com/
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
Re: Need help from the script gods
08-04-2004 13:11
From: someone
Originally posted by Synergy Belvedere
The trick here is that I want to create a list, notecard, whatever, that has the list of prim names, and what texture they're supposed to have, then read from that and apply it when the proper voice command is issued.


This part is quite a bit more arduous then you think. Unless you are willing to store the UUID or some other unique identifyer of the target objects, doing this will prove to be quite difficult.

What you *can* do, is have all the objects that will change texture via command have a script in them. This script will be quite simple, simply a llListen on a specific channel and then a llSetTexture to the message passed to the listen event.

The easiest thing for you to do, would be to have all the textures in the inventory of your "command prim" and have them *named* the command you will give. This allows you to get around two very inconveniant gotchas: The literal-list compiler limit and the script memory limit.

Here's the code for the script in the command prim:
CODE

// The word(s) you will say before a command. For example, if this is set to "texture "
// you will say "texture closed" if you want to issue the command "closed".
string TEXTURE_COMMAND_PREFIX = "texture ";

// Set this to a random number. This number is used
// as the channel to communicate with prims that will
// set their texture based on owner's command.
// This *must* be identical to the texture channel
// that is declared in the target prim's script.
integer TEXTURE_CHANNEL = 381274;

// Utility functions:
integer strStartsWith(string str, string prefix) {
return llSubStringIndex(str, prefix) == 0;
}

string removePrefixFrom(string str, string prefix) {
if (!(llSubStringIndex(str, prefix) == 0))
return str;

integer prefixLen = llStringLength(prefix);
return llDeleteSubString(str, 0, prefixLen - 1);
}

default {
state_entry() {
// Listen to the owner:
llListen(0, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string message) {
// If owner is giving command:
if (strStartsWith(message, TEXTURE_COMMAND_PREFIX)) {
string command = removePrefixFrom(message, TEXTURE_COMMAND_PREFIX);

// The command is the texture's name, get the texture's key.
key textureKey = llGetInventoryKey(command);

// If the texture is in inventory:
if (textureKey != NULL_KEY) {
llSay(TEXTURE_CHANNEL, (string) textureKey);
}
}
}
}


Here's the script that you put in the target prims:
CODE

// This number is used as the channel to communicate
// with the texture storage prim.
// This *must* be identical to the texture channel
// that is declared in the texture storage prim's script.
integer TEXTURE_CHANNEL = 381274;

default {
state_entry() {
// Listen to the texture storage/command prim:
llListen(TEXTURE_CHANNEL, "", NULL_KEY, "");
}

listen(integer channel, string name, key id, string message) {
// Set texture to the key in the message.
llSetTexture(message, ALL_SIDES);
}
}


Gah. After re-reading your message, this is *not* what you asked for.
The target prims do not store what texture they are "normally", so the dissappearing store cant be done with this (unless all your prims have the same texture).

Im on my way out atm, so Ill leave the script you're looking for to someone else. If it isnt posted before I get back, I'll write it up.
==Chris

EDIT: Removed unused global constant from latter script.
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
08-04-2004 14:16
Chris,
I'm awestruck lol. but you're right, it wouldnt work in my case as i'd be putting the target script in a pre-made (by someone else) bed, coffee table, chairs, sofa, etc.

Back on the idea of dragging these items out of inventory at a certain spot, could i create a command prim, store all of the objects in it along with a notecard that listed each object and it's position key (x,y,z coords). Then on command it would read the card and rez each object at its pre-defined position? This seems logical to me but I defer to the script gods in this forum.

My worry here is exactly how to get them back into that command prim, especially on the no-copy, no modify items.
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
09-03-2004 11:49
If there are no restrictions on placing homes at an elevated height in your sim, and you need a place for ...ahem... entertaining, why not build a room high enough that it would be out of the way, and then just put a teleporter in your shoppe which would listen to you or a set number of your friends. Then move all the non-store items that would have shared the same space to the "loft".
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Tiger Crossing
The Prim Maker
Join date: 18 Aug 2003
Posts: 1,560
09-03-2004 13:22
Yes you could have a script that rezzes objects from it's inventory on command, but once out there, it could not get rid of them unless you can modify each one to have a die command. You would also have to have copy privleges or once the object was rezed once, it would no longer be in the scripted rez-machine. There's no way for a script to "take" and object from the world, nor is there a function like llDie that returns the object to it's last inventory location. (llReturn would be needed, and it doesn't exist.)

So when it comes to no-copy, no-mod objects, there is little you can do to make them come and go. In fact, nothing short of moving it by hand.

If you made everything yourself, or have full permissions on everything, then there are several possibilites, as mentioned in the previous posts.
_____________________
~ Tiger Crossing
~ (Nonsanity)