add random seed for each registered decoration, tidy code

This commit is contained in:
tenplus1 2022-09-13 18:30:55 +01:00
parent 97d15d3ea1
commit 6ac255d4c0
38 changed files with 170 additions and 181 deletions

View File

@ -72,7 +72,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.artichoke,
spread = {x = 100, y = 100, z = 100},
seed = 448,
seed = 123,
octaves = 3,
persist = 0.6
},

View File

@ -1,6 +1,9 @@
local S = farming.intllib
-- asparagus
minetest.register_craftitem("farming:asparagus", {
description = "asparagus",
description = S("asparagus"),
inventory_image = "farming_asparagus.png",
groups = {seed = 2, food_asparagus = 1, flammable = 2},
on_place = function(itemstack, placer, pointed_thing)
@ -14,36 +17,31 @@ local def = {
drawtype = "plantlike",
tiles = {"farming_asparagus_1.png"},
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 3,
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = {
type = "fixed",
fixed = {-6 / 16, -8 / 8, -6 / 16, 6 / 16, 1 / 55, 6 / 16},
},
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(),
place_param2 = 3
sounds = default.node_sound_leaves_defaults()
}
-- stage 1
minetest.register_node("farming:asparagus_1", table.copy(def))
-- stage 2
def.tiles = {"farming_asparagus_2.png"}
minetest.register_node("farming:asparagus_2", table.copy(def))
-- stage 3
def.tiles = {"farming_asparagus_3.png"}
minetest.register_node("farming:asparagus_3", table.copy(def))
-- stage 4
def.tiles = {"farming_asparagus_4.png"}
def.drop = {
@ -53,7 +51,6 @@ def.drop = {
}
minetest.register_node("farming:asparagus_4", table.copy(def))
-- stage 5
def.tiles = {"farming_asparagus_5.png"}
def.drop = {
@ -64,7 +61,6 @@ def.drop = {
}
minetest.register_node("farming:asparagus_5", table.copy(def))
-- add to registered_plants
farming.registered_plants["farming:asparagus"] = {
crop = "farming:asparagus",
@ -83,10 +79,10 @@ minetest.register_decoration({
noise_params = {
offset = -0.1,
scale = farming.asparagus,
spread = {x = 50, y = 50, z = 50},
seed = 4242,
spread = {x = 100, y = 100, z = 100},
seed = 234,
octaves = 3,
persist = 0.7
persist = 0.6
},
y_min = 8,
y_max = 32,

View File

@ -263,7 +263,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.beans,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 345,
octaves = 3,
persist = 0.6
},

View File

@ -97,7 +97,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.beetroot,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 456,
octaves = 3,
persist = 0.6
},

View File

@ -70,7 +70,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.blackberry,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 567,
octaves = 3,
persist = 0.6
},

View File

@ -107,7 +107,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.blueberry,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 678,
octaves = 3,
persist = 0.6
},

View File

@ -77,7 +77,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.cabbage,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 789,
octaves = 3,
persist = 0.6
},

View File

@ -137,7 +137,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.carrot,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 890,
octaves = 3,
persist = 0.6
},

View File

@ -122,7 +122,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.chili,
spread = {x = 100, y = 100, z = 100},
seed = 760,
seed = 901,
octaves = 3,
persist = 0.6
},

View File

@ -113,7 +113,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.coffee,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 12,
octaves = 3,
persist = 0.6
},

View File

@ -186,7 +186,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.corn,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 134,
octaves = 3,
persist = 0.6
},

View File

@ -80,7 +80,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.cucumber,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 245,
octaves = 3,
persist = 0.6
},

View File

@ -1,3 +1,4 @@
local S = farming.intllib
-- eggplant
@ -74,10 +75,10 @@ minetest.register_decoration({
noise_params = {
offset = -0.1,
scale = farming.eggplant,
spread = {x = 50, y = 50, z = 50},
seed = 4242,
spread = {x = 100, y = 100, z = 100},
seed = 356,
octaves = 3,
persist = 0.7
persist = 0.6
},
biomes = {"deciduous_forest"},
y_max = 31000,

View File

@ -144,7 +144,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.garlic,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 467,
octaves = 3,
persist = 0.6
},

View File

@ -270,7 +270,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.grapes,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 578,
octaves = 3,
persist = 0.6
},

View File

@ -71,7 +71,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.lettuce,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 689,
octaves = 3,
persist = 0.6
},

View File

@ -116,7 +116,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.melon,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 790,
octaves = 3,
persist = 0.6
},

View File

@ -97,7 +97,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.mint,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 801,
octaves = 3,
persist = 0.6
},

View File

@ -103,7 +103,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.onion,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 912,
octaves = 3,
persist = 0.6
},

View File

