Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

||AllowInventoryDrop Question

Sarah Balderdash
Applesauce Unlimited
Join date: 13 Dec 2005
Posts: 28
01-17-2007 07:07
Hi,

I want to make a guestbook using ||AllowInventoryDrop so visitors to my home can leave me a notecard.

I am wondering if there is a way to add something like ||Instant Message or ||OwnerSay to the script so I am notified when someone has dropped a notecard in my guestbook?

example ~ Guestbook: John Doe has left you a note.

Thanks for your help,
Sarah B.

P.S. I am VERY new to scripting, so please take that into account when replying :o
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-17-2007 07:38
From: Sarah Balderdash
Hi,

I want to make a guestbook using ||AllowInventoryDrop so visitors to my home can leave me a notecard.

I am wondering if there is a way to add something like ||Instant Message or ||OwnerSay to the script so I am notified when someone has dropped a notecard in my guestbook?

example ~ Guestbook: John Doe has left you a note.

Thanks for your help,
Sarah B.

P.S. I am VERY new to scripting, so please take that into account when replying :o


I dont think you can readily get the name of the person who dropped the item only that an Item was dropped. You could ask that peopel put their name in the notecard or even name the notecard after themselves.

The only problem with IM'ing yourself is that if you get too many you will get capped although just getting one would make you go look.

Emailing off world is do able, you could even read the notecard and send it as part of the email, as long as it doesnt have any embedded objects in it.
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
01-17-2007 08:32
llGetInventory or some such thing may be helpfull, if one of the advanced scripters wana take a stab at it.
I do beleave (corrrect me if I am wrong) using the event "change" will produce an IM or email when an item is added.
From: someone

default
{
on_rez(integer x)
{
llResetScript();
}
state_entry()
{
llAlowInventoryDrop();
}
change
{
string he = llGetReginName();
string lo = llGetLoc();
llInstantMessage(llGetOwner(),"You got a note in " + he + " " + lo);
}
}

This is me scripting on the fly again, so I am sure there are errors =^-^=
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-17-2007 12:55
From: Shippou Oud
llGetInventory or some such thing may be helpfull, if one of the advanced scripters wana take a stab at it.
I do beleave (corrrect me if I am wrong) using the event "change" will produce an IM or email when an item is added.

This is me scripting on the fly again, so I am sure there are errors =^-^=


You are correct although the change event will be triggered by any change to the prim. You should always check to see if the change is one you need to cater for.

llAllowInventoryDrop should be set to TRUE.

Thought about it for a while and you can capture the giver if you use a two stage proicess. Make them touch the prim and only then allow inventory drop, and just for 10 or 15 seconds. This minimises the chance of someone else dropping stuff on your prim while they fumble in their inventory

CODE


integer Count = 0;

Reset()
{
llSetTimerEvent(0);
llAllowInventoryDrop(FALSE);
llSetText("Touch to activate\nThen drop Notecard into Inventory.\nThank You.",<1,1,1>,1);
}

default
{
state_entry()
{
Reset();
}

touch_start(integer total_number)
{
dropper = llKey2Name(llDetectedKey(0));
llSetText(dropper + "\nYou have 15 Seconds to drop your notecard",<1,0,0>,1);
llSetTimerEvent(15);
llAllowInventoryDrop(TRUE);
}

changed(integer change)
{
if ((change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY)) )
{
integer counter = llGetInventoryNumber(INVENTORY_NOTECARD);
if(Count != counter)
{
Count = counter - 1;
string notecardId = llGetInventoryName(INVENTORY_NOTECARD,Count);
if(notecardId != "")
{
llInstantMessage(llGetOwner(), dropper + " has left you a notecard called " + notecardId);
Reset();
}
}
}
}

timer()
{
Reset();
}
}


An Email could just as easily have been sent, although it has a 20 second penalty.
Sarah Balderdash
Applesauce Unlimited
Join date: 13 Dec 2005
Posts: 28
01-17-2007 15:48
Thanks for the help everyone.

Okay I just copied the script that Newgate posted into a "New Script" and when I clicked Save I received this -

(18,16): ERROR: Name not defined within scope.
Hamncheese Omlet
what's for breakfast?
Join date: 2 Apr 2006
Posts: 79
01-17-2007 16:54
air code has a habit of getting that error..

he missed
CODE
string dropper;


so the corrected code....

CODE

integer Count = 0;
string dropper;
Reset()
{
llSetTimerEvent(0);
llAllowInventoryDrop(FALSE);
llSetText("Touch to activate\nThen drop Notecard into Inventory.\nThank You.",<1,1,1>,1);
}
default
{
state_entry()
{
Reset();
}

touch_start(integer total_number)
{
dropper = llKey2Name(llDetectedKey(0));
llSetText(dropper + "\nYou have 15 Seconds to drop your notecard",<1,0,0>,1);
llSetTimerEvent(15);
llAllowInventoryDrop(TRUE);
}

changed(integer change)
{
if ((change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY)) )
{
integer counter = llGetInventoryNumber(INVENTORY_NOTECARD);
if(Count != counter)
{
Count = counter - 1;
string notecardId = llGetInventoryName(INVENTORY_NOTECARD,Count);
if(notecardId != "")
{
llInstantMessage(llGetOwner(), dropper + " has left you a notecard called " + notecardId);
Reset();
}
}
}
}

