diff options
author | gpcf <gpcf@gpcf.eu> | 2024-04-21 19:30:31 +0200 |
---|---|---|
committer | gpcf <gpcf@gpcf.eu> | 2024-04-21 19:30:31 +0200 |
commit | a6dd04801f912778a154f9d516c703f0d57aef6a (patch) | |
tree | 497babdec8f43d0c917a65028e55222b7599b65f | |
parent | d948b1e901b38bf515d39e1a28402a45f91bdef1 (diff) | |
download | advtrains_gitexporter-a6dd04801f912778a154f9d516c703f0d57aef6a.tar.gz advtrains_gitexporter-a6dd04801f912778a154f9d516c703f0d57aef6a.tar.bz2 advtrains_gitexporter-a6dd04801f912778a154f9d516c703f0d57aef6a.zip |
Take command line arguments
-rw-r--r-- | gitexporter.lua | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/gitexporter.lua b/gitexporter.lua index 013704b..27384e9 100644 --- a/gitexporter.lua +++ b/gitexporter.lua @@ -2,11 +2,26 @@ require "lfs" + +script_path = arg[0]:match("(.*/)") minetest = {} -- hack around serializelib -minetest.get_modpath = function () return "serialize_lib" end +minetest.get_modpath = function () return script_path.."serialize_lib" end minetest.log = function() end minetest.get_current_modname = function() end -base_path = "envs" +dofile(script_path.."serialize_lib/init.lua") -- load serialize lib + +function usage() + print("Usage: gitexporter.lua worldpath outpath") +end + +if #arg < 2 then + print("too few arguments!") + usage() + return +end + +inpath = arg[1] +base_path = arg[2] function ensure_dir(path) if not (lfs.attributes(path, "mode") == "directory") then @@ -23,9 +38,9 @@ function node_file(env, pos) return base.."/"..pos..".lua" end -dofile("serialize_lib/init.lua") -tb = serialize_lib.read_table_from_file("advtrains_atlatc.ls") + +tb = serialize_lib.read_table_from_file(inpath.."/advtrains_atlatc.ls") ensure_dir(base_path) |