Rivengate Posted April 6 Share Posted April 6 (edited) I've been racking my brain for HOURS! ______________________________________________________________________________________________________________________ // Define a constant for the dialog channel integer DIALOG_CHANNEL = -1; string objectName; default { touch_start(integer total_number) { // Get the key of the user who touched the prim key id = llDetectedKey(0); // Get the number of items in the prim's inventory integer numItems = llGetInventoryNumber(INVENTORY_ALL); // Create a list to hold the names of the items list items; // Loop through the inventory and add each item's name to the list integer i; for (i = 0; i < numItems; i++) { string name = llGetInventoryName(INVENTORY_ALL, i); if (name != llGetScriptName()) // Exclude the script itself { items += name; } } // Show a dialog to the user with the item names as buttons llDialog(id, "Please select an item:", items, DIALOG_CHANNEL); } listen(integer channel, string name, key id, string message) { // Check if the message is from our dialog if (channel == DIALOG_CHANNEL) { // The user selected an item, give it to them objectName = message; llGiveInventory(id, objectName); } } } _______________________________________________________________________________________________________________________ It compiles but then just WON'T send the inventory for some reason... What am I doing wrong? Edited April 6 by Rivengate Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 6 Share Posted April 6 You have made the variable id local to the touch_start event. As soon as execution leaves that event, its value is lost. Instead, you have to make it a global variable. Put the definition at the top of your script, before the default line. Now, that is still likely to lead to confusing results, because the variable id used in the listen event you have created is not the same as the one that's carrying your toucher's UUID. You have created a second id in the header for that event. Never use the same variable name twice in a script unless you are very careful. The cure here is to call your global variable something entirely different, like key Toucher_Id; Then the touch_start event should be changed to use that variable: // Get the key of the user who touched the prim Toucher_Id = llDetectedKey(0); and llGiveInventory line in your listen event should be rewritten as // The user selected an item, give it to them llGiveInventory(Toucher_Id, message); That's not all. You have defined integer DIALOG_CHANNEL = -1; properly as a global variable, so you are set to communicate on a channel using DIALOG_CHANNEL. Unfortunately, you never opened a channel. You need to do that -- most likely in a state_entry event -- like so: state_entry () { llListen ( DIALOG_CHANNEL,"","",""); } That will open the channel. With any luck, the script should now work. Link to comment Share on other sites More sharing options...
Rivengate Posted April 6 Author Share Posted April 6 Thank you SO Much! ❤️ That worked! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now