Jump to content

help with adding a timer to this script please


RunsInTheLight
 Share

You are about to reply to a thread that has been inactive for 4281 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi all i have 5 objects all reporting on a different channel to an object rezzer

each object is shootable, and can take a max number of hits before reporting its score to the rezzer that then speaks the reported text

what i would like to do is to add a timer for 20secs shooting time that reports the amount of hits during that time if the max number of hits hasnt been reached. 


integer maxNumberOfHits = 10;//the maximum number of hits during gameplay the Target can take until the game will end
//
integer x = 0;//this is a 'toggle' that switches between TRUE (1) and FALSE (0) and is used to tell other parts of the script that the game has started and a specific function was triggered
integer points = 0;//total amount of points earned during gameply
integer yellow = 0;//amount of bullseyes hit during gameplay
integer numberOfHits = 0;//total amount of times the target was hit during gameplay
///////////////////////////////
integer main;//this is the name (integer) that represents the link number for the yellow (Target)
say(string text)//just a cleaner looking way of calling 'llSay()'
{
llSay(0,text);
}
endGame()
{


llShout(-5870,"Your Score: "+"\n"+"yellow: "+(string)yellow+"\n"+"For a Total of "+(string)points+" Points");//say the scored points" Points");//say the scored points
llSleep(1.0);//sleep for just a second in case other scripted events need to catch
}
reset()//reset common values. This function is called within the script to reset common values back to default
{
points = 0;//reset the amount of points scored
yellow = 0;//reset how many bullseyes were hit during gameplay
numberOfHits = 0;//reset the amount of overall times the Target was hit during gameplay
}
default
{
on_rez(integer p){
llResetScript();
}
state_entry()
{
}
collision(integer num_detected)//detect information about which part of the Target was hit during gameplay and then update values
{
integer hit = llDetectedLinkNumber(0);//the linked object number that was hit in the link set is labelled 'hit'
if(hit == main)//if the link number that was hit matches the link number for the bullseye prim, then proceed..
{
yellow += 1;//add a point to the amount of yellowtarget hit during gameplay
points += 1;//add 10 points to the 'total points earned' during gameplay
}
numberOfHits += 1;//add a point to the amount of hits the Target has taken during gameplay
if(numberOfHits >= 10)//if the Target has taken 20 hits during gameplay, then proceed to do the function 'endGame()'
{
endGame();
llSleep(5);
llDie();
}
}
}

 

any help would be greatly appreciated

 

Link to comment
Share on other sites

If I understood correctly what you wanted, this should be it

integer maxNumberOfHits = 10;//the maximum number of hits during gameplay the Target can take until the game will end//integer x = 0;//this is a 'toggle' that switches between TRUE (1) and FALSE (0) and is used to tell other parts of the script that the game has started and a specific function was triggeredinteger points = 0;//total amount of points earned during gameplyinteger yellow = 0;//amount of bullseyes hit during gameplayinteger numberOfHits = 0;//total amount of times the target was hit during gameplay///////////////////////////////integer main;//this is the name (integer) that represents the link number for the yellow (Target)say(string text)//just a cleaner looking way of calling 'llSay()'{	llSay(0,text);}endGame(){	llShout(-5870,"Your Score: "+"\n"+"yellow: "+(string)yellow+"\n"+"For a Total of "+(string)points+" Points");//say the scored points" Points");//say the scored points	llSleep(1.0);//sleep for just a second in case other scripted events need to catch}reset()//reset common values. This function is called within the script to reset common values back to default{	points = 0;//reset the amount of points scored	yellow = 0;//reset how many bullseyes were hit during gameplay	numberOfHits = 0;//reset the amount of overall times the Target was hit during gameplay}default{	on_rez(integer p){		llResetScript();	}	state_entry()	{		llSetTimerEvent(30.0);	}	collision(integer num_detected)//detect information about which part of the Target was hit during gameplay and then update values	{		integer hit = llDetectedLinkNumber(0);//the linked object number that was hit in the link set is labelled 'hit'		if(hit == main)//if the link number that was hit matches the link number for the bullseye prim, then proceed..		{			yellow += 1;//add a point to the amount of yellowtarget hit during gameplay			points += 1;//add 10 points to the 'total points earned' during gameplay		}		numberOfHits += 1;//add a point to the amount of hits the Target has taken during gameplay		if(numberOfHits >= 10)//if the Target has taken 20 hits during gameplay, then proceed to do the function 'endGame()'		{			llSetTimerEvent(0);			endGame();			lSleep(5);			llDie();		}	}	timer()	{		llSay(0, "I've been hit " + (string)numberOfHits + " times so far");	}}

 

Link to comment
Share on other sites

I'm guessing that this application doesn't want a fixed sequence of 20 second timer intervals (the hits could straddle the intervals), nor even a timer at all, but rather a list of hit times, pruned to those within the last 20 seconds when a hit occurs, where the list length indicates whether the max was reached.

Link to comment
Share on other sites

thanks darkie tried the revised script and it works ok ....

what i was after it doing witht he timer tho was slightly different.....

game length was going to be 30 secs long . and the max number of hits the target could take would be 10..

if someone only managed say 5 hits in that time then 5 would be the total score reflected in the score shouted.

but cheers for the timer ill have a play with it :))

 

llShout(-5870,"Your Score: "+"\n"+"yellow: "+(string)yellow+"\n"+"For a Total of "+(string)points+" Points");//say the scored points" Points");//say the scored points

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4281 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...