Dot Matrix wrote: ↑Tue Dec 29, 2020 11:28 amGraham’s script also added parentheses around the two SR1 etc size checks; this probably solved the issue.
Arcadia's Scripts
- Koshari Mahana
- Posts: 359
- Joined: Fri Feb 06, 2015 8:14 am
- Has thanked: 280 times
- Been thanked: 500 times
- Contact:
Re: Arcadia's Scripts
Oh, I see, I didn't notice that. I appreciate the help!
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
- John Mela
- Posts: 91
- Joined: Tue Feb 04, 2014 9:50 pm
- Has thanked: 139 times
- Been thanked: 127 times
- Contact:
Re: Arcadia's Scripts
I think the other issue was this code in the touch_start() event:
I'm a little surprised that compiled even in SL - the "spin==0" part should be "spin=0" (assignment, not comparison). Graham's version fixed that.
Code: Select all
if (spin==3){
spin==0;
}
- These users thanked the author John Mela for the post (total 2):
- Graham Mills • Koshari Mahana
- Tess Juel
- Posts: 360
- Joined: Sun Sep 11, 2016 4:24 pm
- Has thanked: 258 times
- Been thanked: 469 times
Re: Arcadia's Scripts
This reminds me of a long standing, allbeit fairly minor, item on my features wishlist: A way to resort the linking order without having to unlink and carefully select each item one by one.
Last edited by Tess Juel on Thu Dec 31, 2020 10:40 pm, edited 1 time in total.
- These users thanked the author Tess Juel for the post:
- Koshari Mahana
- Snoots Dwagon
- Posts: 422
- Joined: Mon Jul 30, 2018 9:45 pm
- Has thanked: 442 times
- Been thanked: 779 times
Re: Arcadia's Scripts
if (llDetectedLinkNumber(0)==11&running==FALSE) // touching backboard
As mentioned by another, this is problematic coding, because link order can easily change. There are two better ways to do this, both similar. Test for either the name of the prim or the description (and then make sure that prim has a specific name or description. You may have to add one). To do this use llGetLinkPrimitiveParams() and the PRIM_NAME or PRIM_DESCparameter.
Semi-code example:
if( name_of_linked_prim == "this name" & running==FALSE) {do this;}
Code example:
if(llGetLinkPrimitiveParams(linknum,[PRIM_NAME])=="specname"...
(I think all that is correct. Doing this on the fly so if syntax is incorrect somewhere, someone feel free to point it out.)
As mentioned by another, this is problematic coding, because link order can easily change. There are two better ways to do this, both similar. Test for either the name of the prim or the description (and then make sure that prim has a specific name or description. You may have to add one). To do this use llGetLinkPrimitiveParams() and the PRIM_NAME or PRIM_DESCparameter.
Semi-code example:
if( name_of_linked_prim == "this name" & running==FALSE) {do this;}
Code example:
if(llGetLinkPrimitiveParams(linknum,[PRIM_NAME])=="specname"...
(I think all that is correct. Doing this on the fly so if syntax is incorrect somewhere, someone feel free to point it out.)
- These users thanked the author Snoots Dwagon for the post:
- Koshari Mahana
~~~~~~~
I'm a dwagon in real life too. (Ask my sister, who totally agrees.)
~~~~~~~
I'm a dwagon in real life too. (Ask my sister, who totally agrees.)
~~~~~~~
- Koshari Mahana
- Posts: 359
- Joined: Fri Feb 06, 2015 8:14 am
- Has thanked: 280 times
- Been thanked: 500 times
- Contact:
Re: Arcadia's Scripts
Tess, lol I did have trouble with this. I naturally thought since there were 12 prims that if I linked it second to last (with the root prim being last) that it would turn out to be link 11. But that wasn't the way it turned out, sometimes it came out to be link 2 and sometimes it came out to be link 12. I ended up linking it 3rd to last which made it link 11. It took a lot of trial and error though, I'm lucky it was only 12 prims!
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
- Koshari Mahana
- Posts: 359
- Joined: Fri Feb 06, 2015 8:14 am
- Has thanked: 280 times
- Been thanked: 500 times
- Contact:
Re: Arcadia's Scripts
Thanks John, that's good to know. I am not knowledgeable about scripting. All help is appreciated! I'm sure there is a reason why sometimes == is used and sometimes = is used but it's way over my head.
John Mela wrote: ↑Tue Dec 29, 2020 1:37 pmI think the other issue was this code in the touch_start() event:
I'm a little surprised that compiled even in SL - the "spin==0" part should be "spin=0" (assignment, not comparison). Graham's version fixed that.Code: Select all
if (spin==3){ spin==0; }
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
- Koshari Mahana
- Posts: 359
- Joined: Fri Feb 06, 2015 8:14 am
- Has thanked: 280 times
- Been thanked: 500 times
- Contact:
Re: Arcadia's Scripts
Thank you Snoots, Yes, I'm sure that's a much easier way. I haven't come across a lot of scripts that used the link number. I think her scripts are old so I imagine that's an old way of doing things. Most of the scripts I've used use the name but I have encountered a few that use the description (mostly those were teleport scripts if memory serves me). I appreciate the help!
Snoots Dwagon wrote: ↑Tue Dec 29, 2020 9:07 pmif (llDetectedLinkNumber(0)==11&running==FALSE) // touching backboard
As mentioned by another, this is problematic coding, because link order can easily change. There are two better ways to do this, both similar. Test for either the name of the prim or the description (and then make sure that prim has a specific name or description. You may have to add one). To do this use llGetLinkPrimitiveParams() and the PRIM_NAME or PRIM_DESCparameter.
Semi-code example:
if( name_of_linked_prim == "this name" & running==FALSE) {do this;}
Code example:
if(llGetLinkPrimitiveParams(linknum,[PRIM_NAME])=="specname"...
(I think all that is correct. Doing this on the fly so if syntax is incorrect somewhere, someone feel free to point it out.)
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
- Koshari Mahana
- Posts: 359
- Joined: Fri Feb 06, 2015 8:14 am
- Has thanked: 280 times
- Been thanked: 500 times
- Contact:
Re: Arcadia's Scripts
The next one that isn't working is her High Striker. There are 3 prims:
1) *Steam Fair* High Striker 4.23 (3 prims) [root prim]
2) Object [numbers on face]
3) weight [the weight that goes up and down]
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.
Also, "S0 = (float)prim_pos.z ;" created problems.
Any and all help is greatly appreciated! Thank you so much!
1) *Steam Fair* High Striker 4.23 (3 prims) [root prim]
2) Object [numbers on face]
3) weight [the weight that goes up and down]
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.
Also, "S0 = (float)prim_pos.z ;" created problems.
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
}
}
}
}
Any and all help is greatly appreciated! Thank you so much!
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
- Snoots Dwagon
- Posts: 422
- Joined: Mon Jul 30, 2018 9:45 pm
- Has thanked: 442 times
- Been thanked: 779 times
Re: Arcadia's Scripts
Removed by Snoots. See John's better explanation of boolean operation below.
Last edited by Snoots Dwagon on Thu Dec 31, 2020 9:11 pm, edited 1 time in total.
- These users thanked the author Snoots Dwagon for the post:
- Koshari Mahana
~~~~~~~
I'm a dwagon in real life too. (Ask my sister, who totally agrees.)
~~~~~~~
I'm a dwagon in real life too. (Ask my sister, who totally agrees.)
~~~~~~~
- Koshari Mahana
- Posts: 359
- Joined: Fri Feb 06, 2015 8:14 am
- Has thanked: 280 times
- Been thanked: 500 times
- Contact:
Re: Arcadia's Scripts
Thanks for your help, Snoot. If it's full of bugs I should probably just not use it since I'm not a scripter and wouldn't be able to find all of the problems. I appreciate the explanation about the == Much of it is above my head. You seem to know a lot about scripting.
Snoots Dwagon wrote: ↑Wed Dec 30, 2020 7:47 amFor the Arcadia script, # cannot be used as a variable identifier. In some languages # means 'integer'. If that is found, remove all instances of that addition to the variable name and make sure the variable has already been declared as an integer (or whatever numbering method it's replacing.
Line 95 & 100 had to be changed to properly declare variable.
The rest of the script is full of bugs that would require some time to debug.
Regarding what you asked about the difference between == and = and =....
Within a decision statement (EXAMPLE: if ( a == b && c = TRUE){ D=9;}
== is a direct comparison: if(a == b) // getting this wrong and using just = is the rue of many a coder.
= is a boolean comparison (true/false, positive/negative) ---- be sure to not confuse == with =. == compares values. = compares boolean logic.
Outside a decision statement, = is an assignment. A=B; C=5; Avatar="Fred"; Scripting="Lame" etc
Those are the 3 ways those symbols are used.
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21