Difference between revisions of "Talk:On rez"

From Second Life Wiki
Jump to navigation Jump to search
 
(One intermediate revision by one other user not shown)
Line 25: Line 25:
== HOW TO GIVE A FLOAT AS STARTPARAMETER IN ON_REZ FUNCTION==
== HOW TO GIVE A FLOAT AS STARTPARAMETER IN ON_REZ FUNCTION==
By Blade Gaelyth
By Blade Gaelyth
<br>
<lsl>
<br>
float f = 12345.6789;
float f = 12345.6789;<br>
 
<br>
//*****ENCODING THE FLOAT INTO AN INTEGER*****
//*****ENCODING THE FLOAT INTO AN INTEGER*****<br>
 
<br>
//separate integers and decimals
//separate integers and decimals<br>
list l = llParseString2List((string)f, ["."], []);
list l = llParseString2List((string)f, [&quot;.&quot;], []);<br>
 
<br>
//define dot's position
//define dot's position<br>
integer n = llStringLength(llList2String(l, 0));
integer n = llStringLength(llList2String(l, 0));<br>
 
<br>
//build the string dot position + integers + decimals
//build the string dot position + integers + decimals<br>
string m = (string)n + llList2String(l, 0) + llList2String(l, 1);
string m = (string)n + llList2String(l, 0) + llList2String(l, 1); <br>
 
<br>
//cast into an integer and send as startParam
//cast into an integer and send as startParam <br>
integer startParam = (integer)m;
integer startParam = (integer)m; <br>
</lsl>
<br>
<lsl>
//*****DECONDING THE FLOAT FROM THE INTEGER*****<br>
//*****DECODING THE FLOAT FROM THE INTEGER*****
<br>
 
//extract dot position<br>
//extract dot position
integer dot = (integer)llGetSubString((string)startParam, 0, 0);<br>
integer dot = (integer)llGetSubString((string)startParam, 0, 0);
<br>
 
//delete dot position<br>
//delete dot position
string num = llDeleteSubString((string)startParam, 0, 0); <br>
string num = llDeleteSubString((string)startParam, 0, 0);
<br>
 
//separate the integers and the decimals <br>
//separate the integers and the decimals
string part1 = llGetSubString(num, 0, dot-1); <br>
string part1 = llGetSubString(num, 0, dot-1);
string part2 = llDeleteSubString(num, 0, dot-1);<br>
string part2 = llDeleteSubString(num, 0, dot-1);
<br>
 
//build the string integers + dot + decimals <br>
//build the string integers + dot + decimals
string v = part1 + &quot;.&quot; + part2;<br>
string v = part1 + "." + part2;
<br>
 
//cast into a float<br>
//cast into a float
float f = (float)v; <br>
float f = (float)v;
<br>
</lsl>
AS YOU SEE BY THIS ROUTINE YOU CAN PRESERVE UNTIL 9 DECIMALS THAT IS MORE THAN  
AS YOU SEE BY THIS ROUTINE YOU CAN PRESERVE UNTIL 9 DECIMALS THAT IS MORE THAN ENOUGH FOR LSL USE.
ENOUGH FOR LSL USE.<br>
HOWEVER YOU CAN PRESERVE AS MANY DECIMALS AS YOU NEED BY SIMPLY ENCODING-DECODING THE HEADER IN TWO OR MORE DIGITS;
HOWEVER YOU CAN PRESERVE AS MANY DECIMALS AS YOU NEED BY SIMPLY  
<lsl>
ENCODING-DECODING THE HEADER IN TWO OR MORE DIGITS;<br>
//UNTIL 99 DECIMALS
//UNTIL 99 DECIMALS<br>
// 07 == 7 DECIMALS
// 07 == 7 DECIMALS<br>
// 12 == 12 DECIMALS
// 12 == 12 DECIMALS<br>
//UNTIL 999 DECIMALS
//UNTIL 999 DECIMALS<br>
// 003 == 3 DECIMALS
// 003 == 3 DECIMALS<br>
// 123 == 123 DECIMALS
// 123 == 123 DECIMALS</p>
</lsl>
 
