Jump to content

A question about Player.ObjectLocation.latitude and Player.ObjectLocation.longitude


Delta68

Recommended Posts

22 hours ago, Delta68 said:

Do Player.ObjectLocation.latitude and Player.ObjectLocation.longitude use a decimal comma in countries where a decimal comma is normally used instead of a decimal point?

 

There are a couple of things to disentangle there. latitude and longitude are decimal numbers, but whether a comma or point is used as separator depends entirely on context. As a cartridge author, you must use a decimal point as @capoaira said. (From the point of view of the device that runs the cartridge, the concept of decimal separator does not even really make sense anymore, since internally numbers are stored as sequences of bits.) But then, if you want to present these numbers to the user, you need to represent them somehow, a process called formatting and that converts a machine number (bits) into a human number (characters, so text, really).

 

That process may or may not be involve cultural settings such as what character is used for the decimal separator, where to put whitespaces, etc. But most of the time one who just wants to show a number does not have to bother with these cultural things, so "we let the programming language do it" and it uses some default. Broadly speaking, in programming in general I would expect the default formatting for numbers to be culturally variant, which means that if I print a number on a French machine, it should give a different result than on an American machine. That's not always the case, and some programming languages default to cultural invariant formatting, which is usually printing numbers an American machine would.

 

Fast-forward to Wherigo: because of the various Lua implementations in use in the various player apps out there, there is no consistent result from printing a number. Depending on the app, you will get culturally variant or invariant results. Worse, there is no way from cartridge code to determine the language of the device the user is using, so you could not even write a custom formatting function if you needed it.

 

The long story short is there is no way to guarantee your formatted number will follow the conventions of the user's country so a cartridge should probably not rely on it.

Edited by Mangatome
Link to comment


Wow that's quite a reply!

 

All I needed to know really was if a decimal  comma is used instead of a decimal point.

The reason I ask, is that I intent to make some of my Wherigos play-anywhere and reusable. The plan is the player (person) will go to their planned final location and request a code.


The code will be the current location encrypted in some way but with the decimal point replaced with a letter. Obviously, I'd need to ensure that the correct decimal separator is used when converting back.

 

Thanks

 

Link to comment

I'm not sure I understand what would then happen with the code when it is converted back to a number.

But I would just multiply the number by 1000000 and then round it. Same for the reverse operation, you can divide the decrypted number by 1000000.

This way you don't bother with decimal separators.

  • Helpful 1
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...