Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rezzer with Menu

Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
11-05-2007 12:35
Hi guys,

Are there any examples out there of a rezzer script that will scan the Contents folder of the containing prim for Objects and present them in a Menu for selection for rezzing? Or must I start from scratch?

TIA

Rock
Smithy Zeno
ownes 9 pet cacti
Join date: 3 Aug 2006
Posts: 52
11-05-2007 12:49
Here you go:


From: LSL Wiki:


list MENU1 = [];
list MENU2 = [];
integer listener;
integer MENU_CHANNEL = 1000;


Dialog(key id, list menu)
{
llListenRemove(listener);
listener = llListen(MENU_CHANNEL, "", NULL_KEY, "";);
llDialog(id, "Select one object below: ", menu, MENU_CHANNEL);
}

default
{
on_rez(integer num)
{
llResetScript();
}

touch_start(integer total_number)
{
integer i = 0;
MENU1 = [];
MENU2 = [];
integer c = llGetInventoryNumber(INVENTORY_OBJECT);
if (c <= 12)
{
for (; i < c; ++i)
MENU1 += llGetInventoryName(INVENTORY_OBJECT, i);
}
else
{
for (; i < 11; ++i)
MENU1 += llGetInventoryName(INVENTORY_OBJECT, i);
if(c > 22)
c = 22;
for (; i < c; ++i)
MENU2 += llGetInventoryName(INVENTORY_OBJECT, i);
MENU1 += ">>";
MENU2 += "<<";
}
Dialog(llDetectedKey(0), MENU1);
}

listen(integer channel, string name, key id, string message)
{
if (channel == MENU_CHANNEL)
{
llListenRemove(listener);
if (message == ">>";)
{
Dialog(id, MENU2);
}
else if (message == "<<";)
{
Dialog(id, MENU1);
}
else
{
// todo add offsets so box sites perfect on rezzer
llRezAtRoot(message, llGetPos(), ZERO_VECTOR, llGetRot(), 0);
}
}
}
}


I got this from the wiki, though I can't remember who posted it :(
Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
11-05-2007 13:24
Many thanks.

I will play with that all evening now :-))
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-05-2007 14:08
Not bad at all for a second post Smithy!!!!! Welcome to the forums:)
_____________________
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
Revolution Perenti
Registered User
Join date: 26 Nov 2006
Posts: 8
11-13-2007 23:58
i created it lol :D

Rev :)
Miles Beck
MilesBeck.com
Join date: 20 Mar 2007
Posts: 537
01-27-2008 23:07
I need a modified version of this, but I don't know how to do it. I have only one object in my containing prim. I'd like to avoid the menu. Is there a way to modify this script so that it will rez the one object when the containing prim is touched? Thanks!
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
01-27-2008 23:25
default
{
touch_start(integer Count)
{
if (llDetectedkey(0) == llgetOwner())
{
llRezObject(yada yada);
}
}
}
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-27-2008 23:53
From: Miles Beck
I need a modified version of this, but I don't know how to do it. I have only one object in my containing prim. I'd like to avoid the menu. Is there a way to modify this script so that it will rez the one object when the containing prim is touched? Thanks!


CODE

string objectName = llGetInventoryName(INVENTORY_OBJECT, 0);
Miles Beck
MilesBeck.com
Join date: 20 Mar 2007
Posts: 537
01-28-2008 10:20
Thanks!
Krstopj Voom
Urban beachbum
Join date: 9 May 2007
Posts: 17
06-12-2008 11:31
Thanks for this script, it's awesome!
Is there any way to revise the script so that it replaces the item instead of adding it on top of the original? For example, rezzing item A in the menu, then pressing B (replaces A)?
Luke Poplin
Registered User
Join date: 2 Feb 2007
Posts: 32
06-13-2008 06:49
From: Squirrel Wood
default
{
touch_start(integer Count)
{
if (llDetectedkey(0) == llgetOwner())
{
llRezObject(yada yada);
}
}
}



