Laufiair Hexicola Posted December 24, 2017 Share Posted December 24, 2017 Evening everyone, putting a script together that'll go into a physical magazine rack(it's 1li so nothing's movable). When a visitor comes along, they buy from the rack and are presented with a menu where they can choose what they want.. only my secondary buttons don't seem to be doing anything when called from the mainmenu. I admit this is a mishmash of scripting and can generally follow along to get done what I'm looking to do, but this one confuses me so if there's anyone out there willing to help, would be appreciated. -Logan Quote integer price = 20; string mainMenuDialog = "Thank you for your purchase, please make a selection."; list mainMenuButtons = ["Magazines", "Close"]; string subMenu_01_Dialog = "MAGAZINES\nNot Implemented yet."; list subMenu_01_Buttons = ["Close"]; //-------------------------------------------------------------// integer dialogChannel; integer dialogHandle; open_menu(key inputKey, string inputString, list inputList) { dialogChannel = (integer)llFrand(DEBUG_CHANNEL)*-1; dialogHandle = llListen(dialogChannel, "", inputKey, ""); llDialog(inputKey, inputString, inputList, dialogChannel); llSetTimerEvent(30.0); } close_menu() { llSetTimerEvent(0); llListenRemove(dialogHandle); } default { state_entry() { llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]); llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); } run_time_permissions(integer perm) { if(perm & PERMISSION_DEBIT) state cash; } on_rez(integer start_param) { llResetScript(); } touch_start(integer numDetected) { key id = llDetectedKey(0); close_menu(); open_menu(id, mainMenuDialog, mainMenuButtons); } listen(integer channel, string name, key id, string message) { if(channel != dialogChannel) return; close_menu(); if(message == "Ok")open_menu(id, mainMenuDialog, mainMenuButtons); else if(message == "Previous")open_menu(id, mainMenuDialog, mainMenuButtons); else if(message == "Magazines")open_menu(id, subMenu_01_Dialog, subMenu_01_Buttons); } timer() { close_menu(); } } state cash { state_entry() { llSetPayPrice(price, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]); } money(key id, integer amount) { if(amount != price) { llGiveMoney(id, amount); llInstantMessage(id, "You paid "+(string)amount+", which is the wrong price. The price is: "+(string)price); } else { llInstantMessage(id, "Thank you for your purchase!"); open_menu(id, mainMenuDialog, mainMenuButtons); } } } Link to comment Share on other sites More sharing options...
Rachel1206 Posted December 24, 2017 Share Posted December 24, 2017 You need to create sub-menu for the magazines in question, take a look at: http://wiki.secondlife.com/wiki/LlDialog Link to comment Share on other sites More sharing options...
Laufiair Hexicola Posted December 24, 2017 Author Share Posted December 24, 2017 defined that already, unless i'm making a sub-menu of a sub-menu. string subMenu_01_Dialog = "MAGAZINES\nNot Implemented yet."; list subMenu_01_Buttons = ["Close"]; else if(message == "Magazines")open_menu(id, subMenu_01_Dialog, subMenu_01_Buttons); Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted December 24, 2017 Share Posted December 24, 2017 (edited) It's awkward without the standard indentation to read, but I think the problem is in your listen event. After you test for the channel being the dialog channel you then call close_menu, which effectively destroys the listen event before moving onto processing the message it has received. Try putting it in a further else option at the very end of the listen event so that the listener is removed only if none of the other options have been matched. Another tip is to stop the timer event at the very entry to the listen event so that it doesn't trigger during the processing if the user has spent a long time reading the buttons. Edited December 24, 2017 by Profaitchikenz Haiku typos as usual Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 24, 2017 Share Posted December 24, 2017 (edited) I don't understand the logic of the script at all, but the most obvious problem is that you request debit permissions in state entry and then, as soon as the owner grants them, you go into state cash, so neither the listen nor the touch events are ever going to fire. So all the script can do at the moment is wait for me to pay something and then either tell me I've paid the wrong amount or open a menu. But the menu doesn't do anything -- there's no listen event in state cash to process whatever message it's expecting to hear when I use the menu. Edited December 24, 2017 by Innula Zenovka Link to comment Share on other sites More sharing options...
Laufiair Hexicola Posted December 24, 2017 Author Share Posted December 24, 2017 3 hours ago, Innula Zenovka said: I don't understand the logic of the script at all, but the most obvious problem is that you request debit permissions in state entry and then, as soon as the owner grants them, you go into state cash, so neither the listen nor the touch events are ever going to fire. So all the script can do at the moment is wait for me to pay something and then either tell me I've paid the wrong amount or open a menu. But the menu doesn't do anything -- there's no listen event in state cash to process whatever message it's expecting to hear when I use the menu. Exactly, thanks for hitting it right on the head. I took a menu script that already works and attempted to add a way so a visitor would have to pay the object first, then get the menu(which is why I call the menu at the very bottom). I did try to put the state cash up in the script but it gave a syntax error, so I figured I'd come to the forums and ask for some help in getting this script to work right. The point of the script is that it sits in a 1li magazine display and visitors pay the display first, then are allowed to make a selection. When I pay, it gives me the main dialog but then hangs when I choose a button other then close(like it's waiting for the pay event again). I'm just not sure how to go about correcting this. Link to comment Share on other sites More sharing options...
Laufiair Hexicola Posted December 24, 2017 Author Share Posted December 24, 2017 5 hours ago, Profaitchikenz Haiku said: It's awkward without the standard indentation to read, but I think the problem is in your listen event. After you test for the channel being the dialog channel you then call close_menu, which effectively destroys the listen event before moving onto processing the message it has received. Try putting it in a further else option at the very end of the listen event so that the listener is removed only if none of the other options have been matched. Another tip is to stop the timer event at the very entry to the listen event so that it doesn't trigger during the processing if the user has spent a long time reading the buttons. I did try and look for the button or code that let me do that but was unable to find it, so used quote. Apologies there. I have tried messing with the placement of the state but every time i move it to anyplace other then where it is, it throws a syntax error. Shortening or eliminating the timer event doesn't do anything. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 24, 2017 Share Posted December 24, 2017 Think about the logic of the script (working out that script's logic is the main part of scripting -- writing it is secondary, to my mind). Personally, I don't like vendor scripts that give refunds. I'd much rather ask people to contact the owner direct if they somehow pay the wrong amount, since it's simpler and it's more secure, but let's keep the refund for the purposes of this script. The reason, I take it, for having two states is to ensure that it never gets as far as taking anyone's money unless it has permission to give them a refund if necessary. Fair enough. In that case, you need to request debit permissions in state entry of state default (which you do) and then, in the run_time_permissions event, once you've been granted debit permissions, move into state cash. That way, nothing can happen until you've been granted the debit permission. Once you arrive in state cash, call llSetPayPrice in state_entry there, and simply move the existing on_rez, touch_start, listen and timer events from state default down into state cash. I don't see where you're getting the names of the magazines from, though, from which the customer can choose, and neither do I see what the script is going to do when I do choose a magazine, but maybe that part isn't written yet. 2 Link to comment Share on other sites More sharing options...
Laufiair Hexicola Posted December 24, 2017 Author Share Posted December 24, 2017 Oh ok I see what you're talking about - and no, that part of the menu hasn't been written yet. The magazine titles are written in a series of what else clauses and giveitem clauses. Let's see how that works lol... Link to comment Share on other sites More sharing options...
Laufiair Hexicola Posted December 24, 2017 Author Share Posted December 24, 2017 Hello Innula, thanks that did it! I moved the listener claus to the event cash and it works now! I'll be fiddling around with the touch start as that will be an owner only feature. Appreciate everyone elses help in trying to get this to work also, Logan Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now