Created
June 27, 2016 14:04
-
-
Save antonyfairport/91e9ed1eb04e6368179282d928f90f0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////// | |
// Z&A Light Ribbon | |
// By Antony Fairport | |
// | |
// Z&A Light Ribbon - Quick and simple glowstick/ribbon | |
// | |
// Revision history: | |
// ------------------------------------------------------------ | |
// | |
// 2016-06-25 | |
// Initial revision. | |
////////////////////////////////////////////////////////////////////// | |
// Make the ribbon | |
MakeRibbon( vector vStartColour, vector vEndColour ) | |
{ | |
// Get the size of the stick, so we can adjust the particle. | |
vector vStickSize = llGetScale(); | |
llParticleSystem( [ | |
PSYS_PART_FLAGS, PSYS_PART_RIBBON_MASK | | |
PSYS_PART_INTERP_COLOR_MASK | | |
PSYS_PART_EMISSIVE_MASK, | |
PSYS_PART_MAX_AGE, 0.75, | |
PSYS_SRC_TEXTURE, TEXTURE_BLANK, | |
PSYS_PART_START_SCALE, < vStickSize.z, 0.02, 0.0 >, | |
PSYS_PART_START_ALPHA, 0.5, | |
PSYS_PART_END_ALPHA, 0.0, | |
PSYS_PART_START_GLOW, 0.2, | |
PSYS_PART_END_GLOW, 0.05, | |
PSYS_PART_START_COLOR, vStartColour, | |
PSYS_PART_END_COLOR, vEndColour | |
] ); | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Refresh the ribbon, loading colours from object desc. | |
RefreshRibbon() | |
{ | |
// Get the description as a list. | |
list lColours = llParseString2List( llGetObjectDesc(), [ "~" ], [] ); | |
// The start and end colours. | |
vector vStart = < 1.0, 0.0, 0.0 >; | |
vector vEnd = < 0.01, 0.0, 0.0 >; | |
// If we seem to have got enough stuff from the description... | |
if ( llGetListLength( lColours ) > 1 ) | |
{ | |
// ...assume we're getting colours. | |
vStart = (vector) llList2String( lColours, 0 ); | |
vEnd = (vector) llList2String( lColours, 1 ); | |
} | |
// Texture the stick itself. | |
llSetLinkPrimitiveParamsFast( LINK_THIS, [ | |
PRIM_GLOW, ALL_SIDES, 0.2, | |
PRIM_FULLBRIGHT, ALL_SIDES, TRUE, | |
PRIM_COLOR, ALL_SIDES, vStart, 1.0 | |
] ); | |
// Make the ribbon. | |
MakeRibbon( vStart, vEnd ); | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Default state. | |
default | |
{ | |
////////////////////////////////////////////////////////////////// | |
// State entry. | |
state_entry() | |
{ | |
// Restrict memory. We don't need much. | |
llSetMemoryLimit( 12 * 1024 ); | |
// Get the ribbon off. | |
RefreshRibbon(); | |
} | |
////////////////////////////////////////////////////////////////// | |
// When rezzed... | |
on_rez( integer _ ) | |
{ | |
RefreshRibbon(); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Handle being atached. | |
attach( key id ) | |
{ | |
if ( id ) | |
{ | |
RefreshRibbon(); | |
} | |
} | |
////////////////////////////////////////////////////////////////// | |
// Handle changes. | |
changed( integer change ) | |
{ | |
// If the owner has changed... | |
if ( change & CHANGED_OWNER ) | |
{ | |
// ...reset the script. | |
llResetScript(); | |
} | |
// If the size of the stick changed... | |
else if ( change & CHANGED_SCALE ) | |
{ | |
// ...refresh the particles. | |
RefreshRibbon(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment