From b1e45725a36f972ab0c343aa7cf7fe7a375f9c7f Mon Sep 17 00:00:00 2001 From: tacigar Date: Tue, 13 Sep 2016 22:11:23 +0900 Subject: [PATCH] [UPDATE] Update something --- maidroid/api.lua | 13 ++++++++----- maidroid_core_basic/init.lua | 2 +- maidroid_core_basic/register.lua | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/maidroid/api.lua b/maidroid/api.lua index da89ac2..e4b9570 100644 --- a/maidroid/api.lua +++ b/maidroid/api.lua @@ -3,6 +3,8 @@ -- https://github.com/tacigar/maidroid ------------------------------------------------------------ +maidroid.debug_mode = true + -- maidroid.animation_frames represents the animation frame data -- of "models/maidroid.b3d". maidroid.animation_frames = { @@ -165,7 +167,7 @@ function maidroid.register_maidroid(product_name, def) on_put = function(inv, listname, index, stack, player) if listname == "core" then local core_name = stack:get_name() - local core = registered_cores[core_name] + local core = maidroid.registered_cores[core_name] core.on_start(self) self.core_name = core_name end @@ -178,12 +180,13 @@ function maidroid.register_maidroid(product_name, def) elseif listname == "core" and maidroid.is_core(stack:get_name()) then return stack:get_count() end + print("KOKO", listname, maidroid.is_core(stack:get_name())) return 0 end, on_take = function(inv, listname, index, stack, player) if listname == "core" then - local core = registered_cores[self.core_name] + local core = maidroid.registered_cores[self.core_name] self.core_name = "" core.on_stop(self) end @@ -268,7 +271,7 @@ function maidroid.register_maidroid(product_name, def) -- on_step is a callback function that is called every delta times. function on_step(self, dtime) if (not self.pause) and self.core_name ~= "" then - local core = registered_cores[self.core_name] + local core = maidroid.registered_cores[self.core_name] core.on_step(self, dtime) end end @@ -288,13 +291,13 @@ function maidroid.register_maidroid(product_name, def) if self.pause == true then self.pause = false if self.core_name ~= "" then - local core = registered_cores[self.core_name] + local core = maidroid.registered_cores[self.core_name] core.on_pause(self) end else self.pause = true if self.core_name ~= "" then - local core = registered_cores[self.core_name] + local core = maidroid.registered_cores[self.core_name] core.on_resume(self) end end diff --git a/maidroid_core_basic/init.lua b/maidroid_core_basic/init.lua index be168a4..574c59d 100644 --- a/maidroid_core_basic/init.lua +++ b/maidroid_core_basic/init.lua @@ -8,4 +8,4 @@ maidroid_core_basic = {} maidroid_core_basic.modname = "maidroid_core_basic" maidroid_core_basic.modpath = minetest.get_modpath(maidroid_core_basic.modname) -dofile(maidroid.modpath .. "/register.lua") +dofile(maidroid_core_basic.modpath .. "/register.lua") diff --git a/maidroid_core_basic/register.lua b/maidroid_core_basic/register.lua index 21c1a58..f63b460 100644 --- a/maidroid_core_basic/register.lua +++ b/maidroid_core_basic/register.lua @@ -31,10 +31,10 @@ local function on_step(self, dtime) local direction = vector.subtract(player_position, position) local velocity = self.object:getvelocity() - if vector.length(dir) < 3 then + if vector.length(direction) < 3 then if self.state == state.ACCOMPANY then self:set_animation(maidroid.animation_frames.STAND) - self.state = state.idle + self.state = state.IDLE self.object:setvelocity{x = 0, y = velocity.y, z = 0} end else @@ -47,7 +47,7 @@ local function on_step(self, dtime) self:set_yaw_by_direction(direction) -- if maidroid is stoped by obstacle, the maidroid must jump. - if velocity == 0 and self.state = state.ACCOMPANY then + if velocity == 0 and self.state == state.ACCOMPANY then local front_node = self:get_front_node() if front_node.name ~= "air" then self.object:setvelocity{x = direction.x, y = 3, z = direction.z}