Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Free Photo Viewer Script

Hiro Pendragon
bye bye f0rums!
Join date: 22 Jan 2004
Posts: 5,905
10-31-2004 17:02
Okay, a friend of mine had a broken picture viewer, so I made my own "HiroTV".

Below is the notecard instructions and then followed by the source code. This is freeware, not supported, please have fun with it! =)

======== HiroTV ========
- easy, low-lag picture display script.
Freeware by Hiro Pendragon
----------------------------------------

Table of Contents:
1. Setup
2. Commands
3. Frequently Asked Questions
-----------------

1. SETUP

Step 1: Drop the HiroTV script into any prim you'd like to display pictures on.
Step 2: Add pictures.
Step 3: say, "HiroTV:reset"

-------------------------

2. COMMANDS

NOTE: All commands are case sensitive

HiroTV:setname
--------
Changes the name your HiroTV responds to. This is useful if you have more than one up in a room.
For example -
HiroTV:setname:MyTV
changes the name to "MyTV". All commands now will begin with "MyTV" instead of "HiroTV".

GetHiroTVName
--------
If you've forgotten the name of your HiroTV, you can use this command and any HiroTV in range that you
own will tell you its name.

HiroTV:setcolor
--------
Changes the color of the floating text, using 0-255 values for Red, Green, and Blue.
Example -
HiroTV:setcolor:255,255,255
changes the floating text to white.
HiroTV:setcolor:255,0,255
changes the floating text to magenta
HiroTV:setcolor:-1
turns off the floating text. You can turn it on again by simply doing the setcolor command with what color you want.

HiroTV:settimer
--------
Changes how many seconds between change of picture
Example -
HiroTV:settimer:10
changes the time between display to 10 seconds

-----------------------

3. Frequently Asked Questions

Q: It won't let me add pictures!
A: Make sure you are: (a) adding them to the Content folder of the TV (b) Not trying to add the pictures while the picture changes.

Q: How do I make the pictures stop changing!
A: HiroTV:settimer:0

Q: I added pictures but why won't they display?
A: HiroTV:reset

Q: Can I modify HiroTV?
A: Yes, it's open source freeware. Please do not delete any comments from the code if you modify. Thanks!

Q: Can I resell HiroTV or modified HiroTV?
A: No, please keep this freeware.

Q: Does the creator offer help with this product?
A: No. Play at your own risk.

Have fun!

CODE
key ownerkey;

string tvname = "HiroTV";

integer numberitems = 0;
integer selected = 1;

integer storelisten = 0;

float r=1.0;
float g=1.0;
float b=1.0;

integer switchtime = 15;

updatetext()
{
if(r==-1)
llSetText("",<0,0,0>,100);
else
llSetText(llGetInventoryName(INVENTORY_TEXTURE,( selected - 1))+
"\nPicture "+(string)selected+" of "+(string)numberitems, <r,g,b>, 1.5);

llSetTexture(llGetInventoryName(INVENTORY_TEXTURE,(selected - 1)),ALL_SIDES);
}


Init()
{
ownerkey = llGetOwner();
llInstantMessage(ownerkey,"HiroTV script reset!");
numberitems = llGetInventoryNumber(INVENTORY_TEXTURE);
updatetext();

llListenRemove(storelisten);
storelisten = llListen(0,"",ownerkey,"");

}

switchpic()
{
selected++;
if (selected > numberitems)
selected = selected - numberitems;
updatetext();

}


default
{
state_entry()
{
Init();
llSetTimerEvent(switchtime);
}

on_rez(integer param)
{
Init();
llSetTimerEvent(switchtime);

}

listen(integer channel, string name, key id, string msg)
{
list command = llParseString2List(msg,[":"],[]);
if(llList2String(command,0)==tvname)
// ALL COMMANDS MUST START WITH THE TVNAME
{
string whichcommand=llList2String(command,1);
if(whichcommand=="setname")
{
string newname=llList2String(command,2);
if(newname!="")
{
llSay(0,"HiroTV '"+tvname+"' has been renamed: '"+newname+"'.");
tvname=newname;

}
else
{
llSay(0,"Sorry, you must enter a name for your vendor. Please try again.");
}
}
else if(whichcommand == "setcolor")
{
list colors = llParseString2List(llList2String(command,2),[","],[]);
r = (float)(llList2String(colors,0));
if(r != -1)
{
r = r / 255;
}
g = ((float)(llList2String(colors,1))/255);
b = ((float)(llList2String(colors,2))/255);
updatetext();
}
else if(whichcommand == "settimer")
{
switchtime = (integer)llList2String(command,2);
llInstantMessage(ownerkey,"HiroTV will now switch every "+(string)switchtime+" seconds.");
llSetTimerEvent(switchtime);
}
else if(whichcommand == "reset")
{
llResetScript();
}
}
else
if(llList2String(command,0)=="GetHiroTVName")
{
llSay(0,"My name is: "+tvname);
}
} // end listen

touch( integer n)
{
// llSay(0,"changing");
switchpic();
}

timer()
{
switchpic();
}

}
_____________________
Hiro Pendragon
------------------
http://www.involve3d.com - Involve - Metaverse / Emerging Media Studio