I think YADA_YADA should be the next constant they add.
RichD Tomsen
Photographer / Builder
Join date: 18 Nov 2007
Posts: 24
06-13-2008 10:09
To answer the Delete question... Yes it is possible... Just put a script inside your rezzed object that is looking for a command spoken on a special channel then just do an llDie() to remove it. If it’s a linked object just place it in the Root prim. Have your Rezzor script shout a command just before rezzing the new item. By using a negative channel number to listen on it will prevent someone from "saying" the command from their client. You can also get fancy and put in a timed event to delete the rezzed object after a set period of time

Rezzor Script

default
{
touch_start(integer Count)
{
if (llDetectedkey(0) == llgetOwner())
{
llShout(-193245,"Clean_Your_Room";); //Tell Rezzed prim to Go Away
llSleep(0.5); //Give Prim A chance to go Away
llRezObject(yada yada);
}
}
}

part of Rezzed Prim

default
{
state_entry()
{
llListen(-193245,"",NULL_KEY,"";)
}
Listen(integer channel, string name, key id,string message)
{
if(message == "Clean_Your_Room";)
llDie();
}
{
Krstopj Voom
Urban beachbum
Join date: 9 May 2007
Posts: 17
06-15-2008 14:35
Hey RichD,
That totally did the trick. Thanks!
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
06-16-2008 08:20
Here are a couple of scripts that work with the "Rezzer with Menu" script to:

1. correct rotations for items that do not have zero rotations;
2. change rezz position of individual items;
3. set the item displayed to "temporary" so it deletes itself after a minute or so;
4. delete the "die" and these other scripts when there is a change of owner.

I provided these so that this rezzer can be used to display and sell copies of the items displayed. Do not use the "temporary" option if you are selling the items.

From: someone
CODE
 //On Rez Change Rotations
// Put this script in any object that needs to change its rotations when rezzed on the rezzer table.

//This script will delete it self if the object it is in changes ownership.
// This will allow you to sell copies of the object directly off of the rezzer display item.

// This script will change the rezz rotations of the object it is in. It is often necessary if the base prim of the object does not have zero rotations.

//ALSO you must edit the <0,0,0> X,Y,Z numbers to say where you want the object to rezz in relation to the center of the rezzer table.


key owner;
rotation rot_xyzq;

default
{

state_entry()
{
owner = llGetOwner();
vector xyz_angles = <0,1.0,0>; // This is to define a 1 degRee change
vector angles_in_radians = xyz_angles*DEG_TO_RAD; // Change to Radians
rot_xyzq = llEuler2Rot(angles_in_radians); // Change to a Rotation
}

on_rez(integer rez_num)
{
if(owner != llGetOwner())
llRemoveInventory(llGetScriptName());
else
llSetRot(llGetRot()*rot_xyzq); //Do the Rotation...
}
}


From: someone
CODE

// Die +Temp on Rez + position change
// Put this script in every object that you include in the inventory of the Object Rezzer.
// This script will make any currently displayed object derezz before the next one rezzes.

//This script will delete itself if the object it is in changes ownership.
// This will allow you to sell copies of the object directly off of the rezzer display item.

// **1. This script can change the rezz location of the object it is in,
//if you remove the // in front of the line indicated **1 below;
//AND you must edit the <0,0,0> X,Y,Z numbers to say where you want the object to rezz in relation to the center of the rezzer table.

// **2 This script can make the object temporary, so it will derezz after a minute or so, if you remove the // in front of the line indicated **2 below.
//Do not use the "temporary" option if you are selling the items.

key owner;

default
{

state_entry()
{
owner = llGetOwner();
llListen(1000,"","",""); //anyone can change it.
}

on_rez(integer rez_num)
{
if(owner != llGetOwner())
llRemoveInventory(llGetScriptName());
else
llResetScript();
//llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]);// **1
//llSetPos(llGetLocalPos() + <0,0,0>); // **2
}

listen(integer chan, string name, key id, string msg)
{
if(msg=="die")
{
llDie();
}
}
}


From: someone
Instructions:
V2.2 update:

1. Change in Owner: The "Die" script deletes itself if the object has a new owner. This allows you to sell copies of objects directly from the object displayed on the rezzer.

2. Change rezz Location: The "Die" script can change the rezz location of the object it is in, if you remove the // in front of the line indicated **1 in the script; AND you must edit the <0,0,0> X,Y,Z numbers to say where you want the object to rezz in relation to the center of the rezzer table.

3. Temporary: The "Die" script can make the object temporary, so it will derezz after a minute or so, IF you remove the // in front of the line indicated **2 in the script. Do not use the "temporary" option if you are selling the items.

4. Rotations: If the base prim of each objects has zero rotations it will rezz fine, otherwise it will rezz at odd angles. You can link an invisible base prim with zero rotations to the object if necessary to achieve this; or use this script.

The "On Rez Change Rotations" script will change the rezz rotations of the object it is in. It is often necessary if the base prim of the object does not have zero rotations. You must edit the <0,0,0> X,Y,Z numbers in the script to reflect the Object rotation numbers you see for that object in the Edit Object window, when it is rezzed in its proper rotation.

Reference SL Forum Discussions
/54/a0/221457/1.html
/54/03/265018/1.html#post2034731
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-08-2008 23:46
you can simplify this a bit more :-) it get's the rotation for you so no needing to hard code it, just drop this in and you're good to go.

From: someone
//On Rez Change Rotations
// Put this script in any object that needs to change its rotations when rezzed on the rezzer table.

//This script will delete it self if the object it is in changes ownership.
// This will allow you to sell copies of the object directly off of the rezzer display item.

// This script will change the rezz rotations of the object it is in. It is often necessary if the base prim of the object does not have zero rotations.


key owner;
rotation origrot;

default
{

state_entry()
{
owner = llGetOwner();
origrot = llGetRot();
}

on_rez(integer rez_num)
{
if(owner != llGetOwner())
llRemoveInventory(llGetScriptName());
else
llSetRot(origrot); //Do the Rotation...
}
}


or even put the 2 together (rotation and position change)

From: someone

vector position = <0,0,0>;//you will have to set this in relation to the rezzer
rotation origrot;
key owner;
default
{
state_entry()
{
owner = llGetOwner();
origrot = llGetRot();
llListen(5,"","","";); //anyone can change it.
}
on_rez(integer rez_num)
{
if(owner != llGetOwner())
llRemoveInventory(llGetScriptName());
else
//llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]);//use only if you want the object to be temp(not selling copies)
llSetPos(llGetLocalPos() + position);
llSetRot(origrot);
}
listen(integer chan, string name, key id, string msg)
{
if(msg=="die";)
{
llDie();
}
}
}
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-09-2008 08:04
ok, i revoke my last reply lol. it just occured to me, that if the table isn't at the original rotation, the rotation of the object won't match up. that's what you were doing in the previous method i guess. but for the position change (haven't used it as i was using a different script for that) the on_rez state is reseting the script before it's supposed to set the position? wouldn't that cause it to not set the position?
Wickman Gibbs
Registered User
Join date: 3 Sep 2007
Posts: 5
Rezzin infront of Object
08-26-2008 15:54
Thanks fer the script -- Trying to Rezz Item(s) 1 m in front instead of instead over on top. Tried setting vector but still rezzes over object. Any solutions?
Dragger Lok
(loading ...)
Join date: 10 Sep 2006
Posts: 228
08-27-2008 01:59
From: Wickman Gibbs
Thanks fer the script -- Trying to Rezz Item(s) 1 m in front instead of instead over on top. Tried setting vector but still rezzes over object. Any solutions?

