1
0
mirror of https://codeberg.org/tenplus1/farming.git synced 2025-06-29 06:40:45 +02:00

code tidy and tweak

This commit is contained in:
tenplus1
2020-07-02 14:31:12 +01:00
parent 0aeeb70ca2
commit 6f0383d5b6
38 changed files with 734 additions and 749 deletions

View File

@ -70,13 +70,13 @@ minetest.register_craftitem("farming:cocoa_beans", {
groups = {seed = 2, food_cocoa = 1, flammable = 2},
on_place = function(itemstack, placer, pointed_thing)
return place_cocoa(itemstack, placer, pointed_thing, "farming:cocoa_1")
end,
end
})
minetest.register_craft( {
output = "dye:brown 2",
recipe = {
{ "farming:cocoa_beans" },
{ "farming:cocoa_beans" }
}
})
@ -84,13 +84,13 @@ minetest.register_craft( {
minetest.register_craftitem("farming:cookie", {
description = S("Cookie"),
inventory_image = "farming_cookie.png",
on_use = minetest.item_eat(2),
on_use = minetest.item_eat(2)
})
minetest.register_craft( {
output = "farming:cookie 8",
recipe = {
{"group:food_wheat", "group:food_cocoa", "group:food_wheat" },
{"group:food_wheat", "group:food_cocoa", "group:food_wheat" }
}
})
@ -98,13 +98,13 @@ minetest.register_craft( {
minetest.register_craftitem("farming:chocolate_dark", {
description = S("Bar of Dark Chocolate"),
inventory_image = "farming_chocolate_dark.png",
on_use = minetest.item_eat(3),
on_use = minetest.item_eat(3)
})
minetest.register_craft( {
output = "farming:chocolate_dark",
recipe = {
{"group:food_cocoa", "group:food_cocoa", "group:food_cocoa"},
{"group:food_cocoa", "group:food_cocoa", "group:food_cocoa"}
}
})
@ -114,7 +114,7 @@ minetest.register_node("farming:chocolate_block", {
tiles = {"farming_chocolate_block.png"},
is_ground_content = false,
groups = {cracky = 2, oddly_breakable_by_hand = 2},
sounds = default.node_sound_stone_defaults(),
sounds = default.node_sound_stone_defaults()
})
minetest.register_craft({
@ -122,19 +122,19 @@ minetest.register_craft({
recipe = {
{"farming:chocolate_dark", "farming:chocolate_dark", "farming:chocolate_dark"},
{"farming:chocolate_dark", "farming:chocolate_dark", "farming:chocolate_dark"},
{"farming:chocolate_dark", "farming:chocolate_dark", "farming:chocolate_dark"},
{"farming:chocolate_dark", "farming:chocolate_dark", "farming:chocolate_dark"}
}
})
minetest.register_craft({
output = "farming:chocolate_dark 9",
recipe = {
{"farming:chocolate_block"},
{"farming:chocolate_block"}
}
})
-- cocoa definition
local crop_def = {
local def = {
drawtype = "plantlike",
tiles = {"farming_cocoa_1.png"},
paramtype = "light",
@ -150,7 +150,7 @@ local crop_def = {
},
groups = {
snappy = 3, flammable = 2, plant = 1, growing = 1,
not_in_creative_inventory=1, leafdecay = 1, leafdecay_drop = 1
not_in_creative_inventory = 1, leafdecay = 1, leafdecay_drop = 1
},
sounds = default.node_sound_leaves_defaults(),
growth_check = function(pos, node_name)
@ -158,37 +158,37 @@ local crop_def = {
return false
end
return true
end,
end
}
-- stage 1
minetest.register_node("farming:cocoa_1", table.copy(crop_def))
minetest.register_node("farming:cocoa_1", table.copy(def))
-- stage 2
crop_def.tiles = {"farming_cocoa_2.png"}
minetest.register_node("farming:cocoa_2", table.copy(crop_def))
def.tiles = {"farming_cocoa_2.png"}
minetest.register_node("farming:cocoa_2", table.copy(def))
-- stage3
crop_def.tiles = {"farming_cocoa_3.png"}
crop_def.drop = {
def.tiles = {"farming_cocoa_3.png"}
def.drop = {
items = {
{items = {"farming:cocoa_beans 1"}, rarity = 1},
{items = {"farming:cocoa_beans 1"}, rarity = 1}
}
}
minetest.register_node("farming:cocoa_3", table.copy(crop_def))
minetest.register_node("farming:cocoa_3", table.copy(def))
-- stage 4 (final)
crop_def.tiles = {"farming_cocoa_4.png"}
crop_def.groups.growing = 0
crop_def.growth_check = nil
crop_def.drop = {
def.tiles = {"farming_cocoa_4.png"}
def.groups.growing = nil
def.growth_check = nil
def.drop = {
items = {
{items = {"farming:cocoa_beans 2"}, rarity = 1},
{items = {"farming:cocoa_beans 1"}, rarity = 2},
{items = {"farming:cocoa_beans 1"}, rarity = 4},
{items = {"farming:cocoa_beans 1"}, rarity = 4}
}
}
minetest.register_node("farming:cocoa_4", table.copy(crop_def))
minetest.register_node("farming:cocoa_4", table.copy(def))
-- add to registered_plants
farming.registered_plants["farming:cocoa_beans"] = {
@ -218,27 +218,22 @@ minetest.register_on_generated(function(minp, maxp)
dir = math.random(1, 80)
if dir == 1 then
pos.x = pos.x + 1
elseif dir == 2 then
pos.x = pos.x - 1
elseif dir == 3 then
pos.z = pos.z + 1
elseif dir == 4 then
pos.z = pos.z -1
if dir == 1 then pos.x = pos.x + 1
elseif dir == 2 then pos.x = pos.x - 1
elseif dir == 3 then pos.z = pos.z + 1
elseif dir == 4 then pos.z = pos.z -1
end
if dir < 5
and minetest.get_node(pos).name == "air"
and minetest.get_node_light(pos) > 12 then
--print ("Cocoa Pod added at " .. minetest.pos_to_string(pos))
--print ("Cocoa Pod added at " .. minetest.pos_to_string(pos))
minetest.swap_node(pos, {
name = "farming:cocoa_" .. tostring(math.random(1, 4))
name = "farming:cocoa_" .. tostring(math.random(4))
})
end
end
end
end)