Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Two scripts I need. Running boost and prim growing.

Hanumi Takakura
Registered User
Join date: 24 May 2006
Posts: 57
09-07-2006 07:34
Hello. I've been learning script little by little. I'd like to start two basic scripts. One would be a run speed increasing script. Much like the famous flight speed boosters, but only for run speed. Second. I'd like to make a script to make a sphere grow for a bit on rez and then dissapear. More or less like a balloon or something. Any help and directions is really appreciated. Thanks.
HtF Visconti
Registered User
Join date: 21 Jul 2006
Posts: 123
09-07-2006 07:55
Hi - the first one I cannot do without SL access - I always mess up the axis. Teh second is easier:

CODE

float growth=0.10; // how much it shall grow (10 cm)
float maxsize=10.0; // maximum size before bursting (10 m)
float interval=10.0l; // seconds between grow boosts (10 seconds)
vector size;

default {
state_entry() {
// maybe some smart things might be needed here :) l
}

on_rez (integer startparam) {
llSetTimerEvent(interval);
}

timer() {
size = llGetScale();
if (size.z >= maxsize) {
llDie();
} else {
size=<size.x + growth,size.y + growth, size.z + growth>;
llSetScale(size);
}
}
}





This is a very rudimentary growing script. it does not adjust the z component (so it will grow into the ground) and it is a uniform growth - if you think balloon you must make an adjustment to the x and y growth and make it smaller than the z growth. But with a bid of fiddling you can pimp this script - to adjust for height use llGetPos and llSetPot and use the size.z component wisely :)
Hanumi Takakura
Registered User
Join date: 24 May 2006
Posts: 57
09-12-2006 23:17
Thanks for this one. I really appreciate it.
Ashrilyn Hayashida
Registered User
Join date: 6 Jul 2006
Posts: 103
09-13-2006 11:20
I wrote a script to give myself directional pushes of set speeds (and to alter my buoyancy). It also works as a flight assist of a sort.
I have used it to appear to run quickly, but it was kind of difficult to control my direction. There would be a lot of momentum, and I'd have to do multiple pushes in the opposite direction - and possibly push too much and go in the wrong direction. Not much like running, really.. though my avatar stayed on the ground. ;)

I'm afraid I don't have a copy of it outside of SL. Perhaps later I'll go get it. :)

What I did was take the SL Library's Popgun script, and cut it apart. I used its control code, adding in the up, down, left, right, forward, and back controls.
I put the script on a HUD-attached prim. A worn prim works as well.
When I press the keys, it uses llPushObject to push the object in the proper direction.

Perhaps sometime I'll toy with making a version with finer control.
Ashrilyn Hayashida
Registered User
Join date: 6 Jul 2006
Posts: 103
09-14-2006 00:47
Well, for what it's worth, here is my script. Like I said, for running controls it's kind of loose. You kind of coast around and may end up overshooting your destination as you coast along.

You can put the script on a prim, attach the prim to yourself, and then use commands like this:
/4 pon
(This sets it to capture your controls)
/4 ps 10.0
(This sets the push speed to 10)
Then you can try moving around..
/4 poff
(That releases your controls again)

/4 buoy 0.5
(This sets your buoyancy to 0.5)

/4 buoy 0
(This resets your buoyancy)

CODE

// Adapted from the Popgun script.
// Listen code adapted from FlipTitle.
// Script by Ashrilyn Hayashida
// (September 14, 2006)

integer have_permissions = FALSE;
key owner;

float speed = 15.0;

HelpMessage() {
llInstantMessage(owner,"/4 pon, /4 poff, /4 ps float_speed, /4 buoy buoyancy");
}