----
 
: *cringe's at all caps*
: If you want to pass a float without having to worry about if it's in range, you can use [[User:Strife_Onizuka/Float_Functions#Float_.3C-Union-.3E_Integer|FUI and IUF]]. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 14:55, 15 October 2013 (PDT)

Latest revision as of 13:55, 15 October 2013

Object Duplicate

It seems that this event does not fire when an object is duplicated in-world using the Shift-Key + Drag-Posistion-Arrow technique. I wonder.. Is there a way (in LSL) to detect this occurance? As I see it there are a few ways for a script to appear in-world:

  1. Copied/moved from inventory.
  2. Creating a new script in an object.
  3. Saving/resetting a script already in an object.
  4. Using the Shift-Drag technique to duplicate an existing rezzed object.
  5. Copying/moving an object, that has a script inside it, from inventory to the world.
  6. Sending a script via llGiveInventory.
  7. Sending a script via llRemoteLoadScriptPin.

As far as I can tell, there is no way to tell, programmatically, between numbers 1, 2, 3, and 4. Number 5 keeps the script's state and fires on_rez; Number 6 sends the script to the other object in a deactivated way; And number 7 can send a start parameter. Yet, to me, it seems that #4 should fire on_rez. Any reasons why not? If doing number 4 reset the script, then called on_rez, it could be easily detected. Cron Stardust 00:42, 26 December 2007 (PST)

Disambiguation

A disambiguation notice should probably be added to the page, to avoid confusion among people looking for the third party OnRez viewer. SignpostMarv Martin 04:34, 26 December 2007 (PST)

Sim restart

Is on_rez triggered when a sim is restarted? —The preceding unsigned comment was added by Mardu Kuhn

Nopes, doesn't trigger an on_rez event. But it triggers changed with CHANGED_REGION_START.
--Zai signature.png (talk|contribs) 17:11, 21 February 2010 (UTC)


HOW TO GIVE A FLOAT AS STARTPARAMETER IN ON_REZ FUNCTION

By Blade Gaelyth <lsl> float f = 12345.6789;

//*****ENCODING THE FLOAT INTO AN INTEGER*****

//separate integers and decimals list l = llParseString2List((string)f, ["."], []);

//define dot's position integer n = llStringLength(llList2String(l, 0));

//build the string dot position + integers + decimals string m = (string)n + llList2String(l, 0) + llList2String(l, 1);

//cast into an integer and send as startParam integer startParam = (integer)m; </lsl> <lsl> //*****DECODING THE FLOAT FROM THE INTEGER*****

//extract dot position integer dot = (integer)llGetSubString((string)startParam, 0, 0);

//delete dot position string num = llDeleteSubString((string)startParam, 0, 0);

//separate the integers and the decimals string part1 = llGetSubString(num, 0, dot-1); string part2 = llDeleteSubString(num, 0, dot-1);

//build the string integers + dot + decimals string v = part1 + "." + part2;

//cast into a float float f = (float)v; </lsl> AS YOU SEE BY THIS ROUTINE YOU CAN PRESERVE UNTIL 9 DECIMALS THAT IS MORE THAN ENOUGH FOR LSL USE. HOWEVER YOU CAN PRESERVE AS MANY DECIMALS AS YOU NEED BY SIMPLY ENCODING-DECODING THE HEADER IN TWO OR MORE DIGITS; <lsl> //UNTIL 99 DECIMALS // 07 == 7 DECIMALS // 12 == 12 DECIMALS //UNTIL 999 DECIMALS // 003 == 3 DECIMALS // 123 == 123 DECIMALS </lsl>


*cringe's at all caps*
If you want to pass a float without having to worry about if it's in range, you can use FUI and IUF. -- Strife (talk|contribs) 14:55, 15 October 2013 (PDT)