@ -64,7 +64,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.parsley,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 23,
octaves = 3,
persist = 0.6
},

View File

@ -99,7 +99,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.peas,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 132,
octaves = 3,
persist = 0.6
},

View File

@ -166,7 +166,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.pepper,
spread = {x = 100, y = 100, z = 100},
seed = 933,
seed = 243,
octaves = 3,
persist = 0.6
},

View File

@ -154,7 +154,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.pineapple,
spread = {x = 100, y = 100, z = 100},
seed = 917,
seed = 354,
octaves = 3,
persist = 0.6
},

View File

@ -120,7 +120,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.potato,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 465,
octaves = 3,
persist = 0.6
},

View File

@ -224,7 +224,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.pumpkin,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 576,
octaves = 3,
persist = 0.6
},

View File

@ -88,7 +88,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.raspberry,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 687,
octaves = 3,
persist = 0.6
},

View File

@ -85,7 +85,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.rhubarb,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 798,
octaves = 3,
persist = 0.6
},

View File

@ -207,7 +207,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.soy,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 809,
octaves = 3,
persist = 0.6
},

View File

@ -1,3 +1,4 @@
local S = farming.intllib
-- spinach
@ -75,10 +76,10 @@ minetest.register_decoration({
noise_params = {
offset = -0.1,
scale = farming.spinach,
spread = {x = 50, y = 50, z = 50},
seed = 4242,
spread = {x = 100, y = 100, z = 100},
seed = 910,
octaves = 3,
persist = 0.7
persist = 0.6
},
biomes = {"deciduous_forest"},
y_max = 31000,

View File

@ -102,7 +102,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.strawberry,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 143,
octaves = 3,
persist = 0.6
},

View File

@ -163,7 +163,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.sunflower,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 254,
octaves = 3,
persist = 0.6
},

View File

@ -114,7 +114,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.tomato,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 365,
octaves = 3,
persist = 0.6
},

View File

@ -130,7 +130,7 @@ minetest.register_decoration({
offset = 0,
scale = farming.vanilla,
spread = {x = 100, y = 100, z = 100},
seed = 329,
seed = 476,
octaves = 3,
persist = 0.6
},

View File

@ -2,6 +2,7 @@
local S = farming.intllib
--= filter sea water into river water
minetest.register_craft({
output = "bucket:bucket_river_water",
recipe = {
@ -71,14 +72,14 @@ minetest.register_craft({
minetest.register_craftitem("farming:caramel", {
description = S("Caramel"),
inventory_image = "farming_caramel.png",
inventory_image = "farming_caramel.png"
})
minetest.register_craft({
type = "cooking",
cooktime = 6,
output = "farming:caramel",
recipe = "group:food_sugar",
recipe = "group:food_sugar"
})
--= Salt
@ -165,8 +166,9 @@ minetest.register_node("farming:salt_crystal", {
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
},
}
})
minetest.register_craft({
output = "farming:salt 9",
recipe = {
@ -367,13 +369,9 @@ minetest.register_craftitem("farming:cactus_juice", {
groups = {vessel = 1, drink = 1},
on_use = function(itemstack, user, pointed_thing)
if user then
if math.random(5) == 1 then
return minetest.do_item_eat(-1, "vessels:drinking_glass",
itemstack, user, pointed_thing)
else
return minetest.do_item_eat(2, "vessels:drinking_glass",
itemstack, user, pointed_thing)
end
local num = math.random(5) == 1 and -1 or 2
return minetest.do_item_eat(num, "vessels:drinking_glass",
itemstack, user, pointed_thing)
end
end
})

View File

@ -190,29 +190,29 @@ farming.register_hoe(":farming:hoe_diamond", {
-- Toolranks support
if tr then
minetest.override_item("farming:hoe_wood", {
original_description = "Wood Hoe",
description = toolranks.create_description("Wood Hoe")})
minetest.override_item("farming:hoe_wood", {
original_description = "Wood Hoe",
description = toolranks.create_description("Wood Hoe")})
minetest.override_item("farming:hoe_stone", {
original_description = "Stone Hoe",
description = toolranks.create_description("Stone Hoe")})
minetest.override_item("farming:hoe_stone", {
original_description = "Stone Hoe",
description = toolranks.create_description("Stone Hoe")})
minetest.override_item("farming:hoe_steel", {
original_description = "Steel Hoe",
description = toolranks.create_description("Steel Hoe")})
minetest.override_item("farming:hoe_steel", {
original_description = "Steel Hoe",
description = toolranks.create_description("Steel Hoe")})
minetest.override_item("farming:hoe_bronze", {
original_description = "Bronze Hoe",
description = toolranks.create_description("Bronze Hoe")})
minetest.override_item("farming:hoe_bronze", {
original_description = "Bronze Hoe",
description = toolranks.create_description("Bronze Hoe")})
minetest.override_item("farming:hoe_mese", {
original_description = "Mese Hoe",
description = toolranks.create_description("Mese Hoe")})
minetest.override_item("farming:hoe_mese", {
original_description = "Mese Hoe",
description = toolranks.create_description("Mese Hoe")})
minetest.override_item("farming:hoe_diamond", {
original_description = "Diamond Hoe",
description = toolranks.create_description("Diamond Hoe")})
minetest.override_item("farming:hoe_diamond", {
original_description = "Diamond Hoe",
description = toolranks.create_description("Diamond Hoe")})
end
@ -314,13 +314,13 @@ local function throw_potion(itemstack, player)
local dir = player:get_look_dir()
local velocity = 20
obj:setvelocity({
obj:set_velocity({
x = dir.x * velocity,
y = dir.y * velocity,
z = dir.z * velocity
})
obj:setacceleration({
obj:set_acceleration({
x = dir.x * -3,
y = -9.5,
z = dir.z * -3
@ -386,15 +386,9 @@ minetest.register_tool("farming:scythe_mithril", {
local def = minetest.registered_nodes[node.name]
if not def then
return
end
if not def.drop then
return
end
if not def.groups
if not def
or not def.drop
or not def.groups
or not def.groups.plant then
return
end

View File

@ -104,7 +104,7 @@ end
-- Growth Logic
local STAGE_LENGTH_AVG = tonumber(
minetest.settings:get("farming_stage_length")) or 200 -- 160
minetest.settings:get("farming_stage_length")) or 200
local STAGE_LENGTH_DEV = STAGE_LENGTH_AVG / 6
@ -367,8 +367,8 @@ function farming.plant_growth_timer(pos, elapsed, node_name)
growth = 1
else
local night_light = (minetest.get_node_light(light_pos, 0) or 0)
local day_light = (minetest.get_node_light(light_pos, 0.5) or 0)
local night_light = (minetest.get_node_light(light_pos, 0) or 0)
local day_light = (minetest.get_node_light(light_pos, 0.5) or 0)
local night_growth = night_light >= MIN_LIGHT and night_light <= MAX_LIGHT
local day_growth = day_light >= MIN_LIGHT and day_light <= MAX_LIGHT
@ -746,4 +746,9 @@ ddoo("spinach.lua", farming.eggplant)
dofile(farming.path .. "/food.lua")
dofile(farming.path .. "/compatibility.lua") -- Farming Plus compatibility
dofile(farming.path .. "/lucky_block.lua")
if minetest.get_modpath("lucky_block") then
dofile(farming.path .. "/lucky_block.lua")
end
print("[MOD] Farming Redo loaded")

View File

@ -1,85 +1,79 @@
-- add lucky blocks
if minetest.get_modpath("lucky_block") then
lucky_block:add_blocks({
{"dro", {"farming:corn"}, 5},
{"dro", {"farming:coffee_cup_hot"}, 1},
{"dro", {"farming:bread"}, 5},
{"nod", "farming:jackolantern", 0},
{"tro", "farming:jackolantern_on"},
{"nod", "default:river_water_source", 1},
{"tel"},
{"dro", {"farming:trellis", "farming:grapes"}, 5},
{"dro", {"farming:bottle_ethanol"}, 1},
{"nod", "farming:melon", 0},
{"dro", {"farming:donut", "farming:donut_chocolate", "farming:donut_apple"}, 5},
{"dro", {"farming:hemp_leaf", "farming:hemp_fibre", "farming:seed_hemp"}, 10},
{"nod", "fire:permanent_flame", 1},
{"dro", {"farming:chili_pepper", "farming:chili_bowl"}, 5},
{"dro", {"farming:bowl"}, 3},
{"dro", {"farming:saucepan"}, 1},
{"dro", {"farming:pot"}, 1},
{"dro", {"farming:baking_tray"}, 1},
{"dro", {"farming:skillet"}, 1},
{"exp", 4},
{"dro", {"farming:mortar_pestle"}, 1},
{"dro", {"farming:cutting_board"}, 1},
{"dro", {"farming:juicer"}, 1},
{"dro", {"farming:mixing_bowl"}, 1},
{"dro", {"farming:hoe_bronze"}, 1},
{"dro", {"farming:hoe_mese"}, 1},
{"dro", {"farming:hoe_diamond"}, 1},
{"dro", {"farming:hoe_bomb"}, 10},
{"dro", {"farming:turkish_delight"}, 5},
{"lig"},
{"dro", {"farming:scythe_mithril"}, 1},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:carrot_8"},
{"farming:cotton_8", "farming:rhubarb_3"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:pepper_5"},
{"farming:cotton_8", "farming:onion_5"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:beetroot_5"},
{"farming:cotton_8", "farming:barley_7"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:corn_8"},
{"farming:cotton_8", "farming:grapes_8"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:pea_5"},
{"farming:cotton_8", "farming:coffee_5"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:raspberry_4"},
{"farming:cotton_8", "farming:tomato_8"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:chili_8"},
{"farming:cotton_8", "farming:cucumber_4"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:spinach_4"},
{"farming:cotton_8", "farming:eggplant_4"},
}},
{"nod", "default:chest", 0, {
{name = "farming:seed_wheat", max = 15},
{name = "farming:seed_barley", max = 15},
{name = "farming:seed_barley", max = 15},
{name = "farming:seed_hemp", max = 15},
{name = "farming:seed_rye", max = 15},
{name = "farming:seed_rice", max = 15},
{name = "farming:seed_oat", max = 15},
{name = "farming:soil_wet", max = 10},
{name = "farming:cotton_wild", max = 5},
{name = "farming:grapebush", max = 5},
{name = "farming:asparagus", max = 7}
}},
{"dro", {"farming:chili_powder"}, 5}
})
end
lucky_block:add_blocks({
{"dro", {"farming:corn"}, 5},
{"dro", {"farming:coffee_cup_hot"}, 1},
{"dro", {"farming:bread"}, 5},
{"nod", "farming:jackolantern", 0},
{"tro", "farming:jackolantern_on"},
{"nod", "default:river_water_source", 1},
{"tel"},
{"dro", {"farming:trellis", "farming:grapes"}, 5},
{"dro", {"farming:bottle_ethanol"}, 1},
{"nod", "farming:melon", 0},
{"dro", {"farming:donut", "farming:donut_chocolate", "farming:donut_apple"}, 5},
{"dro", {"farming:hemp_leaf", "farming:hemp_fibre", "farming:seed_hemp"}, 10},
{"nod", "fire:permanent_flame", 1},
{"dro", {"farming:chili_pepper", "farming:chili_bowl"}, 5},
{"dro", {"farming:bowl"}, 3},
{"dro", {"farming:saucepan"}, 1},
{"dro", {"farming:pot"}, 1},
{"dro", {"farming:baking_tray"}, 1},
{"dro", {"farming:skillet"}, 1},
{"exp", 4},
{"dro", {"farming:mortar_pestle"}, 1},
{"dro", {"farming:cutting_board"}, 1},
{"dro", {"farming:juicer"}, 1},
{"dro", {"farming:mixing_bowl"}, 1},
{"dro", {"farming:hoe_bronze"}, 1},
{"dro", {"farming:hoe_mese"}, 1},
{"dro", {"farming:hoe_diamond"}, 1},
{"dro", {"farming:hoe_bomb"}, 10},
{"dro", {"farming:turkish_delight"}, 5},
{"lig"},
{"dro", {"farming:scythe_mithril"}, 1},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:carrot_8"},
{"farming:cotton_8", "farming:rhubarb_3"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:pepper_5"},
{"farming:cotton_8", "farming:onion_5"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:beetroot_5"},
{"farming:cotton_8", "farming:barley_7"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:corn_8"},
{"farming:cotton_8", "farming:grapes_8"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:pea_5"},
{"farming:cotton_8", "farming:coffee_5"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:raspberry_4"},
{"farming:cotton_8", "farming:tomato_8"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:chili_8"},
{"farming:cotton_8", "farming:cucumber_4"},
}},
{"sch", "instafarm", 0, true, {
{"farming:wheat_8", "farming:spinach_4"},
{"farming:cotton_8", "farming:eggplant_4"},
}},
{"nod", "default:chest", 0, {
{name = "farming:seed_wheat", max = 15},
{name = "farming:seed_barley", max = 15},
{name = "farming:seed_barley", max = 15},
{name = "farming:seed_hemp", max = 15},
{name = "farming:seed_rye", max = 15},
{name = "farming:seed_rice", max = 15},
{name = "farming:seed_oat", max = 15},
{name = "farming:soil_wet", max = 10},
{name = "farming:cotton_wild", max = 5},
{name = "farming:grapebush", max = 5},
{name = "farming:asparagus", max = 7}
}},
{"dro", {"farming:chili_powder"}, 5}
})

View File

@ -7,9 +7,9 @@ local ROOT_2 = math.sqrt(2.0)
local erf
local erf_inv
local A = 8 * (math.pi - 3.0)/(3.0 * math.pi * (4.0 - math.pi))
local A = 8 * (math.pi - 3.0) / (3.0 * math.pi * (4.0 - math.pi))
local B = 4.0 / math.pi
local C = 2.0/(math.pi * A)
local C = 2.0 / (math.pi * A)
local D = 1.0 / A