add mobtamer tool
This commit is contained in:
parent
f586737971
commit
237e5a3215
1
init.lua
1
init.lua
@ -4,3 +4,4 @@
|
||||
dofile(minetest.get_modpath("vivarium") .. "/falling_light.lua")
|
||||
dofile(minetest.get_modpath("vivarium") .. "/staves.lua")
|
||||
dofile(minetest.get_modpath("vivarium") .. "/capturing.lua")
|
||||
dofile(minetest.get_modpath("vivarium") .. "/mobtamer.lua")
|
||||
|
51
mobtamer.lua
Normal file
51
mobtamer.lua
Normal file
@ -0,0 +1,51 @@
|
||||
minetest.register_tool("vivarium:mobtamer", {
|
||||
description = "Mob Tamer",
|
||||
inventory_image = "mobs_nametag.png^[colorize:blue:90",
|
||||
wield_image = "mobs_nametag.png^[colorize:blue:90",
|
||||
range = 5,
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local maxuses = 30
|
||||
|
||||
local pos = user:getpos()
|
||||
pos = {x=pos.x+math.random(1,2),y=pos.y+1,z=pos.z+math.random(1,2)}
|
||||
|
||||
-- here get the mob to the left
|
||||
local inventory = user:get_inventory()
|
||||
local eggname = ''
|
||||
for idx,x in pairs(inventory:get_list("main") ) do
|
||||
if x:get_name() == "vivarium:mobtamer" then
|
||||
break
|
||||
end
|
||||
eggname = x:get_name()
|
||||
end
|
||||
|
||||
|
||||
local luaobj = minetest.add_entity(pos,eggname )
|
||||
local luae = luaobj:get_luaentity()
|
||||
if luae then
|
||||
inventory:remove_item("main", eggname)
|
||||
|
||||
luae.type="npc"
|
||||
luae.attacks_monsters=true
|
||||
luae.state="walk"
|
||||
bomf(pos,2 )
|
||||
else
|
||||
luaobj:remove()
|
||||
minetest.chat_send_player(user:get_player_name(),"Not a mob!")
|
||||
end
|
||||
|
||||
itemstack:add_wear(math.ceil(65536/maxuses))
|
||||
return itemstack
|
||||
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "vivarium:mobtamer",
|
||||
recipe = {
|
||||
{"mobs:leather","mobs:magic_lasso","mobs:leather"},
|
||||
{"mobs:nametag","mobs:nametag","mobs:nametag"}
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user