|
Lewis Nerd
Nerd by name and nature!
Join date: 9 Oct 2005
Posts: 3,431
|
03-15-2006 23:38
I'm trying to write a little script that, when someone "Touches" the item they are given a menu of options, and when they make their choice they are given the Landmark to the place of their choice, kinda like a teleport ticket machine. I've got the menu selection and everything working OK, the three landmarks inside the prim are all fine - but I can't seem to get it to give them out. The line I am using is: llGiveInventory(llDetectedKey(0), "Camp Fire" ;With "Camp Fire" of course being replaced by the name of the Landmark contained in the prim, depending on their choice. Now, it goes through all the motions, but it doesn't dispense a landmark or give any error messages. It seems like "llTeleportAgent" would be a cleaner way of doing it but I don't believe it's functional yet? Any advice gratefully received. Lewis
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-16-2006 00:09
llDetectedKey (and all the llDetected... functions) only works in touch, collision and sensor event. You're probably calling it in the listen event where the dialog menu's button name is received. llDetectedKey will give you NULL_KEY in that function. The solution is to save the key of ther 'toucher' in the touch_start handler to a global variable, then give the inventory to the key saved in that global variable. So... key toucher; // Global
...
default {
...
touch_start(integer num) { toucher = llDeteckedKey(0);
// Do menu stuff... }
listen(integer channel, ...) {
// Figure out what button he clicked on...
llGiveInventory(toucher, whatever); } }
|
|
FireEyes Fauna
Registered User
Join date: 26 Apr 2004
Posts: 138
|
03-16-2006 00:34
or just use the key from the listen event instead of detectedkey
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
03-16-2006 03:10
Yeah, that's easier, that's what I use. e.g. integer gLId = 0;
default { state_entry() { llSetText("Touch me for free stuff!", <1.0, 1.0, 1.0>, 1.0); }
touch_start(integer n) { if (gLId) { llListenRemove(gLId); gLId = 0; } integer channel = -llCeil(llFrand(2000000000)); key id = llDetectedKey(0); gLId = llDialog(id, "What do you want?", ["Item1", "Item2", "Item3"], channel); llListen(channel, "", id, ""); }
listen(integer channel, string name, key id, string msg) { llListenRemove(gLId); gLId = 0; llWhisper(0, "Here you go, " + name + "!"); llGiveInventory(id, msg); } }
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-16-2006 07:46
Good idea.
|
|
Lewis Nerd
Nerd by name and nature!
Join date: 9 Oct 2005
Posts: 3,431
|
03-16-2006 12:30
Great, thanks everyone, it works - although it stumped me for a while as I didn't notice llDetektedkey!
Lewis
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
03-16-2006 12:53
|