1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-12-28 20:05:30 +01:00

[farming] Update from Skyblock

This commit is contained in:
LeMagnesium
2016-03-05 19:14:24 +01:00
parent b25fd961f6
commit bf269a6574
10 changed files with 185 additions and 59 deletions

View File

@@ -2,17 +2,21 @@
-- Hoe registration function
farming.register_hoe = function(name, def)
-- Check for : prefix (register new hoes in your mod's namespace)
if name:sub(1,1) ~= ":" then
name = ":" .. name
end
-- Check def table
if def.description == nil then
def.description = "Hoe"
end
if def.inventory_image == nil then
def.inventory_image = "unknown_item.png"
end
if def.recipe == nil then
def.recipe = {
{"air","air",""},
@@ -20,9 +24,11 @@ farming.register_hoe = function(name, def)
{"","group:stick",""}
}
end
if def.max_uses == nil then
def.max_uses = 30
end
-- Register the tool
minetest.register_tool(name, {
description = def.description,
@@ -31,6 +37,7 @@ farming.register_hoe = function(name, def)
return farming.hoe_on_use(itemstack, user, pointed_thing, def.max_uses)
end
})
-- Register its recipe
-- Registration using material made for MFF
if def.material == nil then
@@ -62,7 +69,9 @@ end
-- Turns dirt with group soil=1 into soil
function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
local pt = pointed_thing
-- check if pointing at a node
if not pt or pt.type ~= "node" then
return
@@ -97,6 +106,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
-- turn the node into soil, wear out item and play sound
minetest.set_node(pt.under, {name = "farming:soil"})
minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5})
if not minetest.setting_getbool("creative_mode") then --MFF DEBUT crabman(26/07/2015) not wearout if creative mod and invtweak refill break tools
local tool_name = itemstack:get_name()