Controller bugs fixed

This commit is contained in:
Joachim Stolberg 2018-06-25 21:53:23 +02:00
parent e011819891
commit 2813fa08a0
4 changed files with 9 additions and 8 deletions

4
.gitignore vendored

@ -42,4 +42,6 @@ luac.out
.buildpath .buildpath
.project .project
org.eclipse.* org.eclipse.*
*.lua.new *.lua.new
test_*.lua

@ -1,6 +0,0 @@
.buildpath
.project
org.eclipse.*
test_*.lua

@ -51,6 +51,7 @@ minetest.register_node("sl_controller:battery", {
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("content", sl_controller.battery_capacity) meta:set_int("content", sl_controller.battery_capacity)
on_timer(pos, 1)
minetest.get_node_timer(pos):start(30) minetest.get_node_timer(pos):start(30)
end, end,
@ -60,6 +61,7 @@ minetest.register_node("sl_controller:battery", {
sunlight_propagates = true, sunlight_propagates = true,
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {choppy=1, cracky=1, crumbly=1}, groups = {choppy=1, cracky=1, crumbly=1},
drop = "",
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })

@ -20,6 +20,9 @@ SaferLua is a subset of Lua with the following restrictions:
- Limited set of available functions - Limited set of available functions
- Store() as alternative to Lua tables - 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 See: goo.gl/WRWZgt
]] ]]
@ -261,7 +264,7 @@ end
local function on_timer(pos, elapsed) local function on_timer(pos, elapsed)
local t = minetest.get_us_time() local t = minetest.get_us_time()
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_int("state") ~= "running" then if meta:get_int("state") ~= tubelib.RUNNING then
return false return false
end end
local number = meta:get_string("number") local number = meta:get_string("number")