forked from mtcontrib/maidroid
Compare commits
5 Commits
nalc-1.0
...
453b6c7400
Author | SHA1 | Date | |
---|---|---|---|
453b6c7400 | |||
f83705bb6c | |||
ec56bc4325 | |||
2f63c8aa42 | |||
ea7c3eb27b |
@ -1,3 +1,5 @@
|
|||||||
|
※ This repository has not been actively updated for a long time.
|
||||||
|
|
||||||
# Maidroid
|
# Maidroid
|
||||||
|
|
||||||
<img src=http://i.imgur.com/oWjrLtK.png>
|
<img src=http://i.imgur.com/oWjrLtK.png>
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
local rod_uses = 100
|
local rod_uses = 100
|
||||||
|
|
||||||
|
local function obj_remove(obj)
|
||||||
|
obj:remove()
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_tool("maidroid_tool:capture_rod", {
|
minetest.register_tool("maidroid_tool:capture_rod", {
|
||||||
description = "maidroid tool : capture rod",
|
description = "maidroid tool : capture rod",
|
||||||
inventory_image = "maidroid_tool_capture_rod.png",
|
inventory_image = "maidroid_tool_capture_rod.png",
|
||||||
@ -10,6 +14,7 @@ minetest.register_tool("maidroid_tool:capture_rod", {
|
|||||||
|
|
||||||
local obj = pointed_thing.ref
|
local obj = pointed_thing.ref
|
||||||
local luaentity = obj:get_luaentity()
|
local luaentity = obj:get_luaentity()
|
||||||
|
if not luaentity then return end
|
||||||
if not maidroid.is_maidroid(luaentity.name) then
|
if not maidroid.is_maidroid(luaentity.name) then
|
||||||
if luaentity.name == "__builtin:item" then
|
if luaentity.name == "__builtin:item" then
|
||||||
luaentity:on_punch(user)
|
luaentity:on_punch(user)
|
||||||
@ -17,12 +22,17 @@ minetest.register_tool("maidroid_tool:capture_rod", {
|
|||||||
return
|
return
|
||||||
end
|
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 drop_pos = vector.add(obj:getpos(), {x = 0, y = 1, z = 0})
|
||||||
local maidroid_name = string.split(luaentity.name, ":")[2]
|
local maidroid_name = string.split(luaentity.name, ":")[2]
|
||||||
local stack = ItemStack("maidroid_tool:captured_" .. maidroid_name .. "_egg")
|
local stack = ItemStack("maidroid_tool:captured_" .. maidroid_name .. "_egg")
|
||||||
stack:set_metadata(luaentity:get_staticdata())
|
stack:set_metadata(luaentity:get_staticdata())
|
||||||
|
|
||||||
obj:remove()
|
minetest.after(0.1, obj_remove, obj)
|
||||||
minetest.add_item(drop_pos, stack)
|
minetest.add_item(drop_pos, stack)
|
||||||
itemstack:add_wear(65535 / (rod_uses - 1))
|
itemstack:add_wear(65535 / (rod_uses - 1))
|
||||||
|
|
||||||
|
@ -242,13 +242,13 @@ do -- register a definition of an egg entity
|
|||||||
})
|
})
|
||||||
self.object:setpos(new_position)
|
self.object:setpos(new_position)
|
||||||
else
|
else
|
||||||
local cur_position = self.object:getpos()
|
local cur_position = self.object:get_pos()
|
||||||
local new_position = {
|
local new_position = {
|
||||||
x = cur_position.x,
|
x = cur_position.x,
|
||||||
y = self.center_position.y + math.sin(self.angle * math.pi / 180.0) * 0.025,
|
y = self.center_position.y + math.sin(self.angle * math.pi / 180.0) * 0.025,
|
||||||
z = cur_position.z,
|
z = cur_position.z,
|
||||||
}
|
}
|
||||||
self.object:setpos(new_position)
|
self.object:set_pos(new_position)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ do -- register a definition of an egg entity
|
|||||||
self.angle = 0
|
self.angle = 0
|
||||||
self.center_position = pos
|
self.center_position = pos
|
||||||
local init_pos = vector.add(pos, {x = 0.15, y = 0, z = 0})
|
local init_pos = vector.add(pos, {x = 0.15, y = 0, z = 0})
|
||||||
self.object:setpos(init_pos)
|
self.object:set_pos(init_pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("maidroid_tool:egg_entity", {
|
minetest.register_entity("maidroid_tool:egg_entity", {
|
||||||
|
Reference in New Issue
Block a user