Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Notecard dispenser Script help for a newbie...

indigo Wolfe
Registered User
Join date: 30 Dec 2004
Posts: 21
02-10-2005 07:40
I'd like to build a notecard reader that will detect a notecard placed in the object and then send it out to those in proximity...without having to change the script to give it the correct notecard name....

Is this possible? If so...ummm...how?

Please explain slowly as I'm VERY new to this...

Thanks!
Tread Whiplash
Crazy Crafter
Join date: 25 Dec 2004
Posts: 291
llGiveInventory()...
02-10-2005 11:07
Inigo -

The function "llGiveInventory()" is at the heart of any object that you want to distribute items to Avatars. However, it requires you to use the name of the Inventory object you want to give out. This presents a particular problem in your case. :rolleyes:

But luckily, there is another handy function that you could use to get around this problem. You can get the name of any unknown Inventory object, by searching on inventory-item type. See the function "llGetInventoryName()" in the LSL Wiki:
http://secondlife.com/badgeo/wakka.php?wakka=llGetInventoryName

You can only use it to retrieve 1 Notecard Name at a time (and then use "llGiveInventory()" with that name); so if there may be more than one notecard, you'll probably want to use a "For" loop to get them all - or use an integer in your script to track how many notecards are in your object, or something similar (it all depends on how to want to use this object)...

Hope this info helps! Take care,

--Noel "HB" Wade
(Tread Whiplash)
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-10-2005 11:11
while I consider this sort of thing boarderline spam I'll help you out.

CODE

sen()
{
llSensor("", "", AGENT, 10, PI);
}

default
{
state_entry()
{
if (llGetInventoryNumber(INVENTORY_NOTECARD))
sen();
}
changed(integer change)
{
if (change == CHANGED_INVENTORY && llGetInventoryNumber(INVENTORY_NOTECARD))
sen();
}
sensor(integer num_detected)
{
string note;
integer counter;
while(llGetInventoryNumber(INVENTORY_NOTECARD))
{
note = llGetInventoryName(INVENTORY_NOTECARD, 0);
counter = num_detected;
while(counter--)
llGiveInventory(llDetectedKey(counter), note);
llRemoveInventory(note);
}
}
}
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
indigo Wolfe
Registered User
Join date: 30 Dec 2004
Posts: 21
02-10-2005 12:10
Tread - Thank you so much! You've been a great help :)


Ahhh Strife..thank you!

As for spam....it will not be used in that capacity at all. It will be used for a group activity where others will be putting their notecards in one at a time, to be distributed to the group assembled for the purpose of receiving the notecards....