forked from theFox6/working_villages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommanding_sceptre.lua
37 lines (35 loc) · 1.05 KB
/
commanding_sceptre.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
minetest.register_tool("smart_villages:commanding_sceptre", {
description = "villager commanding sceptre",
inventory_image = "smart_villages_commanding_sceptre.png",
on_use = function(itemstack, user, pointed_thing)
if (pointed_thing.type == "object") then
local obj = pointed_thing.ref
local luaentity = obj:get_luaentity()
if not smart_villages.is_villager(luaentity.name) then
if luaentity.name == "__builtin:item" then
luaentity:on_punch(user)
end
return
end
local job = luaentity:get_job()
if job ~= nil then
if luaentity.pause == "resting" then
luaentity.pause = "active"
if type(job.on_resume)=="function" then
job.on_resume(luaentity)
end
luaentity:update_infotext()
else
luaentity.pause = "resting"
if type(job.on_pause)=="function" then
job.on_pause(luaentity)
end
luaentity.object:setvelocity{x = 0, y = 0, z = 0}
luaentity:set_animation(smart_villages.animation_frames.STAND)
luaentity:update_infotext()
end
end
return itemstack
end
end
})