Arcadia's Scripts

Creating scripts
User avatar
Koshari Mahana
Posts: 190
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 102 times
Been thanked: 231 times
Contact:

Arcadia's Scripts

Post by Koshari Mahana »

I have Arcadia's free wonder wheel (it's a game) unscripted in Kitely and I bought the free version from the SL Market so I could get the script. When I put it into the wheel here in Kitely (I imagine other grids too) it didn't work.

2 error messages that I'm getting is that # is an illegal character and the other problem is with SR1 SR2 etc...

Any help would definitely be appreciated. Thank you!

Here is the script:

Code: Select all

integer spin#=0;
integer finalspin=0;
integer SpinResult=0;
integer SpinResult1=0;
integer SpinResult2=0;
integer SpinResult3=0;

PrizeCheck(integer SR1, integer SR2, integer SR3) 
    {
;
        if (SR1<SR2 && SR2<SR3)
        
            {  
                llWhisper (0, llDetectedName(0) + ", you win a PRIZE");
                llGiveInventory(llDetectedKey(0),  llGetInventoryName(INVENTORY_OBJECT,(integer)llFrand(llGetInventoryNumber(INVENTORY_OBJECT))));
            }
        else
                llWhisper (0, llDetectedName(0) + ", sorry, you do not win a prize.  Try again?");
 
           
    
//        llResetScript(); // next contestant
}        


spinCylinder(integer linkNumber) {
    list baseRot = llGetLinkPrimitiveParams(linkNumber,[PRIM_ROTATION]);
    integer numberMoves = (integer)(llFrand(300.0)+300); // changed from llFrand(300.0)
    float angle = 0;
    float changeAngle=PI/10.0*((float)numberMoves)/300.0;

    //check which spin#
    spin#++;
    llWhisper (0, "This is Spin number " +(string) spin#) ;
    
    if (spin#==3)
        {
        finalspin=1; //flag finalspin for prize checking
        llWhisper (0, "That was your final spin. " ) ;
        }
            

    llPlaySound("Game Wheel Spin",1.0);    
    while(numberMoves > 0)
     {
        angle += changeAngle;
        llSetLinkPrimitiveParamsFast(linkNumber,
                                    [PRIM_ROTATION,
                                    llEuler2Rot(<0.0,0.0,angle>)*llList2Rot(baseRot,0)/llGetRootRotation()/llGetRootRotation()]);
        llSleep(0.003); // Sleep controls spin duraction, was 0.03
        changeAngle *= 0.98;//deceleration of wheel only
        numberMoves -= 1;
     }
    
    baseRot = llGetLinkPrimitiveParams(linkNumber,[PRIM_ROTATION]);
    vector finalRot = llRot2Euler(llList2Rot(baseRot,0)/llGetRootRotation());
    

    // check for this spin result
    if( (integer)(finalRot.z*RAD_TO_DEG/15.0+13)==1 )
        {
            llWhisper(0,"And the number is " + (string)((integer)(finalRot.z*RAD_TO_DEG/15.0+13)));
            llPlaySound("smallbell",1.0);            
            SpinResult=1;  //use SpinResult for prizes or game
        }
    else
        { 
          llWhisper(0,"And the number is " + (string)((integer)(14-finalRot.z*RAD_TO_DEG/15.0)));
          llPlaySound("smallbell",1.0);            
          SpinResult=(integer)(14-finalRot.z*RAD_TO_DEG/15.0); //use SpinResult for prizes or game
        }
    //llWhisper( 0, "check on SpinResult = " + (string)(SpinResult)  ); // test only
    if (spin#==1) {
        SpinResult1=SpinResult;
        }
    if (spin#==2) {
        SpinResult2=SpinResult;
        }
    if (spin#==3) {
        SpinResult3=SpinResult;
        PrizeCheck(SpinResult1,SpinResult2,SpinResult3); // subroutine build 
        spin#=0; //reset for next contestant
        }
    //llOwnerSay ("TEST Spin Results  "+(string)SpinResult1 +" " +(string)SpinResult2 +" " +(string)SpinResult3 )  ;    
}
//----------------------------------------------------------

default
{
    
    touch_start(integer number) {
        
        integer lupe = llGetNumberOfPrims()+1;

        while(--lupe > 1) {
            if(llGetLinkName(lupe)=="wheel"){
                llWhisper(0, "\nWheee! " + llDetectedName(0) + " is spinning the wheel!  Wait for wheel to completely stop.");
                if (spin#==3){
                    spin#==0;
                }
                spinCylinder(lupe);
            }
        }
        
    }
}
It's this item:

Image

https://marketplace.secondlife.com/p/St ... ms/6324032


.
Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
User avatar
Dot Matrix
Posts: 1575
Joined: Sun Jul 28, 2013 3:26 am
Has thanked: 1091 times
Been thanked: 2184 times

Re: Arcadia's Scripts

Post by Dot Matrix »

Try changing all instances of spin# to spinNo -- it is just the name of a variable that keeps track of the number of spins.

I wonder if SR1 etc would work if changed to SpinResult1 etc.
These users thanked the author Dot Matrix for the post (total 3):
Graham MillsIlan TochnerKoshari Mahana
Graham Mills
Posts: 1074
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 719 times
Been thanked: 842 times

Re: Arcadia's Scripts

Post by Graham Mills »

This compiles but whether it works is another matter.

Code: Select all

integer spinNum=0;
integer finalspin=0;
integer SpinResult=0;
integer SpinResult1=0;
integer SpinResult2=0;
integer SpinResult3=0;

PrizeCheck(integer SR1, integer SR2, integer SR3) 
    {
;
        if ((SR1<SR2) && (SR2<SR3))
        
            {  
                llWhisper (0, llDetectedName(0) + ", you win a PRIZE");
                llGiveInventory(llDetectedKey(0),  llGetInventoryName(INVENTORY_OBJECT,(integer)llFrand(llGetInventoryNumber(INVENTORY_OBJECT))));
            }
        else
                llWhisper (0, llDetectedName(0) + ", sorry, you do not win a prize.  Try again?");
 
           
    
//        llResetScript(); // next contestant
}        


spinCylinder(integer linkNumber) {
    list baseRot = llGetLinkPrimitiveParams(linkNumber,[PRIM_ROTATION]);
    integer numberMoves = (integer)(llFrand(300.0)+300); // changed from llFrand(300.0)
    float angle = 0;
    float changeAngle=PI/10.0*((float)numberMoves)/300.0;

    //check which spinNum
    spinNum++;
    llWhisper (0, "This is Spin number " +(string) spinNum) ;
    
    if (spinNum==3)
        {
        finalspin=1; //flag finalspin for prize checking
        llWhisper (0, "That was your final spin. " ) ;
        }
            

    llPlaySound("Game Wheel Spin",1.0);    
    while(numberMoves > 0)
     {
        angle += changeAngle;
        llSetLinkPrimitiveParamsFast(linkNumber,
                                    [PRIM_ROTATION,
                                    llEuler2Rot(<0.0,0.0,angle>)*llList2Rot(baseRot,0)/llGetRootRotation()/llGetRootRotation()]);
        llSleep(0.003); // Sleep controls spin duraction, was 0.03
        changeAngle *= 0.98;//deceleration of wheel only
        numberMoves -= 1;
     }
    
    baseRot = llGetLinkPrimitiveParams(linkNumber,[PRIM_ROTATION]);
    vector finalRot = llRot2Euler(llList2Rot(baseRot,0)/llGetRootRotation());
    

    // check for this spin result
    if( (integer)(finalRot.z*RAD_TO_DEG/15.0+13)==1 )
        {
            llWhisper(0,"And the number is " + (string)((integer)(finalRot.z*RAD_TO_DEG/15.0+13)));
            llPlaySound("smallbell",1.0);            
            SpinResult=1;  //use SpinResult for prizes or game
        }
    else
        { 
          llWhisper(0,"And the number is " + (string)((integer)(14-finalRot.z*RAD_TO_DEG/15.0)));
          llPlaySound("smallbell",1.0);            
          SpinResult=(integer)(14-finalRot.z*RAD_TO_DEG/15.0); //use SpinResult for prizes or game
        }
    //llWhisper( 0, "check on SpinResult = " + (string)(SpinResult)  ); // test only
    if (spinNum==1) {
        SpinResult1=SpinResult;
        }
    if (spinNum==2) {
        SpinResult2=SpinResult;
        }
    if (spinNum==3) {
        SpinResult3=SpinResult;
        PrizeCheck(SpinResult1,SpinResult2,SpinResult3); // subroutine build 
        spinNum=0; //reset for next contestant
        }
    //llOwnerSay ("TEST Spin Results  "+(string)SpinResult1 +" " +(string)SpinResult2 +" " +(string)SpinResult3 )  ;    
}
//----------------------------------------------------------

default
{
    
    touch_start(integer number) {
        
        integer lupe = llGetNumberOfPrims()+1;

        while(--lupe > 1) {
            if(llGetLinkName(lupe)=="wheel"){
                llWhisper(0, "\nWheee! " + llDetectedName(0) + " is spinning the wheel!  Wait for wheel to completely stop.");
                if (spinNum==3){
                    spinNum=0;
                }
                spinCylinder(lupe);
            }
        }
        
    }
}
These users thanked the author Graham Mills for the post (total 2):
Koshari MahanaDot Matrix
User avatar
Koshari Mahana
Posts: 190
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 102 times
Been thanked: 231 times
Contact:

Re: Arcadia's Scripts

Post by Koshari Mahana »

Thanks so much Dot and Graham, I'll try both.

After I posted this thread I tried several of her other scripts and none of them work here whereas all of them work in SL. I know things are different here but it's more than I'd realized.

I'll add some of the other scripts that work in SL but not in Kitely to this thread later. It would be great if we could get some of Arcadia's items working here.
Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
User avatar
Koshari Mahana
Posts: 190
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 102 times
Been thanked: 231 times
Contact:

Re: Arcadia's Scripts

Post by Koshari Mahana »

Reporting back ...

SpinNo didn't give me the # error but I still got the SR1, Sr2 errors

SpinNum (Grahams script as is) eliminated both errors

It's interesting that changing to SpinNum also got rid of the SR1 etc errors.

Anyway, it works now! Thank you.
These users thanked the author Koshari Mahana for the post:
Graham Mills
Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
Graham Mills
Posts: 1074
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 719 times
Been thanked: 842 times

Re: Arcadia's Scripts

Post by Graham Mills »

My fix incorporated Dot's suggestion. Happy to help with anything simple.
These users thanked the author Graham Mills for the post (total 2):
Ilan TochnerKoshari Mahana
User avatar
Koshari Mahana
Posts: 190
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 102 times
Been thanked: 231 times
Contact:

Re: Arcadia's Scripts

Post by Koshari Mahana »

Working: Duck game, Shooting game and now Wonder Wheel game (thank you!)

The one I'm doing now is the Whack a Pirate game. I've seen it working in open sim but it's not copyable so I can't see the script. The one from SL below doesn't give error messages, it just doesn't work. All of the pirate heads are named correctly so it isn't that. I don't know why it isn't working here. Any help would be GREATLY appreciated! Thanks in advance.

Code: Select all

// Wack-A-Pirate Arcade!

// Globals variables

integer pop1link ; // popper link number
integer pop2link ;
integer pop3link ;
integer pop4link ;
integer pop5link ;
integer pop6link ;
integer pop7link ;
integer pop8link ;
integer pop9link ;

integer Up1 ; // popping logic flag
integer Up2 ;
integer Up3 ;
integer Up4 ;
integer Up5 ;
integer Up6 ;
integer Up7 ;
integer Up8 ;
integer Up9 ;

vector LinkSetPos ;
rotation LinkSetRot ;
vector pop1Down ; // popper down and start position
vector pop2Down ;
vector pop3Down ;
vector pop4Down ;
vector pop5Down ;
vector pop6Down ; 
vector pop7Down ; 
vector pop8Down ; 
vector pop9Down ;
vector pop1Up ; // popper up and hit position
vector pop2Up ;
vector pop3Up ;
vector pop4Up ;
vector pop5Up ;
vector pop6Up ; 
vector pop7Up ; 
vector pop8Up ; 
vector pop9Up ;


// admin variables
string name ;
integer score =0 ; // total score for a round
integer highscore ; // game record
integer running = FALSE; // game in progress flag
integer interval = 1 ; // popping cycle
integer timetotal = 0 ; // tally of running time
integer timeduration = 30 ; // length of game
string status = "Ready";

//---------CALLS-----------------------

stop()
{
    llStopSound();
    llTriggerSound("Boxing Bell Start Round", 1.0);
}                

start()
{
    llTriggerSound(" ", 1.0);
    llSleep(10.0);
    llTriggerSound(" ", 1.0);
    llSleep(3.0);
    llLoopSound(" ", 1.0);
}


//---------- MAIN PROGRAM-------------------------------

default
{
    state_entry()
    {
        llSay(0, "Wack-A-Pirate Arcade!\n");
        llSetTimerEvent(0);
    }

// touch to determine who is starting a round
    touch_start(integer total_number)
    {
        // determine player for this round
        if (llDetectedLinkNumber(0)==11&running==FALSE) // touching backboard
            {
                key id = llDetectedKey(0);
                string name = llDetectedName(0); // players name
                llSay(0, name+ " has started a new game round.\n");
                timetotal=0 ;
                score = 0 ;
                running = TRUE ;
                status = "Running" ;
                llSetTimerEvent(interval); 

                    
                // find prim link numbers
                integer i=1 ;
                integer x = llGetNumberOfPrims()+i ;
                for (i=0; i < x; ++i)
                  if (llGetLinkName(i)     == "pop1") pop1link= i ;
                 else if (llGetLinkName(i) == "pop2") pop2link= i ; 
                 else if (llGetLinkName(i) == "pop3") pop3link= i ; 
                 else if (llGetLinkName(i) == "pop4") pop4link= i ; 
                 else if (llGetLinkName(i) == "pop5") pop5link= i ; 
                 else if (llGetLinkName(i) == "pop6") pop6link= i ; 
                 else if (llGetLinkName(i) == "pop7") pop7link= i ; 
                 else if (llGetLinkName(i) == "pop8") pop8link= i ; 
                 else if (llGetLinkName(i) == "pop9") pop9link= i ; 
        
            vector LinkSetPos   = llGetPos(); // root prim basic position
            rotation LinkSetRot = llGetRot();
        
            vector pop1Down = llList2Vector(llGetLinkPrimitiveParams(pop1link,[PRIM_POSITION]),0);
            vector pop2Down = llList2Vector(llGetLinkPrimitiveParams(pop2link,[PRIM_POSITION]),0);
            vector pop3Down = llList2Vector(llGetLinkPrimitiveParams(pop3link,[PRIM_POSITION]),0);
            vector pop4Down = llList2Vector(llGetLinkPrimitiveParams(pop4link,[PRIM_POSITION]),0);
            vector pop5Down = llList2Vector(llGetLinkPrimitiveParams(pop5link,[PRIM_POSITION]),0);
            vector pop6Down = llList2Vector(llGetLinkPrimitiveParams(pop6link,[PRIM_POSITION]),0);
            vector pop7Down = llList2Vector(llGetLinkPrimitiveParams(pop7link,[PRIM_POSITION]),0);
            vector pop8Down = llList2Vector(llGetLinkPrimitiveParams(pop8link,[PRIM_POSITION]),0);
            vector pop9Down = llList2Vector(llGetLinkPrimitiveParams(pop9link,[PRIM_POSITION]),0);
        
// Convert from region coordinates to local coordinates ie. prim_pos = (prim_pos - obj_pos) / obj_rot;         
            pop1Down = (pop1Down - LinkSetPos) / LinkSetRot ;
            pop2Down = (pop2Down - LinkSetPos) / LinkSetRot ;
            pop3Down = (pop3Down - LinkSetPos) / LinkSetRot ;
            pop4Down = (pop4Down - LinkSetPos) / LinkSetRot ;
            pop5Down = (pop5Down - LinkSetPos) / LinkSetRot ;
            pop6Down = (pop6Down - LinkSetPos) / LinkSetRot ;
            pop7Down = (pop7Down - LinkSetPos) / LinkSetRot ;
            pop8Down = (pop8Down - LinkSetPos) / LinkSetRot ;
            pop9Down = (pop9Down - LinkSetPos) / LinkSetRot ;
        
            } // end of original IF touch backboard to start new game
        
         if (llDetectedLinkNumber(0)==pop1link & running==TRUE) {
             score = score+1 ;
            }
        else if (llDetectedLinkNumber(0)==pop2link & running==TRUE) {
             score = score+1 ;
            }
        else if (llDetectedLinkNumber(0)==pop3link & running==TRUE) {
             score = score+1 ;
            }
        else if (llDetectedLinkNumber(0)==pop4link & running==TRUE) {
             score = score+1 ;
            }
        else if (llDetectedLinkNumber(0)==pop5link & running==TRUE) {
             score = score+1 ;
            }
        else if (llDetectedLinkNumber(0)==pop6link & running==TRUE) {
             score = score+1 ;
            }
        else if (llDetectedLinkNumber(0)==pop7link & running==TRUE) {
             score = score+1 ;
            }
        else if (llDetectedLinkNumber(0)==pop8link & running==TRUE) {
             score = score+1 ;
            }
        else if (llDetectedLinkNumber(0)==pop9link & running==TRUE) {
             score = score+1 ;
            }

    } 
    // end original touch start

   
    timer ()
    {
        //integer timetotal ;
       Up1 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop1link,[PRIM_POSITION,<-0.85,0.9,-0.6>+<0.0,0.0,0.5*Up1>]);          
       Up2 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop2link,[PRIM_POSITION,<-0.85,0.0,-0.6>+<0.0,0.0,0.5*Up2>]);        
       Up3 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop3link,[PRIM_POSITION,<-0.85,-0.9,-0.6>+<0.0,0.0,0.5*Up3>]);        
       Up4 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop4link,[PRIM_POSITION,<0.0,0.9,-0.0>+<0.0,0.0,0.5*Up4>]);        
       Up5 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop5link,[PRIM_POSITION,<0.0,0.0,-0.0>+<0.0,0.0,0.5*Up5>]);        
       Up6 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop6link,[PRIM_POSITION,<0.0,-0.9,-0.0>+<0.0,0.0,0.5*Up6>]);        
       Up7 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop7link,[PRIM_POSITION,<0.85,0.9,0.4>+<0.0,0.0,0.5*Up7>]);        
       Up8 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop8link,[PRIM_POSITION,<0.85,0.0,0.4>+<0.0,0.0,0.5*Up8>]);        
       Up9 =  llRound(llFrand(0.6)) ; 
       llSetLinkPrimitiveParamsFast(pop9link,[PRIM_POSITION,<0.85,-0.9,0.4>+<0.0,0.0,0.5*Up9>]);        

    if (score>highscore) highscore=score ; 
    llSetText("Score "+(string)score+" \n Time "+(string)(timeduration-timetotal)+ "\n High Score "+(string)highscore , <1,1,1>, 1.0) ;
    
    timetotal = timetotal + 1 ;
    if (timeduration - timetotal < 0 ) 
                {
                 running=FALSE ;
                 status = "Game Over" ;
                 stop () ; // function call
                 llSetTimerEvent(0) ;

                }

    }

}

