|
|
@ -1,10 +1,12 @@
|
|
|
|
--anonymous-script.lua
|
|
|
|
--scripts/modtools/anonymous-script.lua
|
|
|
|
--author expwnent
|
|
|
|
--author expwnent
|
|
|
|
--a tool for invoking simple lua scripts without putting them in a file first
|
|
|
|
--a tool for invoking simple lua scripts without putting them in a file first
|
|
|
|
--anonymous-script "print(args[1])" arg1 arg2 # prints "arg1"
|
|
|
|
--anonymous-script "print(args[1])" arg1 arg2
|
|
|
|
|
|
|
|
--# prints "arg1"
|
|
|
|
|
|
|
|
|
|
|
|
local args = {...}
|
|
|
|
local args = {...}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--automatically collect arguments to make the anonymous script more succinct
|
|
|
|
local f,err = load('local args = {...}; ' .. args[1], '=(anonymous lua script)') --,'=(lua command)', 't')
|
|
|
|
local f,err = load('local args = {...}; ' .. args[1], '=(anonymous lua script)') --,'=(lua command)', 't')
|
|
|
|
if err then
|
|
|
|
if err then
|
|
|
|
error(err)
|
|
|
|
error(err)
|
|
|
|