Jump to content

What's the opposite of "Cancel"?


sTeamTraen

Recommended Posts

Is there a way (in Lua or the Groundspeak builder) to say "if the user pressed either button in response to a Message"?

 

I suppose I could say

if action=="Button1" or action=="Button2" then

 

The reason I ask is that I have found some year-old code in Earwigo which allows four values for the reply to a Message: Button1, Button2, Cancel, and "Either". I can't quite remember where I got the idea for Either. If the user selects it, I'm generating code which says

if action ~= nil then

but the Groundspeak builder doesn't like that (it ignores the IF statement, which means you can see an ELSE without an IF), and it doesn't like

if not action == nil then

either (it gets confused and thinks I want to see if the user pressed a button called '=='). I don't especially care what the Groundspeak builder will make of the code, as long as the player can handle it, but now I'm starting to wonder if it's even meaningful (I need more cartridge-building experience, but making a builder has got in the way).

Link to comment

As far as I can tell, you can have one or two buttons in a messagebox (if you try and put no button, it default to 1 button (OK), if you try and put more than 2 buttons, it seems to ignore any more than 2).

 

If you have a Message with two buttons then its always going to be the case that its going to be Button1 or Button2, so there is no need to check.

 

Likewise if its just one button, then its always going to be that button, so again no need to check.

 

So, unless I've missed something, the only time you would ever need to make a check is if you want to react to a specific button, in which case you want something like:

 

if action=="Button1" then
Wherigo.MessageBox{Text=[[Button1 pressed]],}
else
Wherigo.MessageBox{Text=[[Button2 pressed]],}
end

 

The above code does not seem to be displayed in the builder, however, if you publish the code to your machine in the builder, it does seem to run quite happily in the emulator. I've not tried it yet on an Oregon.

Edited by a_snail
Link to comment

a_snail, you're wrong this time

 

it's like this:

 

if user presses button1, action == "Button1"

if user presses button2, if one is present, action == "Button2"

if the message is cancelled (overwritten by another, for example), action == nil

 

"but the Groundspeak builder doesn't like that (it ignores the IF statement, which means you can see an ELSE without an IF), and it doesn't like" =>> this actually is meaningful, and means "if the message is -not- cancelled", that is, if either button is pressed.

 

resason the builder is confused is that precisely this code is autogenerated for every callback script where there are no specific conditions for buttons.

in other words, the default in Builder is "if either button is pressed". therefore, the condition is not shown and builder doesn't expect an ELSE for this.

Link to comment

a_snail, you're wrong this time

 

it's like this:

 

if user presses button1, action == "Button1"

if user presses button2, if one is present, action == "Button2"

if the message is cancelled (overwritten by another, for example), action == nil

 

"but the Groundspeak builder doesn't like that (it ignores the IF statement, which means you can see an ELSE without an IF), and it doesn't like" =>> this actually is meaningful, and means "if the message is -not- cancelled", that is, if either button is pressed.

 

resason the builder is confused is that precisely this code is autogenerated for every callback script where there are no specific conditions for buttons.

in other words, the default in Builder is "if either button is pressed". therefore, the condition is not shown and builder doesn't expect an ELSE for this.

 

Fair enough, I was forgetting my test case was inside the "if action ~= nil then", so what I had was safe and correct. I'm so used to seeing there and ignoring it :laughing: Either way, the builder its self has no way to tell which button is pressed (as far as I know), so you have to start editing it in the .lua file to get what you want, and then you can't see your changes in the editor. Fingers crossed Earwigo handles this much better.

 

Just an aside, I'm sure I've seen comments from people saying early version of the Colorodo couldn't handle multiple buttons on these messageboxes, but I havn't found those articles yet. I think the latest firmware updates has it fixed.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...