Jump to content

Input Dialog Help


Corfman Clan

Recommended Posts

Hi,

 

I'm trying to create an input dialog that displays an integer value (tire pressure) and has two buttons, one a + and the other a -. When the user selects +, I'd like the value of the variable to increase. and the variable text to be updated. Oh, there should also be an ok button when the player has correctly inflated the tire. I'm not sure how to go about doing something like this and so any suggestions will be very helpful. Thanks!

Link to comment

Will the OK button only be displayed with the right tire pressure? That will affect what I'll say, but not that much.

 

Most of the logic can be made using the Builder. Create two multiple choice input dialogs (if you're writing custom code, however, only one will be needed). One dialog will have your increase and decrease buttons and the other will have those and the "OK" button.

 

When the user clicks to increase or decrease the tire pressure, increment or decrement your variable in the event that fires when the user clicks a button (you'll have to do an if/then test). If OK is the chosen value, the user clicked the "OK" button. After that, assuming the user hasn't clicked "OK", have a block of code test for the tire pressure's value. Show the right multiple choice input dialog and repeat.

 

To show the variable's value in the input field, you'll have to write a little custom code.

 

Sound good?

Link to comment

Yes, it would be recursive until the input-handling code receives "OK" as the selected value instead of "+" or "-" (or "Increase" and "Decrease", respectively, should you choose to write it out).

 

Just be careful how you write it because it can easily become an infinite loop if you get the logic wrong.

Link to comment

Ok, I've basically got this working. Instead of two input buttons, (+ and -) I just have one input button, "pump". When "pump" is input, I increment a variable. Once the variable has reached a certain value, pumping stops.

 

What I haven't been able to figure out, is how to display the current pressure in the input dialog. Currently the input displays, "Inflate front tire". As far as I can tell, that is the text property of the input, however I see no way to change the text property in the builder. I also see no way to have a variable be part of the value of the text property.

 

Again, thanks Ranger Fox for your help.

Link to comment

If you're looking for a full Builder-based solution to your question (and I'm right in guessing you want "Inflate back tire" to display next), switch to a second input dialog that looks like the first and go from there.

 

Having a variable as part of the text value would require you to modify the lua code directly. It's possible and will work, but it's your option if you'd like to go this route.

Link to comment

Yeah, you guessed right. I already have an inflate rear tire input.

 

I figured I'd need to update the lua code directly, you have confirmed that. Actually, I'm starting to think it would be easiest just to avoid the builder as much as possible. I really don't enjoy clicking this and clicking that several times just to add a line to a script. I've found myself editing the lua code directly to add lines to a script because I find it much quicker than adding them one by one from the builder. For example, depending on the condition of the bicycle, I want to display a different message when the bike is examined. Conditions are things like whether the tires are inflated, whether it has a toolkit, and whether it has a water bottle. The condition is in a variable and I used the builder to check one value and add the message, then I cut and pasted/edited for the remaining values directly.

 

My biggest problem is that I really don't know what the Wherigo API is/requires and how it reacts. In addition I'm new to lua but it seems simple enough.

 

Thanks Ranger Fox

Link to comment

Just remember to put your edited lua code in the Author Functions section or the Builder might overwrite it.

 

The Builder isn't all bad, though. I use it to make the zone and other object instantiations at the top and to construct some functions if I don't know how the Wherigo API works in that instance. It's a good learning tool for that.

 

But, man, I'd really love to do this all in C# or an IDE with IntelliSense and have the ability to show screens however I want, almost like designing a web page or WinForm. The additional possibilities and presentation differences are more numerous instead of being tied to the zone/see/items/tasks list format. Might be the view was too narrow, though it does provide a good starting point for when someone is just coming to Wherigo development.

Edited by Ranger Fox
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...