From 51f55e42291a73697e1b9f2189ffbe509ddeb235 Mon Sep 17 00:00:00 2001 From: tacigar Date: Fri, 23 Dec 2016 00:56:57 +0900 Subject: [PATCH 1/3] Fix Egg writer bugs (#97) * Fix egg writer bugs * Delete lines --- maidroid_tool/egg_writer.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/maidroid_tool/egg_writer.lua b/maidroid_tool/egg_writer.lua index 22aa353..972d4b5 100644 --- a/maidroid_tool/egg_writer.lua +++ b/maidroid_tool/egg_writer.lua @@ -130,9 +130,10 @@ do -- register egg writer } local function get_nearest_egg_entity(pos) - local all_objects = minetest.get_objects_inside_radius(pos, 1.0) + pos.y = pos.y + 0.25 -- egg entity is above. + local all_objects = minetest.get_objects_inside_radius(pos, 0.2) for _, object in ipairs(all_objects) do - if object:get_luaentity().name == "maidroid_tool:egg_entity" then + if object:get_luaentity() ~= nil and object:get_luaentity().name == "maidroid_tool:egg_entity" then return object:get_luaentity() end end @@ -273,7 +274,7 @@ do -- register a definition of an egg entity on_step = on_step, initialize = initialize, output = "", - current_egg = "", + current_egg = "maidroid:empty_egg", center_position = nil, is_moving = false, angle = 0, From a2a682b877fade5667ef665bafb8cb0ae32668c9 Mon Sep 17 00:00:00 2001 From: tacigar Date: Fri, 23 Dec 2016 01:06:57 +0900 Subject: [PATCH 2/3] Fix core writer --- maidroid_tool/core_writer.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maidroid_tool/core_writer.lua b/maidroid_tool/core_writer.lua index 3047939..1a4b7ec 100644 --- a/maidroid_tool/core_writer.lua +++ b/maidroid_tool/core_writer.lua @@ -115,7 +115,8 @@ do -- register core writer -- get_nearest_core_entity returns the nearest core entity. local function get_nearest_core_entity(pos) - local all_objects = minetest.get_objects_inside_radius(pos, 1.0) + pos.y = pos.y + 0.65 + local all_objects = minetest.get_objects_inside_radius(pos, 0.1) for _, object in ipairs(all_objects) do if object:get_luaentity().name == "maidroid_tool:core_entity" then return object:get_luaentity() From d5c10eee5f8a71724cd3a0b86c235ff2cfda3276 Mon Sep 17 00:00:00 2001 From: tacigar Date: Fri, 23 Dec 2016 01:23:12 +0900 Subject: [PATCH 3/3] Fix egg writer --- maidroid_tool/api.lua | 4 ++-- maidroid_tool/egg_writer.lua | 17 ++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/maidroid_tool/api.lua b/maidroid_tool/api.lua index 6630336..7facdef 100644 --- a/maidroid_tool/api.lua +++ b/maidroid_tool/api.lua @@ -63,7 +63,7 @@ function maidroid_tool.register_writer(nodename, options) swap_node(pos, nodename) if on_deactivate ~= nil then -- call on_deactivate callback. - on_deactivate(pos) + on_deactivate(pos, output) end end else @@ -86,7 +86,7 @@ function maidroid_tool.register_writer(nodename, options) swap_node(pos, nodename .. "_active") if on_activate ~= nil then -- call on_activate callback. - on_activate(pos, output) + on_activate(pos) end end end diff --git a/maidroid_tool/egg_writer.lua b/maidroid_tool/egg_writer.lua index 972d4b5..c7d4928 100644 --- a/maidroid_tool/egg_writer.lua +++ b/maidroid_tool/egg_writer.lua @@ -140,12 +140,12 @@ do -- register egg writer return nil end - local function on_deactivate(pos) + local function on_deactivate(pos, output) local egg_entity = get_nearest_egg_entity(pos) - egg_entity:stop_move() + egg_entity:stop_move(output) end - local function on_activate(pos, output) + local function on_activate(pos) local egg_entity = get_nearest_egg_entity(pos) egg_entity.object:set_properties{textures={"maidroid:empty_egg"}} egg_entity:start_move(output) @@ -192,7 +192,6 @@ do -- register a definition of an egg entity self.is_moving = data["is_moving"] self.center_position = data["center_position"] - self.output = data["output"] self.current_egg = data["current_egg"] self.object:set_properties{textures={self.current_egg}} @@ -208,21 +207,18 @@ do -- register a definition of an egg entity local function start_move(self, output) self.is_moving = true - self.output = output end - local function stop_move(self) - self.object:set_properties{textures={self.output}} + local function stop_move(self, output) + self.object:set_properties{textures={output}} self.is_moving = false - self.current_egg = self.output - self.output = "" + self.current_egg = output end local function get_staticdata(self) local data = { ["is_moving"] = self.is_moving, ["center_position"] = self.center_position, - ["output"] = self.output, ["current_egg"] = self.current_egg, } return minetest.serialize(data) @@ -273,7 +269,6 @@ do -- register a definition of an egg entity get_staticdata = get_staticdata, on_step = on_step, initialize = initialize, - output = "", current_egg = "maidroid:empty_egg", center_position = nil, is_moving = false,