Resizing through dialog menu?
|
|
Keera Zenovka
Registered User
Join date: 23 Mar 2007
Posts: 35
|
03-02-2008 02:13
Is it possible to scale/resize a linkset of prims using dialog menu commands? I don't want to set Mod permissions on my linked object, but I want users to be able to resize the object larger or smaller (in small increments) when they bring up a menu. As large or as small as they like, within the prim limits. I'm a noob at this and many details would be really appreciated 
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
03-02-2008 04:14
The dialog part is easy enough, I think the resizing is the tricky bit!. But as luck would have it there's an example of this very thing on the Wiki:  Controlling the listen using llDialog should be easy enough but you will have to restrict yourself to a finite number of scale factors. For example: llDialog(llGetOwner(), "Change My Size", ["0.25", "0.5", "0.9", "1.1" "2.0", "4.0"], 9);
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
03-02-2008 06:34
Or, you could have "Larger" and "Smaller" buttons which add or subtract a certain percentage, and re-display the dialog each time a request is heard, until a "Done" button is pressed.
|
|
Keera Zenovka
Registered User
Join date: 23 Mar 2007
Posts: 35
|
03-03-2008 19:07
Thanks all - this is what I've pieced together so far with my noobish knowledge. Deanna, I want to do what you suggested - first bring up one dialog menu with the option "Resize", which then brings up another menu showing "Bigger" and "Smaller" options. I want to add and subtract by 10% each time Bigger/Smaller is chosen (don't know where exactly to put this in the code, which integer to +/- .1 from?) Can someone help me with the rest of this and show me what I've done wrong so far? Script in Parent Prim:
integer Channel; integer Handle; list Options = ["Resize", "Bigger", "Smaller"]; string Title = "\nResize Menu";
dialogShow() { llListenRemove(Handle); Channel = ((integer)llFrand(900000) + 100000) * -1; Handle = llListen(Channel, "", llGetOwner(), ""); llDialog(llGetOwner(), Title, Options, Channel); }
Resize(float scale) { integer num_prims = llGetNumberOfPrims(); integer i;
for (i = 1; i <= num_prims; i++) { // first prim in a linked set is 1 llMessageLinked(i, 0, (string)scale, NULL_KEY); }
}
default { touch_start(integer total_number) { if (llDetectedKey(0) == llGetOwner()) dialogShow(); }
attach(key attached) { if (attached != NULL_KEY) { Options = ["Resize", "Bigger", "Smaller"]; } }
listen(integer channel, string name, key id, string message) { llListenRemove(Handle);
if (message == "Resize") { Options = ["Bigger", "Smaller"]; }
if (message == "Bigger") {
float scale; scale = (float)message; if ( scale == 0.0 ) return; // we don't resize by factor 0.0 llSay(0, "Resizing by factor " + (string)scale); Resize(scale); Options = ["Bigger", "Smaller"]; } if (message == "Smaller") //don't know what goes here yet { ? } } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } }
Script in Child Prim:
default { link_message(integer sender_num, integer num, string str, key id) { float scale = (float)str; // size factor vector currentsize = llGetScale(); vector newsize = currentsize * scale; //where to add/subtract by 10%? list primparams = [];
primparams += [PRIM_SIZE, newsize]; // resize
if (llGetLinkNumber() > 1) { primparams += [PRIM_POSITION, llGetLocalPos() * scale]; // reposition } llSetPrimitiveParams(primparams); } }
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
03-03-2008 22:28
From: Keera Zenovka Deanna, I want to do what you suggested - first bring up one dialog menu with the option "Resize"... Will there be other options on the menu besides "Resize"? Is there any reason not to just directly display "Bigger" and "Smaller"? From: someone I want to add and subtract by 10% each time Bigger/Smaller is chosen (don't know where exactly to put this in the code, which integer to +/- .1 from?) If going bigger, multiply the current scale by 1.1. If going smaller, multiply by 0.9. Note that adding/subtracting 10% of the present size will result in subsequent bigger/smaller commands not exactly cancelling out. Adding 10% to 100 results in 110. But subtracting 10% from 110 results in 99. Just a word of caution, if its of any concern. From: someone for (i = 1; i <= num_prims; i++) { // first prim in a linked set is 1 llMessageLinked(i, 0, (string)scale, NULL_KEY); }
Wouldn't it be easier just to send a single message to LINK_SET or LINK_ALL_CHILDREN, rather than iterating through each link number? BTW, you start this loop by sending a message to the root prim (#1), but the root prim script has no link_message handler. I'd suggest just handling the root prim's scaling directly, before messaging the children, rather than having the root wait for a link_message from itself. From: someone if (message == "Bigger"  { float scale; scale = (float)message; [...] Casting the string "Bigger" to a float will always result in the value 0.0. I'd suggest a set of parallel lists, such as: list options = [ "Bigger", "Smaller" ]; list scales = [ 1.1, 0.9 ]; Then, inside the listen handler, use llListFindList to search the options list for the value of message. If found (i.e., if not -1), use that as a lookup index for the scales list, and pass that value to the child prims.
|
|
Soenke Kohime
Registered User
Join date: 5 Jul 2007
Posts: 4
|
03-04-2008 07:42
Hi, From: Deanna Trollop ....... But subtracting 10% from 110 results in 99. Just a word of caution, if its of any concern. .........
Just an idea: What about to multiply the vector by (1/1.1) to make it smaller. I think this gives more precision. Beste regards Sönke
|
|
Keera Zenovka
Registered User
Join date: 23 Mar 2007
Posts: 35
|
03-04-2008 12:03
Sönke thanks for the idea. Deanna, yes I want to eventually add other options to the menu along with Resize, which is why I want Bigger/Smaller to be submenu options....not sure if I'm doing that part right either.
Deanna I understood some of what you are saying but most of it is over my head because I'm not a scripter and I'm just trying to learn. Much of that code is from the Wiki. llListFindList I'm completely unfamiliar with - if someone wouldn't mind providing me with examples for instance on how to include llListFindList or add link_message handler to the root?
|