Visit my SL blog: http://secondtense.blogspot.com
Sensual Casanova
Spoiled Brat
Join date: 28 Feb 2004
Posts: 4,807
11-05-2004 17:50
Original Thread
/15/0e/26151/1.html


Is this the same thing thats in those avalon phones?
Hiro Pendragon
bye bye f0rums!
Join date: 22 Jan 2004
Posts: 5,905
11-11-2004 11:57
Sorta kinda. But:
(a) You can use it in any prim, not just a tiny screen.
(b) It's freeware. Have fun.
_____________________
Hiro Pendragon
------------------
http://www.involve3d.com - Involve - Metaverse / Emerging Media Studio

Visit my SL blog: http://secondtense.blogspot.com
Prokofy Neva
Virtualtor
Join date: 28 Sep 2004
Posts: 3,698
Great!
11-25-2004 08:46
I loved this device and it worked fine after I fixed what seemed to be "syntax errors" -- the separation of the word 'selected' in one place and removal of the line at the end. If you follow the directions precisely it should work and it's a great thing for events because it makes a slideshow that you can leave running with 2 or 10 or more seconds between shots.
Buck Spinnaker
Entrepreneur
Join date: 26 Aug 2004
Posts: 57
Hiro TV
02-26-2005 16:28
Does this random pick or take pics next in line?
Aidoy Edelbrock
Registered User
Join date: 12 Feb 2005
Posts: 4
03-06-2005 11:26
didnt work fo rme and did excatly what the directions where :(
Aleksie Solvang
nani?
Join date: 21 Oct 2004
Posts: 113
04-07-2005 10:42
yay thanks Hiro - it worked perfectly :D
Zante Zapedzki
We need html on a prim!
Join date: 15 Feb 2007
Posts: 123
03-30-2007 05:30
How would one add buttons to this?

So as to cycle through the images I mean : )
Adorna Childs
Registered User
Join date: 10 Feb 2006
Posts: 22
04-17-2007 10:51
I don't understand scripting, but I really like this. Can anyone tell me if there is a way to stop the floating text, and not bust the script?

Thank you bunches
(hugs)
Adorna
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
04-17-2007 11:09
From: Adorna Childs
I don't understand scripting, but I really like this. Can anyone tell me if there is a way to stop the floating text, and not bust the script?

Thank you bunches
(hugs)
Adorna

You can use the command HiroTV:setcolor:-1
or you can change the script.

The floating text is control by the updatetxt function. You can just set it to display blank text by adding r= -1 at the beginning of the function.

CODE

updatetext()
{
r = -1; //always display blank text comment or delete this line to return to normal function
if(r==-1)
llSetText("",<0,0,0>,100);
else
llSetText(llGetInventoryName(INVENTORY_TEXTURE,( selected - 1))+
"\nPicture "+(string)selected+" of "+(string)numberitems, <r,g,b>, 1.5);

llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, (selected - 1)),ALL_SIDES);
}
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
04-17-2007 11:40
Listening on channel 0 incase the owner wants to reset the script seems a bit of a waste. Wouldn't it be better to reset on inventory change or touch by the owner (unless flicking through pics is needed, but then they change on their own anyway).

Here's some much smaller code that does the same thing without the hover text or the listener. If you want hovertext, it's a one line addition.
CODE
integer numberitems = 0;
integer selected = 0;
integer switchtime = 5;

switchpic(){
selected++;
if(selected>=numberitems)
selected=0;
llSetTexture( llGetInventoryName( INVENTORY_TEXTURE, selected), ALL_SIDES);
}

default{
on_rez(integer rez){
llResetScript();
}

changed(integer change){
if(change & CHANGED_INVENTORY)
numberitems=llGetInventoryNumber( INVENTORY_TEXTURE );
}

state_entry(){
numberitems=llGetInventoryNumber( INVENTORY_TEXTURE );
llSetTimerEvent(switchtime);
}

touch(integer touches){
switchpic();
}

timer(){
switchpic();
}
}
Adorna Childs
Registered User
Join date: 10 Feb 2006
Posts: 22
04-18-2007 22:46
Thank you ver much Destiny I will try that.

edit: Thank you it worked. I'm sorry for asking a dumb question. I looked closer at the instructions and found the command listed there as well.
JL Zinner
Inferno Ice Owner
Join date: 15 Nov 2006
Posts: 210
05-09-2007 16:25
Awesome thanks for the script...had it up and running in my house in 5 minutes :-)
Lolita Barbosa
Registered User
Join date: 27 Feb 2007
Posts: 6
06-15-2007 22:43
hey what about if i only want to the pictures display in the front of the object and don't in the sides and back and keeps the last textures right?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
06-16-2007 02:44
From: Lolita Barbosa
hey what about if i only want to the pictures display in the front of the object and don't in the sides and back and keeps the last textures right?


Change the llSetTexture line to use the side number you want rather than ALL_SIDES
_____________________
I'm back......
Finnivar Childs
Registered User
Join date: 27 Feb 2006
Posts: 22
Awesome! Exactly what I needed
06-20-2007 07:38
From: someone
Here's some much smaller code that does the same thing without the hover text or the listener.


Worked like a charm! Switched the ALLSIDES to 2, to show only on the side facing me, painted the rest of the prim black, and put it behind a picture frame prim I designed.