Now that I'm a mighty wizard I am in a position to be able to demonstrate a couple of simple scripts for you to try.
There's nothing complicated about these scripts and they are very basic. They are both in the same vein, a landmark giver and a notecard giver. There are I'm sure more efficient and superior ways of doing this, but I'm just giving you some examples of simple scripts.
The notecard giver will give an avatar a notecard when touched. The first thing to do is to create an object, then go to the content tab and click new script. This creates a new script which defaults to the hello avatar script. Delete everything and then copy and paste the following code into the script.
default
{
touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0));
}
}
Click save and hopefully you get the completed message rather than a syntax error. Now place a notecard into the contents tab and voila, you're good to go. Right click your item, click touch and you should be offered the notecard.
The landmark giver is pretty much identical but you change INVENTORY_NOTECARD to INVENTORY_LANDMARK
So we have:
default
{
touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_LANDMARK, 0));
}
}
Points to note, the code in brackets that says INVENTORY_LANDMARK, 0 tells the object to give you the first landmark (or notecard if you're using the notecard script) in the object. That's what the 0 indicates. If for some reason you wanted two notecards or landmarks in the object and you wanted the object to hand out the second one instead of the first, you'd change the 0 to a 1.
If you want hovertext above the object, such as "Touch for a notecard" then you add some extra code to the script. A point to note about setting text, it doesn't go away! Once the text is set it stays, even if you take the set text code out of the script and save it again.
So to add hovertext we add this code:
state_entry()
{
llSetText("Touch for a notecard.", <0,0,0>, 1.0);
}
This sets the code to black text with no transparency, that's what the numbers mean <0,0,0> is black and 1.0 means no transparency. You can play about with the numbers for different results if you want. So putting it all together our code would now look like this:
default
{
state_entry()
{
llSetText("Touch for Information.", <0,0,0>, 1.0);
}
touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0));
}
}
Now I said earlier that once text is set it sticks, however you can remove it, you just need to change the code to do so, you'd change the set text line to this:
llSetText("", <0,0,0>, 0);
Voila! No text! Simple huh? Of course you're going to want to add textures to your object as a plain brown box doesn't tell people very much!
- Ciaran Laval's blog
- Add new comment
- 2074 reads

Recent comments
1 hour 6 min ago
3 hours 8 min ago
3 hours 34 min ago
4 hours 47 min ago
5 hours 8 min ago
6 hours 34 min ago
6 hours 35 min ago
6 hours 56 min ago
11 hours 19 min ago
16 hours 35 min ago