add autorun script
This commit is contained in:
parent
8e18e26e47
commit
1d33c2fcc0
1 changed files with 31 additions and 0 deletions
31
cc-tweaked/scripts/autorun.lua
Normal file
31
cc-tweaked/scripts/autorun.lua
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
os.run = os.run
|
||||||
|
os.sleep = os.sleep
|
||||||
|
|
||||||
|
function table.slice(tbl, first, last)
|
||||||
|
local result = {}
|
||||||
|
for i = first or 1, last or #tbl do
|
||||||
|
result[#result + 1] = tbl[i]
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local program = ...
|
||||||
|
local args = table.slice(arg, 1)
|
||||||
|
|
||||||
|
local function main()
|
||||||
|
if program == nil then
|
||||||
|
print("Usage: autorun <program> [...args]")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local i = 0
|
||||||
|
while true do
|
||||||
|
i = i + 1
|
||||||
|
os.run({}, "/update", program)
|
||||||
|
os.run({}, program, table.unpack(args))
|
||||||
|
print("autorun", i)
|
||||||
|
os.sleep(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
main()
|
Loading…
Add table
Add a link
Reference in a new issue