Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need Help with Hud scripts for Camera, Particles and Texture Rotation

Layla Honi
Registered User
Join date: 1 Nov 2007
Posts: 171
09-12-2009 02:51
I have to trying to find a script to put in a prim I can link to my existing bike HUD to turn the active camera on and off, but have had no luck.

I have also been trying to get the exhaust smoke on my bike to turn on and off with the hud button in my bike hud. It already works with avatar sit and unsit.

I also can't seem to get the tire and rim texture to rotate when the "burn out" HUD button. The wheel textures work, on the bike with get velocity. I can only seem to get iether the HUD burn out texture rotation or the velocity texture rotation to work, but not both.

I don't know a lot about scripting, but have been trying to learn with little success.
Could someone help me with getting these things to work.
Vance Adder
Registered User
Join date: 29 Jan 2009
Posts: 402
09-12-2009 11:44
You might post your code here if you can and see if we can suggest changes. It sounds like there are multiple things you are wanting to do.
Layla Honi
Registered User
Join date: 1 Nov 2007
Posts: 171
09-12-2009 18:37
From: Vance Adder
You might post your code here if you can and see if we can suggest changes. It sounds like there are multiple things you are wanting to do.


I don't have any scripts for a hud camera control. I want to add a button to my existing hud that will turn the active camera on and off.
This is the active camera line in the main vehicle script I want to control:

