This commit is contained in:
d
2016-06-01 11:15:14 +09:00
parent e7e158052f
commit bb590d0141
6 changed files with 24 additions and 26 deletions

View File

@ -45,9 +45,9 @@ function maidroid.modules._aux.get_upper_pos(vec)
end
-- 落ちているアイテムを拾う
function maidroid.modules._aux.get_item(self, radius, target_pred)
function maidroid.modules._aux.pickup_item(self, radius, target_pred)
local pos = self.object:getpos()
local pred = target_list or (function() return true end)
local pred = target_list or (function(itemstring) return true end)
local all_objects = minetest.get_objects_inside_radius(pos, radius)
for _, obj in ipairs(all_objects) do
if not obj:is_player() and obj:get_luaentity() then
@ -57,6 +57,9 @@ function maidroid.modules._aux.get_item(self, radius, target_pred)
local inv = maidroid._aux.get_maidroid_inventory(self)
local stack = ItemStack(itemstring)
local leftover = inv:add_item("main", stack)
minetest.add_item(obj:getpos(), leftover)
obj:get_luaentity().itemstring = ""
obj:remove()
end
end
end

View File

@ -78,6 +78,10 @@ maidroid.register_module("maidroid:farming_module", {
self.object:set_animation(maidroid.animations.mine, 15, 0)
self.object:setvelocity{x = 0, y = 0, z = 0}
end
-- 種を広い集める
_aux.pickup_item(self, 1.5, function(itemstring)
return minetest.get_item_group(itemstring, "seed") > 0
end)
elseif self.state == state.punch then
if self.time_count >= max_punch_time then
if maidroid.util.table_find_value(target_plants_list, forward_node.name) then

View File

@ -80,6 +80,10 @@ maidroid.register_module("maidroid:lumberjack", {
self.object:set_animation(maidroid.animations.mine, 15, 0)
self.object:setvelocity{x = 0, y = 0, z = 0}
end
-- 苗木を拾い集める
_aux.pickup_item(self, 1.5, function(itemstring)
return util.table_find_value(target_sapling_list, itemstring)
end)
elseif self.state == state.punch then
if self.time_count >= max_punch_time then
local punch_flag, forward_upper_pos, forward_upper_node