Jump to content

Prepopulating an input field with a "default" value


Geofellas

Recommended Posts

In my Build your Own GPSr cartridge it is onerous to enter an entire coordinate string, especially in the Colorado.

 

Is there a way to pre-populate the input fields with a "default value" (e.g. the player's current location)?

 

The Colorado does this for you when you are marking a waypoint outside of a Wherigo

 

This would also be useful if the user makes a mistake that you find when parsing and checking any kind of input but just needs to change one or two characters, say. It would be nice under such circumstances to prepopulate the input field with the previous erroneous entry for them to edit

Link to comment

This is what I'd like to say:

--The zone needs to be set as inactive
zZoneMyWaypoint.Active = false

--Move the waypoint
zZoneMyWaypoint.latitude = Player.ObjectLocation.latitude
zZoneMyWaypoint.longitude = Player.ObjectLocation.longitude

zZoneMyWaypoint.Active = true
zZoneMyWaypoint.Visible = true

 

When programming Whack-A-Lackey, I found you have to move every part of your zone. Remember, zones can be in any shape. Each point of that shape is a ZonePoint and has coordinates you'll need to adjust with respect to the zone's center. Here's something you can use:

--Moves the zone to the players location.
function MoveZoneToPoint(zZone, point, radius)
 --It needs to be inactive so it can be redrawn after we move it.
 zZone.Visible = false
 zZone.Active = false

 local dist = Wherigo.Distance(radius, 'ft')
 local newZp = Wherigo.TranslatePoint(point, dist, radius)   -- new center point for the new zone	
 dist = Wherigo.Distance(ZoneRadius, 'ft')
 local pts = {
Wherigo.TranslatePoint(newZp, dist, 45),
Wherigo.TranslatePoint(newZp, dist, 135),
Wherigo.TranslatePoint(newZp, dist, 225),
Wherigo.TranslatePoint(newZp, dist, 315),
 }

 zZone.Active = false
 zZone.OriginalPoint.latitude = newZp.latitude
 zZone.OriginalPoint.longitude = newZp.longitude

 zZone.Points = pts

 --Now, activate it so it will be redrawn (e.g. updated on the screen)
 zZone.Active = true
 zZone.Visible = true
end 

To use this, you do the following:

MoveZoneToPoint(zZoneMyWaymark, Player.ObjectLocation, 15)

That will move your zone to wherever the player is standing and will make its corners fifteen feet from its center.

 

Since it was part of my Whack-A-Lackey cartridge, I tested it there in its original form. I changed it a bit to answer the question at hand, but haven't had time to do a unit test.

 

If you're interested in moving and manipulating zones, take a look at the source behind Whack-A-Lackey. It messes with zones in a huge way.

Link to comment

Hey RF - I think you answered a different question here. I've got a good handle on manipulating zones - I am interested in how to prepopulate an input field with a good guess at (some of) the data the user is going to enter so as to reduce roller manipulation (on the CO anyway). Maybe this was intended for a different thread

Edited by Geofellas
Link to comment

Hey RF - I think you answered a different question here. I've got a good handle on manipulating zones - I am interested in how to prepopulate an input field with a good guess at (some of) the data the user is going to enter so as to reduce roller manipulation (on the CO anyway). Maybe this was intended for a different thread

Well, it was bound to happen with a bunch of tabs open and looking at different threads at once. Now, what did I do with that other thread...

 

At times like this, the best thing to do is... ah... go find a cache. Yeah. I'll be over somewhere, doing something.

 

And, no, I don't think you can prepopulate an input box.

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...