default
{
state_entry()
{
owner = llGetOwner();
llListen(4,"",llGetOwner(),"");
llSetBuoyancy(0.8);
//if (!have_permissions) { llRequestPermissions(owner,PERMISSION_TAKE_CONTROLS); }
}

touch(integer touches) {
if (llDetectedKey(0) == owner) {
HelpMessage();
}
}
run_time_permissions(integer permissions)
{
if (permissions == PERMISSION_TAKE_CONTROLS)
{
llTakeControls(CONTROL_BACK | CONTROL_FWD | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_ML_LBUTTON, TRUE, FALSE);
//llStartAnimation("hold_R_handgun");
have_permissions = TRUE;
}
}

attach(key attachedAgent)
{
if (attachedAgent != NULL_KEY)
{
HelpMessage();
}
else
{
if (have_permissions)
{
//llStopAnimation("hold_R_handgun");
//llStopAnimation("aim_R_handgun");
llReleaseControls();
llSetRot(<0,0,0,1>);
have_permissions = FALSE;
}
}
}

control(key name, integer levels, integer edges)
{
if ( ((edges & CONTROL_UP) == CONTROL_UP)
&&((levels & CONTROL_UP) == CONTROL_UP) )
{
llPushObject(owner,<0,0,speed>,ZERO_VECTOR,FALSE);
}
if ( ((edges & CONTROL_DOWN) == CONTROL_DOWN)
&&((levels & CONTROL_DOWN) == CONTROL_DOWN) )
{
llPushObject(owner,<0,0,speed * -1>,ZERO_VECTOR,FALSE);
}
if ( ((edges & CONTROL_LEFT) == CONTROL_LEFT)
&&((levels & CONTROL_LEFT) == CONTROL_LEFT) )
{
llPushObject(owner,<0,speed,0>,ZERO_VECTOR,TRUE);
}
if ( ((edges & CONTROL_RIGHT) == CONTROL_RIGHT)
&&((levels & CONTROL_RIGHT) == CONTROL_RIGHT) )
{
llPushObject(owner,<0,speed * -1,0>,ZERO_VECTOR,TRUE);
}
if ( ((edges & CONTROL_FWD) == CONTROL_FWD)
&&((levels & CONTROL_FWD) == CONTROL_FWD) )
{
llPushObject(owner,<speed,0,0>,ZERO_VECTOR,TRUE);
}
if ( ((edges & CONTROL_BACK) == CONTROL_BACK)
&&((levels & CONTROL_BACK) == CONTROL_BACK) )
{
llPushObject(owner,<speed * -1,0,0>,ZERO_VECTOR,TRUE);
}
if ( ((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)
&&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
{
llPushObject(owner,<0,0,0>,ZERO_VECTOR,TRUE);
}
}

listen(integer channel, string name, key id, string message)
{
list strings = llParseString2List(message,[" "],[]);
string command = llList2String(strings,0);
if (command == "ps") {
speed = (float)llList2String(strings,1);
llInstantMessage(owner,"P-Speed: " + (string)speed);
}
else if (command == "poff") {
llReleaseControls();
have_permissions = FALSE;
}
else if (command == "pon") {
llRequestPermissions(owner,PERMISSION_TAKE_CONTROLS);
}
else if (command == "buoy") {
float buoyancy = (float)llList2String(strings,1);
llSetBuoyancy(buoyancy);
llInstantMessage(owner,"Buoyancy: " + (string)buoyancy);
}
}
}
Ashrilyn Hayashida
Registered User
Join date: 6 Jul 2006
Posts: 103
10-01-2006 06:01
For a running boost, what I've just developed works better.

I made a HUD attachment. I have a script on a parent prim, and simple touch scripts on child prims.

On the parent prim:

CODE

key owner;
float speed = 15.0;

default
{
state_entry()
{
owner = llGetOwner();
llListen(4,"",llGetOwner(),"");
}

link_message(integer sender_number, integer number, string message, key id)
{
if (number == 0)
{ // Forward
llPushObject(owner,<speed,0,0>,ZERO_VECTOR,TRUE);
}
else if (number == 1)
{ // Back
llPushObject(owner,<speed * -1,0,0>,ZERO_VECTOR,TRUE);
}
else if (number == 2)
{ // Left
llPushObject(owner,<0,speed,0>,ZERO_VECTOR,TRUE);
}
else if (number == 3)
{ // Right
llPushObject(owner,<0,speed * -1,0>,ZERO_VECTOR,TRUE);
}
else if (number == 4)
{ // Up
llPushObject(owner,<0,0,speed>,ZERO_VECTOR,FALSE);
}
else if (number == 5)
{ // Down
llPushObject(owner,<0,0,speed * -1>,ZERO_VECTOR,FALSE);
}
}

listen(integer channel, string name, key id, string message)
{
list strings = llParseString2List(message,[" "],[]);
string command = llList2String(strings,0);
if (command == "ps") {
speed = (float)llList2String(strings,1);
}
}
}


On a child prim, to click to move forward:

CODE

default
{
touch_start(integer total_number)
{
llMessageLinked(LINK_ROOT,0,"","");
}
}


To add in other directions for other prims, simply change the number from 0 to the matching number in the parent prim's script.

I found this method to work better, as I can boost myself forward.. but I can also press movement keys at any time, and stop.

Again, the push speed can be adjusted with a chat command: "/4 ps 10.0", "/4 ps 5.0" for small pushes, etc.
Tazmania Trefusis
Registered User
Join date: 13 Jan 2008
Posts: 85
Running Man
04-24-2008 13:19
LOl was just thinking of the 'running man' film when I saw that script request
That would be kinda neat..a running man event in SL..where the competitor has to get from A to B and withstand people placed/hiding around the course attacking with guns, vehicles etc. Obviously no orbitting or caging but use of guns that push/damage etc

Maybe even a prize for the person that makes it!!
We have everything you need in Sl..terrain, guns, vehicles (cars & motorbikes) and of course..people!!

People could even watch the event on monitors around SL and route for their favourite victim..er competitor (no betting of course)

Go Ben Richards!



<Now where is that film!?>