Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Better mailbox than this?

Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
08-09-2009 22:27
It seems like there should be a better way for people to drop stuff in a prim and have the items sent to me. This returns a script error for a second every time it goes off. Anyone have any thoughts?

CODE


default
{
state_entry()
{
llSetText("Paul's Mailbox- Drop notecards only.", < 1.0, 0.0, 0.0>, 1.0);
llAllowInventoryDrop(TRUE);
llSetTimerEvent(600);
}
timer()
{
llGiveInventory(llGetOwner(),llGetInventoryName(INVENTORY_NOTECARD,0));
llRemoveInventory(llGetInventoryName(INVENTORY_NOTECARD,0));
}
}

_____________________
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-09-2009 23:02
You may want to test whether there ARE any notecards in inventory before you give or remove them. Try:

CODE

if (llGetInventoryNumber(INVENTORY_NOTECARD) > 0) {...}


or:

CODE

while (llGetInventoryNumber(INVENTORY_NOTECARD) > 0) {...}
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
08-10-2009 02:38
How would I work that in? Every time I try to put it in under the timer, I get a syntax error.

When I replace the timer call with the "if", I also get a syntax error.
_____________________
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-10-2009 09:43
CODE

default
{
state_entry()
{
llSetText("Paul's Mailbox- Drop notecards only.", < 1.0, 0.0, 0.0>, 1.0);
llAllowInventoryDrop(TRUE);
llSetTimerEvent(600);
}
timer()
{
while (llGetInventoryNumber(INVENTORY_NOTECARD) > 0)
{
llGiveInventory(llGetOwner(),llGetInventoryName(INVENTORY_NOTECARD,0));
llRemoveInventory(llGetInventoryName(INVENTORY_NOTECARD,0));
}
}
}
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
08-10-2009 09:54
You can use the changed event to tell when the inventory changes...

CODE

changed (integer mask)
{
if (mask & CHANGED_INVENTORY)
{
// stuff
}
}

Probably have to b e a little careful with that - it will fire when somebody drops stuff in but may also fire when the script deletes things, too.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-10-2009 10:42
Combination of the two great minds above:

CODE

default {
state_entry() {
llSetText("Paul's Mailbox- Drop notecards only.", < 1.0, 0.0, 0.0 >, 1.0);
llAllowInventoryDrop(TRUE);
}
changed(integer change) {
if (change & (CHANGED_INVENTORY | CHANGED_ALLOWED_DROP)) {
while (llGetInventoryNumber(INVENTORY_NOTECARD) > 0) {
llGiveInventory(llGetOwner(), llGetInventoryName(INVENTORY_NOTECARD, 0));
llRemoveInventory(llGetInventoryName(INVENTORY_NOTECARD, 0));
}
}
}
}

EDIT: Thanks Hewee!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-10-2009 10:51
You may also want CHANGED_ALLOWED_DROP instead of (or in addition to, to be really thorough) CHANGED_INVENTORY.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
08-10-2009 10:58
From: Hewee Zetkin
You may also want CHANGED_ALLOWED_DROP instead of (or in addition to, to be really thorough) CHANGED_INVENTORY.

Ya know, I always thought that bit got fired when somebody enabled or disabled dropping stuff via llAllowInventoryDrop. What it actually does makes a lot more sense...

From: Wiki
A user other then the owner (or the owner if the object is no-mod) has added inventory to the prim. This is only possible if enabled with llAllowInventoryDrop.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
08-10-2009 15:20
Oh, this is great. I like it. Thanks, everybody.
_____________________