2020-04-23 06:47:24 -07:00
|
|
|
minetest.register_tool("smart_villages:commanding_sceptre", {
|
2018-04-08 01:43:36 -07:00
|
|
|
description = "villager commanding sceptre",
|
2020-04-23 06:47:24 -07:00
|
|
|
inventory_image = "smart_villages_commanding_sceptre.png",
|
2018-04-08 01:43:36 -07:00
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
|
|
if (pointed_thing.type == "object") then
|
|
|
|
local obj = pointed_thing.ref
|
|
|
|
local luaentity = obj:get_luaentity()
|
2020-04-23 06:47:24 -07:00
|
|
|
if not smart_villages.is_villager(luaentity.name) then
|
2018-04-08 01:43:36 -07:00
|
|
|
if luaentity.name == "__builtin:item" then
|
|
|
|
luaentity:on_punch(user)
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local job = luaentity:get_job()
|
|
|
|
if job ~= nil then
|
2018-05-23 06:54:05 -07:00
|
|
|
if luaentity.pause == "resting" then
|
2018-04-08 01:50:55 -07:00
|
|
|
luaentity.pause = "active"
|
2018-05-19 04:36:14 -07:00
|
|
|
if type(job.on_resume)=="function" then
|
|
|
|
job.on_resume(luaentity)
|
|
|
|
end
|
2018-04-08 01:50:55 -07:00
|
|
|
luaentity:update_infotext()
|
2018-04-08 01:43:36 -07:00
|
|
|
else
|
2018-04-26 07:11:22 -07:00
|
|
|
luaentity.pause = "resting"
|
2018-05-19 04:36:14 -07:00
|
|
|
if type(job.on_pause)=="function" then
|
|
|
|
job.on_pause(luaentity)
|
|
|
|
end
|
2018-05-23 06:57:56 -07:00
|
|
|
luaentity.object:setvelocity{x = 0, y = 0, z = 0}
|
2020-04-23 06:47:24 -07:00
|
|
|
luaentity:set_animation(smart_villages.animation_frames.STAND)
|
2018-04-26 07:11:22 -07:00
|
|
|
luaentity:update_infotext()
|
2018-04-08 01:43:36 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|