1
0
mirror of https://github.com/tacigar/maidroid.git synced 2025-08-07 08:10:19 +02:00

5 Commits

5 changed files with 20 additions and 4 deletions

View File

@ -11,3 +11,5 @@ maidroid.modpath = minetest.get_modpath(maidroid.modname)
dofile(maidroid.modpath .. "/api.lua")
dofile(maidroid.modpath .. "/register.lua")
dofile(maidroid.modpath .. "/crafting.lua")
minetest.log("action", "[maidroid] loaded.")

View File

@ -16,3 +16,5 @@ dofile(maidroid_core.modpath .. "/cores/torcher.lua")
if minetest.global_exists("pdisc") then
dofile(maidroid_core.modpath .. "/cores/ocr.lua")
end
minetest.log("action", "[maidroid_core] loaded.")

View File

@ -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))

View File

@ -242,13 +242,13 @@ do -- register a definition of an egg entity
})
self.object:setpos(new_position)
else
local cur_position = self.object:getpos()
local cur_position = self.object:get_pos()
local new_position = {
x = cur_position.x,
y = self.center_position.y + math.sin(self.angle * math.pi / 180.0) * 0.025,
z = cur_position.z,
}
self.object:setpos(new_position)
self.object:set_pos(new_position)
end
end
@ -256,7 +256,7 @@ do -- register a definition of an egg entity
self.angle = 0
self.center_position = pos
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
minetest.register_entity("maidroid_tool:egg_entity", {

View File

@ -14,3 +14,5 @@ dofile(maidroid_tool.modpath .. "/egg_writer.lua")
dofile(maidroid_tool.modpath .. "/crafting.lua")
dofile(maidroid_tool.modpath .. "/nametag.lua")
dofile(maidroid_tool.modpath .. "/capture_rod.lua")
minetest.log("action", "[maidroid_tool] loaded.")