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 cube
key id;
float heightSize;
float lengthSize;
float widthSize;
float volumeSize;
default
{
touch_start(integer total_number)
{
id = llDetectedKey(0);
llMessageLinked(LINK_ALL_CHILDREN,0,"Cube",id);
}
link_message(integer sender_number, integer number, string message, key id)
{
heightSize=(float)message;
state width;
}
}
state width
{
link_message(integer sender_number, integer number, string message, key id)
{
widthSize=(float)message;
state length;
}
}
state length
{
link_message(integer sender_number, integer number, string message, key id)
{
lengthSize=(float)message;
state display;
}
}
state display
{
state_entry()
{
volumeSize=lengthSize*widthSize*heightSize;
llInstantMessage(id,"Volume is: "+(string)volumeSize
+"\n Height is: "+(string)heightSize
+"\n Length is: "+(string)lengthSize
+"\n Width is: "+(string)widthSize);
llSetText("Volume is: "+(string)volumeSize
+"\n Height is: "+(string)heightSize
+"\n Length is: "+(string)lengthSize
+"\n Width is: "+(string)widthSize,
<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 cube
//global variables
float lengthSize;
float widthSize;
float heightSize;
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 liste=["Yes","No"];
string menuLength="Please Enter Length:";
string menuWidth="Please Enter Width:";
string menuHeight="Please Enter Height:";
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]);
}
Cubevolume()
{
volumeSize=lengthSize*widthSize*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=="Cube")
{
shape=PRIM_TYPE_BOX;
primshape();
state Height;
}
else if (message=="Pyramid")
{
llResetScript();
}
else if (message=="Cone")
{
llResetScript();
}
else if (message=="Cylinder")
{
llResetScript();
}
}
}
//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=="Cube"||usermessage=="Pyramid")
{
state width;
}
else if (usermessage=="Cylinder"||usermessage=="Cone")
{
llResetScript();
}
}
}
//state to get width
state width
{
state_entry()
{
llListen(channel,"", id2,"");
llDialog(id2, menuWidth, listc,channel);
}
listen(integer channel, string name, key id, string message)
{
widthSize=(float)message;
llMessageLinked(LINK_ROOT,0,(string)widthSize,"");
state length;
}
}
//state to get length
state length
{
state_entry()
{
llListen(channel,"", id2,"");
llDialog(id2, menuLength, listc,channel);
}
listen(integer channel, string name, key id, string message)
{
lengthSize=(float)message;
llMessageLinked(LINK_ROOT,0,(string)lengthSize,"");
llOwnerSay("Length"+message);
if (usermessage=="Cube")
{
Cubevolume();
state display;
}
else if (usermessage=="Pyramid")
{
llResetScript();
state display;
}
else if (usermessage=="Cylinder")
{
llResetScript();
state display;
}
else if (usermessage=="Cone")
{
llResetScript();
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();
}
}
//Script End:
No comments:
Post a Comment