forked from mtcontrib/maidroid
Compare commits
4 Commits
nalc-1.0
...
f83705bb6c
Author | SHA1 | Date | |
---|---|---|---|
f83705bb6c | |||
ec56bc4325 | |||
2f63c8aa42 | |||
ea7c3eb27b |
@ -1,3 +1,5 @@
|
||||
※ This repository has not been actively updated for a long time.
|
||||
|
||||
# Maidroid
|
||||
|
||||
<img src=http://i.imgur.com/oWjrLtK.png>
|
||||
|
@ -1,5 +1,9 @@
|
||||
local rod_uses = 100
|
||||
|
||||
local function obj_remove(obj)
|
||||
obj:remove()
|
||||
end
|
||||
|
||||
minetest.register_tool("maidroid_tool:capture_rod", {
|
||||
description = "maidroid tool : capture rod",
|
||||
inventory_image = "maidroid_tool_capture_rod.png",
|
||||
@ -10,6 +14,7 @@ minetest.register_tool("maidroid_tool:capture_rod", {
|
||||
|
||||
local obj = pointed_thing.ref
|
||||
local luaentity = obj:get_luaentity()
|
||||
if not luaentity then return end
|
||||
if not maidroid.is_maidroid(luaentity.name) then
|
||||
if luaentity.name == "__builtin:item" then
|
||||
luaentity:on_punch(user)
|
||||
@ -17,12 +22,17 @@ minetest.register_tool("maidroid_tool:capture_rod", {
|
||||
return
|
||||
end
|
||||
|
||||
if luaentity.is_removed then
|
||||
return
|
||||
end
|
||||
|
||||
luaentity.is_removed = true
|
||||
local drop_pos = vector.add(obj:getpos(), {x = 0, y = 1, z = 0})
|
||||
local maidroid_name = string.split(luaentity.name, ":")[2]
|
||||
local stack = ItemStack("maidroid_tool:captured_" .. maidroid_name .. "_egg")
|
||||
stack:set_metadata(luaentity:get_staticdata())
|
||||
|
||||
obj:remove()
|
||||
minetest.after(0.1, obj_remove, obj)
|
||||
minetest.add_item(drop_pos, stack)
|
||||
itemstack:add_wear(65535 / (rod_uses - 1))
|
||||
|
||||
|
Reference in New Issue
Block a user