Jump to content

Using Env.Platform


Forest-Ghost

Recommended Posts

I am creating a Wherigo where a player has an item "cell phone." I thought it would be fun if the Wherigo detected what type of device the player is using and then name the cell phone based upon the players device (Example Joe's Iphone, Dan's Android). Is there a general code I can use to check for all iOS, Android, or other devices?

 

The problem I stumbled on to is Env.platform gives the specific  iteration of the operating system (iOS 15.1 for example is the most current for iphone) so in order to set the variable, I would have to include every possible version of that operating system to account for every possible device. I was wondering if there was a way to simply check for just iOS, Android, or other operating platforms?

Link to comment

You can use Env.Platform with pattern matching or substring etc. I have an Example for a play anywhere WIG where I detect if the platform is an iOS, because iPhones doesn't show the border of a Zone:

-- I use a local variable called platform, witch has the same value like Env.Platform
if string.sub(platform, 1, 6) == "iPhone" or string.sub(plattform, 1, 3) == "iOS"  then
  -- ...
end

On this (german) wiki you can see the different player and its Platform. For iOS you have to test iPhone and iOS because the new Wherigo App use iOS, the old one use iPhone.

 

I think this code could be working (but I haven't test it):

local phonename = "My Phone"
if string.sub(Env.Platform, 1, 4) == "MIDP" then
  phonename = "My Andoid"
elseif Env.Platform == "Vendor 1 ARM9" then
  -- Garmin has always the same value for Env.Platform
  phonename = "My Garmin"
elseif string.sub(Env.Platform, 1, 6) == "iPhone" or string.sub(plattform, 1, 3) == "iOS"  then
  phonename = "My iPhone"
end

 

Edited by capoaira
  • 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...