Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Temp Prim Rezzer

Eata Kitty
Registered User
Join date: 21 Jan 2005
Posts: 387
08-02-2006 02:55
This is my version of those temporary rezzers that some jokers charge comedy prices for. I don't personally use one so I'm not sure if it's totally bug free and I didn't spend too long working on it so there's probably some improvements to be made.

Three scripts in the main object, one script for all objects to be rezzed.

Main object:
Dialog
CODE
integer CHANNEL;
// What we use here is a dynamic menu, this is a list that we define before
// calling the dialog. It allows us to have changing buttons by using
// global variables.
list dynMenu = [];

// Variables for dynamic menu buttons
string power = "Turn On";
string avSensor = "Sensor On";

default
{
state_entry()
{
CHANNEL = (integer)llFrand(2000000000.0);
llListen(CHANNEL, "", NULL_KEY, "");
}

touch_start(integer total_number)
{
// Build the dynamic menu before we use it as a dialog
list dynMenu = ["Reset", avSensor, power];
if (llDetectedKey(0) == llGetOwner())
llDialog(llDetectedKey(0), "What do you want to do?", dynMenu, CHANNEL);
}

listen(integer channel, string name, key id, string message)
{
llOwnerSay("You have selected: '" + message + "'.");
if (message == "Reset")
{
// Reset
llMessageLinked(LINK_THIS, 1000, "", NULL_KEY);
llMessageLinked(LINK_THIS, 1500, "", NULL_KEY);
power = "Turn On";
avSensor = "Sensor On";
}
else if (message == "Turn On")
{
// Go online
llMessageLinked(LINK_THIS, 1200, "", NULL_KEY);
power = "Turn Off";
}
else if (message == "Turn Off")
{
// Go offline
llMessageLinked(LINK_THIS, 1300, "", NULL_KEY);
power = "Turn On";
}
else if (message == "Sensor On")
{
// Start the sensor mode
llMessageLinked(LINK_THIS, 1400, "", NULL_KEY);
avSensor = "Sensor Off";
}
else if (message == "Sensor Off")
{
// Stop the sensor mode
llMessageLinked(LINK_THIS, 1500, "", NULL_KEY);
avSensor = "Sensor On";
}
}

on_rez(integer start_param)
{
llResetScript();
}

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


Main
CODE

// Empty variables that will store set position/rotation
// DON'T CHANGE THESE
vector rezPosition = <0,0,0>;
rotation rezRotation = <0,0,0,0>;
// Inter-object commands
string commandDerez = "derez";
// Chat channel
integer commChannel;
// Rezzed object key
key childKey = NULL_KEY;
// How often our sensor checks, smaller is more responsive but more demanding
float sensorTime = 0.5;
// Tick to avoid getting pos too often
integer tick;
// avSensor is running
integer avSensor = FALSE;

// InventoryCheck
// Checks the status of our inventory
integer InventoryCheck()
{
// Check if we have too many objects
if (llGetInventoryNumber(INVENTORY_OBJECT) > 1)
{
llOwnerSay("ERROR - Too many objects! This rezzer only takes a single object");
return 1;
}
// No objects
else if (llGetInventoryNumber(INVENTORY_OBJECT) == 0)
{
llOwnerSay("ERROR - No objects in inventory!");
return 1;
}
// Inventory must be copy
if (llGetInventoryPermMask(llGetInventoryName(INVENTORY_OBJECT, 0), MASK_OWNER) & PERM_COPY)
return 0;
else
{
llOwnerSay("ERROR - Object does not have copy permissions");
return 1;
}
}

rez()
{
// Check if we have a rez position set, don't want to rez at 0,0,0
if (rezPosition == <0,0,0>)
llRezObject(llGetInventoryName(INVENTORY_OBJECT, 0), llGetPos(), ZERO_VECTOR, rezRotation, commChannel);
else
llRezObject(llGetInventoryName(INVENTORY_OBJECT, 0), rezPosition, ZERO_VECTOR, rezRotation, commChannel);
}

default
{
state_entry()
{
llSetAlpha(1.0, ALL_SIDES);
childKey = NULL_KEY;
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
if (!InventoryCheck())
llOwnerSay("Ready to run");
}
if (change & CHANGED_OWNER)
{
llOwnerSay("New owner, resetting.");
llOwnerSay("To use me put a 0 Prim Object script inside the object you want to be rezzed then put it in my inventory and turn me on. You can fine tune the rez position/rotation through the Set P/R button (10M max distance).");
llResetScript();
}
}

link_message(integer sender, integer num, string message, key id)
{
// Turn on message
if (num == 1200)
{
if (!InventoryCheck())
state running;
}
// avSensor is running
else if (num == 1400)
{
avSensor = TRUE;
}
// avSensor is disabled
else if (num == 1500)
{
avSensor = FALSE;
}
else
{
llOwnerSay("Error - Rezzer not running");
}
}
}

state running
{
state_entry()
{
llOwnerSay("Running.");
childKey = NULL_KEY;
llSetTimerEvent(0.0);
llSetAlpha(0.0, ALL_SIDES);
// Random comm channel
commChannel = (integer)llFrand(2000000000.0);
// Create object
if (!avSensor)
rez();
}

object_rez(key child)
{
// Very important, we use this to sense our child
childKey = child;
llSleep(2);
llSetTimerEvent(sensorTime);
}

timer()
{
llSensor("", childKey, SCRIPTED, 10, PI);
}

sensor(integer num_detected)
{
if (tick >= 5)
{
tick = 0;
rezPosition = llDetectedPos(0);
rezRotation = llDetectedRot(0);
}
else
tick++;
}

no_sensor()
{
childKey = NULL_KEY;
rez();
}

on_rez(integer param)
{
// Move back to default, keep object info
state default;
}

changed(integer change)
{
// If out inventory changes
if (change & CHANGED_INVENTORY)
{
// This calls our inventory check function, if there is an inventory
// problem it returns a 1 which will causes us to return to default
if (InventoryCheck())
state default;
}
}

link_message(integer sender, integer num, string message, key id)
{
// Reset
if (num == 1000)
{
llOwnerSay("Resetting - Object info cleared");
llSay(commChannel, commandDerez);
llResetScript();
}
// Turn on message
else if (num == 1200)
{
llOwnerSay("Rezzer already running... resynching with dialog");
// Inform user, we don't really need to do anything as dialog will now be in synch
}
// Turn off message
else if (num == 1300)
{
llOwnerSay("Rezzer turning off...");
llSay(commChannel, commandDerez);
llMessageLinked(LINK_THIS, 1500, "", NULL_KEY);
state default;
}
// avSensor is running
else if (num == 1400)
{
avSensor = TRUE;
}
// avSensor is disabled
else if (num == 1500)
{
avSensor = FALSE;
}
// avSensor detected an av
else if (num == 2000)
{
if (childKey == NULL_KEY)
rez();
}
// avSensor detects no av
else if (num == 2100)
{
llSetTimerEvent(0.0);
llSay(commChannel, commandDerez);
childKey = NULL_KEY;
}
}
}


sensor
CODE

// Is the sensor enabled
integer active = FALSE;
// How often sensor checks, longer uses less resources but means slower reaction
integer sensorPeriod = 10;
// Distance in M the sensor will find avs
integer sensorDist = 20;
// Sensor detected an av on last run if true
integer avDetected = FALSE;

default
{
link_message(integer sender, integer num, string message, key id)
{
// Sensor on message
if (num == 1400)
{
avDetected = FALSE;
llSensorRepeat("", NULL_KEY, AGENT, sensorDist, PI, sensorPeriod);
}
// Sensor off message
else if (num == 1500)
{
avDetected = FALSE;
llSensorRemove();
}
}

sensor(integer total_number)
{
// Only do something if this is the first detection of an av
if (!avDetected)
{
// We detected something, tell Main to rez
llMessageLinked(LINK_THIS, 2000, "", NULL_KEY);
avDetected = TRUE;
}
}

no_sensor()
{
// Only do something if we had detected an av last sensor
if (avDetected)
{
// No avs, disable rezzing
llMessageLinked(LINK_THIS, 2100, "", NULL_KEY);
avDetected = FALSE;
}
}

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


Script for rezzed objects:
CODE

// Chat channel
integer commChannel;

default
{
state_entry()
{
// Makes the object temporary so the whole 0 prim part works
llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]);
}

on_rez(integer param)
{
if (!param)
// If not rezzed by the rezzer this stops temporary so we can edit it
llSetPrimitiveParams([PRIM_TEMP_ON_REZ, FALSE]);
else
{
// Chat channel to use, passed to us as a rez parameter
commChannel = param;
llListen(commChannel, "", NULL_KEY, "");
}
}

