+WINSLMA Posted March 16, 2013 Share Posted March 16, 2013 I am have having issues programming my new Wherigo. Can anyone help me? Basically, the player picks up one item in each of the 7 zones and then the player takes the items to the store zone to "sell" them. The "sell" command should be enabled when they are OnProximity to the zone, but it does not happen for all the items. I used this same command is a previous Wherigo so I am confused why it does not work now. The full LUA file is attached, but my problem area is below. function zoneStore:OnProximity() -- #GroupDescription=Script -- -- #Comment=Script Comment -- if Player:Contains(zitemItem1) then zitemItem1.Commands["Sell"].Enabled = true elseif Player:Contains(zitemItem2) then zitemItem2.Commands["Sell"].Enabled = true elseif Player:Contains(zitemItem3) then zitemItem3.Commands["Sell"].Enabled = true elseif Player:Contains(zitemItem4) then zitemItem4.Commands["Sell"].Enabled = true elseif Player:Contains(zitemItem5) then zitemItem5.Commands["Sell"].Enabled = true elseif Player:Contains(zitemItem6) then zitemItem6.Commands["Sell"].Enabled = true elseif Player:Contains(zitemItem7) then zitemItem7.Commands["Sell"].Enabled = true end end Seven Items.zip Quote Link to comment
+charlenni Posted March 16, 2013 Share Posted March 16, 2013 Your problem is, that you could hold more than one item at a time, but you check only on the first item. If a item is found in your if clause, no other item is checked. You should do it like this: if Player:Contains(zitemItem1) then zitemItem1.Commands["Sell"].Enabled = true end if Player:Contains(zitemItem2) then zitemItem2.Commands["Sell"].Enabled = true end if Player:Contains(zitemItem3) then zitemItem3.Commands["Sell"].Enabled = true end if Player:Contains(zitemItem4) then zitemItem4.Commands["Sell"].Enabled = true end if Player:Contains(zitemItem5) then zitemItem5.Commands["Sell"].Enabled = true end if Player:Contains(zitemItem6) then zitemItem6.Commands["Sell"].Enabled = true end if Player:Contains(zitemItem7) then zitemItem7.Commands["Sell"].Enabled = true end or even easier: zitemItem1.Commands["Sell"].Enabled = Player:Contains(zitemItem1) zitemItem2.Commands["Sell"].Enabled = Player:Contains(zitemItem2) zitemItem3.Commands["Sell"].Enabled = Player:Contains(zitemItem3) zitemItem4.Commands["Sell"].Enabled = Player:Contains(zitemItem4) zitemItem5.Commands["Sell"].Enabled = Player:Contains(zitemItem5) zitemItem6.Commands["Sell"].Enabled = Player:Contains(zitemItem6) zitemItem7.Commands["Sell"].Enabled = Player:Contains(zitemItem7) or -- Table with all items that have a "Sell" command and should be checked (could be set in OnStart/OnRestore) items = { zitemItem1, zitemItem2, zitemItem3, zitemItem4, zitemItem5, zitemItem6, zitemItem7 } -- Set all commands to enabled/disabled for k,v in ipairs(items) v.Commands["Sell"].Enabled = Player:Contains(v) end There is also a method to select all things, that have a "Sell" command automatically, but this is a step further ;-) Quote Link to comment
+WINSLMA Posted March 17, 2013 Author Share Posted March 17, 2013 Thank you charlenni!!! It worked! Quote Link to comment
+WINSLMA Posted March 17, 2013 Author Share Posted March 17, 2013 Follow up question. If I only want the "Sell" command to appear while in or in proximity to the Store, is there a better way than to show Sell enable true on Enter and Sell enable false on Exit? I had to change the on Proximity to on Enter because I could not a way to Sell enable false otherwise. I believe/hope this will work in the field, but I know there are sometimes issues with certain units (my phone - Android network) that had issues with entering zones and that is why I try to use proximity. Quote Link to comment
Ranger Fox Posted March 17, 2013 Share Posted March 17, 2013 I did that with The Fox, Chicken, and Feed cartridge. You might find it useful to pick that apart (all my cartridges are open source). The source code for this one is clean because I created it as an example for someone, then decided to publish it in my area as well. Quote Link to comment
+WINSLMA Posted March 20, 2013 Author Share Posted March 20, 2013 I see your "author script", but unless I can see it in the box under Events I have a hard time understanding the programming. My show Sell enable true on Enter and Sell enable false on Exit seems to be working OK. Here is my new question/problem. Why does this work on the WhereYouGo app and not my Oregon 200? Basically when the player clicks on a Character, it should bring up a message and then it should take them to the inventory screen. The WhereYouGo works perfectly, but the message doesn't come up on the Oregon. function zcharacterMarioBatali:OnClick() -- #GroupDescription=Script -- -- #Comment=Script Comment -- Wherigo.MessageBox{Text=[[Can you check to see if my shoes are ready?]],Callback=cartLarrytheLeprechaun.MsgBoxCBFuncs.MsgBoxCB6} end Quote Link to comment
Ranger Fox Posted March 20, 2013 Share Posted March 20, 2013 Garmin didn't implement OnClick for characters and tasks. I don't remember if they implemented it for zones. I think they did. Quote Link to comment
+WINSLMA Posted March 21, 2013 Author Share Posted March 21, 2013 Does the On Click work for Items? Is there any real difference between Characters and Items? If the On Click works for Items, I could put the "Characters" under the Items. Quote Link to comment
Ranger Fox Posted March 21, 2013 Share Posted March 21, 2013 I'd have to test it again. It has been too long since I needed to know just where Garmin's Player stops functioning. Quote Link to comment
+WINSLMA Posted April 11, 2013 Author Share Posted April 11, 2013 I was finally able to test the On Click. It does not work for Items nor does it work for Characters. While it wasn't a huge part of the cartridge, it would have been a nice touch. It seems like everytime I learn something new, I learn two things that don't work. Quote Link to comment
+WINSLMA Posted April 22, 2013 Author Share Posted April 22, 2013 So here is my new issue. I am trying to sell some items worth $5 and $10 and put the money in the wallet once sold. I have seen Ranger Fox's Shopping Demo, but the coding under the "Author Script Editor" is too complicated for me. I have attached a starter cartridge. Can anyone help me program so the wallet $ increases by the amounts sold. Money.zip Quote Link to comment
+jonny65 Posted April 22, 2013 Share Posted April 22, 2013 Oh a lua file, do you use the GC Builder ? Sorry, too complex for me and it surely takes 10 minutes Better 1 minute in urwigo and I hope this helps nevertheless Quote Link to comment
+WINSLMA Posted April 23, 2013 Author Share Posted April 23, 2013 Thank you for your help! I understand what I need to do, but I am still having problems (I am a very basic programmer - I wish I knew a lot more). I can create the Set Wallet description to equal, but I cannot create the concatenate function. Can anyone tell how to create this in the Groundspeak Wherigo builder. Unfortunately the builder is what I used to learn how to create Wherigo's (I know I am in the minority). Quote Link to comment
+WINSLMA Posted April 24, 2013 Author Share Posted April 24, 2013 Some how, some way, I found my answer. I found the needle in the haystack in Ranger Fox's Shopping Demo. For most people, you are probably saving duh and it looks exactly the same. Groundspeak Builder answer - Set zitemWallet Description equal to [[You have ]] .. Money .. [[ dollars in your wallet.]] Quote Link to comment
+WINSLMA Posted May 28, 2013 Author Share Posted May 28, 2013 Just when I think I have finished my Wherigo, I run into problems testing it in real life. My latest problem is that the Wherigo has problems processing the information and goes back to a previous screen. Example: On my items the player clicks "Sell". There are 2 options, Button 1 and Button 2. If Button 1 it displays a message and then when the player clicks OK it processes the following information. cartLarrytheLeprechaun.MsgBoxCBFuncs.MsgBoxCB29 = function(action) if action ~= nil then -- #GroupDescription=Script -- -- #Comment=Script Comment -- zitemYellowSneakers:MoveTo(zcharacterSkeetReese) zcharacterSkeetReese.Visible = false Money = Money + 85 zitemWallet.Description = [[You have ]] .. Money .. [[ gold coins in your wallet.]] Wherigo.ShowScreen(Wherigo.DETAILSCREEN,zitemWallet) cartLarrytheLeprechaun:RequestSync() end end If Button 2 it displays a message and then gives 2 more options - Button 1 and Button 2. Button 1 then displays a message and processes the basically the same information as the previous Button 1. Button 2 displays a message and then gives 2 more options - Button 1 and Button 2. Button 1 then displays a message and processes the basically the same information as the previous Button 1. Button 2 displays a message and processes the following information. cartLarrytheLeprechaun.MsgBoxCBFuncs.MsgBoxCB35 = function(action) if action ~= nil then -- #GroupDescription=Script -- -- #Comment=Script Comment -- zcharacterSkeetReese.Visible = false zitemYellowSneakers.Commands["Sell"].Enabled = false cartLarrytheLeprechaun:RequestSync() end end I have one issue on my Oregon 200 and one on my Andriod phone. Oregon - The Oregon doesn't have any problems when selecting the different options, it is only slow when processing the "following information". It basically shows the item and the "Sell" again until it is down processing the information. I am not as concerned with this problem. I am more concerned with my Andriod phone. Andriod phone - The phone doesn't seem to have problems processing the original option 1, but it has a problem navigating through the other options. 50% of the time it will just go back to the "Sell" screen and you will have to start the process all over again. I have tried waiting a few seconds before answering Button 1 or Button 2, but that doesn't seems to always work. Also, is there a perferred method for scripting Button 1 and Button 2. I have tried both of these options, but then seem to work the same. If Button 1 message end If Button 2 message end If Button 1 message else if Button 2 message end Please help. Quote Link to comment
Geo-Magician Posted May 31, 2013 Share Posted May 31, 2013 (edited) Also, is there a perferred method for scripting Button 1 and Button 2. I have tried both of these options, but then seem to work the same. If Button 1 message end If Button 2 message end If Button 1 message else if Button 2 message end A better way to use the else statement is to leave it open If Button 1 messageA else messageB end This will ensure that minimum messageB is printed. In your examples the second massage is tied to button 2. If the WIG (for whatever reason) decides that button 3 or anything else was clicked there will be no message (and no selling action) at all. Note to programmers: please give me some slack, I know that this is a very general statement and can be debated depending on the actual needs of the program. Edited May 31, 2013 by Geo-Magician Quote Link to comment
+WINSLMA Posted June 1, 2013 Author Share Posted June 1, 2013 Thank you Geo-Magician. I thought about that, but I don't think will solve my bigger problem (I could be wrong though). Can anyone solve my bigger problem? Quote Link to comment
+jonny65 Posted June 1, 2013 Share Posted June 1, 2013 It would be a thing of 1 minute to find the problem and bugfix it, if you would post an urwigo source. The GC builder is too confuse (for me) Quote Link to comment
+WINSLMA Posted June 2, 2013 Author Share Posted June 2, 2013 It would be a thing of 1 minute to find the problem and bugfix it, if you would post an urwigo source. The GC builder is too confuse (for me) Short story - see attached file. Long story - I imported the lua file into Urwigo and saved. Thank you for your help! If you can find the issue(s), please let me know what the issue is (instead of just fixing it). That way I can learn what the issue is. Plus, I don't think there is an import a Urwigo file into lua. Larry.zip Quote Link to comment
+jonny65 Posted June 3, 2013 Share Posted June 3, 2013 Oh I have meant you make a small sample cartridge only with the "problem part". I think all of the items have the same procedure (pic up, sell). I have not read exactly your post above, where you wrote ONLY the android has problems and not always but sometimes. This is very difficult. Would be "better" an error always occurs. Because of this, you must try some things. Create a small sample with the issue that doesn't work - remove the showobjectdetails command - remove the save game command (better save after exiting a zone, not after every click) - use inputs instead of 2 or 3 nested message boxes - place the commands in other order, not in the onclicked event of the message box, but before I have heard from a programmer, that sometimes (on iphone) commands will be skipped, if they are in the onlcicked These are some things, which you can try and test, whether it better works. Only change 1 thing, test it and so on. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.