Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Output notecard help

JamesAK Karas
Registered User
Join date: 23 May 2008
Posts: 2
10-30-2008 17:37
Hello,

I'm building an object with three report templates whose script opens a menu when a resident touches the object. Now my programming skills is rusty so bare with me. Given that Input/Output methods are either non-existent in LSL or overlooked by my fault, what command should I use to have the object send a notecard to the resident once he/she picks which template notecard to choose?

Here's my algorithm of how the script should run.

Alg TouchNote
input: user touches on object
output: user receives notecard
user <= scan
if user touches object
return notecard
else
Say "no notecard available"

I'd be glad to receive some professional tips on sending out notecards or lms from an object. Thank you.
Klug Kuhn
Registered User
Join date: 7 Sep 2007
Posts: 126
10-30-2008 18:47
Below is a short sample script that gives notecard and landmark to the person whose touches the object. And will check if the notecard and landmark is in the object's content by the instance that it is touched.

You only need to change the notecard and landmark names in the first 2 lines. I've just typed it out from a text editor and didn't have in-world compile, so please check with syntax error. But this would be the idea to go. :)


//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
string NC = "Giving Notecard"; // put the exact giving notecard name
string LM = "Giving Landmark"; // put the exact giving landmark name

//==========================================
integer check_if_in_content(string checking_item)
{
string checking_name = "";
integer i;
for (i = 0; i <= llGetInventoryNumber(INVENTORY_ALL) - 1; i++)
{
checking_name = llGetInventoryName(INVENTORY_ALL,i);
if (checking_name == checking_item)
return 1;
}
return 0;
}
//==========================================
default
{
state_entry()
{
}
touch_start(integer int)
{
key user = llDetectedKey(0);

if (check_if_in_content(NC) == 1) // check and give notecard
llGiveInventory(user,NC);
else
llSay(0," no notecard available.";);

if (check_if_in_content(LM) == 1) // check and give landmark
llGiveInventory(user,LM);
else
llSay(0," no landmark available.";);
}
}
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
JamesAK Karas
Registered User
Join date: 23 May 2008
Posts: 2
11-17-2008 16:40
Beats doing I/O with files lol. Your sample script seems to agree with my algorithm and very understandable. Thanks a million!