Addon script I made to Trigger a ZEDS prim animation and hide the folded top. Also triggers windows down with default "wswitch" Window notecard window switch command.
integer pluginAPI = 2565;
list APIbuttons = ["Roof"];
string lAnimName = "Convertible";
integer lFrameMax = 11;
float lFrameDelay = .5;
string lSoundOpen = "49716d20-6a73-b46b-511d-7ec53ce2e515"';
string lSoundClose = "49716d20-6a73-b46b-511d-7ec53ce2e515";
float lSoundVolume = 1.0;
topup()
{
integer x = llGetNumberOfPrims();
for (; x >= 0; --x)
{
if (llGetLinkName(x) == "Folded")
{
llSetLinkPrimitiveParamsFast(x,[
PRIM_COLOR, ALL_SIDES, llGetColor(x) , 0.0]);
}
}
}
topdown()
{
integer x = llGetNumberOfPrims();
for (; x >= 0; --x)
{
if (llGetLinkName(x) == "Folded")
{
llSetLinkPrimitiveParamsFast(x,[
PRIM_COLOR, ALL_SIDES, llGetColor(x) , 1.0]);
}
}
}
integer lSwitch = 0;
integer lFrame = 0;
list main_menu = [];
integer listen_handle;
integer Switch = FALSE;
drawMenu(key user)
{
llListenRemove(listen_handle);
integer rand_chan = (integer)llFrand(10000)+10;
listen_handle = llListen(rand_chan, "", user, "");
llDialog(user, "settings", main_menu, rand_chan);
}
default
{
on_rez(integer num)
{
llResetScript();
}
state_entry()
{
llSetMemoryLimit(llGetUsedMemory()+1024);
llMessageLinked(-1,-2,llDumpList2String([lAnimName,lFrame],"|"),"");
llSetTimerEvent(0);
}
link_message(integer sender_num,integer num,string message,key id)
{
if(num == pluginAPI)
{
if(message == "getButtons")
{
llMessageLinked(LINK_SET, pluginAPI, "setButtons:"+llDumpList2String(APIbuttons,"|"), "");
}
else if(message == llList2String(APIbuttons,0))
{
llMessageLinked(LINK_SET,1,"wswitch","");
if(lFrame == 0){
lSwitch = 1;
llSetTimerEvent(lFrameDelay);
}
else if(lFrame == lFrameMax){
lSwitch = 0;
llSetTimerEvent(lFrameDelay);
}
llMessageLinked(LINK_SET, pluginAPI, "Back", id);
}
}
}
timer(){
if(lSwitch){
if(lFrame == 0)
llPlaySound(lSoundOpen,lSoundVolume);
lFrame++;
if(lFrame == lFrameMax)
llSetTimerEvent(0);
topdown();
}
else{
if(lFrame == lFrameMax)
llPlaySound(lSoundClose,lSoundVolume);
lFrame--;
if(lFrame == 0)
llSetTimerEvent(0);
topup();
}
llMessageLinked(-1,-2,llDumpList2String([lAnimName,lFrame],"|"),"");
}
}