To use these scripts place the control script in the root prim. Then place the slave script in the prim that will be changing shape.
Control Script:
// this script is placed in the main control prim for a sphere
key id;
float radiusSize;
float volumeSize;
default
{
touch_start(integer total_number)
{
id = llDetectedKey(0);
llMessageLinked(LINK_ALL_CHILDREN,0,"Cone",id);
state radius;
}
}
state radius
{
link_message(integer sender_number, integer number, string message, key id)
{
radiusSize=(float)message;
state display;
}
}
state display
{
state_entry()
{
volumeSize=(4.0/3.0)*PI*((radiusSize*radiusSize)*radiusSize);
llInstantMessage(id,"Volume is: "+(string)volumeSize
+"\n Radius is: "+(string)radiusSize);
llSetText("Volume is: "+(string)volumeSize
+"\n Radius is: "+(string)radiusSize,
<0.0,>, 1.0);
llMessageLinked(LINK_ALL_CHILDREN,0,"reset",id);
llResetScript();
}
}
Slave Script:
//place in the prim you want to change shape for a sphere
//global variables
float lengthSize;
float widthSize;
float radiusSize;
float volumeSize;
integer channel;
integer shape;
integer phantom=FALSE;
vector top_size=<1.0,1.0,0.0>;
vector startSize=<2.0,2.0,2.0>;//starting size of prim
string usermessage;
key id2;
//dialog list items
list listc= [".2", ".4", ".6", ".8", "1", "1.2", "1.4", "1.6", "1.8","2"];
list listd= ["0.1","0.2","0.3","0.4","0.5","0.6","0.7","0.8","0.9","1"];
list liste=["Yes","No"];
string menuHeight="Please Enter Height:";
string menuRadius="Please Enter Radius:";
string menurestart="Would You Like To Continue";
//============================================
//user defined functions
primsize()
{
float z= lengthSize;
float x= lengthSize;
float y= widthSize;
llSetScale(
}
primshape()
{
llSetPrimitiveParams([
PRIM_PHANTOM,phantom,
PRIM_TYPE,shape,
PRIM_HOLE_DEFAULT,
<0.0,1.0,0.0>,
0.0,
ZERO_VECTOR,
<0.0,1.0,0.0>]);
}
spherevolume()
{
volumeSize=(4.0/3.0)*PI*((radiusSize*radiusSize)*radiusSize);
}
reset()
{
llSleep(2.0);
llResetScript();
}
//======================================
//Script states
default
{
state_entry()
{
channel=(integer)llFrand(1000.0);
llListen(channel,"", id2,"");
}
link_message(integer sender_number, integer number, string message, key id)
{
id2=id;
usermessage=message;
if (message=="Square")
{
llResetScript();
}
else if (message=="Pyramid")
{
llResetScript();
}
else if (message=="Cylinder")
{
llResetScript();
}
else if (message=="Cone")
{
shape=PRIM_TYPE_SPHERE;
primshape();
state radiusState;
}
}
}
//state to get radius
state radiusState
{
state_entry()
{
llListen(channel,"", id2,"");
llDialog(id2, menuRadius, listd,channel);
}
listen(integer channel, string name, key id, string message)
{
radiusSize=(float)message;
llMessageLinked(LINK_ROOT,0,(string)radiusSize,"");
lengthSize=radiusSize*2;
widthSize=lengthSize;
llOwnerSay("Length"+message);
if (usermessage=="Cylinder")
{
llResetScript();
}
else if (usermessage=="Square")
{
llResetScript();
}
else if (usermessage=="Pyramid")
{
llResetScript();
}
else if (usermessage=="Cone")
{
spherevolume();
state display;
}
}
}
//state for display size
state display
{
state_entry()
{
llMessageLinked(LINK_ALL_CHILDREN,0,"start","");
llSleep(4.0);
primsize();
}
link_message(integer sender_number, integer number, string message, key id)
{
if (message=="reset")
reset();
}
}
No comments:
Post a Comment