listen(integer channel, string name, key id, string message)
{
// Security - check the object belongs to our owner
if (llGetOwnerKey(id) != llGetOwner())
return;
if (message == "derez")
llDie();
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
08-02-2006 08:05
/15/a3/126304/1.html
_____________________
i've got nothing. ;)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
08-02-2006 08:20
This one will not be deleted.
_____________________
i've got nothing. ;)
Nubee Scaggs
Registered User
Join date: 17 Nov 2006
Posts: 19
Hi
12-13-2006 15:12
Hi nada, i see where you were going with

llRezObject(llGetInventoryName(INVENTORY_OBJECT, 0), llGetPos(), ZERO_VECTOR, rezRotation, commChannel);

and

llRezObject(llGetInventoryName(INVENTORY_OBJECT, 0), rezPosition, ZERO_VECTOR, rezRotation, commChannel);
return 0;

I'm not sure why the string is returning an incorrect value, but it sure is.

I took the example for llRezObject() from the wiki and made your fine code work. My line is :

llRezObject(llGetInventoryName(INVENTORY_OBJECT, 0), llGetPos() + <0,0,0.1> , ZERO_VECTOR, rezRotation, commChannel);

Which positions the object correctly, and negates the need for your position check.

Would like to know what is wrong with the string call, but sooo many things keep coming to my door :-)

Be well and thank you for your great work.

Nubee~
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
This is Eata's work!
12-13-2006 17:11
and as much as i would like to take credit for this script (as well as all the other ones in the library) i can't. :)
_____________________
i've got nothing. ;)
Nubee Scaggs
Registered User
Join date: 17 Nov 2006
Posts: 19
12-14-2006 00:39
ooopsie, thanks eata.
chr0nic MacKay
Registered User
Join date: 12 Jul 2006
Posts: 26
01-07-2007 08:31
hey there i have been wrokign on geting this script working i have got it all done and runing but when the object rez and i move it into place were i want ti (not moveing it more then 6 away) it stay but intell the temp rez rerezs the object its not remembering why i have place it it and seting it back to the defuelt
can any one help me please

rico

update i have it remebering but now for some reason when i use more then 1 prim tahts link liek i used a 3 prim tree it remebers the side way pos and the rota but it gets higher evey time it re rez's any idea why this might be ??

rico

i hav ebeen looking into it and still cant fig out why its doing what it is, it saves the rota and pos fine whne moveing it the only prob is that when it rerezs it gets hight evey time i wwould say by 0.5 eazy and i cant find or fig out why can any one help me please
chr0nic MacKay
Registered User
Join date: 12 Jul 2006
Posts: 26
01-27-2007 16:50
hey can any one help please i let the msg above but no one has repled i know it hard to udnerstand me when i'm typeing i'm sorry for that nto that hot on spelling

rico
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
Its probably Floating Point Drift
01-27-2007 20:37
Chr0nic,
I suspect its DRIFT. SL uses floating point numbers for its calculations. These have small errors in them when you compare a fixed number vs a floating point. as you continually rerez something, these errors slowly accumulate, and the item seems to 'drift' away.

I'm not good enough coder to fix the scripts. Others, however, have solved the problem by having their scripts record whre they are when they are initialized. < x, y, z >.
Then, when they re-rez, instead of just 'rezing', they rez AT the original <x,y,z> location. Thus the drift is removed.
Dilbert Cleanslate
Registered User
Join date: 18 Nov 2006
Posts: 9
Fix for drifting linked objects
02-12-2007 10:08
I believe the problem is the difference between the positions used by llRezObject and llDetectedPos. For single prim objects, these scripts should work fine. They definitely don't work with linked objects. llRezObject uses the position which is the geometric center of the entire linkset. A sensor only detects the root prim of a linkset, and the position it returns will be the geometric center of that prim, not the entire linkset. The distance between the two positions is the amount of drift which will occur each time the object is rezzed, until the distance from the object containing the rezzer scripts has moved > 10M, at which time the scripts shut down. Fortunately, the fix is very easy. Use llRezAtRoot instead of llRezObject, and the scripts work great!

Thank you, Eata Kitty... I'll be using these a lot.
Nexus Laguna
Registered User
Join date: 20 Dec 2006
Posts: 40
02-27-2007 14:52
Can I just mention that temp rezzing no longer seesm to work ... Either LL have found a way around it (because if you really think about it it is cheating the system as far as prims is concerned) or they never really worked in the first place.

