Differ Android and iOS with Lua

I have a Lua script and it should be executed on Android and iOS, so sometimes I need to know if it is being executed on iOS or if it is being executed on Android. The only way I found was checking the beginning of debug.getinfo(1).source, but I think that there should be a better way.

Any suggestion?

Upvotes: 1

Views: 222

Answers (2)

Oliver
Oliver

Reputation: 29463

There is no builtin method, that I know of. If your script can call os.execute and os.getenv, you can probably figure out an OS command or an environment variable that would allow you to distinguish. Otherwise whatever runs your script must provide it (possibly through os.getenv: for example, doesnt' apache set some environment variable with apache version etc? if this is what runs your script then os.getenv should do it).

Upvotes: 1

catwell
catwell

Reputation: 7048

In what context is this script running?

If it is in the context of an existing application or framework, that application should provide you this information. If you are writing the lower-level code calling Lua, you should provide it yourself.

I don't know how you can guess the OS by looking at debug.getinfo(1).source by the way. How is it different on iOS and Android?

If you give more details about what you are doing, I will be able to give you a better answer.

Upvotes: 2

Related Questions