167 lines
4.7 KiB
Lua
167 lines
4.7 KiB
Lua
PyuTestCore.make_tool = function (nsname, sname, desc, groups, wield_image, extra_conf)
|
|
local conf = {
|
|
description = Translate(desc),
|
|
wield_image = wield_image,
|
|
inventory_image = wield_image,
|
|
groups = groups
|
|
}
|
|
|
|
if extra_conf ~= nil then
|
|
for k, v in pairs(extra_conf) do
|
|
conf[k] = v
|
|
end
|
|
end
|
|
|
|
minetest.register_tool(nsname, conf)
|
|
minetest.register_alias(sname, nsname)
|
|
end
|
|
|
|
PyuTestCore.make_item = function (nsname, sname, desc, groups, wield_image, extra_conf)
|
|
local conf = {
|
|
description = Translate(desc),
|
|
wield_image = wield_image,
|
|
inventory_image = wield_image,
|
|
groups = groups
|
|
}
|
|
|
|
if extra_conf ~= nil then
|
|
for k, v in pairs(extra_conf) do
|
|
conf[k] = v
|
|
end
|
|
end
|
|
|
|
minetest.register_craftitem(nsname, conf)
|
|
minetest.register_alias(sname, nsname)
|
|
end
|
|
|
|
PyuTestCore.make_food = function (nsname, sname, desc, wield_image, health_fill, extra_code)
|
|
local code = extra_code or function()end
|
|
|
|
PyuTestCore.make_item(nsname, sname, desc, {}, wield_image, {
|
|
on_use = function (itemstack, user, pt)
|
|
if user == nil then return end
|
|
minetest.sound_play({name = "eat", gain = 1}, {pos = user:get_pos(), start_time = 1.2})
|
|
minetest.do_item_eat(health_fill, "", itemstack, user, pt)
|
|
code()
|
|
end
|
|
})
|
|
end
|
|
|
|
PyuTestCore.make_tool("pyutest_core:wooden_pickaxe", "wooden_pickaxe", "Wooden Pickaxe", {}, "wooden-pickaxe.png", {
|
|
stack_max = 1,
|
|
tool_capabilities = {
|
|
groupcaps = {
|
|
block = {
|
|
times = {
|
|
[PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.085,
|
|
[PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.65,
|
|
[PyuTestCore.BLOCK_BREAKABLE_CHOPPY] = 1.2,
|
|
[PyuTestCore.BLOCK_BREAKABLE_MIDDLE] = 2,
|
|
},
|
|
uses = 200,
|
|
}
|
|
},
|
|
punch_attack_uses = 100,
|
|
damage_groups = {fleshy = 2}
|
|
}
|
|
})
|
|
|
|
PyuTestCore.make_tool("pyutest_core:iron_pickaxe", "iron_pickaxe", "Iron Pickaxe", {}, "iron-pickaxe.png", {
|
|
stack_max = 1,
|
|
tool_capabilities = {
|
|
groupcaps = {
|
|
block = {
|
|
times = {
|
|
[PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.035,
|
|
[PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.35,
|
|
[PyuTestCore.BLOCK_BREAKABLE_CHOPPY] = 0.7,
|
|
[PyuTestCore.BLOCK_BREAKABLE_MIDDLE] = 1,
|
|
[PyuTestCore.BLOCK_BREAKABLE_LONG] = 2,
|
|
[PyuTestCore.BLOCK_BREAKABLE_FOREVER] = 4
|
|
},
|
|
uses = 750,
|
|
}
|
|
},
|
|
punch_attack_uses = 375,
|
|
damage_groups = {fleshy = 4}
|
|
}
|
|
})
|
|
|
|
PyuTestCore.make_tool("pyutest_core:diamond_pickaxe", "diamond_pickaxe", "Diamond Pickaxe", {}, "diamond-pickaxe.png", {
|
|
stack_max = 1,
|
|
tool_capabilities = {
|
|
groupcaps = {
|
|
block = {
|
|
times = {
|
|
[PyuTestCore.BLOCK_BREAKABLE_INSTANT] = 0.015,
|
|
[PyuTestCore.BLOCK_BREAKABLE_NORMAL] = 0.15,
|
|
[PyuTestCore.BLOCK_BREAKABLE_CHOPPY] = 0.15,
|
|
[PyuTestCore.BLOCK_BREAKABLE_MIDDLE] = 0.35,
|
|
[PyuTestCore.BLOCK_BREAKABLE_LONG] = 0.85,
|
|
[PyuTestCore.BLOCK_BREAKABLE_FOREVER] = 1.7
|
|
},
|
|
uses = 1200,
|
|
}
|
|
},
|
|
punch_attack_uses = 600,
|
|
damage_groups = {fleshy = 4}
|
|
}
|
|
})
|
|
|
|
PyuTestCore.make_item("pyutest_core:bomb", "bomb", "Bomb", {}, "bomb.png", {
|
|
stack_max = 16,
|
|
on_use = function (_, user)
|
|
if user == nil then
|
|
return
|
|
end
|
|
local pos = user:get_pos()
|
|
PyuTestCore.create_explosion(pos, 2, false, 3, user)
|
|
local stack = user:get_wielded_item()
|
|
stack:set_count(stack:get_count() - 1)
|
|
|
|
user:set_wielded_item(stack)
|
|
end
|
|
})
|
|
|
|
PyuTestCore.make_item("pyutest_core:stick", "stick", "Stick", {}, "stick.png", {
|
|
stack_max = 99
|
|
})
|
|
|
|
PyuTestCore.make_item("pyutest_core:gunpowder", "gunpowder", "Gunpowder", {}, "powder.png", {
|
|
color = "dimgray",
|
|
stack_max = 99
|
|
})
|
|
|
|
PyuTestCore.make_item("pyutest_core:ash", "ash", "Ash", {}, "powder.png", {
|
|
color = "gray",
|
|
stack_max = 99
|
|
})
|
|
|
|
PyuTestCore.make_item("pyutest_core:sugar", "sugar", "Sugar", {}, "powder.png", {
|
|
stack_max = 99
|
|
})
|
|
|
|
PyuTestCore.make_item("pyutest_core:coin", "coin", "Coin", {}, "coin.png", {
|
|
stack_max = 99,
|
|
on_secondary_use = function (_, user)
|
|
local pos = user:get_pos()
|
|
minetest.sound_play({name = "coin", gain = 1}, {
|
|
pos = pos
|
|
})
|
|
return nil
|
|
end
|
|
})
|
|
|
|
PyuTestCore.make_item("pyutest_core:wheat", "wheat", "Wheat", {}, "wheat.png")
|
|
|
|
PyuTestCore.make_item("pyutest_core:apple", "apple", "Apple", {}, "apple.png", {
|
|
on_use = function (itemstack, user, pt)
|
|
if user == nil then return end
|
|
minetest.sound_play({name = "eat", gain = 1}, {pos = user:get_pos(), start_time = 1.2})
|
|
minetest.do_item_eat(3, "", itemstack, user, pt)
|
|
end
|
|
})
|
|
|
|
PyuTestCore.make_food("pyutest_core:apple", "apple", "Apple", "apple.png", 5)
|
|
PyuTestCore.make_food("pyutest_core:bread", "bread", "Bread", "bread.png", 3)
|