timer()
{
Reset();
}
}
Sarah Balderdash
Applesauce Unlimited
Join date: 13 Dec 2005
Posts: 28
01-17-2007 19:31
Okay the script works great in my guest book. But the floating text - "you have 15 seconds..." doesn't go away after the notecard is dropped, nor after 15 seconds have expired. Is there a line I can add to time out the floating text?
Sarah Balderdash
Applesauce Unlimited
Join date: 13 Dec 2005
Posts: 28
01-17-2007 20:32
Okay I did some experimenting and my Guest Book works great now. I avoided the problem with the Floating Text by changing that line from 11SetText to 11Whisper (I found the info about "Whisper" on the LSLWiki, btw). I am not a fan of having Floating Text in my house anyway, so 11Whisper is a good option for me. I also made the timer longer since I don't anticipate having multiple people trying to put things in my book at the same time. (Things are pretty quiet at my place) :)

Here is the final version of the Guest Book Script:

CODE

//integer Count = 0;
string dropper;
Reset()
{
llSetTimerEvent(0);
llAllowInventoryDrop(FALSE);
}
default
{
state_entry()
{
Reset();
}

touch_start(integer total_number)
{
dropper = llKey2Name(llDetectedKey(0));
llWhisper(0, dropper + " if you want to leave a message for Sarah please write it on a notecard, then drag the notecard from your inventory onto my pages. You have one minute to give me your notecard.");
llSetTimerEvent(60);
llAllowInventoryDrop(TRUE);
}

changed(integer change)
{
if ((change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY)) )
{
integer counter = llGetInventoryNumber(INVENTORY_NOTECARD);
if(Count != counter)
{
Count = counter - 1;
string notecardId = llGetInventoryName(INVENTORY_NOTECARD,Count);
if(notecardId != "")
{
llInstantMessage(llGetOwner(), dropper + " has left you a notecard called " + notecardId);
Reset();
}
}
}
}

timer()
{
Reset();
}
}


Thanks for your help everyone! Feel free to stop by The Enchanted Woods of Achemon and drop me a note ;)
Kitty Barnett
Registered User
Join date: 10 May 2006
Posts: 5,586
01-18-2007 01:55
From: Sarah Balderdash
CODE
Count = counter - 1;
string notecardId = llGetInventoryName(INVENTORY_NOTECARD,Count);
A prim's inventory is sorted alphabetically; assuming no other notecards are present dropping notecards named "B", "C" and "A" would return "B", "C", "C" respectively.

The only way to figure out which inventory item was added is to either keep a list of what was there before the drop; or to have a second prim where as soon as a note is dropped on the main one, you move it over to the second prim.
Scott Woollahra
Registered User
Join date: 21 Oct 2006
Posts: 2
01-31-2007 16:13
From: Hamncheese Omlet


CODE

changed(integer change)
{
if ((change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY)) )
{
integer counter = llGetInventoryNumber(INVENTORY_NOTECARD);
if(Count != counter)
{
Count = counter - 1;
string notecardId = llGetInventoryName(INVENTORY_NOTECARD,Count);
if(notecardId != "")
{
llInstantMessage(llGetOwner(), dropper + " has left you a notecard called " + notecardId);
Reset();
}
}
}
}



I was struggling with this same problem last night, making a dropbox that would report the item dropped and the person dropping it (you can do it with more than just notecards if you control-drag the item into the dropbox). Now, I'm new at scripting, so just jump in if I'm wrong...

The snippet of code above reports the last item in the inventory, not the last item dropped. Since inventories are stored in alphabetical order, there is no easy way that I can tell to retrieve the last item dropped. The only way I can figure to do this (and I haven't yet tried it) is a list comparison algorithm of order n^2:

1) As you drop items, you can build up a list of them using step 3) (which will be sorted first-last), or simply create a list of items by reading the inventory (in its alphabetical order) before the item is dropped; better to do the former and store the list between drops. Use llGetInventoryNumber to get the count of items, then llGetInventoryName to pick off each one to build the list.

2) After you drop a new item, you'd have to build up the inventory list again, in which the new item will be in alphabetical order.

3) You then need to compare the two lists till you find the item on the new list which is not on the old list. This should work because duplicate names are not allowed in prim inventories, and new items will always be unique (they'll automatically have a number appended if there's a name clash).

If someone has a better way to do this, I'd love to know!
Morwen Bunin
Everybody needs a hero!
Join date: 8 Dec 2005
Posts: 1,743
02-28-2007 01:39
From: Sarah Balderdash


Thanks for your help everyone! Feel free to stop by The Enchanted Woods of Achemon and drop me a note ;)


I started to use this script today and it works well. But there is one thing I would like more... a floating text above the object with the script saying something as "Please drop your notecard with comments here".

