Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save antonyfairport/fa64ed4c1ab6f48debec to your computer and use it in GitHub Desktop.

Select an option

Save antonyfairport/fa64ed4c1ab6f48debec to your computer and use it in GitHub Desktop.
//////////////////////////////////////////////////////////////////////
// Z&A Simple Animated Billboard Thing
// By Antony Fairport
//
// Z&A Simple Animated Billboard Thing - Quick and dirty animated
// billboard. Shows textures on a face, on a timer, from inventory,
// and also hands out other content.
//
// Revision history:
// ------------------------------------------------------------
//
// 2015-04-17
// Initial revision.
//////////////////////////////////////////////////////////////////////
// Config.
integer DISPLAY_FACE = 0;
integer FLIP_SECONDS = 5;
//////////////////////////////////////////////////////////////////////
// Globals.
list g_lTextures;
integer g_iTexture;
//////////////////////////////////////////////////////////////////////
// Load textures.
LoadTextures()
{
integer iMax = llGetInventoryNumber( INVENTORY_TEXTURE );
integer i;
for ( i = 0; i < iMax; i++ )
{
g_lTextures += llGetInventoryName( INVENTORY_TEXTURE, i );
}
}
//////////////////////////////////////////////////////////////////////
// Show the next texture in the sequence.
ShowNextTexture()
{
// Assuming we have some textures...
if ( g_lTextures )
{
// Show the texture.
llSetTexture( llList2String( g_lTextures, g_iTexture ), DISPLAY_FACE );
// Bump to the next.
if ( ++g_iTexture >= llGetListLength( g_lTextures ) )
{
// Made it to the end. Start again.
g_iTexture = 0;
}
}
}
//////////////////////////////////////////////////////////////////////
// Default state.
default
{
//////////////////////////////////////////////////////////////////
// Set things up.
state_entry()
{
// To start with, find all the textures.
llOwnerSay( "Loading textures to show..." );
LoadTextures();
llOwnerSay( "Found " + ( (string) llGetListLength( g_lTextures ) ) + " textures to show." );
// Show the first one.
ShowNextTexture();
// Now start the timer.
llSetTimerEvent( FLIP_SECONDS );
}
//////////////////////////////////////////////////////////////////
// Handle a touch.
touch_start( integer num_detected )
{
// See if there's a notecard or landmark inside us.
string sNC = llGetInventoryName( INVENTORY_NOTECARD, 0 );
string sLM = llGetInventoryName( INVENTORY_LANDMARK, 0 );
// For every touch detected...
integer i;
for ( i = 0; i < num_detected; i++ )
{
// Find out who touched us.
key kToucher = llDetectedKey( i );
// If there's a notecard...
if ( sNC )
{
// ...give it to the toucher.
llGiveInventory( kToucher, sNC );
}
// Landmark?
if ( sLM )
{
// Yup. Give that too.
llGiveInventory( kToucher, sLM );
}
}
}
//////////////////////////////////////////////////////////////////
// React to a timer event.
timer()
{
// Show the next image.
ShowNextTexture();
}
//////////////////////////////////////////////////////////////////
// React to changes.
changed( integer change )
{
// If the owner or the content has changed...
if ( ( change & CHANGED_OWNER ) || ( change & CHANGED_INVENTORY ) )
{
// ...start again.
llResetScript();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment