CC: Tweaked

CC: Tweaked

57M Downloads

_G.arg

RGFTheCoder opened this issue ยท 3 comments

commented

Useful information to include:

  • Simply does the equvalent of adding the line _G.arg = { ... } to the top of files run in the shell/ shell.run.
  • This is useful as it allows haxe programs compiled with the vanilla lua flag to run without modification. Currently one has to add the _G.arg = { ... } line to the top of the haxe program for it to run in cctweaked.
  • This functionality exists in the regular lua cli.
commented

This functionality already exists, does it not? However it should be _ENV.arg, because each program is run in its own environment.

Since the shell is also written in Lua, arg would be persisted after each program run otherwise.

commented

both should work since they both work in the lua cli. Try making this file in cctweaked and as a plain lua cli file

print(_G.arg[1])
print(_ENV.arg[1])

and run it like file.lua parameter. Plain lua prints it fine (both times), but cctweaked fails cuz _G.arg doesn't exist.

commented

It doesn't make sense to put this in _G as the arguments aren't global - they're specific to the currently running program.