mirror of
https://github.com/tacigar/maidroid.git
synced 2025-01-10 16:20:19 +01:00
[UPDATE] Update something
This commit is contained in:
parent
55b0af6189
commit
b1e45725a3
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user