Hi all,
I'm new to scripting and I'm just trying to create more scripts for practice.
Right now I am trying to create a script that I can put into a prim, drop a texture, have certain sides change texture and then have the texture and script be deleted from the prim's inventory.
The problem I am having is when I call the delete_all_contents() (more specifically, when the texture is deleted) function the faces are reset to default due to the changed() function. I'm assuming because the script is still inside even though it is deleted. Any tips on how I can fix this?
Thank you!
delete_all_contents()
{
string thisScript = llGetScriptName();
string inventoryItemName;
integer index = llGetInventoryNumber(INVENTORY_ALL);
while (index)
{
--index; // (faster than index--;)
inventoryItemName = llGetInventoryName(INVENTORY_ALL, index);
llRemoveInventory(thisScript);
llRemoveInventory(inventoryItemName);
}
}
default
{
changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llOwnerSay("The inventory has changed.");
string name = llGetInventoryName(INVENTORY_TEXTURE, 0);
// transparent texture
string trans = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903";
// Sets all sides transparent, because I want the rim to be transparent
llSetTexture(trans, ALL_SIDES);
// Sets texture on front and back faces
llSetTexture(name, 3);
llSetTexture(name, 1);
}
}
touch(integer num_detected){
llOwnerSay("Deleting Scripts...");
delete_all_contents();
}
state_entry()
{
llOwnerSay("Milou's Simple Texture change Prim thingy");
}
}