Firebox Script problems.
|
Katherine Jacobs
Junior Member
Join date: 22 Aug 2004
Posts: 5
|
08-24-2004 11:15
A fairly simple script to create a sphere of particles (in this case, the blue and green from the rocket). This is my first script, so it may be very inefficient, at least it's fully commented though. Error: 35,12 Syntax error. //******************************************// // Name: Trigger Script // // Object: Firebox v0.5b // // Creator: Katherine Jacobs // // Date: 24-08-2004 // //************** Description: **************// // A simple script for the Firebox object, // // it is designed to spread particles in a // // spherical explosion around a small box. // // Touch to turn on, and the do-while loop // // should activate, touch again to turn off // // and the second do-while loop should take // // care of de-activation. // //******************************************//
integer ON = FALSE; //Declare global integer, ON, to be FALSE, since object starts off.
default { state_entry() { llSay(0, "Firebox V0.5b on standby."); //Initiation for testing, like a test marker to see how far the script is running. } touch_start(integer total_number) { if(ON == TRUE) //Check for ON being true, if on is true, execute code below. { ON = FALSE; //Make ON false. } else //If on is not true, execute this. { ON = TRUE; //Make ON true. } } //Above IF then ELSE statment is like a switch. If it's on, when touched, it will be turned off. If it is off, when touched, it will be activated. Used for //the do-while loop below. do { { llSay(0, "Firebox Activated."); //User notification and test marker for code execution. llSetTimerEvent(0.1); //Timer event set. } timer() { llMakeExplosion(250, 0.25, 5.0, 10.0, 30.0, "green", ZERO_VECTOR); //Lots of shrapnel created by the explosion, excellent strobe lighting effect. llMakeExplosion(250, 0.25, 5.0, 10.0, 30.0, "blue", ZERO_VECTOR); } }while(ON == TRUE) //Above executed while ON is true. do { llSay(0, "Firebox Deactivated"); //User notification and test marker for code execution. }while(!ON) //Above executed while ON is false. }
|
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
|
08-24-2004 12:21
The syntax error is because you're missing a semicolon at the end of your do-while loop. There are other problems. You should probably try something simpler for your very first script. (This is a good try, though.) Quick rundown: -- You've declared timer() inside of touch_start(). You can't declare one event handler inside another. -- An event handler doesn't interrupt currently executing code; events queue up, and are handled in turn. So your do-while loop won't ever finish, because the ON variable will never be reset while they're running. -- The llMakeExplosion library call is deprecated. llParticleSystem is recommended instead. See the LSL wiki at http://www.badgeometry.com/wiki/HomePage or the LSL help file at /54/30/16885/1.html for more information.
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
Re: Firebox Script problems.
08-25-2004 07:58
Try something like this. Note that I'm using the touch event to turn the timer on and off, and that I moved the actual making of the particles to a function, so you could use the new function, llParticleSystem, and get as complicated as you like, without cluttering up the control code. Also, in LSL, you done refer to colours by a string name, but as a vector, an RGB triple //******************************************// // Name: Trigger Script // // Object: Firebox v0.5b // // Creator: Katherine Jacobs // // Date: 24-08-2004 // //************** Description: **************// // A simple script for the Firebox object, // // it is designed to spread particles in a // // spherical explosion around a small box. // // Touch to turn on, and the do-while loop // // should activate, touch again to turn off // // and the second do-while loop should take // // care of de-activation. // //******************************************//
integer ON = FALSE; //Declare global integer, ON, to be FALSE, since object starts off.
vector vGreen = <0.0 1.0, 0.0>; vector vBlue = <0.0, 0.0, 1.0>;
makeParticles() { llMakeExplosion(250, 0.25, 5.0, 10.0, 30.0, vGreen, ZERO_VECTOR); //Lots of shrapnel created by the explosion, excellent strobe lighting effect. llMakeExplosion(250, 0.25, 5.0, 10.0, 30.0, vBlue, ZERO_VECTOR); }
default { state_entry() { llSay(0, "Firebox V0.5b on standby."); //Initiation for testing, like a test marker to see how far the script is running. } touch_start(integer total_number) { if(ON == TRUE) //Check for ON being true, if on is true, execute code below. { llSetTimerEvent(0.0); // turn the timer off } else //If on is not true, execute this. { llSetTimerEvent(0.1); // turn the timer on (note, this interval is *way* to short, it should probably be more like 0.5 or 1.0) llSay(0, "Firebox Deactivated" ; //User notification and test marker for code execution. } ON = !ON; // flip the value of ON } timer() { makeParticles(); } } [/B][/QUOTE]
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Katherine Jacobs
Junior Member
Join date: 22 Aug 2004
Posts: 5
|
08-25-2004 09:09
Thanks for making an actual script, but I'm going to ignore it for the time being. I like to learn things by asking questions and progressivly taking steps. After Jake's post, I took another stab at the code, and eventually got it working. This may seem like a primitive coding to some of you, so I'd like to know how to enhance it and make it, "up to date", so to speak. //********************************************************************// // Name: Trigger Script // // Object: Psyco Psychodelic Spear V1.0 // // Creator: Katherine Jacobs // // Worthy Note: Jake Cellardoor, pointing out scripting errors // // Date: 24-08-2004 // //*************************** Description: ***************************// // A simple script for the Spear object, it is designed to spread // // particles in a spherical explosion around an object. // // If-then-else statment covers the major part of the "lightswitch" // // function. Touch on, touch off. // //************************** Script History **************************// // ~v0.1a by Katherine Jacobs~ // // First stable release, extremely limited. No on-off functionality, // // cumbersome and messy code. Still in alpha. // // // // ~v0.5b by Katherine Jacobs~ // // Unstable release, racked with bugs and condemned to problematic // // coding and many inefficient ways of doing things. // // // // ~v1.0 by Katherine Jacobs~ // // Most stable release yet. Still insanely inefficient, but I'm // // building up on my scripting knowledge and improving. Clean code, // // well commented. Updates for the future: replacment of depreciated // // llMakeExplosion(). // //********************************************************************// integer ON = FALSE;
default { state_entry() { llSay(0, "Psyco Psychodelic Spear V1.0 Stable (by Katherine) on standby."); //Initiation for testing, like a test marker to see how far the script is running. } touch_start(integer total_number) { if(ON == FALSE) { llSay(0, "Boom Boom Mode Activated."); //User notification and test marker for code execution. ON = TRUE; llSetTimerEvent(0.1); //Timer event set. } else { llSetTimerEvent(0.0); llSay(0, "Boring Mode Activated."); //Another test marker. ON = FALSE; } } timer() { llMakeExplosion(250, 0.1, 5.0, 10.0, 30.0, "green", ZERO_VECTOR); //Lots of shrapnel created by the explosion, excellent strobe lighting effect. llMakeExplosion(250, 0.1, 5.0, 10.0, 30.0, "blue", ZERO_VECTOR); } }
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
08-25-2004 09:46
From: someone Originally posted by Katherine Jacobs Thanks for making an actual script, but I'm going to ignore it for the time being. I like to learn things by asking questions and progressivly taking steps. Good deal. I wasn't trying to write the script for you, just help you with what you already had. If you look at them now, you'll see they're pretty similar  Oh, and I made a dumb mistake in my script, those aren't colour names, those are your textures, sorry. I would strongly recommend putting the particle making code in a function instead of all in the timer event, but other than that, I think your script is pretty good, and there's not much more optimizing to be done.
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Katherine Jacobs
Junior Member
Join date: 22 Aug 2004
Posts: 5
|
08-25-2004 12:17
How's it looking now? // *******************************************************************// // Name: Trigger Script // // Object: Psyco Psychodelic Spear V1.1 // // Creator: Katherine Jacobs // // Worthy Note: Jake Cellardoor, pointing out scripting errors // // Wednesday Grimm, suggestion to make createExplosion() // // Date: 24-08-2004 // //*************************** Description: ***************************// // A simple script for the Spear object, it is designed to spread // // particles in a spherical explosion around an object. // // If-then-else statment covers the major part of the "lightswitch" // // function. Touch on, touch off. // //************************** Script History **************************// // ~v0.1a by Katherine Jacobs~ // // First stable release, extremely limited. No on-off functionality, // // cumbersome and messy code. Still in alpha. // // // // ~v0.5b by Katherine Jacobs~ // // Unstable release, racked with bugs and condemned to problematic // // coding and many inefficient ways of doing things. // // // // ~v1.0 by Katherine Jacobs~ // // Most stable release yet. Still insanely inefficient, but I'm // // building up on my scripting knowledge and improving. Clean code, // // well commented. Updates for the future: replacment of depreciated // // llMakeExplosion(). This version is courtesy of Jake Cellardoor's // // aid with creating a stable, working version of the v0.5b script. // // // // ~v1.1 by Katherine Jacobs~ // // Slight enhancment to the script, timer() is now linked to // // createExplosion(). Thanks to Wednesday Grimm for this little edit. // // *******************************************************************//
integer ON = FALSE;
createExplosion() { llMakeExplosion(250, 0.1, 5.0, 10.0, 30.0, "green", ZERO_VECTOR); //Lots of shrapnel created by the explosion, excellent strobe lighting effect. llMakeExplosion(250, 0.1, 5.0, 10.0, 30.0, "blue", ZERO_VECTOR); }
default { state_entry() { llSay(0, "Psyco Psychodelic Spear V1.1 Stable (by Katherine) on standby."); //Initiation for testing, like a test marker to see how far the script is running. } touch_start(integer total_number) { if(ON == FALSE) { llSay(0, "Boom Boom Mode Activated."); //User notification and test marker for code execution. ON = TRUE; llSetTimerEvent(0.1); //Timer event set. } else { llSetTimerEvent(0.0); llSay(0, "Boring Mode Activated."); ON = FALSE; } } timer() { createExplosion(); //Jump to createExplosion. } }
|