Have not tried it but ArchTx Edo's secind script you can try uncommenting this and use the positioning explaination found below:

//llSetPos(llGetLocalPos() + <0,0,0>;); // **2

* To uncomment remove the "//" from in front of the line*


Or the original script you could replace this:

// todo add offsets so box sits perfect on rezzer
llRezAtRoot(message, llGetPos(), ZERO_VECTOR, llGetRot(), 0);

With this:

CODE

//where 0, 0, 0, is in llGetPos() + <0, 0, 0> add the values to position the rezzed
//object away from the rezzer
//llEuler2Rot(< 0, 270, 180> is rotation of the root prim
llRezAtRoot(message, llGetPos() + <0, 0, 0>*llGetRot(), ZERO_VECTOR, llEuler2Rot(< 0, 270, 180> * DEG_TO_RAD)*llGetRot(), 0);


explained --->

Prim Positioning ... llGetPos() + <0, 0, 0>

0, 0, 0

1st 0 up is - (minus) ... down is + (plus) *number without a + prefix
2nd 0 north is - (minus) ... south is + (plus) *number without a + prefix
3rd 0 east is - (minus) ... west is + (plus) *number without a + prefix

1, 1, 1
one meter down
one meter south
one meter west

-1, -1, -1
one meter up
one meter north
one meter east

