Last active
December 30, 2020 13:28
-
-
Save FelixWolf/29f602bda331c5603ea561d413cd7afb to your computer and use it in GitHub Desktop.
reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
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
/******************************************************************************\ | |
* Accepts textures in the following format: | |
* <somename>_cfg:<args> or <some name>cfg:<args> | |
* Valid args: | |
* m: Mode (See http://wiki.secondlife.com/wiki/LlSetTextureAnim) | |
* x: SizeX | |
* y: SizeY | |
* s: Start | |
* l: Length | |
* r: Rate | |
* d: Delay (in seconds before choosing a new gif) | |
* m: Sound (Must be in inventory) | |
* p: Loop sound? (1 or 0) | |
\******************************************************************************/ | |
preloadTexture(string name){ | |
//A simple way to preload a texture without a extra prim | |
llLinkParticleSystem(LINK_THIS, [ | |
PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_DROP, | |
PSYS_SRC_BURST_RADIUS,0, | |
PSYS_SRC_ANGLE_BEGIN,0, | |
PSYS_SRC_ANGLE_END,0, | |
PSYS_SRC_TARGET_KEY,llGetKey(), | |
PSYS_PART_START_COLOR,<1.000000,1.000000,1.000000>, | |
PSYS_PART_END_COLOR,<1.000000,1.000000,1.000000>, | |
PSYS_PART_START_ALPHA,0, | |
PSYS_PART_END_ALPHA,1, | |
PSYS_PART_START_GLOW,0, | |
PSYS_PART_END_GLOW,0, | |
PSYS_PART_BLEND_FUNC_SOURCE,PSYS_PART_BF_SOURCE_ALPHA, | |
PSYS_PART_BLEND_FUNC_DEST,PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA, | |
PSYS_PART_START_SCALE,<1.000000,1.000000,0.000000>, | |
PSYS_PART_END_SCALE,<0.500000,0.500000,0.000000>, | |
PSYS_SRC_TEXTURE,name, | |
PSYS_SRC_MAX_AGE,0, | |
PSYS_PART_MAX_AGE,1, | |
PSYS_SRC_BURST_RATE,1, | |
PSYS_SRC_BURST_PART_COUNT,1, | |
PSYS_SRC_ACCEL,<0.000000,0.000000,0.000000>, | |
PSYS_SRC_OMEGA,<0.000000,0.000000,0.000000>, | |
PSYS_SRC_BURST_SPEED_MIN,0.5, | |
PSYS_SRC_BURST_SPEED_MAX,0.5, | |
PSYS_PART_FLAGS, 208 | |
/* | |
PSYS_PART_FOLLOW_SRC_MASK | |
| PSYS_PART_TARGET_LINEAR_MASK | |
| PSYS_PART_TARGET_POS_MASK | |
*/ | |
]); | |
} | |
list loadGif(string exclude){ | |
//Setup defautls if it isn't specified in the name | |
integer mode = ANIM_ON | LOOP; | |
integer sizex = 1; | |
integer sizey = 1; | |
float start = 0; | |
float length = 0; | |
float rate = 0; | |
float delay = 10; | |
string sound = ""; | |
float soundvolume = 1; | |
integer soundloop = FALSE; | |
//Choose a texture(optionally, if exclude is set, don't choose that one) | |
integer count = llGetInventoryNumber(INVENTORY_TEXTURE); | |
string name = llGetInventoryName(INVENTORY_TEXTURE, llFloor(llFrand(count))); | |
if(exclude != "" && count > 1){ | |
while(name == exclude){ | |
name = llGetInventoryName(INVENTORY_TEXTURE, llFloor(llFrand(count))); | |
} | |
} | |
//Parse arguments | |
list args = llParseString2List(llList2String(llParseString2List(name, ["cfg:"],[]),-1),["&"],[]); | |
integer i = 0; | |
integer l = llGetListLength(args); | |
for(;i<l;i++){ | |
string opt = llGetSubString(llList2String(args,i),0,0); | |
string val = llGetSubString(llList2String(args,i),1,-1); | |
if(opt == "m") mode = (integer)val; | |
else if(opt == "x") sizex = (integer)val; | |
else if(opt == "y") sizey = (integer)val; | |
else if(opt == "s") start = (float)val; | |
else if(opt == "l") length = (float)val; | |
else if(opt == "r") rate = (float)val; | |
else if(opt == "d") delay = (float)val; | |
else if(opt == "m") sound = val; | |
else if(opt == "v") soundvolume = (float)val; | |
else if(opt == "p") soundloop = (integer)val; | |
} | |
//Return the data as a list | |
return [name, mode, sizex, sizey, start, length, rate, delay, sound, soundvolume, soundloop]; | |
} | |
setGif(list opts){ | |
//Set the texture | |
llSetLinkPrimitiveParamsFast(LINK_THIS, [ | |
PRIM_TEXTURE, ALL_SIDES, llList2String(opts, 0), <1,1,0>, <0,0,0>, 0 | |
]); | |
//Set the animations | |
llSetTextureAnim( | |
llList2Integer(opts, 1), | |
ALL_SIDES, | |
llList2Integer(opts, 2), | |
llList2Integer(opts, 3), | |
llList2Float(opts, 4), | |
llList2Float(opts, 5), | |
llList2Float(opts, 6) | |
); | |
//Play the sound | |
string sound = llList2String(opts,8); | |
if(sound != ""){ | |
float volume = llList2Float(opts,9); | |
if(llList2Integer(opts, 10)) | |
llLoopSound(sound, volume); | |
else | |
llPlaySound(sound, volume); | |
}else //Or stop it, if not specified. | |
llStopSound(); | |
//Delay it as specified | |
llSetTimerEvent(llList2Float(opts, 7)); | |
} | |
list nextGif; | |
chooseNext(){ | |
//Choose a new gif that isn't the current one | |
nextGif = loadGif(llList2String(nextGif, 0)); | |
//and preload it | |
preloadTexture(llList2String(nextGif, 0)); | |
//Preload sound as well if it is specified | |
string sound = llList2String(nextGif,8); | |
if(sound != "") | |
llPreloadSound(sound); | |
} | |
default{ | |
state_entry(){ | |
//Setup memory limit, we don't go above 16KiB | |
llSetMemoryLimit(0x4000); | |
//Choose initial gif and set it | |
nextGif = loadGif(""); | |
setGif(nextGif); | |
//Chose next gif | |
chooseNext(); | |
} | |
timer(){ | |
//Set the gif to the scheduled gif | |
setGif(nextGif); | |
//Choose a new one | |
chooseNext(); | |
} | |
changed(integer c){ | |
//If inventory changed, we might have lost the next gif, so choose a new one. | |
if(c&CHANGED_INVENTORY){ | |
chooseNext(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment