strawberries; cultured wheat
54
api_ng.lua
|
@ -8,35 +8,6 @@ local table_insert = function(tab,tin)
|
|||
return out
|
||||
end
|
||||
|
||||
farming.enlarge_drop_table = function(item_name,def)
|
||||
--[[
|
||||
insert new seed at beginning of drop table. calculate new rarity.
|
||||
|
||||
example:
|
||||
farming_grain.enlarge_drop("default:grass_4",{items={"farming:seed_wheat"},rarity=8})
|
||||
]]
|
||||
|
||||
local tdrop=minetest.registered_nodes[item_name].drop.items -- get drop.items table of stored item
|
||||
local new_drop={def}
|
||||
|
||||
-- new drop table
|
||||
if tdrop ~= nil then
|
||||
for i=1,#tdrop do
|
||||
new_drop[i+1]=tdrop[i]
|
||||
end
|
||||
end
|
||||
-- calculate new rarity for each element. if all seeds have same rarity then the first element will drop more often than following elements
|
||||
for i=1,#new_drop do
|
||||
new_rarity=2^(#new_drop-i)
|
||||
new_drop[i].rarity=new_rarity
|
||||
end
|
||||
-- grab old drop table
|
||||
local old_def=minetest.registered_nodes[item_name].drop
|
||||
old_def.items=new_drop
|
||||
-- override drop table
|
||||
minetest.override_item(item_name,{drop=old_def})
|
||||
end
|
||||
|
||||
|
||||
-- Register plants
|
||||
farming.register_plant = function(name, def)
|
||||
|
@ -66,8 +37,12 @@ farming.register_plant = function(name, def)
|
|||
def.switch_drop_count = def.steps
|
||||
end
|
||||
end
|
||||
-- wild form, which are placed by mapgen
|
||||
if not def.wildname then
|
||||
|
||||
def.wildname = name
|
||||
end
|
||||
if not def.max_harvest then
|
||||
def.max_harvest = 2
|
||||
end
|
||||
if not def.spawnon then
|
||||
def.spawnon = { spawnon = {"default:dirt_with_grass"},
|
||||
|
@ -155,11 +130,13 @@ farming.register_plant = function(name, def)
|
|||
})
|
||||
|
||||
-- Register growing steps
|
||||
local grad_harvest = def.max_harvest / def.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 step_harvest = math.floor(i * grad_harvest + 0.05)
|
||||
-- create drop table
|
||||
local drop = {
|
||||
items = {
|
||||
|
@ -171,11 +148,13 @@ farming.register_plant = function(name, def)
|
|||
table.insert(drop.items,1,{items={seed_name}})
|
||||
end
|
||||
-- with higher grow levels you harvest more
|
||||
if (i >= def.switch_drop_count ) then
|
||||
table.insert(drop.items,1,{items={harvest_name},rarity=base_rarity})
|
||||
if step_harvest > 1 then
|
||||
for h = 2,step_harvest do
|
||||
table.insert(drop.items,1,{items={harvest_name},rarity=base_rarity*h})
|
||||
if def.groups.drop_seed ~= nil then
|
||||
table.insert(drop.items,1,{items={seed_name},rarity=base_rarity})
|
||||
table.insert(drop.items,1,{items={seed_name},rarity=base_rarity*h})
|
||||
end
|
||||
end
|
||||
end
|
||||
-- at the end stage you can harvest by change a cultured seed (if defined)
|
||||
if (i == def.steps and def.next_plant ~= nil) then
|
||||
|
@ -226,15 +205,16 @@ farming.register_plant = function(name, def)
|
|||
})
|
||||
|
||||
-- register mapgen
|
||||
print("spawn "..dump(def.spawnon))
|
||||
print("scale "..def.spawnon.scale)
|
||||
-- print("spawn "..dump(def.spawnon))
|
||||
-- print("scale "..def.spawnon.scale)
|
||||
if def.groups[no_spawn] ~= nil then
|
||||
for j,onpl in ipairs(def.spawnon.spawnon) do
|
||||
minetest.register_decoration({
|
||||
deco_type = "simple",
|
||||
place_on = onpl,
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0.12 - 0.08*i,
|
||||
offset = 0.12,
|
||||
scale = def.spawnon.scale, -- 0.006,
|
||||
spread = {x = 200, y = 200, z = 200},
|
||||
seed = 329,
|
||||
|
@ -243,7 +223,7 @@ farming.register_plant = function(name, def)
|
|||
},
|
||||
y_min = def.spawnon.spawn_min,
|
||||
y_max = def.spawnon.spawn_max,
|
||||
decoration = harvest_name.."_1",
|
||||
decoration = def.wildname,
|
||||
spawn_by = def.spawnon.spawnby,
|
||||
num_spawn_by = def.spawnon.spawn_num,
|
||||
})
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
-- Mustard
|
||||
|
||||
farming.register_plant("farming:mustart", {
|
||||
description = "Mustart",
|
||||
paramtype2 = "meshoptions",
|
||||
inventory_image = "farming_mustard.png",
|
||||
steps = 5,
|
||||
switch_drop_count = 3, -- at which stage more harvest
|
||||
minlight = 13,
|
||||
maxlight = default.LIGHT_MAX,
|
||||
fertility = {"grassland"},
|
||||
groups = {food_wheat = 1, flammable = 4,no_seed=1},
|
||||
place_param2 = 3,
|
||||
spawnon = { spawnon = farming.change_soil or {"default:dirt_with_grass"},
|
||||
spawn_min = 0,
|
||||
spawn_max = 42,
|
||||
spawnby = nil,
|
||||
scale = 0.006, -- 0.006
|
||||
spawn_num = -1}
|
||||
})
|
||||
|
||||
|
|
@ -5,7 +5,9 @@ farming.register_plant("farming:wheat", {
|
|||
paramtype2 = "meshoptions",
|
||||
inventory_image = "farming_wheat_seed.png",
|
||||
steps = 8,
|
||||
switch_drop_count = 6, -- at which stage more harvest
|
||||
max_harvest=2,
|
||||
next_plant="farming:culturewheat",
|
||||
next_plant_rarity=12,
|
||||
minlight = 13,
|
||||
maxlight = default.LIGHT_MAX,
|
||||
fertility = {"grassland"},
|
||||
|
@ -19,4 +21,16 @@ farming.register_plant("farming:wheat", {
|
|||
spawn_num = -1}
|
||||
})
|
||||
|
||||
farming.register_plant("farming:culturewheat", {
|
||||
description = "Wheat Seed",
|
||||
paramtype2 = "meshoptions",
|
||||
inventory_image = "farming_culturewheat_seed.png",
|
||||
steps = 4,
|
||||
max_harvest=4,
|
||||
minlight = 11,
|
||||
maxlight = default.LIGHT_MAX,
|
||||
fertility = {"grassland"},
|
||||
groups = {food_wheat = 1, flammable = 4,no_spawn=1},
|
||||
place_param2 = 3,
|
||||
})
|
||||
|
||||
|
|
24
init.lua
|
@ -11,11 +11,24 @@ minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- start loadi
|
|||
-- Load files
|
||||
|
||||
farming.rarety = 0.002 -- 0.006
|
||||
farming.barley = minetest.settings:get("farming.barley") or true
|
||||
farming.blueberry = minetest.settings:get("farming.blueberry") or true
|
||||
farming.blackberry = minetest.settings:get("farming.blackberry") or true
|
||||
farming.potato = minetest.settings:get("farming.potato") or true
|
||||
farming.carrot = minetest.settings:get("farming.carrot") or true
|
||||
farming.chili = minetest.settings:get("farming.chili") or true
|
||||
farming.cocoa = minetest.settings:get("farming.cocoa") or true
|
||||
farming.corn = minetest.settings:get("farming.corn") or true
|
||||
farming.coffee = minetest.settings:get("farming.coffee") or true
|
||||
farming.garlic = minetest.settings:get("farming.garlic") or true
|
||||
farming.mustard = minetest.settings:get("farming.mustard") or true
|
||||
farming.rhubarb = minetest.settings:get("farming.rhubard") or true
|
||||
farming.spelt = minetest.settings:get("farming.spelt") or true
|
||||
farming.tomato = minetest.settings:get("farming.tomato") or true
|
||||
farming.wheat = minetest.settings:get("farming.wheat") or true
|
||||
farming.cotton = minetest.settings:get("farming.cotton") or true
|
||||
farming.raspberry = minetest.settings:get("farming.raspberry") or true
|
||||
farming.strawberry = minetest.settings:get("farming.strawberry") or true
|
||||
|
||||
dofile(farming.path .. "/config.lua")
|
||||
--[[
|
||||
|
@ -38,11 +51,20 @@ dofile(farming.path .. "/craft.lua")
|
|||
|
||||
|
||||
dofile(farming.path .. "/crops/wheat.lua")
|
||||
dofile(farming.path .. "/crops/spelt.lua")
|
||||
dofile(farming.path .. "/crops/barley.lua")
|
||||
dofile(farming.path .. "/crops/potato.lua")
|
||||
dofile(farming.path .. "/crops/carrot.lua")
|
||||
dofile(farming.path .. "/crops/corn.lua")
|
||||
dofile(farming.path .. "/crops/cocoa.lua")
|
||||
dofile(farming.path .. "/crops/coffee.lua")
|
||||
dofile(farming.path .. "/crops/tomato.lua")
|
||||
dofile(farming.path .. "/crops/barley.lua")
|
||||
dofile(farming.path .. "/crops/blueberry.lua")
|
||||
dofile(farming.path .. "/crops/blackberry.lua")
|
||||
dofile(farming.path .. "/crops/raspberry.lua")
|
||||
dofile(farming.path .. "/crops/strawberry.lua")
|
||||
dofile(farming.path .. "/crops/cotton.lua")
|
||||
dofile(farming.path .. "/crops/rhubarb.lua")
|
||||
|
||||
|
||||
|
||||
|
|
After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 119 B |
After Width: | Height: | Size: 170 B |
After Width: | Height: | Size: 217 B |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 110 B |
After Width: | Height: | Size: 178 B |
After Width: | Height: | Size: 256 B |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 407 B |
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 444 B |
After Width: | Height: | Size: 100 B |
After Width: | Height: | Size: 223 B |
After Width: | Height: | Size: 411 B |
After Width: | Height: | Size: 424 B |
After Width: | Height: | Size: 231 B |
After Width: | Height: | Size: 327 KiB |