-0.5, 1.5, -2
one half meter up
one and a half meter south
two meters east

*orientation of the root prim takes some tinkering:
llEuler2Rot(< 0, 270, 180>

* In the original script with the replaced snippet to orientate each object so they come out with the same orientation you will need to add a "base" prim to each object and make it the root prim.
Cera Dreadlow
Registered User
Join date: 9 Jul 2008
Posts: 21
10-12-2008 17:06
From: Smithy Zeno
Here you go:




I got this from the wiki, though I can't remember who posted it :(


So, I was testing this out, and the menu comes up perfectly with the names of the objects, but when it is selected in the menu, nothing happens - nothing is rezzed... Is there something more that needs to be added to the script to make this happen?
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
10-12-2008 17:37
From: Cera Dreadlow
So, I was testing this out, and the menu comes up perfectly with the names of the objects, but when it is selected in the menu, nothing happens - nothing is rezzed... Is there something more that needs to be added to the script to make this happen?


It works fine for me, though if your rezbox is large and your objects small,
CODE
llRezAtRoot(message, llGetPos(), ZERO_VECTOR, llGetRot(), 0);
may well be causing them to rez inside the the box.

Maybe try llGetPos()+<0,0,1.5> and see what happens then?
Cera Dreadlow
Registered User
Join date: 9 Jul 2008
Posts: 21
11-12-2008 09:01
From: Innula Zenovka
may well be causing them to rez inside the the box.


That's exactly what was happening... Duh! I went to move my rezzer and had about 30 objects "inside" it that I had to delete... Thanks!
Minke Bailey
Registered User
Join date: 8 Feb 2007
Posts: 27
yet another variation needed ;-)
02-03-2009 21:09
I found this script on another site but it looks realted to this so I'll just ask here ;-)

I'd need another small change to it and can't figure out how make the needed channel changes (keep getting script errors), so here's what I'd need:

I would like to use multiple instances of the rezzer prim to group certain items, but one display area only, so basicly I'd need the rezzed item to be derezzed from the display area even if an item from one of the other rezzer prims will be rezzed. I want a total of 2-3 display areas, so I'd need to be able to change the channel for each set of rezzers. I know I could just set items to temp but since they consist of quite a few sculpties, loading time might take longer than just 1 minute, so I'd rather have them not temp.

Any help with this would really be GREATLY appreciated :-)

Here's the two scripts I have:

this one for the rezzer prim:

From: someone
list MENU1 = [];
list MENU2 = [];
integer listener;
integer MENU_CHANNEL = 12745;
integer REZ_CHANNEL = -789;


Dialog(key id, list menu)
{
llListenRemove(listener);
listener = llListen(MENU_CHANNEL, "", NULL_KEY, "";);
llDialog(id, "Select one object below: ", menu, MENU_CHANNEL);
}

