Difference between revisions of "User:Daemonika Nightfire/Scripts/*DS* Resize Script"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
==*DS* Resize | ==*DS* Resize Example v3.0.00== | ||
Single resize script for a complete linkset with save and restore option. | Single resize script for a complete linkset with save and restore option. | ||
<source lang="lsl2"> | <source lang="lsl2"> | ||
// | // | ||
// ╔═════════════════════════════════════−−−→ | // ╔═════════════════════════════════════−−−→ | ||
// ║ *DS* Resize | // ║ *DS* Resize Example by Daemonika Nightfire (daemonika.nightfire) | ||
// ╚══════════════════════−−−→ | // ╚══════════════════════−−−→ | ||
// | // | ||
// Resize Script for rezzed Objects and Attachments. | // Resize Script for rezzed Objects and Attachments. | ||
// Single-script for a complete linkset with save and restore option. | // Single-script for a complete linkset with save and restore option. | ||
Line 16: | Line 14: | ||
// The parameters will be stored in the descriptionfield of each prim, that needs no script-memory :) | // The parameters will be stored in the descriptionfield of each prim, that needs no script-memory :) | ||
// • You can save, resize and restore individual prims or the complette linkset. | // • You can save, resize and restore individual prims or the complette linkset. | ||
// | // | ||
// Important: | // Important: | ||
Line 53: | Line 42: | ||
integer LinkSet = TRUE; | integer LinkSet = TRUE; | ||
integer Prim; | integer Prim; | ||
integer links; | |||
integer Channel; | integer Channel; | ||
Line 91: | Line 81: | ||
{ | { | ||
owner = llGetOwner(); | owner = llGetOwner(); | ||
llOwnerSay("/me " + llGetScriptName() + " Free Memory: " + (string)llGetFreeMemory() + " bytes."); | |||
} | } | ||
Line 99: | Line 89: | ||
if(llDetectedKey(0) == owner) | if(llDetectedKey(0) == owner) | ||
{ | { | ||
links = llGetNumberOfPrims(); | |||
Prim = llDetectedLinkNumber(0); | |||
menu1(); | |||
} | } | ||
} | } | ||
Line 171: | Line 147: | ||
{ | { | ||
llOwnerSay("Please wait..."); | llOwnerSay("Please wait..."); | ||
integer i = 0; | |||
do | |||
{ | { | ||
link = llGetLinkPrimitiveParams( | link = llGetLinkPrimitiveParams(i, [PRIM_SIZE , PRIM_POS_LOCAL]); | ||
size = llList2Vector(link, 0); | |||
position = llList2Vector(link, 1); | position = llList2Vector(link, 1); | ||
llSetLinkPrimitiveParamsFast( | if(i > 1) | ||
{ | |||
llSetLinkPrimitiveParamsFast(i,[PRIM_DESC,(string)size + "#" + (string)position]); | |||
} | |||
else | |||
{ | { | ||
llSetLinkPrimitiveParamsFast(i,[PRIM_DESC,(string)size]); | |||
} | } | ||
} | } | ||
while(++i <= links); | |||
new = FALSE; | |||
llOwnerSay("All parameters are stored"); | llOwnerSay("All parameters are stored"); | ||
menu2(); | menu2(); | ||
Line 221: | Line 188: | ||
else | else | ||
{ | { | ||
integer i = 0; | |||
do | |||
{ | { | ||
link = llGetLinkPrimitiveParams(i, [PRIM_DESC]); | link = llGetLinkPrimitiveParams(i, [PRIM_DESC]); | ||
Line 232: | Line 200: | ||
if(i > 1) | if(i > 1) | ||
{ | { | ||
llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, size, | llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, size, PRIM_POS_LOCAL, position]); | ||
} | } | ||
else | else | ||
Line 239: | Line 207: | ||
} | } | ||
} | } | ||
while(++i <= links); | |||
} | } | ||
llOwnerSay("All stored parameters restored."); | llOwnerSay("All stored parameters restored."); | ||
Line 262: | Line 231: | ||
else | else | ||
{ | { | ||
integer i = 0; | |||
do | |||
{ | { | ||
link = llGetLinkPrimitiveParams(i, [PRIM_SIZE, | link = llGetLinkPrimitiveParams(i, [PRIM_SIZE, PRIM_POS_LOCAL]); | ||
size = llList2Vector(link, 0) * shift; | size = llList2Vector(link, 0) * shift; | ||
position = llList2Vector(link, 1 | position = llList2Vector(link, 1) * shift; | ||
if(i > 1) | if(i > 1) | ||
{ | { | ||
llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, size, | llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, size, PRIM_POS_LOCAL, position]); | ||
} | } | ||
else | else | ||
Line 278: | Line 247: | ||
} | } | ||
} | } | ||
while(++i <= links); | |||
} | } | ||
llOwnerSay("Finish."); | llOwnerSay("Finish."); |
Revision as of 14:13, 16 March 2023
*DS* Resize Example v3.0.00
Single resize script for a complete linkset with save and restore option.
//
// ╔═════════════════════════════════════−−−→
// ║ *DS* Resize Example by Daemonika Nightfire (daemonika.nightfire)
// ╚══════════════════════−−−→
//
// Resize Script for rezzed Objects and Attachments.
// Single-script for a complete linkset with save and restore option.
//
// Featueres:
// • By the first run or reset of this script, it will ask you to save all parameters.
// The parameters will be stored in the descriptionfield of each prim, that needs no script-memory :)
// • You can save, resize and restore individual prims or the complette linkset.
//
// Important:
// • Undersize is possible, but take care.
// if you are small your object and several prims already have minimum dimensions, they are not further reduced, but they are moved proportionally.
// • Sculpted Prims are no problem, but take care.
// Sculpties with moved Bounding Box perhaps moving optical not correct
// That is not true, they are moving correctly, but when the visible Sculptie is not the center of the Bounding Box, it will be looking wrong.
//
// Terms of use:
// You can use, edit and sell this script inside your creations with the following permissions in Second Life:
// • MOD Yes • COPY Yes • TRANSFER Yes
//
// Yes that means fullperm. Other settings, are against the following licenses.
// The permission of your Object (prim), remain unaffected by these terms
//
// https://wiki.secondlife.com/wiki/User:Daemonika_Nightfire/Scripts/*DS*_Resize_Script
// http://wiki.secondlife.com/wiki/Project:Terms_of_Service
// http://creativecommons.org/licenses/by-sa/3.0/
//
// violation of this Terms are against the Second Life TOS at §7 Content Licenses and Intellectual Property Rights.
// http://secondlife.com/corporate/tos.php
//
key owner;
integer new = TRUE;
integer LinkSet = TRUE;
integer Prim;
integer links;
integer Channel;
integer Listener;
Chan()
{
llListenRemove(Listener);
Channel = (integer)(llFrand(1) * -DEBUG_CHANNEL);
Listener = llListen(Channel, "", owner, "");
llSetTimerEvent(60);
}
menu1()
{
Chan();
if(new)
{
llDialog(owner, "\nYour first run or reset of this script.\nDo you whish to save current parameters?",
["Save","Later"], Channel);
}
else
{
llDialog(owner, "\nselect an option\nThis = touched Prim\nAll = complete Object",
["This","All","Done"], Channel);
}
}
menu2()
{
Chan();
llDialog(owner, "\n+ - = resize\nSave = record all parameters\nRestore = restore saved parameters",
["Save","Restore","Done","-1%","-5%","-10%","+1%","+5%","+10%"], Channel);
}
default
{
state_entry()
{
owner = llGetOwner();
llOwnerSay("/me " + llGetScriptName() + " Free Memory: " + (string)llGetFreeMemory() + " bytes.");
}
touch_start(integer total_number)
{
owner = llGetOwner();
if(llDetectedKey(0) == owner)
{
links = llGetNumberOfPrims();
Prim = llDetectedLinkNumber(0);
menu1();
}
}
listen(integer channel, string name, key id, string msg)
{
float shift = 0;
vector position;
vector size;
list link;
integer i;
if(msg == "This")
{
LinkSet = FALSE;
menu2();
}
else if(msg == "All")
{
LinkSet = TRUE;
menu2();
}
else if(msg == "Done" || msg == "Later")
{
llListenRemove(Listener);
llSetTimerEvent(0);
}
else if(msg == "-1%")
{
shift = 0.99;
}
else if(msg == "-5%")
{
shift = 0.95;
}
else if(msg == "-10%")
{
shift = 0.9;
}
else if(msg == "+1%")
{
shift = 1.01;
}
else if(msg == "+5%")
{
shift = 1.05;
}
else if(msg == "+10%")
{
shift = 1.1;
}
// Record
else if(msg == "Save")
{
llOwnerSay("Please wait...");
integer i = 0;
do
{
link = llGetLinkPrimitiveParams(i, [PRIM_SIZE , PRIM_POS_LOCAL]);
size = llList2Vector(link, 0);
position = llList2Vector(link, 1);
if(i > 1)
{
llSetLinkPrimitiveParamsFast(i,[PRIM_DESC,(string)size + "#" + (string)position]);
}
else
{
llSetLinkPrimitiveParamsFast(i,[PRIM_DESC,(string)size]);
}
}
while(++i <= links);
new = FALSE;
llOwnerSay("All parameters are stored");
menu2();
}
// Restore
else if(msg == "Restore")
{
if(!new)
{
llOwnerSay("Please wait...");
if(!LinkSet)
{
link = llGetLinkPrimitiveParams(Prim, [PRIM_DESC]);
list parsed = llParseString2List(llList2CSV(link), ["#"], []);
string vect = llList2String(parsed, 0);
size = (vector)vect;
llSetLinkPrimitiveParamsFast(Prim, [PRIM_SIZE, size]);
}
else
{
integer i = 0;
do
{
link = llGetLinkPrimitiveParams(i, [PRIM_DESC]);
list parsed = llParseString2List(llList2CSV(link), ["#"], []);
string vect = llList2String(parsed, 0);
size = (vector)vect;
string posi = llList2String(parsed, 1);
position = (vector)posi;
if(i > 1)
{
llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, size, PRIM_POS_LOCAL, position]);
}
else
{
llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, size]);
}
}
while(++i <= links);
}
llOwnerSay("All stored parameters restored.");
menu2();
}
else if(new)
{
llOwnerSay("Please first save all paremeters to use this.");
}
}
// Resize
if(shift != 0)
{
llOwnerSay("Please wait...");
if(!LinkSet)
{
link = llGetLinkPrimitiveParams(Prim, [PRIM_SIZE]);
size = llList2Vector(link, 0) * shift;
llSetLinkPrimitiveParamsFast(Prim, [PRIM_SIZE, size]);
}
else
{
integer i = 0;
do
{
link = llGetLinkPrimitiveParams(i, [PRIM_SIZE, PRIM_POS_LOCAL]);
size = llList2Vector(link, 0) * shift;
position = llList2Vector(link, 1) * shift;
if(i > 1)
{
llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, size, PRIM_POS_LOCAL, position]);
}
else
{
llSetLinkPrimitiveParamsFast(i, [PRIM_SIZE, size]);
}
}
while(++i <= links);
}
llOwnerSay("Finish.");
menu2();
}
}
timer()
{
llSetTimerEvent(0);
llListenRemove(Listener);
llOwnerSay("Listener timeout, please touch again to use the menu.");
}
on_rez(integer Dae)
{
if(new)
{
llResetScript();
}
}
}