Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Mickey Mouse version of on_rez

Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
11-27-2006 05:58
People - call me thick (I'm sure you will) but I just can't get my head around how 'on_rez' works (yes I've read Wiki) How to set up the arg or parameters etc - I can open and close my door but getting the script to reset !!! using on_rez ....

Can anyone point me to a simplistic 'Mickey Mouse' examples or tutorials on using this function.

Pleeeeze

Tarak
:-)
Kale Kawabata
Registered User
Join date: 18 Sep 2005
Posts: 41
on_rez
11-27-2006 06:22
CODE

on_rez
{
llResetScript;
}
}


or put whatever command you want in where the llResetScript is, then when you rez our object, it will do whatever it is told in the "on_rez" handle
_____________________
Kale Kawabata =P
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-27-2006 06:51
Just remember that they are state specific.
Each state needs its own handler or it will ignore it.
Raeyan Aldrich
Registered User
Join date: 14 Oct 2006
Posts: 44
11-27-2006 07:03
From: Kale Kawabata
CODE

on_rez
{
llResetScript;
}
}


or put whatever command you want in where the llResetScript is, then when you rez our object, it will do whatever it is told in the "on_rez" handle



actually it would be llResetScript(); not llResetScript;
2k Suisei
Registered User
Join date: 9 Nov 2006
Posts: 2,150
11-27-2006 07:07
From: Kale Kawabata
CODE

on_rez
{
llResetScript;
}
}


or put whatever command you want in where the llResetScript is, then when you rez our object, it will do whatever it is told in the "on_rez" handle


Kale?

So that code is correct now? :)

Shouldn't it be?:

CODE

on_rez(integer start_param)
{
llResetScript();
}
2k Suisei
Registered User
Join date: 9 Nov 2006
Posts: 2,150
11-27-2006 07:11
From: Raeyan Aldrich
actually it would be llResetScript(); not llResetScript;


and he forgot about the start parameter.

like this:


CODE
on_rez(integer start_param)
{
llResetScript();
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-27-2006 12:58
And he had one extra } !!!!

Think we have been picky enough yet?
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
11-27-2006 13:39
On rez is a function that is called when ever the object is put into the world from a inventory. or when someone logs in wearing the item containing the script.

The on rez will give you parimiter that will tell you well i dont know i dont care really i just throe int blahh in there :P

If you want the script to go back over the state entry you can do a llResetScript(); like the others said.
if your havfing problems with a door
i would use a timer event on touch.
_____________________
LSL Scripting Database - http://lsl.dimentox.com
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-27-2006 14:00
From: Dimentox Travanti
On rez is a function that is called when ever the object is put into the world from a inventory. or when someone logs in wearing the item containing the script.

The on rez will give you parimiter that will tell you well i dont know i dont care really i just throe int blahh in there :P

If you want the script to go back over the state entry you can do a llResetScript(); like the others said.
if your havfing problems with a door
i would use a timer event on touch.



The parameter is for use when the object is being rezzed by other objects. I usually use it for setting comms channels between rezzer and rezzee.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
11-27-2006 15:23
Newgate's quite right. To expand a little further, the llRezObject and llRezObjectAtRoot functions both have a parameter variable in their description. That value gets passed to the rezzed object. If you rez "by hand" so to speak, it will be 0.

One of the commonest uses is probably to code a listen channel. You can also encode a vector with integer or known and limited dp's into it uniquely and other things.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
11-27-2006 17:04
Thanks people - I'll need to digest this.

I'd already tried:

on_rez(integer start_param)
{
llResetScript();
}

also

on_rez(integer arg)


And while it compiled OK it did nothing so it must be where I am placing it in the script.

Anyway - I will digest what you have said and try again

Tarak
:-)
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
11-27-2006 17:39
From: Tarak Voss

And while it compiled OK it did nothing so it must be where I am placing it in the script.


To better demonstrate what's going on, use the tried and true programmers debug tool... have the script blather on about what it's doing!

CODE

default {
state_entry() {
llOwnerSay("Whee! doing state_entry()!");
}

on_rez(integer start_param) {
llOwnerSay("Huzzah! doing on_rez()! start_param = "
+ (string)start_param );
llResetScript(); // which will cause state_entry() to run again!
}

object_rez(key id) {
llOwnerSay("Hey! This script just rezzed something from its prim's contents! The new object's new key is: "
+ (string) id );
// (which of course won't happen with this script as it is now.)
}
}


Anyway, watch your chat history when you compile the script on a prim... when you rez the prim in world.... or wear it... and such. You'll get a solid idea of when on_rez() happens pretty quickly. :)
_____________________
* The Particle Laboratory * - One of SecondLife's Oldest Learning Resources.
Free particle, control and targetting scripts. Numerous in-depth visual demonstrations, and multiple sandbox areas.
-
Stop by and try out Jopsy's new "Porgan 1800" an advanced steampunk styled 'particle organ' and the new particle texture store!
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
11-27-2006 17:57
Is it possible to both reset the script and keep the start_param value?
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
11-27-2006 22:47
From: ed44 Gupte
Is it possible to both reset the script and keep the start_param value?

