Wednesday, January 8, 2014

Creator resource - When your object is a trash can, and you don't know

This tutorial is available at Creator resource - When your object is a trash can, and you don't know.



I was sorting inventory a couple of days ago, and rezzed one of the items to see what it contained (oldies from when I was a newbie, that were still hiding). The box had hover text and, as usual, the hover text script was left inside the object (You can safely delete that script! Read here for all the information. Help reducing SL's lag provoked by scripts :-))

The script had the following code:

default
{
    state_entry()
    {
        llAllowInventoryDrop(TRUE);
        llSetText("FREE eyes!!!", <1,1,1>, 1.5);
    }
}

On a picky note, it's worth noting that llSetText will ignore any value greater than one that we pass to the function as a last parameter. In less cryptic words, that means the last 1.5 isn't correct. It should be a number between 0 and 1, although typing a number outside from the range will not make the script to scream.

Anyway, the relevant is the line above llSetText: llAllowInventoryDrop(TRUE);

We don't need that line to have our prim showing floating text. But if we keep the script inside our prim, we are allowing something else: that residents have the ability of dropping assets inside the prim! Which, in practical terms, means that we've made a public trash can of sorts of our prim :-) (Here for all the technical notes on the llAllowInventoryDrop function.)

A script like that would allow you to offer a very simple mailbox (and I believe that's the origin of the "floating text" script I found), but if you only want to show floating text, as it was the case, you really don't need the other line :-) (Even more, as noted at the beginning... You don't even need the script in the prim, once the floating text shows as you want!)

So, what to do?

Easy solution: Simply, delete the script from the prim. You will see that the floating text remains, and your prim is no longer a trash can of sorts.

If you feel insecure that you may have activated any strange property that will make the prim to continue being said trash can, then copy the following text and paste it in a new script in SL, save it, and drop the script in the prim:

default
{
    state_entry()
    {
        llAllowInventoryDrop(FALSE);
        llRemoveInventory(llGetScriptName());
    }
}

You will see the script self deleting: I've included that line so you don't accidentally forget the script inside the prim. Once the script has done its job, you no longer need it inside the prim. In those cases, I make my scripts to self delete :-)

And that's it! Check the prims you have out with floating text, delete the hover text script from them, and if it makes you feel more sure, then drop the deactivate propertie + self delete script. Before deleting the hover text script, make sure it's a very simple script as the one I've shown! Do not delete more complex scripts, they may be doing other tasks you need :-)

Have a great day!

No comments:

Post a Comment