I am no scripter, so I have no idea how to handle this.

Thanks in advance.

Morwen.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-28-2007 02:15
From: Morwen Bunin
I started to use this script today and it works well. But there is one thing I would like more... a floating text above the object with the script saying something as "Please drop your notecard with comments here".

I am no scripter, so I have no idea how to handle this.

Thanks in advance.

Morwen.



In state_entry add

CODE

llSetText("Please drop your notecard with comments here",<1,1,1>,1);
Morwen Bunin
Everybody needs a hero!
Join date: 8 Dec 2005
Posts: 1,743
02-28-2007 02:45
From: Newgate Ludd
In state_entry add

CODE

llSetText("Please drop your notecard with comments here",<1,1,1>,1);


Thank you :)

Morwen.
Princess Ivory
SL is my First Life
Join date: 17 Jan 2007
Posts: 720
STill getting error message on mail box/ guest book script
06-23-2008 09:16
I am trying to use Sarah's final version of her Guest Book Script. However, I am getting an error of name not defined in scope, just like an earlier post described. She fixed the string dropper command at the beginning and apparently it worked for her. But I am getting it showing up later in my script. The quote below shows her script; I have followed it with a post of my slightly modified script. Can someone take a look, and tell me what I need to fix? Basically I just want a mailbox that will accept notecards from people, and email me when they are submitted.

Thanks,
Princess Ivory

From: Sarah Balderdash
Okay I did some experimenting and my Guest Book works great now. I avoided the problem with the Floating Text by changing that line from 11SetText to 11Whisper (I found the info about "Whisper" on the LSLWiki, btw). I am not a fan of having Floating Text in my house anyway, so 11Whisper is a good option for me. I also made the timer longer since I don't anticipate having multiple people trying to put things in my book at the same time. (Things are pretty quiet at my place) :)

Here is the final version of the Guest Book Script:

CODE

//integer Count = 0;
string dropper;
Reset()
{
llSetTimerEvent(0);
llAllowInventoryDrop(FALSE);
}
default
{
state_entry()
{
Reset();
}

touch_start(integer total_number)
{
dropper = llKey2Name(llDetectedKey(0));
llWhisper(0, dropper + " if you want to leave a message for Sarah please write it on a notecard, then drag the notecard from your inventory onto my pages. You have one minute to give me your notecard.");
llSetTimerEvent(60);
llAllowInventoryDrop(TRUE);
}

changed(integer change)
{
if ((change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY)) )
{
integer counter = llGetInventoryNumber(INVENTORY_NOTECARD);
if(Count != counter)
{
Count = counter - 1;
string notecardId = llGetInventoryName(INVENTORY_NOTECARD,Count);
if(notecardId != "")
{
llInstantMessage(llGetOwner(), dropper + " has left you a notecard called " + notecardId);
Reset();
}
}
}
}

timer()
{
Reset();
}
}


Thanks for your help everyone! Feel free to stop by The Enchanted Woods of Achemon and drop me a note ;)


Here is my script:

//integer Count = 0;
string dropper;
Reset()
{
llSetTimerEvent(0);
llAllowInventoryDrop(FALSE);
}
default
{
state_entry()
{
llSetText("Please drop your notecard with tips for the AvaStar What's Hot Line here",<1,1,1>,1);
Reset();
}

touch_start(integer total_number)
{
dropper = llKey2Name(llDetectedKey(0));
llWhisper(0, dropper + " if you want to leave a tip for the AvaStar What's Hot Line please write it on a notecard, rename the notecard with your name, then drag the notecard from your inventory onto my pages. You have one minute to give me your notecard.";);
llSetTimerEvent(60);
llAllowInventoryDrop(TRUE);
}

changed(integer change)
{
if ((change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY)) )
{
integer counter = llGetInventoryNumber(INVENTORY_NOTECARD);
if(Count != counter)
{
Count = counter - 1;
string notecardId = llGetInventoryName(INVENTORY_NOTECARD,Count);
if(notecardId != "";)
{
llInstantMessage(llGetOwner(), dropper + " has left you a notecard called " + notecardId);
Reset();
}
}
}
}

timer()
{
Reset();
}
}
_____________________
Princess Ivory
Cory Fimicoloud
Registered User
Join date: 23 May 2007
Posts: 5
06-23-2008 10:40
Remove the two forward slashes in front of "integer Count = 0;".
Princess Ivory
SL is my First Life
Join date: 17 Jan 2007
Posts: 720
06-23-2008 11:00
From: Cory Fimicoloud
Remove the two forward slashes in front of "integer Count = 0;".


Duh. Can't believe I missed that. Thanks. It now saves without errors, but it doesn't work when I put it in the object. Not sure why - my scripting is a bit rusty at the moment.

Any ideas?
_____________________
Princess Ivory
Zerlinda Boucher
Registered User
Join date: 11 Oct 2008
Posts: 23
12-07-2008 00:57
there is any ways to implement the feature to read the notecard and send the content by email plus the IM?

could be very useful if u are offline :)

Zer