From e71a1cade4732b2c3208f6bfccc84fb534ed154a Mon Sep 17 00:00:00 2001 From: HybridDog Date: Mon, 22 Dec 2014 14:14:46 +0100 Subject: [PATCH] :boom: --- .gitignore | 4 ++++ LICENSE.txt | 1 + depends.txt | 1 + init.lua | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 depends.txt create mode 100644 init.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d9c069a --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +## Generic ignorable patterns and files +*~ +.*.swp +debug.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..bc0b1db --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1 @@ +WTFPL diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..947647e --- /dev/null +++ b/init.lua @@ -0,0 +1,47 @@ +local load_time_start = os.clock() + +-- path of the file +local path = minetest.get_worldpath().."/tmp.lua" + +-- the file becomes checked every seconds +local step = 1 + +local function run_stuff() +-- search file + local file = io.open(path, "r") + if not file then + return + end + +-- test if it contains something + local text = file:read("*all") + io.close(file) + if text == "" then + return + end + +-- run it + dofile(path) + +-- reset it + file = io.open(path, "w") + file:write("") + io.close(file) + +-- inform that it worked + minetest.log("info", "[outgame_intervention] file executed.") + return true +end + +local timer = 0 +local step = 1 +minetest.register_globalstep(function(dtime) + timer = timer+dtime + if timer < step then + return + end + timer = 0 + run_stuff() +end) + +minetest.log("info", string.format("[outgame_intervention] loaded after ca. %.2fs", os.clock() - load_time_start))