From 2813fa08a02b41dac320aa0a69e0c5f0b808e0b9 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Mon, 25 Jun 2018 21:53:23 +0200 Subject: [PATCH] Controller bugs fixed --- .gitignore | 4 +++- safer_lua/.gitignore | 6 ------ sl_controller/battery.lua | 2 ++ sl_controller/controller.lua | 5 ++++- 4 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 safer_lua/.gitignore diff --git a/.gitignore b/.gitignore index 5590841..f3b8f7c 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,6 @@ luac.out .buildpath .project org.eclipse.* -*.lua.new \ No newline at end of file +*.lua.new + +test_*.lua \ No newline at end of file diff --git a/safer_lua/.gitignore b/safer_lua/.gitignore deleted file mode 100644 index b28395b..0000000 --- a/safer_lua/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.buildpath -.project -org.eclipse.* - - -test_*.lua \ No newline at end of file diff --git a/sl_controller/battery.lua b/sl_controller/battery.lua index 0ab5684..9b93ceb 100644 --- a/sl_controller/battery.lua +++ b/sl_controller/battery.lua @@ -51,6 +51,7 @@ minetest.register_node("sl_controller:battery", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) meta:set_int("content", sl_controller.battery_capacity) + on_timer(pos, 1) minetest.get_node_timer(pos):start(30) end, @@ -60,6 +61,7 @@ minetest.register_node("sl_controller:battery", { sunlight_propagates = true, paramtype2 = "facedir", groups = {choppy=1, cracky=1, crumbly=1}, + drop = "", is_ground_content = false, sounds = default.node_sound_stone_defaults(), }) diff --git a/sl_controller/controller.lua b/sl_controller/controller.lua index 78674da..73b2bac 100644 --- a/sl_controller/controller.lua +++ b/sl_controller/controller.lua @@ -20,6 +20,9 @@ SaferLua is a subset of Lua with the following restrictions: - Limited set of available functions - Store() as alternative to Lua tables +The controller needs a battery nearby. +Don't remove the battery, it will be destroyed! + See: goo.gl/WRWZgt ]] @@ -261,7 +264,7 @@ end local function on_timer(pos, elapsed) local t = minetest.get_us_time() local meta = minetest.get_meta(pos) - if meta:get_int("state") ~= "running" then + if meta:get_int("state") ~= tubelib.RUNNING then return false end local number = meta:get_string("number")