Jump to content

System variables


rodz

Recommended Posts

I would find it useful to have details of how to access system variables such as those output in the logging file. For example I am interested in setting a cache that can only be done after dark and would like to know how to check the time. Also Device ID would be useful to see if the Wherigo is being played on the builder. I spotted that the tutorial lua file that "Player.PositionAccuracy:GetValue('ft')" will give me the accuracy of the GPSr at that time. Anyone got some others?

Link to comment

Formal documentation is coming, and hopefully these, and many other, details will be covered in the documentation as it is initially published and then fleshed out. However, here are some quick answers to your questions in the meantime.

 

Some of what you are looking for is actually done in the underlying C-code of the Wherigo Engine, but can be found via various Lua libraries. The logging, for example, is actually done by the Engine, and so the date and time are supplied by the C runtime libraries. However, there is a Lua library called "os" that exposes the API calls to get the current date and time. There is an API in the "os" library called "date" that will return the current date and time formatted however you'd like (within reason, of course). For example:

now = os.date("%c")

This will set the variable "now" to a string that represents the current date and time using the system's locale format.

 

Of course, I need to make a few warning comments here: First, it should hopefully be obvious that the date/time reported by the system are only as accurate as what the user sets the device to. In other words, if the user has the time on their device set incorrectly, you'll get an incorrect date/time returned. Also, the "standard" Lua libraries are not fully supported on the PPC device, so not all API call are implemented (or implemented as you might expect). This includes the os.date() API. Sadly, the PPC support for the ANSI C runtime library is, uhm... "broken," and so most of the format specifiers for os.date() don't actually work. I know that os.date("%c") works, but I haven't tried any others and don't expect them to work. So, caveat emptor.

 

As for DeviceID, that is available in the Lua "Env" table. For example:

usersDeviceID = Env.DeviceID

This will set the Lua variable "usersDeviceID" to a string containing the user's DeviceID.

 

There are many others. Some of them can be found by an enterprising Lua hacker by playing around with the runtime environment in the Builder. Many of them will eventually be documented. But, until then, I guess you can ask about specific things.

 

Also, and this hopefully also goes without saying, please don't assume that anything I reveal on these forums is "binding" and will always work or always be supported. One reason for not publicly documenting some of this is that we're still determining just what should stay in and what should be removed (or left in, but completely unsupported). We want to learn from all of you what features and functionality are important and what is maybe less so.

 

Cheers,

-peter

Link to comment

I would find it useful to have details of how to access system variables such as those output in the logging file. For example I am interested in setting a cache that can only be done after dark and would like to know how to check the time. Also Device ID would be useful to see if the Wherigo is being played on the builder. I spotted that the tutorial lua file that "Player.PositionAccuracy:GetValue('ft')" will give me the accuracy of the GPSr at that time. Anyone got some others?

 

Can you get system variables set to varibles you can use in the cartridge? What I would like to do is show the user gps accuracy and elevation. I have been trying to play around with this but can not get it to set the variables in game?

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