Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Texture Viewer to give current texture

Lucah Blanco
Registered User
Join date: 30 Dec 2007
Posts: 7
01-13-2010 10:02
I have a free, full perm texture viewer that consists of a central prim and 8 surrounding. The user drops their textures into the viewer and they are displayed on the face of the outer prims. When an outer texture is clicked, that texture is displayed in a larger version on the center prim. When that center prim is clicked, the texture is given.

Could someone please help me with the code that would enable an object of the same name as the texture to be given when the central prim is touched a second time?

eg Avatar click on small (outer) display of Texture 1, Texture 1 shows in the center frame, Avatar clicks on center frame, center frame dispenses Object 1.

I would be really grateful!

Here is the script in its current form:

string direction = "forward";
list textures;
integer begin = 0;
integer start;
integer max = 0;
key current = "NULL";


settextures()
{
integer start = begin;
integer i = 1;
for(i;i < 13; i++)
{

if(begin < max )

{

llMessageLinked(LINK_SET,1,(string)i,llGetInventoryKey(llGetInventoryName(INVENTORY_TEXTURE,begin)));

begin++;
}

else
{
begin = 0;
llMessageLinked(LINK_SET,1,(string)i,llGetInventoryKey(llGetInventoryName(INVENTORY_TEXTURE,begin)));

begin++;
}

}
llSetText("Textures " + (string)(start) + " to " +(string)(begin - 1) + "\n \n \n \n \n \n",<1,1,1>,1);
}
settexturesback()
{ integer start = begin;
integer i = 0;
for(i;i < 13; i++)
{

if(begin > 0)

{
llMessageLinked(LINK_SET,1,(string)i,llGetInventoryKey(llGetInventoryName(INVENTORY_TEXTURE,begin)));
begin--;
}
else
{
begin = max;
llMessageLinked(LINK_SET,1,(string)i,llGetInventoryKey(llGetInventoryName(INVENTORY_TEXTURE,begin)));
begin--;

}
}

llSetText("Textures " + (string)(begin) + " to " +(string)(start) + "\n \n \n \n \n \n",<1,1,1>,1);
}

default
{
state_entry()
{
max = llGetInventoryNumber(INVENTORY_TEXTURE);
llOwnerSay("There are " + (string)max + " textures loaded.";);
llSetTexture("83a9eed2-51c0-0023-d77c-c5dd08d899d1",ALL_SIDES);
settextures();
}
on_rez(integer param)
{
llResetScript();
}

touch_start(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
if(current != "NULL";)
{
if(llGetInventoryKey(llGetTexture(1)) != NULL_KEY)
{
llInstantMessage(llGetOwner(),llGetTexture(1));
llGiveInventory(llDetectedKey(0),llGetTexture(1));
}
else
{
llSay(0,"Texture not found in inventory";);
}

}
}

}


link_message(integer sender,integer num, string mess,key id)
{
if(mess == "next";)
{
direction = "forward";
settextures();


}
if(mess == "prev";)
{
direction = "reverse";

settexturesback();

}
if(mess == "chosen";)
{
llSetTexture(id,ALL_SIDES);
current = id;
}
}


changed(integer change)
{
if(change && CHANGED_INVENTORY)
{
max = llGetInventoryNumber(INVENTORY_TEXTURE);
llOwnerSay("There are " + (string)max + " textures loaded.";);
settextures();
}
}

}
Laurie Stilman
Registered User
Join date: 11 Apr 2006
Posts: 45
01-13-2010 12:28
From: Lucah Blanco
I have a free, full perm texture viewer that consists of a central prim and 8 surrounding. The user drops their textures into the viewer and they are displayed on the face of the outer prims. When an outer texture is clicked, that texture is displayed in a larger version on the center prim. Could someone please give me the code that will enable that particular texture to be given when the central prim is touched a second time? I would be most grateful.


Umm, it looks like it already should; there's an llGiveInventory() call in the touch event. It should IM you the texture details and hand you the texture when you touch it. Does it do either? neither? Is the texture viewer working otherwise?
Lucah Blanco
Registered User
Join date: 30 Dec 2007
Posts: 7
01-13-2010 12:35
I'm sorry. I'm a complete dolt. What I actually want is an Object of the same name as the texture displayed in the center given, eg Avatar click on small display of Texture 1, Texture 1 shows in the center frame, Avatar clicks on center frame, center frame dispenses Object 1.