CODE
llSetCameraParams([
CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive



--------------------------------------------------------------------------------------------------------


This is the code for the exhaust smoke that works with sit and unsit presently. I added the smoke to my bike and now want to also control it with the hud button to turn if off and on as well as still work with sit/unsit:

CODE
default
{
state_entry()
{
//updateParticles();
keystate = 0 ;
//target = llGetLinkKey(2) ;
//updateParticles() ;
//llParticleSystem([]) ;
//llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
llListen(11,"","","started");
}
link_message(integer sender_num, integer num, string str, key id){
if(str == "SMOKEON"){
updateParticles();
}
if(str == "SMOKEOFF"){
llParticleSystem([]);
}

}
}


//// this goes in the seat
// changed(integer change){
// if(change == CHANGED_LINK){
// if(llAvatarOnSitTarget() != NULL_KEY){
// llMessageLinked(LINK_SET, 0, "SMOKEON", NULL_KEY);
// }else{
// llMessageLinked(LINK_SET, 0, "SMOKEOFF", NULL_KEY);
// }
// }
// }



--------------------------------------------------------------------------------------------------------


This is the code in the hud start stop button. This starts and stops the bike motor regardless if you are sitting or not. I want this to control the exhaust smoke as well as be controlled by sit/unsit:

CODE
key stop="e63c2f40-11cb-407e-9f04-247717bd49fd";
key start="be8840c4-1924-4a56-adf6-31e7f3a2a68b";
integer started=TRUE;
default
{
state_entry()
{
llSetTexture(stop,ALL_SIDES);
started=TRUE;
llListen(11,"","","started");
}

touch_start(integer total_number)
{
if (started){llWhisper(4,"stop");started=FALSE;llSetTexture(start,ALL_SIDES);}
else {llWhisper(4,"start");started=TRUE;llSetTexture(stop,ALL_SIDES);}
}

listen(integer ch, string name, key id, string msg)
{
if (llGetOwnerKey(id) != llGetOwner()) return;
started=TRUE;llSetTexture(stop,ALL_SIDES);
}
}


--------------------------------------------------------------------------------------------------------


This is the code for burn out, presently controlled by the hud button. This controls the burn out smoke for the back tire and is working. I need the tire rotation texture to work with the hud button as well as by the bike velocity:
CODE

default
{
on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
llListen(3,"",NULL_KEY,"");
llSetTimerEvent(0.0);
llStopSound();
}

listen(integer channel, string name, key id, string message)
{
if(message == "off")
{
llSetTimerEvent(0.0);

llStopSound();
llParticleSystem([]);
} else if(message == "on")
{

llSetTimerEvent(0.1);
}
}

timer()
{



llParticleSystem([
PSYS_PART_FLAGS,
//PSYS_PART_BOUNCE_MASK |
PSYS_PART_INTERP_SCALE_MASK |
PSYS_PART_INTERP_COLOR_MASK,
//PSYS_PART_WIND_MASK,

PSYS_PART_MAX_AGE, 2.0,


PSYS_PART_START_SCALE, <1.1, 1.1, 0.0>,
PSYS_PART_END_SCALE, <0.1, 0.1, 0.1>,

PSYS_PART_START_COLOR, <1,1,1>,
PSYS_PART_END_COLOR, <1,1,1>,
PSYS_PART_START_ALPHA, 1.0,
PSYS_PART_END_ALPHA, 0.0,

PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE,

PSYS_SRC_TEXTURE, "d1df5743-efa9-8fab-0d2f-8c206931299b",

PSYS_SRC_INNERANGLE, 0.0,
PSYS_SRC_OUTERANGLE, 0.3,

PSYS_SRC_BURST_RADIUS, 0.2,
PSYS_SRC_BURST_PART_COUNT, 300,
PSYS_SRC_BURST_RATE, 0.04,

PSYS_SRC_MAX_AGE, 0.5,

PSYS_SRC_ACCEL, <0,0,0.0>,

PSYS_SRC_BURST_SPEED_MAX, 8.0,
PSYS_SRC_BURST_SPEED_MAX, 0.0

]);
llLoopSound("burnout Slayer",1.0);//0.0 with no sound - 1.0 max Sound
}
}



--------------------------------------------------------------------------------------------------------

This is the code for the burn out button on the hud. This script presently works for the burnout smoke. I need it to work with the tire rotation texture as well. This script has references to light, but works with the burn out script in the tire.

CODE
integer menu_handler;
integer menu_channel;
integer light = FALSE;

setLight() {
if (light) {
llWhisper(3,"on");
//llSay(0,"is ON");
}

else
{
llWhisper(3,"off");
//llSay(0,"is OFF");
}
}

default
{
state_entry()
{
setLight();
}

on_rez(integer start)
{
llResetScript();
}

touch_start(integer total_number)
{
light = !light;
setLight();
}
}


--------------------------------------------------------------------------------------------------------

This is the code for the tire texture rotation. It is controlled by the velocity of the bike. I want it to also be controlled on and off with the hud button.

CODE
default 
{
state_entry()
{
llSetTimerEvent(0.20);
}
timer()
{
vector vel = llGetVel();
float speed = llVecMag(vel);
//speed = 0.2; //uncoment this to see the rotation stationary to check it's right
if(speed > 0)
{
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, ALL_SIDES, 0, 0, 0, 1, speed*-6.5);
}
else
{
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP | REVERSE, 0, 0, 0, 0, 1, speed*-6.5);
}
}
}



I hope I supplied enought code to work with. I cannot post the main script here because it was purchased for building and is not to be destributed freely.
Vance Adder
Registered User
Join date: 29 Jan 2009
Posts: 402
09-13-2009 17:22
I don't think this solves everything, but it's somewhere to start...

In your new button, put in a script like this:

CODE

integer nFlag;

default
{
touch_start(integer total_number)
{
nFlag = !nFlag;
llMessageLinked(LINK_SET, nFlag, "TOGGLE", NULL_KEY);
}
}


When you click it, it will send "TOGGLE" and a value of either 1 or 0 to every prim in your HUD. You can then listen for this and turn on or off your features as you see fit. For example, you would have this handler somewhere in one of your other scripts.

CODE

link_message(integer sender_num, integer num, string str, key id)
{
// this checks for the "TOGGLE" message from your button and then looks at the number you passed it (1 or 0) and sets that equal to the global variable g_Flag, to use in your script.
if(str == "TOGGLE")
{
g_Flag = num;
}
}


I hope that makes sense. Let me know if I can elaborate.