default
{
on_rez(integer num)
{
llResetScript();
}

touch_start(integer total_number)
{
integer i = 0;
MENU1 = [];
MENU2 = [];
integer c = llGetInventoryNumber(INVENTORY_OBJECT);
if (c <= 12)
{
for (; i < c; ++i)
MENU1 += llGetInventoryName(INVENTORY_OBJECT, i);
}
else
{
for (; i < 11; ++i)
MENU1 += llGetInventoryName(INVENTORY_OBJECT, i);
if(c > 22)
c = 22;
for (; i < c; ++i)
MENU2 += llGetInventoryName(INVENTORY_OBJECT, i);
MENU1 += ">>";
MENU2 += "<<";
}
Dialog(llDetectedKey(0), MENU1);
}

listen(integer channel, string name, key id, string message)
{
if (channel == MENU_CHANNEL)
{
llListenRemove(listener);
if (message == ">>";)
{
Dialog(id, MENU2);
}
else if (message == "<<";)
{
Dialog(id, MENU1);
}
else
{
llSay(REZ_CHANNEL, "die";);

llRezAtRoot(message, llGetPos() + <1.0, -0.2, -0.5>, ZERO_VECTOR, llGetRot(), (REZ_CHANNEL = (integer)llFrand(-2147483392.0) - 255));
}
}
}
}



and this one for the item:

