All pastes #582298 Raw Edit

boombox.lsl

public text v1 · immutable
·published 2007-06-21 22:18 UTC
rendered paste body
//BoomBox by Mitz
integer counter;
integer soundCount;
integer listener;
list songs;
list NEXT;

GetSongNames()
{
	integer i;
	for(i=0;i < llGetInventoryNumber(INVENTORY_SOUND);i++)
	{
		songs += llGetInventoryName(INVENTORY_SOUND, i);
	}
}


default
	
{
	on_rez(integer rez)
	{
		llResetScript();
	}
	
	state_entry()
	{
		counter =0;
		llStopSound();
		llSay(0, "Boombox Off");
		llSetText("Boomboxin' (Hazim n' Spotz edit)\nStopped", <1,0,0>, 1.5);
		GetSongNames();
		//PreLoadSongs();
		soundCount = llGetInventoryNumber(INVENTORY_SOUND);
		llListen(-1, "", llGetOwner(), "");
		NEXT = llList2List(songs, 0, 8);
	}
	
	touch_start(integer fingers)
	{
		if (llDetectedLinkNumber(0) != 3 && llDetectedKey(0) == llGetOwner())
		{
			llDialog(llGetOwner(), "Songs", NEXT + ["< Prev", "Stop", "Next >"], -1);
		}
	}
	
	listen(integer channel, string name, key id, string message)
	{
		if(message != "< Prev" && message != "Stop" && message != "Next >" && message != "Reset" )
		{
			llLoopSound(message, 1);
			llSay(0, "Now Playing: " + message );
			llSetText("Boomboxin' (Hazim n' Spotz edit)\nNow Playing: " + message, <0,1,0>, 1.5);
		}else{
			if(message == "< Prev")
			{
				counter = counter - 9;
				NEXT = [];
				NEXT = llList2List(songs, counter , -1);
				if( llGetListLength(NEXT) > 9)
				{
					NEXT = llDeleteSubList(NEXT, 9, -1);
				}
				llDialog(llGetOwner(), "Songs", NEXT + ["< Prev", "Stop", "Next >"], -1);
			}
			
			if(message == "Stop")
			{
				llStopSound();
				llSetText("Boomboxin' (Hazim n' Spotz edit)\nStopped", <1,0,0>, 1.5);
			}
			
			if(message == "Reset")
			{
				llResetScript();
			}
			
			if(message == "Next >")
			{
				counter = counter + 9;
				NEXT = [];
				NEXT = llList2List(songs, counter , -1);
				if( llGetListLength(NEXT) > 9)
				{
					NEXT = llDeleteSubList(NEXT, 9, -1);
				}
				llDialog(llGetOwner(), "Songs", NEXT + ["< Prev", "Stop", "Next >"], -1);
			}
		}
	}
}