Image
Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
User avatar
John Mela
Posts: 74
Joined: Tue Feb 04, 2014 9:50 pm
Has thanked: 109 times
Been thanked: 101 times
Contact:

Re: Arcadia's Scripts

Post by John Mela »

My first guess is that this line needs changing:

Code: Select all

 if (llDetectedLinkNumber(0)==11&running==FALSE) // touching backboard
That's assuming the backboard prim is link number 11, which might not be the case if the object has been relinked.
These users thanked the author John Mela for the post:
Koshari Mahana
User avatar
Dot Matrix
Posts: 1575
Joined: Sun Jul 28, 2013 3:26 am
Has thanked: 1091 times
Been thanked: 2184 times

Re: Arcadia's Scripts

Post by Dot Matrix »

Koshari Mahana wrote:
Mon Dec 28, 2020 10:29 pm
Reporting back ...

SpinNo didn't give me the # error but I still got the SR1, Sr2 errors

SpinNum (Grahams script as is) eliminated both errors

It's interesting that changing to SpinNum also got rid of the SR1 etc errors.

Anyway, it works now! Thank you.
Graham’s script also added parentheses around the two SR1 etc size checks; this probably solved the issue.
These users thanked the author Dot Matrix for the post:
Koshari Mahana
User avatar
Koshari Mahana
Posts: 190
Joined: Fri Feb 06, 2015 8:14 am
Has thanked: 102 times
Been thanked: 231 times
Contact:

Re: Arcadia's Scripts

Post by Koshari Mahana »

Thank you so much! That was the problem, I didn't have the backboard as link 11. It's working great now.


John Mela wrote:
Tue Dec 29, 2020 10:32 am
My first guess is that this line needs changing:

Code: Select all

 if (llDetectedLinkNumber(0)==11&running==FALSE) // touching backboard
That's assuming the backboard prim is link number 11, which might not be the case if the object has been relinked.
These users thanked the author Koshari Mahana for the post:
John Mela
Image
VISIT FOUR WINDS ON THE MARKET
VISIT FOUR WINDS INWORLD: hop://grid.kitely.com:8002/Coopersville/909/907/21
Post Reply