Commit fb9a43a9 authored by Andrea Plati's avatar Andrea Plati

2017.05

parent f536aaa6
......@@ -2,4 +2,5 @@ creative_mode = false
enable_damage = true
enable_tnt = true
give_initial_stuff = true
time_speed = 24
\ No newline at end of file
time_speed = 24
no_sneak_glitch = true
......@@ -13,6 +13,8 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
Changelog:
1.25 - Added check for farming.conf setting file to disable specific crops globally (inside mod folder) or world specific (inside world folder)
1.24 - Added Hemp which can be crafted into fibre, paper, string, rope and oil.
1.23 - Huge code tweak and tidy done and added barley seeds to be found in dry grass, barley can make flour for bread also.
1.22 - Added grape bushes at high climates which can be cultivated into grape vines using trellis (9 sticks).
1.21 - Added auto-refill code for planting crops (thanks crabman77), also fixed a few bugs
......@@ -45,7 +47,7 @@ Changelog:
0.1 - Fixed growing bug
0.0 - Initial release
Lucky Blocks: 10 (plus 3 for default farming items)
Lucky Blocks: 11 (plus 3 for default farming items)
License of media (textures):
......@@ -150,4 +152,5 @@ Created by TenPlus1
farming_rhubarb_2.png
farming_rhubarb_3.png
farming_rhubarb.png
farming_rhubarb_pie.png
\ No newline at end of file
farming_rhubarb_pie.png
farming_hemp*.png
......@@ -6,46 +6,69 @@
local S = farming.intllib
-- beans
minetest.register_craftitem("farming:beans", {
description = S("Green Beans"),
inventory_image = "farming_beans.png",
on_use = minetest.item_eat(1),
-- place beans
function place_beans(itemstack, placer, pointed_thing, plantname)
on_place = function(itemstack, placer, pointed_thing)
local pt = pointed_thing
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return
end
-- check if pointing at a node
if not pt or pt.type ~= "node" then
local nodename = minetest.get_node(pointed_thing.under).name
return
end
if nodename == "farming:beanpole" then
minetest.set_node(pointed_thing.under, {name = "farming:beanpole_1"})
local under = minetest.get_node(pt.under)
minetest.sound_play("default_place_node", {pos = pointed_thing.above, gain = 1.0})
else
return
end
-- return if any of the nodes are not registered
if not minetest.registered_nodes[under.name] then
return
end
if not minetest.setting_getbool("creative_mode") then
-- am I right-clicking on something that has a custom on_place set?
-- thanks to Krock for helping with this issue :)
local def = minetest.registered_nodes[under.name]
if def and def.on_rightclick then
return def.on_rightclick(pt.under, under, placer, itemstack)
end
itemstack:take_item()
-- check if pointing at bean pole
if under.name ~= "farming:beanpole" then
return
end
-- check for refill
if itemstack:get_count() == 0 then
-- add the node and remove 1 item from the itemstack
minetest.set_node(pt.under, {name = plantname})
minetest.after(0.20,
farming.refill_plant,
placer,
"farming:beans",
placer:get_wield_index()
)
end
end
minetest.sound_play("default_place_node", {pos = pt.under, gain = 1.0})
return itemstack
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
-- check for refill
if itemstack:get_count() == 0 then
minetest.after(0.20,
farming.refill_plant,
placer,
"farming:beans",
placer:get_wield_index()
)
end
end
return itemstack
end
-- beans
minetest.register_craftitem("farming:beans", {
description = S("Green Beans"),
inventory_image = "farming_beans.png",
on_use = minetest.item_eat(1),
on_place = function(itemstack, placer, pointed_thing)
return place_beans(itemstack, placer, pointed_thing, "farming:beanpole_1")
end,
})
-- beans can be used for green dye
......@@ -62,7 +85,7 @@ minetest.register_node("farming:beanpole", {
drawtype = "plantlike",
tiles = {"farming_beanpole.png"},
inventory_image = "farming_beanpole.png",
visual_scale = 1.45,
visual_scale = 1.90, -- 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
......@@ -125,7 +148,7 @@ minetest.register_craft({
local crop_def = {
drawtype = "plantlike",
tiles = {"farming_beanpole_1.png"},
visual_scale = 1.45,
visual_scale = 1.90, -- 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
......
......@@ -10,7 +10,6 @@ else
minetest.register_node(":ethereal:banana", {
description = "Banana",
drawtype = "torchlike",
visual_scale = 1.0,
tiles = {"banana_single.png"},
inventory_image = "banana_single.png",
wield_image = "banana_single.png",
......@@ -49,7 +48,7 @@ minetest.register_alias("farming_plus:cocoa_bean", "farming:cocoa_beans")
minetest.register_alias("farming_plus:orange_1", "farming:tomato_1")
minetest.register_alias("farming_plus:orange_2", "farming:tomato_4")
minetest.register_alias("farming_plus:orange_3", "farming:tomato_6")
minetest.register_alias("farming_plus:orange", "farming:tomato_8")
--minetest.register_alias("farming_plus:orange", "farming:tomato_8")
if eth then
minetest.register_alias("farming_plus:orange_item", "ethereal:orange")
......@@ -59,7 +58,6 @@ else
minetest.register_node(":ethereal:orange", {
description = "Orange",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"farming_orange.png"},
inventory_image = "farming_orange.png",
wield_image = "farming_orange.png",
......@@ -142,3 +140,17 @@ minetest.register_alias("farming_plus:tomato", "farming:tomato_8")
-- Weed
minetest.register_alias("farming:weed", "default:grass_2")
-- Classic Bushes compatibility
if minetest.get_modpath("bushes_classic") then
if eth then
minetest.register_alias("bushes:strawberry", "farming:strawberry")
else
minetest.register_alias("bushes:strawberry", "farming:raspberries")
end
minetest.register_alias("bushes:blueberry", "farming:blueberries")
minetest.register_alias("bushes:raspberry", "farming:raspberries")
end
\ No newline at end of file
......@@ -31,9 +31,21 @@ minetest.register_craft({
})
-- ethanol (thanks to JKMurray for this idea)
minetest.register_craftitem("farming:bottle_ethanol", {
minetest.register_node("farming:bottle_ethanol", {
description = S("Bottle of Ethanol"),
drawtype = "plantlike",
tiles = {"farming_bottle_ethanol.png"},
inventory_image = "farming_bottle_ethanol.png",
wield_image = "farming_bottle_ethanol.png",
paramtype = "light",
is_ground_content = false,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
},
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_craft( {
......@@ -89,7 +101,7 @@ minetest.register_node("farming:corn_5", table.copy(crop_def))
-- stage 6
crop_def.tiles = {"farming_corn_6.png"}
crop_def.visual_scale = 1.45
crop_def.visual_scale = 1.9 -- 1.45
minetest.register_node("farming:corn_6", table.copy(crop_def))
-- stage 7
......
......@@ -48,7 +48,7 @@ crop_def.tiles = {"farming_cucumber_4.png"}
crop_def.groups.growing = 0
crop_def.drop = {
items = {
{items = {'farming:cucumber'}, rarity = 1},
{items = {'farming:cucumber 2'}, rarity = 1},
{items = {'farming:cucumber 2'}, rarity = 2},
}
}
......
--[[
Farming settings can be changed here and kept inside mod folder
even after the mod has been updated, or you can place inside
world folder for map specific settings.
--]]
-- true to enable crop/food in-game and on mapgen
farming.carrot = true
farming.potato = true
farming.tomato = true
farming.cucumber = true
farming.corn = true
farming.coffee = true
farming.coffee = true
farming.melon = true
farming.sugar = true
farming.pumpkin = true
farming.cocoa = true
farming.raspberry = true
farming.blueberry = true
farming.rhubarb = true
farming.beans = true
farming.grapes = true
farming.barley = true
farming.hemp = true
farming.donuts = true
......@@ -57,7 +57,7 @@ minetest.register_node("farming:trellis", {
drawtype = "plantlike",
tiles = {"farming_trellis.png"},
inventory_image = "farming_trellis.png",
visual_scale = 1.45,
visual_scale = 1.9, -- 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
......@@ -120,7 +120,7 @@ minetest.register_craft({
local crop_def = {
drawtype = "plantlike",
tiles = {"farming_grapes_1.png"},
visual_scale = 1.45,
visual_scale = 1.9, -- 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
......
local S = farming.intllib
-- hemp seeds
minetest.register_node("farming:seed_hemp", {
description = S("Hemp Seed"),
tiles = {"farming_hemp_seed.png"},
inventory_image = "farming_hemp_seed.png",
wield_image = "farming_hemp_seed.png",
drawtype = "signlike",
groups = {seed = 1, snappy = 3, attached_node = 1},
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
sunlight_propagates = true,
selection_box = farming.select,
on_place = function(itemstack, placer, pointed_thing)
return farming.place_seed(itemstack, placer, pointed_thing, "farming:hemp_1")
end,
})
-- harvested hemp
minetest.register_craftitem("farming:hemp_leaf", {
description = S("Hemp Leaf"),
inventory_image = "farming_hemp_leaf.png",
})
-- hemp oil
minetest.register_node("farming:hemp_oil", {
description = S("Bottle of Hemp Oil"),
drawtype = "plantlike",
tiles = {"farming_hemp_oil.png"},
inventory_image = "farming_hemp_oil.png",
wield_image = "farming_hemp_oil.png",
paramtype = "light",
is_ground_content = false,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
},
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_craft( {
output = "farming:hemp_oil",
recipe = {
{"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
{"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
{"", "vessels:glass_bottle", ""}
}
})
minetest.register_craft( {
output = "farming:hemp_oil",
recipe = {
{"farming:seed_hemp", "farming:seed_hemp", "farming:seed_hemp"},
{"farming:seed_hemp", "farming:seed_hemp", "farming:seed_hemp"},
{"farming:seed_hemp", "vessels:glass_bottle", "farming:seed_hemp"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "farming:hemp_oil",
burntime = 20,
replacements = {{ "farming:hemp_oil", "vessels:glass_bottle"}}
})
-- hemp fibre
minetest.register_craftitem("farming:hemp_fibre", {
description = S("Hemp Fibre"),
inventory_image = "farming_hemp_fibre.png",
})
minetest.register_craft( {
output = "farming:hemp_fibre 8",
recipe = {
{"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
{"farming:hemp_leaf", "bucket:bucket_water", "farming:hemp_leaf"},
{"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"}
},
replacements = {{ "bucket:bucket_water", "bucket:bucket_empty"}}
})
minetest.register_craft( {
output = "farming:hemp_fibre 8",
recipe = {
{"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
{"farming:hemp_leaf", "bucket:bucket_river_water", "farming:hemp_leaf"},
{"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"}
},
replacements = {{ "bucket:bucket_river_water", "bucket:bucket_empty"}}
})
-- paper
minetest.register_craft( {
output = "default:paper",
recipe = {
{"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
}
})
-- string
minetest.register_craft( {
output = "farming:cotton",
recipe = {
{"farming:hemp_fibre"},
{"farming:hemp_fibre"},
{"farming:hemp_fibre"},
}
})
-- hemp rope
minetest.register_node("farming:hemp_rope", {
description = S("Hemp Rope"),
walkable = false,
climbable = true,
sunlight_propagates = true,
paramtype = "light",
tiles = {"farming_hemp_rope.png"},
wield_image = "farming_hemp_rope.png",
inventory_image = "farming_hemp_rope.png",
drawtype = "plantlike",
groups = {flammable = 2, choppy = 3, oddly_breakable_by_hand = 3},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
})
-- string
minetest.register_craft( {
output = "farming:hemp_rope 6",
recipe = {
{"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
{"farming:cotton", "farming:cotton", "farming:cotton"},
{"farming:hemp_fibre", "farming:hemp_fibre", "farming:hemp_fibre"},
}
})
-- hemp definition
local crop_def = {
drawtype = "plantlike",
tiles = {"farming_hemp_1.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults()
}
-- stage 1
minetest.register_node("farming:hemp_1", table.copy(crop_def))
-- stage 2
crop_def.tiles = {"farming_hemp_2.png"}
minetest.register_node("farming:hemp_2", table.copy(crop_def))
-- stage 3
crop_def.tiles = {"farming_hemp_3.png"}
minetest.register_node("farming:hemp_3", table.copy(crop_def))
-- stage 4
crop_def.tiles = {"farming_hemp_4.png"}
minetest.register_node("farming:hemp_4", table.copy(crop_def))
-- stage 5
crop_def.tiles = {"farming_hemp_5.png"}
minetest.register_node("farming:hemp_5", table.copy(crop_def))
-- stage 6
crop_def.tiles = {"farming_hemp_6.png"}
crop_def.drop = {
items = {
{items = {'farming:hemp_leaf'}, rarity = 2},
{items = {'farming:seed_hemp'}, rarity = 1},
}
}
minetest.register_node("farming:hemp_6", table.copy(crop_def))
-- stage 7
crop_def.tiles = {"farming_hemp_7.png"}
crop_def.drop = {
items = {
{items = {'farming:hemp_leaf'}, rarity = 1},
{items = {'farming:hemp_leaf'}, rarity = 3},
{items = {'farming:seed_hemp'}, rarity = 1},
{items = {'farming:seed_hemp'}, rarity = 3},
}
}
minetest.register_node("farming:hemp_7", table.copy(crop_def))
-- stage 8 (final)
crop_def.tiles = {"farming_hemp_8.png"}
crop_def.groups.growing = 0
crop_def.drop = {
items = {
{items = {'farming:hemp_leaf 2'}, rarity = 1},
{items = {'farming:hemp_leaf'}, rarity = 2},
{items = {'farming:seed_hemp'}, rarity = 1},
{items = {'farming:seed_hemp'}, rarity = 2},
}
}
minetest.register_node("farming:hemp_8", table.copy(crop_def))
--[[
Minetest Farming Redo Mod 1.23 (12th November 2016)
Farming Redo Mod 1.25 (6th May 2017)
by TenPlus1
NEW growing routine by prestidigitator
auto-refill by crabman77
......@@ -14,38 +14,6 @@ farming.select = {
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
}
farming.DEBUG = false
-- farming.DEBUG = {} -- Uncomment to turn on profiling code/functions
local DEBUG_abm_runs = 0
local DEBUG_abm_time = 0
local DEBUG_timer_runs = 0
local DEBUG_timer_time = 0
if farming.DEBUG then
function farming.DEBUG.reset_times()
DEBUG_abm_runs = 0
DEBUG_abm_time = 0
DEBUG_timer_runs = 0
DEBUG_timer_time = 0
end
function farming.DEBUG.report_times()
local abm_n = DEBUG_abm_runs
local abm_dt = DEBUG_abm_time
local abm_avg = (abm_n > 0 and abm_dt / abm_n) or 0
local timer_n = DEBUG_timer_runs
local timer_dt = DEBUG_timer_time
local timer_avg = (timer_n > 0 and timer_dt / timer_n) or 0
local dt = abm_dt + timer_dt
print("ABM ran for "..abm_dt.."µs over "..abm_n.." runs: "..abm_avg.."µs/run")
print("Timer ran for "..timer_dt.."µs over "..timer_n.." runs: "..timer_avg.."µs/run")
print("Total farming time: "..dt.."µs")
end
end
local statistics = dofile(farming.path.."/statistics.lua")
......@@ -163,7 +131,7 @@ local function plant_name_stage(node)
local name
if type(node) == 'table' then
if type(node) == "table" then
if node.name then
name = node.name
......@@ -346,30 +314,13 @@ end
minetest.after(0, function()
for _, node_def in pairs(minetest.registered_nodes) do
for _, node_def in ipairs(minetest.registered_nodes) do
register_plant_node(node_def)
end
end)
local abm_func = farming.handle_growth
if farming.DEBUG then
local normal_abm_func = abm_func
abm_func = function(...)
local t0 = minetest.get_us_time()
local r = { normal_abm_func(...) }
local t1 = minetest.get_us_time()
DEBUG_abm_runs = DEBUG_abm_runs + 1
DEBUG_abm_time = DEBUG_abm_time + (t1 - t0)
return unpack(r)
end
end
-- Just in case a growing type or added node is missed (also catches existing
-- nodes added to map before timers were incorporated).
......@@ -399,8 +350,7 @@ function farming.plant_growth_timer(pos, elapsed, node_name)
if stages.plant_name == "farming:cocoa" then
if not minetest.find_node_near(pos, 1,
{"default:jungletree", "moretrees:jungletree_leaves_green"}) then
if not minetest.find_node_near(pos, 1, {"default:jungletree"}) then
return true
end
......@@ -465,23 +415,6 @@ function farming.plant_growth_timer(pos, elapsed, node_name)
return growth ~= max_growth
end
if farming.DEBUG then
local timer_func = farming.plant_growth_timer;
farming.plant_growth_timer = function(pos, elapsed, node_name)
local t0 = minetest.get_us_time()
local r = { timer_func(pos, elapsed, node_name) }
local t1 = minetest.get_us_time()
DEBUG_timer_runs = DEBUG_timer_runs + 1
DEBUG_timer_time = DEBUG_timer_time + (t1 - t0)
return unpack(r)
end
end
-- refill placed plant by crabman (26/08/2015)
local can_refill_plant = {
["farming:blueberry_1"] = "farming:blueberries",
......@@ -502,6 +435,7 @@ local can_refill_plant = {
["farming:rhubarb_1"] = "farming:rhubarb",
["farming:cocoa_1"] = "farming:cocoa_beans",
["farming:barley_1"] = "farming:seed_barley",
["farming:hemp_1"] = "farming:seed_hemp",
}
function farming.refill_plant(player, plantname, index)
......@@ -513,7 +447,7 @@ function farming.refill_plant(player, plantname, index)
return
end
for i, stack in pairs(inv:get_list("main")) do
for i, stack in ipairs(inv:get_list("main")) do
if stack:get_name() == plantname and i ~= index then
......@@ -595,7 +529,7 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname)
end
end
-- Function to register plants (for compatibility)
-- Function to register plants (default farming compatibility)
farming.register_plant = function(name, def)
......@@ -645,15 +579,19 @@ farming.register_plant = function(name, def)
-- Register growing steps
for i = 1, def.steps do
local base_rarity = 1
if def.steps ~= 1 then
base_rarity = 8 - (i - 1) * 7 / (def.steps - 1)
end
local drop = {
items = {
{items = {mname .. ":" .. pname}, rarity = 9 - i},
{items = {mname .. ":" .. pname}, rarity= 18 - i * 2},
{items = {mname .. ":seed_" .. pname}, rarity = 9 - i},
{items = {mname .. ":seed_" .. pname}, rarity = 18 - i * 2},
{items = {mname .. ":" .. pname}, rarity = base_rarity},
{items = {mname .. ":" .. pname}, rarity = base_rarity * 2},
{items = {mname .. ":seed_" .. pname}, rarity = base_rarity},
{items = {mname .. ":seed_" .. pname}, rarity = base_rarity * 2},
}
}
local g = {snappy = 3, flammable = 2, plant = 1, not_in_creative_inventory = 1, attached_node = 1, growing = 1}
-- Last step doesn't need growing=1 so Abm never has to check these
......@@ -676,7 +614,7 @@ farming.register_plant = function(name, def)
sounds = default.node_sound_leaves_defaults(),
})
-- register_plant_node(node_name)
register_plant_node(node_name)
end
-- Return info
......@@ -684,30 +622,71 @@ farming.register_plant = function(name, def)
return r
end
-- load crops
-- default settings
farming.carrot = true
farming.potato = true
farming.tomato = true
farming.cucumber = true
farming.corn = true
farming.coffee = true
farming.coffee = true
farming.melon = true
farming.sugar = true
farming.pumpkin = true
farming.cocoa = true
farming.raspberry = true
farming.blueberry = true
farming.rhubarb = true
farming.beans = true
farming.grapes = true
farming.barley = true
farming.hemp = true
farming.donuts = true
-- Load new global settings if found inside mod folder
local input = io.open(farming.path.."/farming.conf", "r")
if input then
dofile(farming.path .. "/farming.conf")
input:close()
input = nil
end
-- load new world-specific settings if found inside world folder
local worldpath = minetest.get_worldpath()
local input = io.open(worldpath.."/farming.conf", "r")
if input then
dofile(worldpath .. "/farming.conf")
input:close()
input = nil