Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

touch cannon

Billybob Street
Registered User
Join date: 18 Aug 2004
Posts: 26
03-19-2005 20:32
i am working on a touch cannon and i dont know how have a 15 sec reload time between each shot heres what i got done so far

integer FORCE = 30;
vector STARTOFFSET = <-1.7,0,0>;

default
{
state_entry()
{

}

touch_start(integer total_number)
{ llTriggerSound("Report", 1.0);
llRezObject("CannonBall", llGetPos() + STARTOFFSET * llGetRot(), <-1 * FORCE,0,0> * llGetRot(),ZERO_ROTATION,0);
}
}
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
03-19-2005 21:18
llSleep(15.0);
_____________________
---
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
03-19-2005 21:31
Or (to avoid queueing up lots of shots):

CODE
integer FORCE = 30;
vector STARTOFFSET = <-1.7,0,0>;
float tod; // global variables

touch_start(integer n)
{
float ctod = llGetWallclock();
if ((ctod - tod) < 15.0) // less than 15 seconds since last firing time
{
llWhisper(0, "Still reloading!");
}
else
{
llTriggerSound("Report", 1.0);
llRezObject("CannonBall", llGetPos() + STARTOFFSET * llGetRot(), <-1 * FORCE,0,0> * llGetRot(),ZERO_ROTATION,0);
tod = llGetWallClock();
}
}
_____________________
Billybob Street
Registered User
Join date: 18 Aug 2004
Posts: 26
03-19-2005 22:13
i keep geting a syntex error with the script above
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
03-19-2005 23:36
If you insist on No Queuing...

CODE


integer FORCE = 30;
vector STARTOFFSET = <-1.7,0,0>;

default
{

touch_start(integer total_number)
{
llTriggerSound("Report", 1.0);
llRezObject("CannonBall", llGetPos() + STARTOFFSET * llGetRot(), <-1 * FORCE,0,0> * llGetRot(),ZERO_ROTATION,0);
state wait;
}
}

state wait
{
state_entry()
{
llSleep(15.0);
state default;
}
}
_____________________
---
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
03-20-2005 06:39
Yeah, that is better. But, sleep freezes the script. To be flexible enough to do other things (Specifically: user feedback) how about:

CODE
integer FORCE = 30;
vector STARTOFFSET = <-1.7,0,0>;

default
{

touch_start(integer total_number)
{
llTriggerSound("Report", 1.0);
llRezObject("CannonBall", llGetPos() + STARTOFFSET * llGetRot(), <-1 * FORCE,0,0> * llGetRot(),ZERO_ROTATION,0);
state wait;
}
}

state wait
{
state_entry()
{
llSetTimerEvent(15.0);
}

touch_start(integer n)
{
llWhisper(0, "Still reloading.");
}

timer()
{
state default;
}
}
:D
_____________________
Billybob Street
Registered User
Join date: 18 Aug 2004
Posts: 26
03-20-2005 09:36
thx that one worked now is how can u make alot of smoke come out of the cannon when u shoot it