1
0
mirror of https://codeberg.org/tenplus1/farming.git synced 2024-12-26 02:30:20 +01:00

updating to newer 0.4.16 functions

This commit is contained in:
TenPlus1 2017-10-09 11:32:00 +01:00
parent 4c2965a524
commit ce0c3e8eb8
6 changed files with 12 additions and 10 deletions

View File

@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
Changelog: Changelog:
1.29 - Updating functions so requires Minetest 0.4.16 and above to run
1.28 - Added chili peppers and bowl of chili, optimized code and fixed a few bugs, added porridge 1.28 - Added chili peppers and bowl of chili, optimized code and fixed a few bugs, added porridge
1.27 - Added meshoptions to api and wheat plants, added farming.rarity setting to spawn more/less crops on map, have separate cotton/string items (4x cotton = 1x wool, 2x cotton = 2x string) 1.27 - Added meshoptions to api and wheat plants, added farming.rarity setting to spawn more/less crops on map, have separate cotton/string items (4x cotton = 1x wool, 2x cotton = 2x string)
1.26 - Added support for [toolranks] mod when using hoe's 1.26 - Added support for [toolranks] mod when using hoe's

View File

@ -121,7 +121,7 @@ minetest.register_node("farming:beanpole", {
minetest.set_node(pointed_thing.above, {name = "farming:beanpole"}) minetest.set_node(pointed_thing.above, {name = "farming:beanpole"})
if not minetest.setting_getbool("creative_mode") then if not farming.is_creative(placer:get_player_name()) then
itemstack:take_item() itemstack:take_item()
end end

View File

@ -116,7 +116,7 @@ minetest.register_node("farming:trellis", {
minetest.set_node(pointed_thing.above, {name = "farming:trellis"}) minetest.set_node(pointed_thing.above, {name = "farming:trellis"})
if not minetest.setting_getbool("creative_mode") then if not farming.is_creative(placer:get_player_name()) then
itemstack:take_item() itemstack:take_item()
end end

View File

@ -69,7 +69,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
if not pt or pt.type ~= "node" then if not pt or pt.type ~= "node" then
return return
end end
local under = minetest.get_node(pt.under) local under = minetest.get_node(pt.under)
local upos = pointed_thing.under local upos = pointed_thing.under
@ -80,23 +80,23 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
local p = {x = pt.under.x, y = pt.under.y + 1, z = pt.under.z} local p = {x = pt.under.x, y = pt.under.y + 1, z = pt.under.z}
local above = minetest.get_node(p) local above = minetest.get_node(p)
-- return if any of the nodes is not registered -- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] if not minetest.registered_nodes[under.name]
or not minetest.registered_nodes[above.name] then or not minetest.registered_nodes[above.name] then
return return
end end
-- check if the node above the pointed thing is air -- check if the node above the pointed thing is air
if above.name ~= "air" then if above.name ~= "air" then
return return
end end
-- check if pointing at dirt -- check if pointing at dirt
if minetest.get_item_group(under.name, "soil") ~= 1 then if minetest.get_item_group(under.name, "soil") ~= 1 then
return return
end end
-- turn the node into soil, wear out item and play sound -- turn the node into soil, wear out item and play sound
minetest.set_node(pt.under, {name = "farming:soil"}) minetest.set_node(pt.under, {name = "farming:soil"})
@ -104,7 +104,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
local wear = 65535 / (uses -1) local wear = 65535 / (uses -1)
if minetest.setting_getbool("creative_mode") then if farming.is_creative(user:get_player_name()) then
if tr then if tr then
wear = 1 wear = 1
else else

View File

@ -7,6 +7,7 @@
farming = {} farming = {}
farming.mod = "redo" farming.mod = "redo"
farming.version = "1.29"
farming.path = minetest.get_modpath("farming") farming.path = minetest.get_modpath("farming")
farming.select = { farming.select = {
type = "fixed", type = "fixed",
@ -29,7 +30,7 @@ farming.intllib = S
-- Utility Function -- Utility Function
local time_speed = tonumber(minetest.setting_get("time_speed")) or 72 local time_speed = tonumber(minetest.settings:get("time_speed")) or 72
local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60 / time_speed) or 0 local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60 / time_speed) or 0
local function clamp(x, min, max) local function clamp(x, min, max)
return (x < min and min) or (x > max and max) or x return (x < min and min) or (x > max and max) or x

View File

@ -39,7 +39,7 @@ register_plant("beanbush", 18, 35, "", -1, farming.beans)
register_plant("grapebush", 25, 45, "", -1, farming.grapes) register_plant("grapebush", 25, 45, "", -1, farming.grapes)
if minetest.get_mapgen_params().mgname == "v6" then if minetest.get_mapgen_setting("mg_name") == "v6" then
register_plant("carrot_8", 1, 30, "group:water", 1, farming.carrot) register_plant("carrot_8", 1, 30, "group:water", 1, farming.carrot)
register_plant("cucumber_4", 1, 20, "group:water", 1, farming.cucumber) register_plant("cucumber_4", 1, 20, "group:water", 1, farming.cucumber)