Friday, July 13, 2012

Sending Notecards in Second Life

Creating a simple object. 

Notecards are essentially Second Life's version of text files. This post will detail how to create an object that gives out a notecard when it is touched.

The Notecard Giver

The notecard giver needs to exist in the Second Life world. For this purpose, a simple triangular object was created using the GUI.

Creating the Notecard

A test notecard was created with a title and a message. To store it in the inventory of the object, simply drag it from your inventory window to the inventory window of the object.

Scripting it to work with touch

I wanted the object to send the notecard when it was touched. This involved overriding the touch_start method.

touch_start(integer total_number)
    llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_NOTECARD,0));
    llSay(0, "I sent you a notecard");

The llGiveInventory() method is naturally the key here. Here is a list of the arguments it was given.

  • KEY: llDetectedKey(0) will return the key (a Second Life identifier).
  • STRING: llGetInventoryName() will return the title of the selected item in the object's inventory.
    • INVENTORY_NOTECARD describes the type of the item, while the zero will return the first item of that type.


All that was left for my avatar to do, was to simply touch the object, to initiate the touch_start method.

The object is sending the notecard when it is touched.
Using llSay() to confirm that the card was sent.


Although the utility of notecards is questionable, should you need to implement it, this post might help.

No comments:

Post a Comment