need a couple basic scripts
|
|
Trout Recreant
Public Enemy No. 1
Join date: 24 Jul 2007
Posts: 4,873
|
08-30-2008 12:59
Sorry for the dumb question - I know this is kindergarten level scripting for you guys. I checked the library, but my search fu must be weak.
I'm looking for two scripts to put in objects I've made.
1) a simple lid lift script for a box I made, where if you click on it, the box opens and closes. I assume I'd put it in the lid.
2) A script where by clicking on the object, it gives you one of several textures I've placed in the item. It would be cool if it did it sequentially, so every time you click, it gives you a different one and then just cycles through them.
Does anyone know where I can get something like that?
Thanks!
_____________________
From: Jerboa Haystack A Trout Rating (tm) is something to cherish. To flaunt and be proud of. It is something all women should aspire to obtain!
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
08-30-2008 13:11
The first one is generally done by having two prims, one the box lid when open and one when closed. At any one time, one of them is set to full alpha. (At least, if the physical structure of the box doesn't matter all that much - if it's a huge box and people might fly into the transparent lid when it's closed, you might want to physically move the lid instead of having two of them, but that's a more advanced topic.) One can actually just have one central script which changes the alpha values in subprims. The second is quite easy and I can just do that right here and now... let me see... integer gTexture = 0;
default { touch_start(integer n) { llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_TEXTURE, gTexture++)); if (gTexture >= llGetInventoryNumber(INVENTORY_TEXTURE)) gTexture = 0; } }
That will cycle through all of the textures in the object's inventory and loop around at the end.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Trout Recreant
Public Enemy No. 1
Join date: 24 Jul 2007
Posts: 4,873
|
08-30-2008 13:18
Thanks Ordinal! That's exactly what I needed. I guess I thought that for some reason the lid one was a script that just repositioned the box lid. The box is pretty small and it's designed to sit on a desktop/table/whatever, so nobody is going to crash onto it.
I appreciate the help.
_____________________
From: Jerboa Haystack A Trout Rating (tm) is something to cherish. To flaunt and be proud of. It is something all women should aspire to obtain!
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
08-30-2008 13:26
This is probably a little over the top for the box lid but, well, why not? // Box open/closed on touch script // Ordinal Malaprop // 30 August 2008
// Put this in the root prim of an object, and have two subprims to // represent the open and closed lids.
//--------------------------------------------------------------------- // Globals and constants
// The names of the prims representing the lid in open and closed positions // You can change these. string NAME_OPEN = "lid open"; string NAME_CLOSED = "lid closed";
// Don't change any of this stuff integer gOpen = -1; integer gOpenLink = 0; integer gClosedLink = 0;
//--------------------------------------------------------------------- // Functions
update_links() { // Look through all of the prims in the object and pick out the // link numbers of the prims called "lid open" and "lid closed". gOpenLink = 0; gClosedLink = 0; integer f = llGetNumberOfPrims() - 1; do { string name = llGetLinkName(f); if (name == "lid open") gOpenLink = f; else if (name == "lid closed") gClosedLink = f; } while (--f > 0 && (gOpenLink == 0 || gClosedLink == 0)); if (gOpenLink == 0 || gClosedLink == 0) llOwnerSay("ERROR - this link set needs to have prims called '" + NAME_OPEN + "' and '" + NAME_CLOSED + "'. Edit names and reset."); }
update_lid(integer open) { if (gOpenLink == 0 || gClosedLink == 0) llSay(0, "This box hasn't been set up correctly."); else if (open != gOpen) { if (open) { llSetLinkAlpha(gClosedLink, 0.0, ALL_SIDES); llSetLinkAlpha(gOpenLink, 1.0, ALL_SIDES); } else { llSetLinkAlpha(gOpenLink, 0.0, ALL_SIDES); llSetLinkAlpha(gClosedLink, 1.0, ALL_SIDES); } gOpen = open; // update open status } }
//--------------------------------------------------------------------- // Main
default { state_entry() { update_links(); llOwnerSay(llGetScriptName() + " ready"); }
changed(integer change) { if (change & CHANGED_LINK) { update_links(); } }
touch_start(integer n) { // Only respond to touches on the lid, whether open or closed integer link = llDetectedLinkNumber(0); if ((link == gOpenLink && gOpen) || (link == gClosedLink && !gOpen)) update_lid(!gOpen); } }
It should work, I have used the principle a lot, but I have not tested it inworld, I only wrote it just now.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
|
08-30-2008 13:29
Trout, if the lid is simple (one prim), you could also use a simple door script to open/close it. That has the advantage of showing the movement more realistically. .
|
|
Trout Recreant
Public Enemy No. 1
Join date: 24 Jul 2007
Posts: 4,873
|
08-30-2008 14:41
Thanks again, Ordinal, and Nika, too! I'll try both. I didn't really plan it out as well as I should, I guess. I built the box and then it occurred to me I had no way to get it to open and close. 
_____________________
From: Jerboa Haystack A Trout Rating (tm) is something to cherish. To flaunt and be proud of. It is something all women should aspire to obtain!
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-30-2008 16:03
You are going to get into scripts now Trout???????
Commented scripts are going to take on a whole new meaning now
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-30-2008 16:09
And a nice, simple script that works great on chests etc. Pay attention to the line; REQUIREMENTS on how to set up the prim for the lid. This allows the cut prim to rotate from it's edge and not the middle. /54/a7/220597/1.html
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Trout Recreant
Public Enemy No. 1
Join date: 24 Jul 2007
Posts: 4,873
|
08-30-2008 22:56
From: Jesse Barnett You are going to get into scripts now Trout???????
Commented scripts are going to take on a whole new meaning now lol - nope - I think scripts may be permanently beyond me. They reek of magic. I'm having fun building stuff, and I just needed a little help figuring out the scripts I needed.
_____________________
From: Jerboa Haystack A Trout Rating (tm) is something to cherish. To flaunt and be proud of. It is something all women should aspire to obtain!
|
|
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
|
08-31-2008 09:39
From: Trout Recreant They reek of magic. Is not magic a big reason why we're all in SL? Do not ever be discouraged if your builds do not reach reality, Trout ... SL is the place to push beyond the real. What would a hyperreal sextant DO, and how would it work? There is a cavorite mine in one of Caledon's sims. It has typically realistic Steampunk touches, conveyor belts, some sort of churning machine, lalala ... but the material spews out and floats, bobbing eerily with just the right amount of anitgravity ... because it can. It is beautiful. .
|