Passing arguments into the simulator

This took me a while to figure out, so I’m posting it here incase it helps someone else.

You may want to pass information from the OS into the simulator, obviously this will not work on a device, however there are situations where you might want to do this - for example, automated testing.

You cannot pass command line arguments “args” is always empty. However, you can make an OS call. So you can set an environmental variable, then read it from the simulator.

export TESTNUMBER=3

execute simulator on command line…

/Applications/Corona/Corona\ Simulator.app/Contents/MacOS/Corona\ Simulator ~/Projects/x1 -no-console YES 

In main.lua:

local test=io.popen"echo $TESTNUMBER":read’*l’

print(">> " … test)