[UPDATE] Update something

This commit is contained in:
tacigar 2016-09-13 22:11:23 +09:00
parent 55b0af6189
commit b1e45725a3
3 changed files with 12 additions and 9 deletions

View File

@ -3,6 +3,8 @@
-- https://github.com/tacigar/maidroid -- https://github.com/tacigar/maidroid
------------------------------------------------------------ ------------------------------------------------------------
maidroid.debug_mode = true
-- maidroid.animation_frames represents the animation frame data -- maidroid.animation_frames represents the animation frame data
-- of "models/maidroid.b3d". -- of "models/maidroid.b3d".
maidroid.animation_frames = { maidroid.animation_frames = {
@ -165,7 +167,7 @@ function maidroid.register_maidroid(product_name, def)
on_put = function(inv, listname, index, stack, player) on_put = function(inv, listname, index, stack, player)
if listname == "core" then if listname == "core" then
local core_name = stack:get_name() local core_name = stack:get_name()
local core = registered_cores[core_name] local core = maidroid.registered_cores[core_name]
core.on_start(self) core.on_start(self)
self.core_name = core_name self.core_name = core_name
end end
@ -178,12 +180,13 @@ function maidroid.register_maidroid(product_name, def)
elseif listname == "core" and maidroid.is_core(stack:get_name()) then elseif listname == "core" and maidroid.is_core(stack:get_name()) then
return stack:get_count() return stack:get_count()
end end
print("KOKO", listname, maidroid.is_core(stack:get_name()))
return 0 return 0
end, end,
on_take = function(inv, listname, index, stack, player) on_take = function(inv, listname, index, stack, player)
if listname == "core" then if listname == "core" then
local core = registered_cores[self.core_name] local core = maidroid.registered_cores[self.core_name]
self.core_name = "" self.core_name = ""
core.on_stop(self) core.on_stop(self)
end end
@ -268,7 +271,7 @@ function maidroid.register_maidroid(product_name, def)
-- on_step is a callback function that is called every delta times. -- on_step is a callback function that is called every delta times.
function on_step(self, dtime) function on_step(self, dtime)
if (not self.pause) and self.core_name ~= "" then 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) core.on_step(self, dtime)
end end
end end
@ -288,13 +291,13 @@ function maidroid.register_maidroid(product_name, def)
if self.pause == true then if self.pause == true then
self.pause = false self.pause = false
if self.core_name ~= "" then if self.core_name ~= "" then
local core = registered_cores[self.core_name] local core = maidroid.registered_cores[self.core_name]
core.on_pause(self) core.on_pause(self)
end end
else else
self.pause = true self.pause = true
if self.core_name ~= "" then if self.core_name ~= "" then
local core = registered_cores[self.core_name] local core = maidroid.registered_cores[self.core_name]
core.on_resume(self) core.on_resume(self)
end end
end end

View File

@ -8,4 +8,4 @@ maidroid_core_basic = {}
maidroid_core_basic.modname = "maidroid_core_basic" maidroid_core_basic.modname = "maidroid_core_basic"
maidroid_core_basic.modpath = minetest.get_modpath(maidroid_core_basic.modname) maidroid_core_basic.modpath = minetest.get_modpath(maidroid_core_basic.modname)
dofile(maidroid.modpath .. "/register.lua") dofile(maidroid_core_basic.modpath .. "/register.lua")

View File

@ -31,10 +31,10 @@ local function on_step(self, dtime)
local direction = vector.subtract(player_position, position) local direction = vector.subtract(player_position, position)
local velocity = self.object:getvelocity() local velocity = self.object:getvelocity()
if vector.length(dir) < 3 then if vector.length(direction) < 3 then
if self.state == state.ACCOMPANY then if self.state == state.ACCOMPANY then
self:set_animation(maidroid.animation_frames.STAND) 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} self.object:setvelocity{x = 0, y = velocity.y, z = 0}
end end
else else
@ -47,7 +47,7 @@ local function on_step(self, dtime)
self:set_yaw_by_direction(direction) self:set_yaw_by_direction(direction)
-- if maidroid is stoped by obstacle, the maidroid must jump. -- 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() local front_node = self:get_front_node()
if front_node.name ~= "air" then if front_node.name ~= "air" then
self.object:setvelocity{x = direction.x, y = 3, z = direction.z} self.object:setvelocity{x = direction.x, y = 3, z = direction.z}