CODE

integer saved_start_param;

default {
state_entry() {
saved_start_param = (integer) llGetObjectDesc();
llOwnerSay( (string) saved_start_param );
}

on_rez( integer start_param ) {
llSetObjectDesc( (string) start_param );
llResetScript();
}
}
_____________________
* The Particle Laboratory * - One of SecondLife's Oldest Learning Resources.
Free particle, control and targetting scripts. Numerous in-depth visual demonstrations, and multiple sandbox areas.
-
Stop by and try out Jopsy's new "Porgan 1800" an advanced steampunk styled 'particle organ' and the new particle texture store!
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
11-28-2006 05:00
That is absolutely amazing, Jopsy! Great lateral thinking!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-28-2006 05:05
Its one of the best ways of storing 'small' amounts of info
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
11-29-2006 01:22
I'm just going to have to take some other approach - I've tried your suggested test script and it doesn't work for me - compiles - says the first llOwnerSay line and then nothing - I've tried other example scripts that others have sent me or I've pilferred but while they all compile - nuffin -

Thanks for the try - think I'll go back to Rocket Science

Tarak
:-)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-29-2006 01:29
From: Tarak Voss
I'm just going to have to take some other approach - I've tried your suggested test script and it doesn't work for me - compiles - says the first llOwnerSay line and then nothing - I've tried other example scripts that others have sent me or I've pilferred but while they all compile - nuffin -

Thanks for the try - think I'll go back to Rocket Science

Tarak
:-)



Tarak, if you post your code, we can probably help you more.
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
11-29-2006 03:34
Getting a bit frustrated here - even the test scripts don't seem to work for me!? - and the Telecom people have just dug up the cable meaning I have to go to a mates place every time I want to test anything

I've enclosed what I'm trying to do in a flowchart format - it is only the reset that is causing me problems.

I've tried everything above but nothing seems to work when it come to on_rez.

Tarak
:-)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-29-2006 04:30
From: Tarak Voss
Getting a bit frustrated here - even the test scripts don't seem to work for me!? - and the Telecom people have just dug up the cable meaning I have to go to a mates place every time I want to test anything

I've enclosed what I'm trying to do in a flowchart format - it is only the reset that is causing me problems.

I've tried everything above but nothing seems to work when it come to on_rez.

Tarak
:-)



I dont see where on_rez comes into the diagram? What are you rezzing?

From the diagram it would appear that all you want to do is call llResetScript after performing your actions

Prim A
CODE



string MESSAGEA = "MESSAGE A";
string MESSAGEB = "MESSAGE B";
integer CHANNEL = 9999;
default
{
state_entry()
{
// Init?
}

on_rez(integer num)
{
llResetScript();
}

touch_start(integer total_number)
{
llSay(CHANNEL,MESSAGEA);
}
}


other prim

CODE


string MESSAGEA = "MESSAGE A";
string MESSAGEB = "MESSAGE B";
CHANNEL = 9999;

DoActionA()
{
}

DoActionB()
{
}

default
{
state_entry()
{
llListen(CHANNEL,"","",MESSAGEA);
llListen(CHANNEL,"","",MESSAGEB);
}

on_rez(integer num)
{
llResetScript();
}

listen(integer number, string name, key id, string message)
{
if(MESSAGEA == message)
{
DoActionA();
llResetScript();
}
else
{
DoActionB();
llResetScript();
}
}
}

Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
11-29-2006 04:46
Tail between legs time - thanks - sometimes one can't see the wood for the trees.

Thanks for your patience

Tarak
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-29-2006 05:05
From: Tarak Voss
Tail between legs time - thanks - sometimes one can't see the wood for the trees.

Thanks for your patience

Tarak


No worries.
And no need to be disheartened. Sometimes you get to wrapped up in a problem, 'tunnel vision' sets in and you really cannot see the solution. happens to all of us.

One question, why do you need to reset the script after each action?
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
11-29-2006 09:24
Just a suggestion.. if those two prims are linked, it's much better to use llMessageLinked() to send and link_message() to receive.

(listens tend to have a bad reputation for contributing to lag)
_____________________
* The Particle Laboratory * - One of SecondLife's Oldest Learning Resources.
Free particle, control and targetting scripts. Numerous in-depth visual demonstrations, and multiple sandbox areas.
-
Stop by and try out Jopsy's new "Porgan 1800" an advanced steampunk styled 'particle organ' and the new particle texture store!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-29-2006 12:22
From: Jopsy Pendragon
Just a suggestion.. if those two prims are linked, it's much better to use llMessageLinked() to send and link_message() to receive.

(listens tend to have a bad reputation for contributing to lag)



Very True, I had assumed from the original posting that they are not but....