Exploding Objects
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
07-21-2009 14:37
this is going to be alot tougher than I thought because as soon as I put the script into the pieces i have to quickly take them or they disapear. I cant get more than one out of my inventory at a time. even if i could i would not be able to get all 25 out fast enough to select them all then choose take before the disapeare. my only hope is a script that would alow me to rez more than one object at a time or combine all the peices while in my inventory. I'm stumped again.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
07-21-2009 14:55
From: SirFency Blackheart this is going to be alot tougher than I thought because as soon as I put the script into the pieces i have to quickly take them or they disapear. I cant get more than one out of my inventory at a time. even if i could i would not be able to get all 25 out fast enough to select them all then choose take before the disapeare. my only hope is a script that would alow me to rez more than one object at a time or combine all the peices while in my inventory. I'm stumped again. Noooooo! The script won't do anything until you rez the object out of your inventory. That's why it does all its stuff in the on-rez event. Let's try this again ....... Create the individual pieces and don't take them to inventory yet. Move the pieces so that they are on top of each other, drag a selection window around them, and then take the coalesced object -- which now consists of several parts treated as one, but NOT linked -- into your inventory. If you have done it right, in inventory it will have an icon next to it that looks like a stack of boxes. THAT's the thing that you rez. When you do, the pieces will scatter to the wind.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
07-21-2009 15:14
Here you go with a very simple listen setup for your script. You might want to think about if you really want an open listen always there but assuming you do this might help: //----------- //Landmine //----------- integer MyChannel = 7; vector pos; // Used to store the current position.
// Follows the function used to rez in random position a burst of // ten bullets. // Be sure that they are temporary prims!
burst() {
// The bullet contained into your object's inventory is rezzed at // the acquired position with random initial velocity and zero // rotation.
llRezObject("piece_1", pos, < llFrand(9) + llFrand(-9), llFrand(9) + llFrand(-9), llFrand(9) > , ZERO_ROTATION, 0);
}
default { on_rez(integer start_param) { llResetScript(); } // Script is resetted to its default values on object's rezzing // (state_entry section).
state_entry() { llListen(MyChannel, "", NULL_KEY, ""); llSetAlpha(1, ALL_SIDES); // This makes your object visible.
llSetStatus(STATUS_PHANTOM, FALSE); // This makes your object solid.
pos = llGetPos(); // Used to acquire the actual position.
pos = pos + < 0.0, 0.0, 0.5 > ; // Used to add a little offset to the bullets rezzing point. }
listen(integer channel, string name, key id, string message) { if (channel == MyChannel) { if (message == "investigate") { llSetAlpha(0, ALL_SIDES); // This makes your object invisible.
llSetStatus(STATUS_PHANTOM, TRUE); // This makes your object "phantom" (non solid).
llSay(0, llDetectedName(0) + " you just stepped on a landmine!"); // Whenever someone walks on your object, will receive this // message.
burst(); // Bullets are rezzed.
llSleep(20); // This makes the script sleep for 600 seconds (10 minutes) // before your object's initial status is restored.
llResetScript(); // Script is resetted and your object's initial status // is restored (state_entry section). } } } }
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
07-21-2009 15:29
Thanks very much for the help the bomb is now exploding into all 25 peices and cleaning itself up. only a couple more fetures to add. The land mine is blowing up when I walk over it but the particle explosion happens when I say investigate in chat channel 7. I'm not sure what would be easier. switching the boot to blow up on command or switching the particles to go off when i walk over the landmine. also the bomb is not disapearing temporarily like it should.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
07-21-2009 15:55
Cool! So now you have the pieces. You have to decide how you intend to trigger your device. That determines what sort of event all the exciting stuff goes in. My guess is that you want either a collision event or a touch_start event, but a listen event would work too. In any case, it's simply a matter of creating a script that looks schematically like this ... default { on_rez(integer start_params) { //anything you want to do when this thing is rezzed from your inventory, like maybe llResetScript() } state_entry() { //Anything that needs to be initialized, like a llListen handle, llSetAlpha(1.0), etc. //Oh, yes, and llPreloadSound("Big Bang") so that it's ready to play later } aTriggeringEvent // Like listen, touch_start, or collision_start. // The specific event you choose will determine what syntax is necessary here { llSetAlpha(0.0); llParticleSystem( [//all of its parameters go here ]); llRezObject("myScaryObject",llGetPos()+< 0,0,0.1>,ZERO_VECTOR,ZERO_ROTATION,1); llPlaySound("BigBang",1.0); llSetTimerEvent(10); // This sets the timer to wait 10 seconds before restarting everything } timer() { llResetScript(); } }
Clean it up, put it into your device along with that exploding coalesced object ("myScaryObject"  , and you're set.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
07-21-2009 15:58
From: Celty Westwick Here you go with a very simple listen setup for your script. You might want to think about if you really want an open listen always there but assuming you do this might help: //----------- //Landmine //----------- integer MyChannel = 7; vector pos; // Used to store the current position.
// Follows the function used to rez in random position a burst of // ten bullets. // Be sure that they are temporary prims!
burst() {
// The bullet contained into your object's inventory is rezzed at // the acquired position with random initial velocity and zero // rotation.
llRezObject("piece_1", pos, < llFrand(9) + llFrand(-9), llFrand(9) + llFrand(-9), llFrand(9) > , ZERO_ROTATION, 0);
}
default { on_rez(integer start_param) { llResetScript(); } // Script is resetted to its default values on object's rezzing // (state_entry section).
state_entry() { llListen(MyChannel, "", NULL_KEY, ""); llSetAlpha(1, ALL_SIDES); // This makes your object visible.
llSetStatus(STATUS_PHANTOM, FALSE); // This makes your object solid.
pos = llGetPos(); // Used to acquire the actual position.
pos = pos + < 0.0, 0.0, 0.5 > ; // Used to add a little offset to the bullets rezzing point. }
listen(integer channel, string name, key id, string message) { if (channel == MyChannel) { if (message == "investigate") { llSetAlpha(0, ALL_SIDES); // This makes your object invisible.
llSetStatus(STATUS_PHANTOM, TRUE); // This makes your object "phantom" (non solid).
llSay(0, llDetectedName(0) + " you just stepped on a landmine!"); // Whenever someone walks on your object, will receive this // message.
burst(); // Bullets are rezzed.
llSleep(20); // This makes the script sleep for 600 seconds (10 minutes) // before your object's initial status is restored.
llResetScript(); // Script is resetted and your object's initial status // is restored (state_entry section). } } } }
thanks this worked great now when I say investigate the bomb blows up and the particles go off adding to the explosion effect. now all I have to do is get the bomb disapearing temporarily and add a delayed smoke effect that fades away over time. I am having wierd issues with some of the peices no disapearing it says it reached the bounds of the sandbox but there is no sandbox I have permisions to build and script anywere on our island.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
07-21-2009 16:04
From: SirFency Blackheart I am having wierd issues with some of the peices no disapearing it says it reached the bounds of the sandbox but there is no sandbox I have permisions to build and script anywere on our island. That's because I was using the STATUS_SANDBOX limitation in the exploding pieces to make them disappear before they go very far. You could take that out and just let the timer kill the pieces if you want.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
07-21-2009 17:11
I'm not sure why your object is not going invisible (alpha) for you it works for me with that exact script. Is the object one prim?
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
07-21-2009 21:11
Good progress! Here are a few things to think about .... //----------- //Landmine //----------- integer MyChannel = 7; vector pos; // Used to store the current position.
// Follows the function used to rez in random position a burst of // ten one bullets. // Be sure that they are temporary prims! // Temporary prims have a lifetime of close to one hour. To make them // disappear faster, you'll need to script them individually to llDie burst() {
// The bullet contained into your object's inventory is rezzed at // the acquired position with random initial velocity and zero // rotation.
llRezObject("piece_1", pos, < llFrand(9) + llFrand(-9), llFrand(9) + llFrand(-9), llFrand(9) > , ZERO_ROTATION, 0);
}
default { on_rez(integer start_param) { llResetScript(); } // Script is resetted to its default values on object's rezzing // (state_entry section).
state_entry() { llListen(MyChannel, "", NULL_KEY, ""); llSetAlpha(1, ALL_SIDES); // This makes your object visible.
llSetStatus(STATUS_PHANTOM, FALSE); // This makes your object solid.
pos = llGetPos(); // Used to acquire the actual position.
pos = pos + < 0.0, 0.0, 0.5 > ; // Used to add a little offset to the bullets rezzing point. // Or you could just put vector pos = llGetPos() + < 0,0,0.5> in the user defined function burst() instead of here and save a global variable }
listen(integer channel, string name, key id, string message) { if (channel == MyChannel) // Not needed since you already have filtered to listen // only on MyChannel in the llListen handle above { if (message == "investigate") // Try using either llToLower(message) == "investigate" // or llToUpper(message) == "INVESTIGATE" to avoid user uc/lc issues { llSetAlpha(0, ALL_SIDES); // This makes your object invisible.
llSetStatus(STATUS_PHANTOM, TRUE); // This makes your object "phantom" (non solid).
llSay(0, llDetectedName(0) + " you just stepped on a landmine!"); // llDetectedName will not work in a listen event. If you want to use the avatar's name, // you'll need llKey2Name(id) instead // Whenever someone walks on your object, will receive this // message.
burst(); // Bullets are rezzed.
llSleep(20); // This makes the script sleep for 600 seconds (10 minutes) actually 20 seconds // before your object's initial status is restored.
llResetScript(); // Script is resetted and your object's initial status // is restored (state_entry section). } } } }
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
07-22-2009 05:23
Sweet! I'm almost there. I'm not sure why the temporary invisibillity wasnt working but I rebuilt the entire bomb from scratch and now it works. I wonder if it was some kinda ghost script glitch were it was reading old scripts inside the object. My last step is to add the smoke. I'll let you all know how it goes.
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
07-22-2009 06:08
From: Rolig Loon Good progress! Here are a few things to think about ....
// Follows the function used to rez in random position a burst of // ten one bullets. // Be sure that they are temporary prims! // Temporary prims have a lifetime of close to one hour. To make them // disappear faster, you'll need to script them individually to llDie burst() {
// The bullet contained into your object's inventory is rezzed at // the acquired position with random initial velocity and zero // rotation.
llRezObject("piece_1", pos, < llFrand(9) + llFrand(-9), llFrand(9) + llFrand(-9), llFrand(9) > , ZERO_ROTATION, 0);
}
I should have also pointed out last night that this way of scripting the user defined function will rez your bomb at a random location. What you want to do instead is rez the bomb where the parent (unexploded) device has been. The bomb is the coalesced object we created back in post #22 of this thread. Its parts are the things that get a random impulse and scatter to the wind. That's why they need their own scripts. So, if you really want to put the "exploding" activity in a user defined function like this, then it ought to look like this .... burst() { llSetAlpha(0.0); llParticleSystem( [//all of its parameters go here ]); llRezObject("myScaryObject",llGetPos()+< 0,0,0.1>,ZERO_VECTOR,ZERO_ROTATION,1); llPlaySound("BigBang",1.0); }
Don't forget to llPreloadSound in the state_entry event so that your sound file is ready to play when this function is called.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
07-22-2009 07:03
Ok i have figured out I needed to add another object and call on it in the main script so now the script calls on the exploding object then it calls on a object i made to look like a crater, its an alpha texture linked with another object that looks like a glowing hot coal. this obect has the particle smoke effect. so all shows up and the smoke works. my issue now is placing the alpha texture object close to the ground. right now its rezzing above the bomb. I dont know how to tell it were i want it to show up. I looked at vector offsets but I dont understand what I'm looking at. I'm using the same bullet script used for the peices that fly out but i shut off the physics and set all the llFrand functions to zero. this is the last thing I need to do then mission accomplished thanks to you guys.
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
07-22-2009 07:15
nevermind guys I figured it out. It works and looks decent for what I wanted it for. Thanks for all the help.
|