From: someone
integer iListenHandle = 0;
key kOwner = NULL_KEY;
default
{
on_rez(integer iStartParam)
{
kOwner = llGetOwner();
llListenRemove(iListenHandle);
if (iStartParam != 0)
iListenHandle = llListen(iStartParam, "", NULL_KEY, "die";);
}

listen(integer iChannel, string sName, key kID, string sMessage)
{
if (llGetOwnerKey(kID) == kOwner)
llDie();
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
02-03-2009 21:35
This one's written for a specific use, but it wouldn't be hard to make the minor tweaks to get it to do what you want. It's obviously meant to be in a rezzing object with four named benches that it rezzes. You can rez any one of the four benches at any one of three preset positions. Rezzing a new bench in an occupied position replaces the one that's there, and you can kill any one or all of the benches from the dialog box.

In the rezzing object:

CODE

list benches = ["Remove", "Stone", "Garden", "Park", "Rustic"];
list positions = ["Left", "Middle", "Right", "Notecard?"];
integer channel = 97;
integer killchannel;
integer killoffset;
rotation xrot;
string benchname;
vector kvector;
key id;
init ()
{
llResetScript();
}
default
{
on_rez(integer start_param)
{
init();
}
state_entry()
{
killchannel = 3657;
llListen (channel,"",NULL_KEY, "");
}
touch_start(integer total_number)
{
id = llDetectedKey(0);
if (llSameGroup(id)== TRUE)
{
llDialog(id,"\n Hello, " + llDetectedName(0) + "! \n \n SELECT A BENCH POSITION",positions,channel);
}
}
listen(integer channel,string name,key id, string message)
{
if (llListFindList(positions,[message]) != -1)
{
if (message == "Notecard?")
{
llGiveInventory(id,llGetInventoryName(INVENTORY_NOTECARD, 0));
}
if (message == "Right")
{
killoffset = 10;
kvector = <0,-2.6,-0.443>;
killchannel = killchannel + killoffset;
xrot = llEuler2Rot( <0, 0, -30 * DEG_TO_RAD> );
state choosebench;
}
else if (message == "Middle")
{
killoffset = 20;
kvector = <0.684,0,-0.443>;
killchannel = killchannel+killoffset;
xrot = llEuler2Rot(<0,0,0>);
state choosebench;
}
else if (message == "Left")
{
killoffset = 30;
kvector = <0,2.6,-0.443>;
killchannel = killchannel + killoffset;
xrot = llEuler2Rot( <0, 0, 30 * DEG_TO_RAD> );
state choosebench;
}
}
}
}
state choosebench
{
state_entry()
{
llListen (channel,"",NULL_KEY, "");
llDialog(id,"Which bench would you like to create?",benches,channel);
}
listen(integer channel,string name,key id, string message)
{
if (llListFindList(benches,[message]) != -1)
{
if (message == "Stone")
{
benchname = "Stone Bench";
llSay(killchannel, "kill" );
vector eul = <0,90,90>;
eul *= DEG_TO_RAD;
rotation quat = llEuler2Rot(eul);
quat = quat * xrot;
llRezObject(benchname, llGetLocalPos() + <-2, 0, -0.3> + kvector, ZERO_VECTOR, quat, killoffset);
}
else if (message == "Garden")
{
benchname = "Garden Bench";
llSay(killchannel, "kill" );
vector eul = <0,0,0>;
eul *= DEG_TO_RAD;
rotation quat = llEuler2Rot(eul);
quat = quat * xrot;
llRezObject(benchname, llGetLocalPos() + <-2, 0, 0> + kvector, ZERO_VECTOR, quat, killoffset);
}
else if (message == "Rustic")
{
benchname = "Rustic Bench";
llSay(killchannel, "kill" );
vector eul = <0,0,0>;
eul *= DEG_TO_RAD;
rotation quat = llEuler2Rot(eul);
quat =- quat * xrot;
llRezObject(benchname, llGetLocalPos() + <-2, 0, 0> + kvector, ZERO_VECTOR, quat, killoffset);
}
else if (message == "Park")
{
benchname = "Park Bench";
llSay(killchannel, "kill" );
vector eul = <180,0,90>;
eul *= DEG_TO_RAD;
rotation quat = llEuler2Rot(eul);
quat = quat * xrot;
llRezObject(benchname, llGetLocalPos() + <-1.123, 0, 0.44> + kvector, ZERO_VECTOR, quat, killoffset);
}
else if (message == "Remove")
{
llSay(killchannel, "kill");
llSay(0,"Bench removed, as you requested.");
}
}
state default;
}
}


And in each of the objects to be rezzed:

CODE

integer channel;
list confirm = ["Yes", "No"];
default
{
on_rez(integer start_param)
{
llSay(0, "Creating a new bench. Please sit down.");
channel = 3657 + start_param;
llSetTimerEvent(5400.0);
llListen(channel,"",NULL_KEY,"");
}
listen(integer channel, string name, key id, string message)
{
if ((llListFindList(confirm,[message]) != -1 && (message == "Yes")) || message == "kill")
{
llDie();
}
}
touch_start(integer total_number)
{
key id = llDetectedKey(0);
if (llSameGroup(id)== TRUE)
{
llDialog(id,"\n Do you really want to remove this bench?",confirm,channel);
}
}
timer()
{
llSay(0,"WARNING: This bench will self-destruct in 30 seconds.");
llSleep(30.0);
llDie();
}
}


Minke Bailey
Registered User
Join date: 8 Feb 2007
Posts: 27
02-03-2009 23:25
Thank you Rolig for posting this, I'll look into it - and if I can't use it for the one project I asked about I've had something else in mind for a while where it could be really be of great help:-)

Looks like there will be a lot of "set up work" involved with this specific script though, I liked the other one because it "fetches" inventory names automatically, and with roughly 200 items to set up / put inside the rezzers I'd still love to learn how the "depending on channel derezzing code" could be included ;-)
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
02-04-2009 07:45
That was the part that gave me the hardest time too. As you study my code, take a look at the killoffset parameter. It has a different value for each position where I want to rez one of the objects in inventory. Its function is to generate a distinct communication channel for each position, so that once an object is rezzed, I have a way for the parent object to tell it to llDie on command without affecting objects that may have been rezzed at other positions -- even if those are identical objects.

As for the amount of setup work, yes, there is a bit. It's not as hard as it seems, though. To determine what kvector (the positioning parameter for each of the three rez locations) should be, you simply use the device to rez an object and then physically move it to where you want future objects to rez. The difference between the rezzed position and your new location is kvector.

EDIT: Oh, and xrot gives me the flexibility to define a different rotation for each rez location, obviously.
1 2