Give Inventory if script? - SLUniverse Forums
 
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » Give Inventory if script?


Scripting Discuss scripting for SL and other platforms

Reply
 
LinkBack Thread Tools Display Modes
Old 10-11-2009, 01:32 AM   #1 (permalink)
Abundantia Owner
 
Yessika's Avatar
 
Join Date: Sep 2009
Location: SL
Posts: 13
My Mood:
Give Inventory if script?

I'm still pretty new to scripting, but I'm trying to learn. Currently I'm trying for a script which would give inventory of a box only to people holding a "coupon." (An avatar equips the coupon using "wear" and then clicks on my box. My box then gives the inventory item, like a shirt or something.)

I have a give inventory script, and a script to give objects only to group, but I haven't been able to figure this one out. Anyone?

TouchStart
if Special Coupon then GiveInventory
else no Special Coupon then Say "You need the Coupon!"
Code:
default
{
    touch_start(integer n)
    {
       if (Special Coupon detected)
       llGiveInventory(item list);
       else if (no Special Coupon detected)
       Say "You need the coupon!"
    }
}
Ok, that isn't even real script... but hopefully you see where I'm going with this. Anyone???

As a side note, I'm not the one making the coupon-- it's part of my store ad in the Second Times Sunday paper. I'm not 100% certain how that might effect any UUID's. Any other thoughts or suggestions are also welcome. Thanks much!!

My other thought is, instead of someone needing to wear/equip the coupon--- perhaps the box could listen for them to say a phrase in chat which would trigger the "give inventory"? That might be easier. I don't know. Like I said, I'm open to suggestions.
__________________
Yessika is offline   Reply With Quote
Old 10-11-2009, 09:21 AM   #2 (permalink)
Junior Member
 
Rebekka's Avatar
 
Join Date: May 2009
Location: Germany
Posts: 16
SL Join Date: 3-5-2008
I'm writing something similar and use two scripts for box and coupon. A small example is below.
Code:
// script for giver box
integer CHANNEL = 12345;
key User;

default
{
    state_entry()
    {
        llListen(CHANNEL, "", NULL_KEY, "ok");
    }
    touch_start(integer total_number)
    {
        User = llDetectedKey(0);
        llWhisper(CHANNEL, (string)User);
        llSetTimerEvent(3);
    }
    listen(integer channel, string name, key id, string message)
    {
        if(message == "ok")
        {
            llSetTimerEvent(0);
            llGiveInventory(User, "object");
        }
    }
    timer()
    {
        llSay(0, "Sorry but you need the coupon.");
        llSetTimerEvent(0);
    }
}
Code:
// script for coupon
integer CHANNEL = 12345;
key User;

default
{
    state_entry()
    {
        llListen(CHANNEL, "", NULL_KEY, "");;
    }
    listen(integer channel, string name, key id, string message)
    {
        User = (key)message;
        if(User == llGetOwner()) llWhisper(CHANNEL, "ok");
    }
}
Hope that helps a bit.
Rebekka is offline   Reply With Quote
Old 10-13-2009, 08:23 AM   #3 (permalink)
Member
 
Innula Zenovka's Avatar
Rather more than just a pretty face
 
Join Date: May 2009
Posts: 34
My Mood:
SL Join Date: 17 June 2007
We had a long chat about this over the road in the Scripting Tips forum earlier in the year. The specific application there was a key card -- you could only open the door if you were wearing one -- but the principle is the same.

Might be useful to take a look at it.
Innula Zenovka is offline   Reply With Quote
Old 10-15-2009, 12:09 AM   #4 (permalink)
Abundantia Owner
 
Yessika's Avatar
 
Join Date: Sep 2009
Location: SL
Posts: 13
My Mood:
Yeah, but I'm still really just looking for something that gives inventory if someone says the "secret password" or whatever. Because the coupon is not something which is made by me, not something I can put a script into, and not something which I will even have the UUID for.
Yessika is offline   Reply With Quote
Old 10-15-2009, 02:43 PM   #5 (permalink)
Scripter / Builder
 
Join Date: Oct 2009
Posts: 4
My Mood:
Post Give based on secret message

Hey. You can try this...its basic and probably needs to be built out. If you need help let me know.

Code:
 
default
{
   state_entry()
   {
      llListen(0,"","","");
   }
   listen(integer channel, string name, key id, string message)
   {
      if(message == "Secret Password")
         llGiveInventory(id,"NameOfItemToGive");
   }
}
Steven Broderick is offline   Reply With Quote
Old 10-15-2009, 05:42 PM   #6 (permalink)
Abundantia Owner
 
Yessika's Avatar
 
Join Date: Sep 2009
Location: SL
Posts: 13
My Mood:
That script looks great- and much like one of the four that I tried in my failure process. This might be largely due to the fact that I don't know enough about the Listen command.

I assume I would change the 0 to the channel number I want. But what else do I need to change, alter, or insert in order for the box (or whatever) to give the inventory to anyone with the "secret password" ?
Yessika is offline   Reply With Quote
Old 10-15-2009, 08:28 PM   #7 (permalink)
Animates and Scripts
 
jeaniesing's Avatar
 
Join Date: Oct 2009
Location: rural northeast US
Posts: 34
My Mood:
SL Join Date: Sept 2006
llGiveInventory(id,"NameOfItemToGive");

this line says that the id (read key) of the person who says the right word will get the stuff.... so its pretty straightforward... if you say the word on the right channel, you get the goodies


this part
listen(integer channel, string name, key id, string message)

is the one tells the script who said what
__________________
jeaniesing is offline   Reply With Quote
Old 10-15-2009, 08:40 PM   #8 (permalink)
she, not he!

SLU Supporter
 
Jesse Barnett's Avatar
addicted to catnip
 
Join Date: Apr 2009
Location: South of DC
Posts: 530
My Mood:
SL Join Date: 5/21/2006
Code:
integer chn = 1234; //Enter your listen channel here
string password = "test"; //enter your password here in quotes
string prize = "gift"; //enter the name in quotes of the item in the object contents that you wish to give

 default{
     state_entry(){
        llListen(chn, "", "", password);
    }
     listen(integer channel, string name, key id, string msg) {
         //you are only listening for the password so you do not need to test for it
         llGiveInventory(id, prize);
     }
}
__________________
Coffee smells like freshly ground heaven. ~Jessi Lane Adams
Jesse Barnett is offline   Reply With Quote
1 User Said Yay!:
1 User Said Thanks:
1 User Agreed:
Old 10-15-2009, 08:48 PM   #9 (permalink)
she, not he!

SLU Supporter
 
Jesse Barnett's Avatar
addicted to catnip
 
Join Date: Apr 2009
Location: South of DC
Posts: 530
My Mood:
SL Join Date: 5/21/2006
and here is some homework to help you understand:

LSL Wiki : llListen

LSL Wiki : listen

LSL Wiki : llGiveInventory
Jesse Barnett is offline   Reply With Quote
Old 10-15-2009, 10:40 PM   #10 (permalink)
Abundantia Owner
 
Yessika's Avatar
 
Join Date: Sep 2009
Location: SL
Posts: 13
My Mood:
It works Jesse!!! You are so awesomeeeeeeeeeeeeee!!! Thank you so much!
Yessika is offline   Reply With Quote
1 User Said Yay!:
Reply

Tags
coupon, give, inventory, llgiveinventory, script

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On