|
LeVey Palou
Registered User
Join date: 31 Aug 2006
Posts: 131
|
11-11-2007 18:28
Hello,
I have had some luck lately with LLscripting. Recently I scripted a few vehicles and was happy with the outcome.
I have created a box that when touched turns on and off a particle script. I would like to chat the commands on another channel ( /1 whatever) so that i can turn on and off a bunch of these boxes at once.
Trouble is I cant figure this out?
I understand from looking at other scripts that there is a listen function set up.the script listens for and command on a specific channel and initiates a reaction.
I tried taking out the ontouch command line in my particle script and replacing it with code i found else where which successfully compiled but ignored me and did nothing.
So a few question if I may:
Would this be better orgastrated if the listen thingy were in a seperate script?
Can anyone plz give an example?
Thanks for the help!
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
11-11-2007 19:03
deafult { state_entry() { llListen(1,"",llGetOwner(),""  ; //channel, name,id,msg } listen(integer channel, string name, key id, string message) { if (message == "on"  // do on code here else if (message == "off"  // do off code here else return; } } input would look like this in the chat bar ... /1 on
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
11-11-2007 19:07
i belive i know what you are talking about at the top of script in state_entry() you need llListen([channel number],llGetOwner() (lets script know to only listen to what owner says),""  ; followed by listen(integer channel, string name, key id, string message) // tells script what to do on listen and finnaly since it is a particle script something like this listen(integer channel, string name, key id, string message) { if (message="[whatever]"  { [particle naming] } else if(message="stop"  llParticleSystem([]); // cancels out the particels } } something to that effect, here is a example from one of my scripts default { state_entry() { llListen(0,"",llGetOwner(),""); // will listen to owner on channel 1 or any other channel if not 0 (/#) } listen(integer channel, string name, key id, string message) { if(message = "afterburner on") { mySetParticles(); // turn on a particle pump that i deifned at top of script } else if(message = "afterburner off") { llParticleSystem([]); // shut it off } } }
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
11-11-2007 20:06
Yeah! You win the prize, you understood the concept! You have won a life time supply of "Hello Avatar"scripts. Well actually you nearly got it. Your if test and else if test need == instead of just a single =. http://www.cheesefactory.us/lslwm/binary.htm
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
LeVey Palou
Registered User
Join date: 31 Aug 2006
Posts: 131
|
11-12-2007 02:22
Hi and thanks everyone for posting!
bare with me plz...
mySetParticles(); // turn on a particle pump that i deifned at top of script
ok this confused me a bit can some one please ellaborate? is this saying "to set an interger at the top of script?"
and would the script you are showing be a seperate script from the particle script (yes?). in other words there would be two scripts in prim one with this listen script and the other with the particle script?
Sorry, doing my best to follow...lol
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
11-12-2007 02:36
From: LeVey Palou Hi and thanks everyone for posting!
bare with me plz...
mySetParticles(); // turn on a particle pump that i deifned at top of script
ok this confused me a bit can some one please ellaborate? is this saying "to set an interger at the top of script?"
and would the script you are showing be a seperate script from the particle script (yes?). in other words there would be two scripts in prim one with this listen script and the other with the particle script?
Sorry, doing my best to follow...lol No need to apologize... what going on there is defining a function. LSL has many built in functions, llSay(), llGetOwner(), etc.. well, you, yes YOU can define your own functions! It's like you're exending the language by create new functions by combining pre-existing functions. This is called a 'user defined function'. The format for creating a function is as follows: type functionName(type parameter1, type parameter2, type parameter3) { // code goes here: } for example... //notice this goes BEFORE the default state. This doesnt go into any state because it's a declaration, not code inside the script... float getAbsoluteValueOf(float value) { if (value < 0) return value * -1; return value; } // here's the begining of the script.... default { state_entry() { float myFloat = 4.392; float absFloat = getAbsoluteValueOf(myFloat); // <--- our 'new' function being used! llSay(0, "The absolute value of " (string) myFloat " is " (string) absFloat); } } hope that clears things up 
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
11-12-2007 13:27
il give you a complete script that i did, will fix that mis comunicate it took me forever to learn how to acculy know what peaple ment // Mask Flags - set to TRUE to enable integer glow = TRUE; // Make the particles glow integer bounce = FALSE; // Make particles bounce on Z plan of object integer interpColor = TRUE; // Go from start to end color integer interpSize = TRUE; // Go from start to end size integer wind = FALSE; // Particles effected by wind integer followSource = TRUE; // Particles follow the source integer followVel = TRUE; // Particles turn to velocity direction
// Choose a pattern from the following: // PSYS_SRC_PATTERN_EXPLODE // PSYS_SRC_PATTERN_DROP // PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY // PSYS_SRC_PATTERN_ANGLE_CONE // PSYS_SRC_PATTERN_ANGLE integer pattern = PSYS_SRC_PATTERN_EXPLODE;
// Select a target for particles to go towards // "" for no target, "owner" will follow object owner // and "self" will target this object // or put the key of an object for particles to go to key target = "";
// Particle paramaters float age = 1; // Life of each particle float maxSpeed = .1; // Max speed each particle is spit out at float minSpeed = .1; // Min speed each particle is spit out at string texture; // Texture used for particles, default used if blank float startAlpha = 1; // Start alpha (transparency) value float endAlpha = 0.1; // End alpha (transparency) value vector startColor = <0,0,0>; // Start color of particles <R,G,B> vector endColor = <0.9,0.9,0.9>; // End color of particles <R,G,B> (if interpColor == TRUE) vector startSize = <1,1,1>; // Start size of particles vector endSize = <.1,1,.1>; // End size of particles (if interpSize == TRUE) vector push = <0,0,4>; // Force pushed on particles
// System paramaters float rate = .1; // How fast (rate) to emit particles float radius = .3; // Radius to emit particles for BURST pattern integer count = 15; // How many particles to emit per BURST float outerAngle = 1.75; // Outer angle for all ANGLE patterns float innerAngle = 1.55; // Inner angle for all ANGLE patterns vector omega = <5,1,10>; // Rotation of ANGLE patterns around the source float life = 0; // Life in seconds for the system to make particles
// Script variables integer flags;
mySetParticles() { flags = 0; if (target == "owner") target = llGetOwner(); if (target == "self") target = llGetKey(); if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK; if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK; if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK; if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK; if (wind) flags = flags | PSYS_PART_WIND_MASK; if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK; if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK; if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
llParticleSystem([ PSYS_PART_MAX_AGE,age, PSYS_PART_FLAGS,flags, PSYS_PART_START_COLOR, startColor, PSYS_PART_END_COLOR, endColor, PSYS_PART_START_SCALE,startSize, PSYS_PART_END_SCALE,endSize, PSYS_SRC_PATTERN, pattern, PSYS_SRC_BURST_RATE,rate, PSYS_SRC_ACCEL, push, PSYS_SRC_BURST_PART_COUNT,count, PSYS_SRC_BURST_RADIUS,radius, PSYS_SRC_BURST_SPEED_MIN,minSpeed, PSYS_SRC_BURST_SPEED_MAX,maxSpeed, PSYS_SRC_TARGET_KEY,target, PSYS_SRC_INNERANGLE,innerAngle, PSYS_SRC_OUTERANGLE,outerAngle, PSYS_SRC_OMEGA, omega, PSYS_SRC_MAX_AGE, life, PSYS_SRC_TEXTURE, texture, PSYS_PART_START_ALPHA, startAlpha, PSYS_PART_END_ALPHA, endAlpha ]); }
default { state_entry() { llListen(0,"",llGetOwner(),""); } listen(integer channel, string name, key id, string message) { if(message=="[your message]") { mySetParticles(); // name of a "subscript" what i call it } else if(message=="[other message]") { llParticleSystem([]); // stops the particles } } }
i hope that cleared it up, at the top all the integers and strings tell the particles what to do and how to look
|