| Scripting Discuss scripting for SL and other platforms |
| |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Abundantia Owner ![]() 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!" } } 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.
__________________ |
| | |
| | #2 (permalink) |
| Junior Member ![]() 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");
}
}
|
| | |
| | #3 (permalink) |
| Member ![]()
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. |
| | |
| | #4 (permalink) |
| Abundantia Owner ![]() 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. |
| | |
| | #5 (permalink) |
| Scripter / Builder ![]() Join Date: Oct 2009
Posts: 4
My Mood: | 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");
}
}
|
| | |
| | #6 (permalink) |
| Abundantia Owner ![]() 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" ? |
| | |
| | #7 (permalink) |
| Animates and Scripts ![]() Join Date: Oct 2009 Location: rural northeast US
Posts: 34
My Mood: SL Join Date: Sept 2006
Business: jeaniesing's things | 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 |
| | |
| | #8 (permalink) |
| she, not he! ![]() ![]() ![]() ![]() ![]() ![]() SLU Supporter ![]() ![]()
addicted to catnip
| 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 |
| | |
| 1 User Said Yay!: |
| 1 User Said Thanks: |
| 1 User Agreed: |
| | #9 (permalink) |
| she, not he! ![]() ![]() ![]() ![]() ![]() ![]() SLU Supporter ![]() ![]()
addicted to catnip
| and here is some homework to help you understand: LSL Wiki : llListen LSL Wiki : listen LSL Wiki : llGiveInventory |
| | |
![]() |
| Tags |
| coupon, give, inventory, llgiveinventory, script |
| Thread Tools | |
| Display Modes | |
| |