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:
// copy from here down
// this script is placed in the main control prim for a cone
key id;
float heightSize;
float radiusSize;
float volumeSize;
default
{
touch_start(integer total_number)
{
id = llDetectedKey(0);
llMessageLinked(LINK_ALL_CHILDREN,0,"Cone",id);
}
link_message(integer sender_number, integer number, string message, key id)
{
heightSize=(float)message;
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=(1.0/3.0)*PI*(radiusSize*radiusSize)*heightSize;
llInstantMessage(id,"Volume is: "+(string)volumeSize
+"\n Height is: "+(string)heightSize
+"\n Radius is: "+(string)radiusSize);
llSetText("Volume is: "+(string)volumeSize
+"\n Height is: "+(string)heightSize
+"\n Radius is: "+(string)radiusSize,
<0.0,>, 1.0);
llMessageLinked(LINK_ALL_CHILDREN,0,"reset",id);
llResetScript();
}
}
//End of first script
Slave Script:
//copy from here down
//place in the prim you want to change shape for a cone
//global variables
float lengthSize;
float widthSize;
float heightSize;
float radiusSize;
float volumeSize;
integer channel;
integer shape;
integer phantom=FALSE;//Select TRUE for Phantom prim FALSE for normal.
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= heightSize;
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,
top_size,
ZERO_VECTOR]);
}
conevolume()
{
volumeSize=(1.0/3.0)*PI*(radiusSize*radiusSize)*heightSize;
}
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_CYLINDER;
top_size=ZERO_VECTOR;
primshape();
state Height;
}
}
}
//state to get height
state Height
{
state_entry()
{
llListen(channel,"", id2,"");
llDialog(id2, menuHeight, listc,channel);
}
listen(integer channel, string name, key id, string message)
{
heightSize=(float)message;
llMessageLinked(LINK_ROOT,0,(string)heightSize,"");
if (usermessage=="Square"||usermessage=="Pyramid")
{
llResetScript();
}
else if (usermessage=="Cylinder"||usermessage=="Cone")
{
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")
{
conevolume();
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();
}
}
//end of script
No comments:
Post a Comment