(example added to the initial post)
Laurie Stilman
Registered User
Join date: 11 Apr 2006
Posts: 45
01-13-2010 12:44
Assuming you have some sort of naming convention to derive the name of the object from the name of the texture, you just need to change the llGiveInventory() call to use that name instead of llGetTexture(1). For example:

CODE

string texture_name = llGetTexture(1);
string object_name = texture_name + "_object";
llGiveInventory(llDetectedKey(0), object_name);


Change the assignment of object_name to do whatever mapping you need between texture name and object name (they can't be named the same AFAIK, since if you drop two items with the same name into the same object, the second will get its name changed to keep it unique).
Lucah Blanco
Registered User
Join date: 30 Dec 2007
Posts: 7
01-13-2010 12:59
I'm actually going to individually name the textures and objects so that they correspond. Could you please tell me which code to enter where? I'm really grateful for your help this far.
Raster Teazle
Registered User
Join date: 13 Sep 2005
Posts: 114
01-13-2010 19:33
Assuming texture name is AAAA
and object name is AAAA_obj

Both items need to be in content of object.


CODE

if(llGetInventoryKey(llGetTexture(1)) != NULL_KEY)
{
llInstantMessage(llGetOwner(),llGetTexture(1));
llGiveInventory(llDetectedKey(0),llGetTexture(1));
llGiveInventory(llDetectedKey(0), llGetTexture(1) + "_obj"); // add "_obj" to texture name
}
else
{
llSay(0,"Texture not found in inventory");
}
Lucah Blanco
Registered User
Join date: 30 Dec 2007
Posts: 7
01-13-2010 23:44
From: Raster Teazle
Assuming texture name is AAAA
and object name is AAAA_obj

Both items need to be in content of object.


CODE

if(llGetInventoryKey(llGetTexture(1)) != NULL_KEY)
{
llInstantMessage(llGetOwner(),llGetTexture(1));
llGiveInventory(llDetectedKey(0),llGetTexture(1));
llGiveInventory(llDetectedKey(0), llGetTexture(1) + "_obj"); // add "_obj" to texture name
}
else
{
llSay(0,"Texture not found in inventory");
}



This is working fantastically. Thanks a lot! Now I have a second question for the same script...

Please ignore the added object and just consider the viewer contains textures only. What would I need to add or change so that when the center prim is clicked and the featured texture is given, the viewer deletes that texture completely from its contents. The textures are full perm.
Laurie Stilman
Registered User
Join date: 11 Apr 2006
Posts: 45
01-14-2010 00:17
After the "llGiveInventory(llDetectedKey(0), ...);" line, add "llRemoveInventory(x);", where 'x' is whatever you you have for '...'. Make sure the remove happens after the give! :-)
Lucah Blanco
Registered User
Join date: 30 Dec 2007
Posts: 7
01-14-2010 02:32
From: Laurie Stilman
After the "llGiveInventory(llDetectedKey(0), ...);" line, add "llRemoveInventory(x);", where 'x' is whatever you you have for '...'. Make sure the remove happens after the give! :-)


I edited the script as I think you meant:

From: someone
if(current != "NULL";)
{
if(llGetInventoryKey(llGetTexture(1)) != NULL_KEY)
{
llInstantMessage(llGetOwner(),llGetTexture(1));
llGiveInventory(llDetectedKey(0),llGetTexture(1));
llRemoveInventory(llDetectedKey(0),llGetTexture(1));
}
else
{
llSay(0,"Texture not found in inventory";);


but I get a syntax error between the two brackets behind 1.
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
01-14-2010 02:38
From: someone
llRemoveInventory(llDetectedKey(0),llGetTexture(1) );
llRemoveInventory takes only one parameter - the name of the inventory item. The llDetectedKey (0) shouldn't be there.
Lucah Blanco
Registered User
Join date: 30 Dec 2007
Posts: 7
01-14-2010 03:27
My script is now:

From: someone
if(llGetInventoryKey(llGetTexture(1)) != NULL_KEY)
{
llInstantMessage(llGetOwner(),llGetTexture(1));
llGiveInventory(llDetectedKey(0),llGetTexture(1));
llRemoveInventory,llGetTexture(1) );
}


but I'm getting a syntax error right before the comma after llRemoveInventory.
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
01-14-2010 04:03
That's because the compiler expects an opening bracket after a function name. Try

llRemoveInventory(llGetTexture (1) );
Lucah Blanco
Registered User
Join date: 30 Dec 2007
Posts: 7
01-14-2010 08:19
Fantastic!! Thank you so much!