75 lines
1.8 KiB
Lua
75 lines
1.8 KiB
Lua
PyuTest.make_item = function(nsname, 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
|
|
|
|
core.register_craftitem(nsname, conf)
|
|
end
|
|
|
|
PyuTest.make_tool = function(nsname, desc, groups, wield_image, extra_conf)
|
|
local conf = {
|
|
description = Translate(desc),
|
|
wield_image = wield_image,
|
|
inventory_image = wield_image,
|
|
groups = PyuTest.util.tableconcat(groups, {
|
|
tool = 1,
|
|
})
|
|
}
|
|
|
|
if extra_conf ~= nil then
|
|
for k, v in pairs(extra_conf) do
|
|
conf[k] = v
|
|
end
|
|
end
|
|
|
|
core.register_tool(nsname, conf)
|
|
end
|
|
|
|
PyuTest.make_sword = function(nsname, desc, texture, damage, durability, atkspeed)
|
|
PyuTest.make_tool(nsname, desc, {
|
|
weapon = 1,
|
|
sword = 1
|
|
}, texture, {
|
|
stack_max = 1,
|
|
tool_capabilities = PyuTest.tool_caps({
|
|
uses = durability / 2,
|
|
attack_uses = durability,
|
|
damage_groups = { fleshy = damage or 3 },
|
|
full_punch_interval = atkspeed or 1
|
|
})
|
|
})
|
|
end
|
|
|
|
PyuTest.make_food = function(nsname, desc, wield_image, hunger_fill, cook_into, extra_code)
|
|
PyuTest.make_item(nsname, desc .. string.format("\nHeals %d health", hunger_fill), {
|
|
food = 1
|
|
}, wield_image, {
|
|
on_use = function(itemstack, user, pt)
|
|
if user == nil then return end
|
|
core.sound_play({ name = "eat", gain = 1 }, { pos = user:get_pos(), start_time = 1.2 })
|
|
PyuTest.hunger_add(user:get_player_name(), hunger_fill)
|
|
if extra_code then extra_code() end
|
|
|
|
itemstack:take_item()
|
|
return itemstack
|
|
end,
|
|
})
|
|
|
|
if cook_into ~= nil then
|
|
core.register_craft({
|
|
type = "cooking",
|
|
output = cook_into,
|
|
recipe = nsname
|
|
})
|
|
end
|
|
end
|