replaced capture rod with commanding sceptre

master
theFox6 2018-04-08 10:43:36 +02:00
parent a8efc6ddd2
commit 6f4ae9964b
9 changed files with 32 additions and 132 deletions

View File

@ -1,131 +0,0 @@
local rod_uses = 100
minetest.register_tool("working_villages:capture_rod", {
description = "villager capturing rod",
inventory_image = "maidroid_tool_capture_rod.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 working_villages.is_villager(luaentity.name) then
if luaentity.name == "__builtin:item" then
luaentity:on_punch(user)
end
return
end
local drop_pos = vector.add(obj:getpos(), {x = 0, y = 1, z = 0})
local villager_name = string.split(luaentity.name, ":")[2]
local stack = ItemStack("working_villages:captured_" .. villager_name .. "_egg")
stack:set_metadata(luaentity:get_staticdata())
obj:remove()
minetest.add_item(drop_pos, stack)
itemstack:add_wear(65535 / (rod_uses - 1))
minetest.sound_play("maidroid_tool_capture_rod_use", {pos = drop_pos})
minetest.add_particlespawner({
amount = 20,
time = 0.2,
minpos = drop_pos,
maxpos = drop_pos,
minvel = {x = -1.5, y = 2, z = -1.5},
maxvel = {x = 1.5, y = 4, z = 1.5},
minacc = {x = 0, y = -8, z = 0},
maxacc = {x = 0, y = -4, z = 0},
minexptime = 1,
maxexptime = 1.5,
minsize = 1,
maxsize = 2.5,
collisiondetection = true,
vertical = false,
texture = "maidroid_tool_capture_rod_star.png",
player = user
})
return itemstack
end
end
})
for name, _ in pairs(working_villages.registered_villagers) do
local villager_name = string.split(name, ":")[2]
local egg_def = working_villages.registered_eggs[name .. "_egg"]
local inv_img = "maidroid_tool_capture_rod_plate.png^" .. egg_def.inventory_image
minetest.register_tool("working_villages:captured_" .. villager_name .. "_egg", {
description = "captured " .. egg_def.description,
inventory_image = inv_img,
groups = {not_in_creative_inventory = 1},
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
if pointed_thing.type == "object" then
local luaentity = pointed_thing.ref:get_luaentity()
if luaentity.name == "__builtin:item" then
luaentity:on_punch(user)
end
end
return
end
local meta = itemstack:get_metadata()
local obj = minetest.add_entity(pointed_thing.above, name)
local luaentity = obj:get_luaentity()
luaentity:set_yaw_by_direction(vector.subtract(user:getpos(), obj:getpos()))
luaentity:on_activate(meta)
obj:setvelocity{x =0, y = 5, z = 0}
--workaround: we are not creating a new villager
working_villages.manufacturing_data[name] = working_villages.manufacturing_data[name] - 1
local pos = vector.add(obj:getpos(), {x = 0, y = -0.2, z = 0})
minetest.sound_play("maidroid_tool_capture_rod_open_egg", {pos = pos})
minetest.add_particlespawner({
amount = 30,
time = 0.1,
minpos = pos,
maxpos = pos,
minvel = {x = -2, y = 1.0, z = -2},
maxvel = {x = 2, y = 2.5, z = 2},
minacc = {x = 0, y = -5, z = 0},
maxacc = {x = 0, y = -2, z = 0},
minexptime = 0.5,
maxexptime = 1,
minsize = 0.5,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "maidroid_tool_capture_rod_star.png^[colorize:#ff8000:127",
player = user
})
local rad = user:get_look_horizontal()
minetest.add_particle({
pos = pos,
velocity = {x = math.cos(rad) * 2, y = 1.5, z = math.sin(rad) * 2},
acceleration = {x = 0, y = -3, z = 0},
expirationtime = 1.5,
size = 6,
collisiondetection = false,
vertical = false,
texture = "(" .. inv_img .. "^[resize:32x32)^[mask:maidroid_tool_capture_rod_mask_right.png",
player = user
})
minetest.add_particle({
pos = pos,
velocity = {x = math.cos(rad) * -2, y = 1.5, z = math.sin(rad) * -2},
acceleration = { x = 0, y = -3, z = 0},
expirationtime = 1.5,
size = 6,
collisiondetection = false,
vertical = false,
texture = "(" .. inv_img .. "^[resize:32x32)^[mask:maidroid_tool_capture_rod_mask_left.png",
player = user
})
itemstack:take_item()
return itemstack
end,
})
end

31
commanding_sceptre.lua Normal file
View File

@ -0,0 +1,31 @@
minetest.register_tool("working_villages:commanding_sceptre", {
description = "villager commanding sceptre",
inventory_image = "working_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 working_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 == "active" or luaentity.pause == "sleeping" then
luaentity.pause = "resting"
job.on_pause(self)
elseif luaentity.pause == "resting" then
luaentity.pause == "active"
job.on_resume(self)
else
minetest.log("warning","unknown pause state: "..self.pause)
end
end
return itemstack
end
end
})

View File

@ -17,7 +17,7 @@ dofile(working_villages.modpath.."/homes.lua")
dofile(working_villages.modpath.."/api.lua")
dofile(working_villages.modpath.."/register.lua")
dofile(working_villages.modpath.."/capture_rod.lua")
dofile(working_villages.modpath.."/commanding_sceptre.lua")
--jobs
dofile(working_villages.modpath.."/jobs/util.lua")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B