Wherigo (Class)

From Wherigo Foundation Wiki
Jump to: navigation, search

The Wherigo class defines several classes, methods, and constants used as part of the Wherigo framework.


Properties / Constants

DETAILSCREEN Constant referencing the detail screen of a Wherigo character, item, zone, etc.
INVALID_ZONEPOINT Constant representing a coordinate which does not exist, used to indicate that a variable should not hold a real value.
INVENTORYSCREEN Constant referencing the player's inventory screen.
ITEMSCREEN Constant referencing the visible item list screen.
LOCATIONSCREEN Constant referencing the visible locations list screen.
LOGDEBUG For log messages, indicates the message is a Debugging message. (messages are not displayed at default log level)
LOGCARTRIDGE For log messages, indicates the message is a default message.
LOGINFO For log messages, indicates the message is Informational, and not as severe as a Warning. (no coordinates are recorded)
LOGWARNING For log messages, indicates the message is a Warning, but not as severe as an Error. (no coordinates are recorded)
LOGERROR For log messages, indicates the message is an Error.
MAINSCREEN Constant referencing the main Wherigo screen allowing access to the various list screens.
Player A ZCharacter instance representing the user currently playing the Wherigo cartridge.
TASKSCREEN Constant referencing the visible task list screen.


Classes

Distance A distance between two points.
ZCartridge The cartridge being played.
ZCharacter A character in the game.
ZCommand A command usable on a character, item, zone, etc. Included in ZCharacter.Commands table.
ZInput A user input field.
ZItem An item which can be placed in a zone or held by a character.
ZMedia A media file such as an image or sound.
ZObject Unsure; probably ancestor class of ZCharacter, ZItem, Zone, etc. to allow generic actions against any object type.
Zone Geographical area defined by several ZonePoints.
ZonePoint A specific geographical point, or the INVALID_ZONEPOINT constant to represent no value.
ZReciprocalCommand A command, that is created automatically by as a reciprocal version of the original ZCommand.
ZTask A task the user can attempt to accomplish.
ZTimer A timer object allowing time or activity tracking.


Methods

Dialog{table} Displays a dialog to the user. Parameter table contains one or more tables, which may include two named values: Text, a string value containing the message to display, and Media, a ZMedia object to display in the dialog.
PlayAudio(media) Plays a sound file. Single parameter is a ZMedia object representing a sound file.
ShowStatusText(text) Updates the status text displayed on PPC players to the specified value. At this time, the Garmin Colorado does not support status text.
VectorToZone(ZonePoint from, Zone to) Returns Distance and number. Calculates distance and bearing from the ZonePoint from to the Zone zone. It uses the closest point to zone boundary.
TranslatePoint(ZonePoint point, Distance distance, Number angle) Returns ZonePoint. Result is a ZonePoint object calculated by starting at the provided point and moving Distance from that point at the specified angle. Bearing is a number between 0 and 360.
NoCaseEquals(String str1, String str2) Returns boolean. Compares two strings for equality, ignoring case.
Command(text) Commands found in LUA from Builder:
  • "SaveClose"
  • "DriveTo" (not currently supported on Colorado series)
  • "StopSound"
  • "Alert"
LogMessage(table)

LogMessage(text, level)

Allows messages to be added to the cartridge play log at one of the defined log levels. Parameters are the actual text and an optional log level at which the text is displayed. If level is not specified it defaults to LOGCARTRIDGE. There are two possible calling conventions: as individual parameters or as a table parameter with named values.

Examples:

  • Wherigo.LogMessage({Text="Enter Zone"})
  • Wherigo.LogMessage({Text="missing item", Level=Wherigo.LOGERROR})
  • Wherigo.LogMessage("Zone activated", Wherigo.LOGINFO)
  • Wherigo.LogMessage("no zone")
IsPointInZone(ZonePoint point, Zone zone) Returns boolean. Checks whether a specified point of type ZonePoint is within a specified zone of type Zone.
VectorToPoint(ZonePoint zonepoint1, ZonePoint zonepoint2) Returns Distance and number. Accepts two ZonePoint instances zonepoint1 and zonepoint2. Returns distance and bearing from zonepoint1 to zonepoint2. d is a Distance instance; b is a number with the bearing between 0 and 360.
MessageBox{table} Displays a dialog to the user with the possibility of user actions triggering additional events. Parameter table may take four named values: Text, a string value containing the message to display; Media, a ZMedia object to display in the dialog; Buttons, a table of strings to display as button options for the user; and Callback, a function reference to a function taking one parameter, the name of the button the user pressed to dismiss the dialog.
GetInput(ZInput input) Displays the provided ZInput dialog and returns the value entered or selected by the user.
ShowScreen(number screen,[ZObject item]) Switches the currently displayed screen to one specified by the screen parameter. The several SCREEN constants defined in the Wherigo object allow the screen to be specified. If DETAILSCREEN is specified, the optional second parameter item specifies the zone, character, item, etc. to display the detail screen of.
VectorToSegment(ZonePoint point, ZonePoint linestart, ZonePoint lineend) Returns Distance and number. Calculates the distance and bearing to the closest point from the ZonePoint point to the line starting with linestart and ending with lineend.