Add on_move and allow_move

This commit is contained in:
tacigar 2017-01-07 18:45:53 +09:00
parent 9185079c8b
commit 0011c39158

View File

@ -405,7 +405,37 @@ function maidroid.register_maidroid(product_name, def)
end end
return stack:get_count() return stack:get_count()
end, end,
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
if to_list == "core" or from_list == "core" then
local core_name = inv:get_stack(to_list, to_index):get_name()
local core = maidroid.registered_cores[core_name]
if to_list == "core" then
core.on_start(self)
elseif from_list == "core" then
core.on_stop(self)
end
self:update_infotext()
end
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
if to_list == "wield_item" then
return 0
end
if to_list == "main" then
return count
elseif to_list == "core" and maidroid.is_core(inv:get_stack(from_list, from_index):get_name()) then
return count
end
return 0
end,
}) })
inventory:set_size("main", 16) inventory:set_size("main", 16)
inventory:set_size("core", 1) inventory:set_size("core", 1)
inventory:set_size("wield_item", 1) inventory:set_size("wield_item", 1)