The next one that isn't working is her High Striker. There are 3 prims:
Here is the only script that's in it [named High Striker] and it's in the root prim in SL - once again there is the "#" that is a problem, I tried to change it from "weight_prim#" to "weight_primNum" and "weight_prim_Num" and neither worked and gave error messages.
Code: Select all
// Strength Test Game Control, in root prim, controlling weight prim in linkset
//global variables
// physics parameters
float V0 = 0.0 ; // initial velocity
float A = 0.0 ; // acceleration (positive is upwards) gravity= -9.8
float S0 = 0.0 ; // initial distance from point of rest
float S = 0.0; //vertical displacement from rest point ;
integer weight_prim# ; // check actual prim in linkset
key id ;
string name =""; // player name
string prim_name="weight" ;
integer win=0 ;
integer Swing_power = 0 ;
integer i ; //incremental counter
integer total_number;
float interval = 10.0 ; //time period for swing
integer count ; // tally touches during swing
list responseLow =[ "I don't remember getting one THAT low before.", "Get out of the rocking chair before you try next time", "Maybe you should get a nap and a sandwich before you try next time", "Do you want some help?", "Try using two hands next time", "The test for grandparents is a squeeze ball","Don't hurt yourself.", "We have a smaller hammer, if you like.","Keep trying, the Amusement Park is open 7 days a week", "The toddler behind you is getting impatient", "Did you know you can take classes in how to swing a hammer?","You forgot to take your pill this morning, didn't you?","I hope your family is not watching this!", "No, that is not ME who is laughing, is there someone at the computer desk with you?"];
integer SelectResponse ;
ParticleEffect ()
{
llParticleSystem([ PSYS_PART_MAX_AGE,5.0,
PSYS_PART_START_COLOR, <1,1,1>,
PSYS_PART_END_COLOR, <1,1,1>,
PSYS_PART_START_SCALE,<1,1,1>,
PSYS_PART_END_SCALE,<1,1,1>,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE,
PSYS_SRC_BURST_RATE,0.18,
PSYS_SRC_ACCEL, <0,0,-0.3>,
PSYS_SRC_BURST_PART_COUNT,3,
PSYS_SRC_BURST_RADIUS,3.0,
PSYS_SRC_BURST_SPEED_MIN,0.1,
PSYS_SRC_BURST_SPEED_MAX,3.0,
PSYS_SRC_TARGET_KEY,(key) NULL_KEY,
PSYS_SRC_ANGLE_BEGIN,0.0,
PSYS_SRC_ANGLE_END,0.2,
PSYS_SRC_OMEGA, <0,0,0>,
PSYS_SRC_MAX_AGE, 5.0,
PSYS_SRC_TEXTURE, "Star",
PSYS_PART_START_ALPHA, 1.0,
PSYS_PART_END_ALPHA, 1.0,
PSYS_PART_FLAGS,PSYS_PART_EMISSIVE_MASK
]);
//llSleep(20);
}
default
{
state_entry()
{
llWhisper(0, "Strength Test Game is ready");
}
touch_start(integer total_number)
{
key id = llDetectedKey(0) ;
string name = llDetectedName(0);
llWhisper(0,name +", has stepped up to challenge the Strength Test!");
{
//weight full travel height of 4.8m, with initial velocity input (V0) up to 10
// 1 in 5 win for full height, medium mass avatar is target
// determine weight initial position
integer weight_prim# ;
integer lupe = llGetNumberOfPrims()+1;
while(--lupe > 1)
{
if(llGetLinkName(lupe)=="weight")
weight_prim#=lupe;
//llOwnerSay ("weight prim "+(string)weight_prim#) ;
}
vector obj_pos = llGetPos(); // position of game linkset
rotation obj_rot = llGetRot(); // rotation of game linket
vector prim_pos = llList2Vector(llGetLinkPrimitiveParams(weight_prim,[PRIM_POSITION]),0);
prim_pos = (prim_pos - obj_pos) / obj_rot; // Convert from region coordinates to local coordinates
// Swing input
llWhisper (0,name+", get ready to SWING ! ");
llSetLinkPrimitiveParamsFast (3, [PRIM_COLOR, ALL_SIDES, <0.0, 0.8, 0.2>, 1.0]); //turn prim GREEN
llSleep(5.0);
float V0 = llFrand(10.0) ; // initial velocity imparted by player ---TEST MANUAL----
llSetLinkPrimitiveParamsFast (3, [PRIM_COLOR, ALL_SIDES, <1.0, 0.2, 0.0>, 1.0]); //turn prim RED
llSleep(3.0);
// physics
S0 = (float)prim_pos.z ;
float S = 0 ; // displacement Z direction
float S_peak=0; // height achieved
float A = -9.8 ; // gravitation acceleration
float T = 0.0 ; // incremental time in seconds
float S0 = (prim_pos.z) ; // initial displacement in Z direction
float S_max = 4.8 ; // bell height
integer Bell_ring = FALSE ;
integer Win = FALSE ;
llSetLinkPrimitiveParamsFast (weight_prim#, [PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 1.0]);
// do the hammer hit and rise fall sounds
// s = (0.5 * (A)*t^2 + v0*t + s0 <--- basic formula
for (T=0; T < 2.5; T=T+0.03)
{
S = (0.5 * (A*(T*T)) + V0*T ) ; //deviation only, S0 is not included
if (S>S_max) Win=TRUE;
if (S>S_peak) (S_peak=S) ;
//if (Win) Bell_ring=TRUE
if (S<0) S=0 ;
// prim movement
prim_pos.z = S0 + S ;
llSetLinkPrimitiveParamsFast(weight_prim#,[PRIM_POSITION,prim_pos]);
llSleep(0.01);
}
// FINAL REPORT
integer Score = (integer)llRound(100*S_peak/S_max) ;
llWhisper (0,"You hit a "+(string) llRound(100*S_peak/S_max)+ " percent strength.") ;
// llOwnerSay ("S_peak = "+ (string)S_peak+" V0= "+(string)V0);
// llOwnerSay ("integer round "+ (string) llRound (100*S_peak/S_max) );
//Score=100; // test
if (Score<50)
{
integer length = llGetListLength(responseLow);
SelectResponse = (integer)(llFrand(length));
i=SelectResponse;
llWhisper(0,llList2String(responseLow, i)+"\n\n");
}
if (Score>49 & Score<80) llWhisper (0," << Now THAT is looking a little better. >>\n\n");
if (Score>=80 & Score<=95) llWhisper (0," << Wow, have you been practicing?>>\n\n ");
if (Score> 95)
{
llWhisper (0,"<< CONGRATULATIONS !! DING, you win !! >>\n\n");
llTriggerSound("Boxing Bell Start Round", 1.0);
for (i=0;i<=50;++i)
{
ParticleEffect () ;
}
llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_OBJECT,(integer)llFrand(llGetInventoryNumber(INVENTORY_OBJECT))));
//llSleep(60);
//llParticleSystem([]);//turn particles off
}
}
}
}