How do I know this? Well .. a good freind of mine was using a temp rezzing system (I won't name the maker, he/she doesnt need to be discredited since it may have been a fix by LL), and while she was trying to create items she got a message saying she couldn't because the parcel was full, even though the prim count in About Land said everything was fine and that she was way under her limit.

Oh well .. so much for an idea that LL was going to try and find a way around anyway....
Sue Stonebender
Piano Craftsman
Join date: 7 Jan 2005
Posts: 219
02-27-2007 15:23
I've been using my own temp rezzer script in test products and came to the same conclusion. My partner and I set trees out with it, and it instantly filled up both of our SIMs. Even though we had lots of spare prims left, still being reported through About land, we got the constant parcel full errors every time it tried to respawn, or we tried to create something.

I went through every single child link in the linked sets, and set everything manually, not through LSL, and while each prim was indeed set to Temp, the SIM certainly didn't see it that way.

Hoping we can get an official statement from LL on this one way or another.

Sue.
Dilbert Cleanslate
Registered User
Join date: 18 Nov 2006
Posts: 9
02-28-2007 08:47
From: Sue Stonebender
I've been using my own temp rezzer script in test products and came to the same conclusion. My partner and I set trees out with it, and it instantly filled up both of our SIMs. Even though we had lots of spare prims left, still being reported through About land, we got the constant parcel full errors every time it tried to respawn, or we tried to create something.

I went through every single child link in the linked sets, and set everything manually, not through LSL, and while each prim was indeed set to Temp, the SIM certainly didn't see it that way.

Hoping we can get an official statement from LL on this one way or another.

Sue.

You are correct, at the SIM level it doesn't matter whether prims are TEMP or not. There is a hard limit of 15,000 prims for each full sim (3,750 for an openspace sim). A temp rezzer doesn't allow you to exceed the sim limit. It just lets you "borrow" prim allocations from other land parcels which are currently not using their full allocations. If the sim is completely filled, there's nothing to borrow. Prim allocations cannot be shared across regions.

I'm not from LL, but I hope this helps explain the limitations on temp rezzers.

Dilbert Cleanslate
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
02-28-2007 10:34
From: Sue Stonebender
I've been using my own temp rezzer script in test products and came to the same conclusion. My partner and I set trees out with it, and it instantly filled up both of our SIMs. Even though we had lots of spare prims left, still being reported through About land, we got the constant parcel full errors every time it tried to respawn, or we tried to create something.


I believe a recent SL update made temp-on-rez prims still count against limits in the normal way, precisely because people were abusing temp-on-rezzers to get "free" high-prim structures rerezzed constantly. Of course the cost of their free lunches on the mainland was rez failures elsewhere in the sim and degraded performance for every avatar there. Yes, there are innocent reasons for rerezzers (such as holo vending) but this did happen an awful lot..
Sue Stonebender
Piano Craftsman
Join date: 7 Jan 2005
Posts: 219
02-28-2007 10:39
Dilbert and Yumi,

thanks so much for your replies. At least now I can stop bashing my head against the wall wondering what I'm going wrong.

Thanks a bunch,

Sue.
Eris Fallon
Registered User
Join date: 27 Sep 2006
Posts: 11
No derez
04-07-2007 04:12
I'm using Eata's Holovendor 3.0 and I have it working almost perfectly. The *only* thing that it's not doing is derezzing old objects when a new one is called up. This means that each time the rez button is pressed, a new object is rezzed over top of the old one, and neither disappears until the default lifetime runs out.

Has anyone else had a similar problem or might know what causing it? I'm popping aspirin like it's pez trying to understand how the mechanics of the scripts work, but it's simply beyond my limited scripting skill. Any help would be greatly appreciated.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
04-07-2007 13:13
As one of a number of people that make holovendors I can tell you how to fix it...

You need a script in the thing that you rez which listens on some odd channel - I use a big negative random number for each one so adjacent vendors don't trigger each other. You can pass this in the on_rez event using the parameter.

When you change models you send a "die" command, the old model listens and dies, the new one rezzes, no double models. There's no other way that's sensible. You could do llHTTPRequest out and xml-rpc in and the like, but it's no friendlier on the sim than an obscure channel listen.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Eris Fallon
Registered User
Join date: 27 Sep 2006
Posts: 11
04-07-2007 14:08
Thanks for the pointer, Eloise. I'll give that a try to see if I can make it work.
Eris Fallon
Registered User
Join date: 27 Sep 2006
Posts: 11
04-13-2007 23:15
I've got it working properly now. I didn't understand the logic of the scripts I was working with and didn't have the one that derezzes the temp object *in* the object.

Got that straightened out, but now I'm trying to get it to rez a fully functional object with running scripts and non-temp prims, but it won't derezz the existing sampler when a new object is requested to be displayed. I'm wondering if the scripts that are in it need to be turned off before the it will listen to the Die() command, or something else needs to happen before it can be derezzed.

In all fairness to the vendor's creator, the instructions explicitly state that the rezzed object can have no scripts running in it that aren't specifically appearance related, but since I learned that I'm going to have to pay for the prims in the temp objects that are rezzed anyway, I wanted to use a fully functional version and get the most out of my prim limit.

I know there aren't a lot of details here, but if anyone can point me to what might be the cause, I'd appreciate it.

Thanks.
Eris Fallon
Registered User
Join date: 27 Sep 2006
Posts: 11
04-13-2007 23:51
*sigh*

Never mind ... I managed to trial and error it into working. I think it was just a matter of changing object's properties back to "Temporary".

Sorry about that.