pull everything from other fork:

update deprecated `minetest.env:` from Jat
Bananas and cocoa fall when tree and leaves disappear from Lukc
centralize place_seed in init from farming mod from asl97, myself
add translation support from Xanthin
master
asl97 2014-04-16 02:28:11 +08:00
parent 793551e713
commit aac6de40a3
14 changed files with 335 additions and 134 deletions

View File

@ -1,11 +1,24 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_node("farming_plus:banana_sapling", {
description = "Banana Tree Sapling",
description = S("Banana Tree Sapling"),
drawtype = "plantlike",
tiles = {"farming_banana_sapling.png"},
inventory_image = "farming_banana_sapling.png",
wield_image = "farming_banana_sapling.png",
paramtype = "light",
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {dig_immediate=3,flammable=2},
sounds = default.node_sound_defaults(),
})
@ -41,14 +54,14 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
return
end
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
local pos = minetest.find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
if pos ~= nil then
farming:generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "default:tree", "farming_plus:banana_leaves", {"default:dirt", "default:dirt_with_grass"}, {["farming_plus:banana"]=10})
end
end)
minetest.register_node("farming_plus:banana", {
description = "Banana",
description = S("Banana"),
tiles = {"farming_banana.png"},
inventory_image = "farming_banana.png",
wield_image = "farming_banana.png",
@ -56,7 +69,7 @@ minetest.register_node("farming_plus:banana", {
paramtype = "light",
sunlight_propagates = true,
walkable = false,
groups = {fleshy=3,dig_immediate=3,flammable=2},
groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
sounds = default.node_sound_defaults(),
on_use = minetest.item_eat(6),

View File

@ -1,14 +1,17 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_craftitem("farming_plus:carrot_seed", {
description = "Carrot Seeds",
description = S("Carrot Seeds"),
inventory_image = "farming_carrot_seed.png",
on_place = function(itemstack, placer, pointed_thing)
local above = minetest.env:get_node(pointed_thing.above)
if above.name == "air" then
above.name = "farming_plus:carrot_1"
minetest.env:set_node(pointed_thing.above, above)
itemstack:take_item(1)
return itemstack
end
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:carrot_1")
end
})
@ -81,7 +84,7 @@ minetest.register_node("farming_plus:carrot", {
})
minetest.register_craftitem("farming_plus:carrot_item", {
description = "Carrot",
description = S("Carrot"),
inventory_image = "farming_carrot.png",
on_use = minetest.item_eat(3),
})

View File

@ -1,11 +1,24 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_node("farming_plus:cocoa_sapling", {
description = "Cocoa Tree Sapling",
description = S("Cocoa Tree Sapling"),
drawtype = "plantlike",
tiles = {"farming_cocoa_sapling.png"},
inventory_image = "farming_cocoa_sapling.png",
wield_image = "farming_cocoa_sapling.png",
paramtype = "light",
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {dig_immediate=3,flammable=2},
sounds = default.node_sound_defaults(),
})
@ -41,14 +54,14 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
return
end
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:desert_sand"})
local pos = minetest.find_node_near(tmp, maxp.x-minp.x, {"default:desert_sand"})
if pos ~= nil then
farming:generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "default:tree", "farming_plus:cocoa_leaves", {"default:sand", "default:desert_sand"}, {["farming_plus:cocoa"]=20})
end
end)
minetest.register_node("farming_plus:cocoa", {
description = "Cocoa",
description = S("Cocoa"),
tiles = {"farming_cocoa.png"},
visual_scale = 0.5,
inventory_image = "farming_cocoa.png",
@ -57,7 +70,7 @@ minetest.register_node("farming_plus:cocoa", {
paramtype = "light",
sunlight_propagates = true,
walkable = false,
groups = {fleshy=3,dig_immediate=3,flammable=2},
groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
sounds = default.node_sound_defaults(),
})

View File

@ -1,2 +1,3 @@
default
farming
intllib?

View File

@ -1,4 +1,3 @@
farming.registered_plants = {}
function farming:add_plant(full_grown, names, interval, chance)
@ -8,14 +7,14 @@ function farming:add_plant(full_grown, names, interval, chance)
chance = chance,
action = function(pos, node)
pos.y = pos.y-1
if minetest.env:get_node(pos).name ~= "farming:soil_wet" then
if minetest.get_node(pos).name ~= "farming:soil_wet" then
return
end
pos.y = pos.y+1
if not minetest.env:get_node_light(pos) then
if not minetest.get_node_light(pos) then
return
end
if minetest.env:get_node_light(pos) < 8 then
if minetest.get_node_light(pos) < 8 then
return
end
local step = nil
@ -32,7 +31,7 @@ function farming:add_plant(full_grown, names, interval, chance)
if new_node.name == nil then
new_node.name = full_grown
end
minetest.env:set_node(pos, new_node)
minetest.set_node(pos, new_node)
end
})
@ -46,7 +45,7 @@ end
function farming:generate_tree(pos, trunk, leaves, underground, replacements)
pos.y = pos.y-1
local nodename = minetest.env:get_node(pos).name
local nodename = minetest.get_node(pos).name
local ret = true
for _,name in ipairs(underground) do
if nodename == name then
@ -55,17 +54,17 @@ function farming:generate_tree(pos, trunk, leaves, underground, replacements)
end
end
pos.y = pos.y+1
if not minetest.env:get_node_light(pos) then
if not minetest.get_node_light(pos) then
return
end
if ret or minetest.env:get_node_light(pos) < 8 then
if ret or minetest.get_node_light(pos) < 8 then
return
end
node = {name = ""}
for dy=1,4 do
pos.y = pos.y+dy
if minetest.env:get_node(pos).name ~= "air" then
if minetest.get_node(pos).name ~= "air" then
return
end
pos.y = pos.y-dy
@ -73,7 +72,7 @@ function farming:generate_tree(pos, trunk, leaves, underground, replacements)
node.name = trunk
for dy=0,4 do
pos.y = pos.y+dy
minetest.env:set_node(pos, node)
minetest.set_node(pos, node)
pos.y = pos.y-dy
end
@ -91,39 +90,39 @@ function farming:generate_tree(pos, trunk, leaves, underground, replacements)
pos.z = pos.z+dz
if dx == 0 and dz == 0 and dy==3 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
minetest.set_node(pos, {name=name})
end
end
end
elseif dx == 0 and dz == 0 and dy==4 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
minetest.set_node(pos, {name=name})
end
end
end
elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then
if minetest.env:get_node(pos).name == "air" then
minetest.env:set_node(pos, node)
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
minetest.set_node(pos, {name=name})
end
end
end
else
if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
if minetest.get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
minetest.set_node(pos, {name=name})
end
end
end
@ -202,6 +201,50 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end)
function farming:place_seed(itemstack, placer, pointed_thing, plantname)
local pt = pointed_thing
-- check if pointing at a node
if not pt then
return
end
if pt.type ~= "node" then
return
end
local under = minetest.get_node(pt.under)
local above = minetest.get_node(pt.above)
-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
return
end
if not minetest.registered_nodes[above.name] then
return
end
-- check if pointing at the top of the node
if pt.above.y ~= pt.under.y+1 then
return
end
-- check if you can replace the node above the pointed node
if not minetest.registered_nodes[above.name].buildable_to then
return
end
-- check if pointing at soil
if minetest.get_item_group(under.name, "soil") <= 1 then
return
end
-- add the node and remove 1 item from the itemstack
minetest.add_node(pt.above, {name=plantname})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
-- ========= ALIASES FOR FARMING MOD BY SAPIER =========
-- potatoe -> potatoe
minetest.register_alias("farming:potatoe_node", "farming_plus:potatoe")
@ -211,7 +254,7 @@ minetest.register_alias("farming:seed_potatoe", "farming_plus:potatoe_seed")
for lvl = 1, 6, 1 do
minetest.register_entity(":farming:potatoe_lvl"..lvl, {
on_activate = function(self, staticdata)
minetest.env:set_node(self.object:getpos(), {name="farming_plus:potatoe_1"})
minetest.set_node(self.object:getpos(), {name="farming_plus:potatoe_1"})
end
})
end
@ -225,7 +268,7 @@ minetest.register_abm({
interval = 1,
chance = 1,
action = function(pos)
minetest.env:set_node(pos, {name="farming:wheat_8"})
minetest.set_node(pos, {name="farming:wheat_8"})
end,
})

50
locale/de.txt Normal file
View File

@ -0,0 +1,50 @@
# Translation by Xanthin
### bananas.lua ###
Banana Tree Sapling = Bananenbaumsetzling
Banana = Banane
### carrots.lua ###
Carrot Seeds = Karottensamen
Carrot = Karotte
### cocoa.lua ###
Cocoa Tree Sapling = Kakaobaumsetzling
Cocoa = Kakao
Cocoa Bean = Kakaobohne
### oranges.lua ###
Orange Seeds = Orangensamen
Orange = Orange
### potatoes.lua ###
Potato Seeds = Kartoffelsamen
Potato = Kartoffel
### pumpkin.lua ###
Pumpkin Seed = Kuerbissamen
Pumpkin = Kuerbis
Pumpkin Face = Kuerbislaterne
Pumpkin Face With Light = Leuchtende Kuerbislaterne
Big Pumpkin = Riesen-Kuerbis
Scarecrow = Vogelscheuche
Scarecrow With Light = Leuchtende Vogelscheuche
Pumpkin Bread = Kuerbisbrot
Pumpkin Flour = Kuerbismehl
### rhubarb.lua ###
Rhubarb Seeds = Rhabarbersamen
Rhubarb = Rhabarber
### strawberries.lua ###
Strawberry Seeds = Erdbeersamen
Strawberry = Erdbeere
### tomatoes.lua ###
Tomato Seeds = Tomatensamen
Tomato = Tomate
### init.lua ###
### weed.lua ###
Weed = Unkraut

51
locale/template.txt Normal file
View File

@ -0,0 +1,51 @@
# Template
### bananas.lua ###
Banana Tree Sapling =
Banana =
### carrots.lua ###
Carrot Seeds =
Carrot =
### cocoa.lua ###
Cocoa Tree Sapling =
Cocoa =
Cocoa Bean =
### oranges.lua ###
Orange Seeds =
Orange =
### potatoes.lua ###
Potato Seeds =
Potato =
### pumpkin.lua ###
Pumpkin Seed =
Pumpkin =
Pumpkin Face =
Pumpkin Face With Light =
Big Pumpkin =
Scarecrow =
Scarecrow With Light =
Pumpkin Bread =
Pumpkin Flour =
### rhubarb.lua ###
Rhubarb Seeds =
Rhubarb =
### strawberries.lua ###
Strawberry Seeds =
Strawberry =
### tomatoes.lua ###
Tomato Seeds =
Tomato =
### init.lua ###
### weed.lua ###
Weed =

View File

@ -1,14 +1,17 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_craftitem("farming_plus:orange_seed", {
description = "Orange Seeds",
description = S("Orange Seeds"),
inventory_image = "farming_orange_seed.png",
on_place = function(itemstack, placer, pointed_thing)
local above = minetest.env:get_node(pointed_thing.above)
if above.name == "air" then
above.name = "farming_plus:orange_1"
minetest.env:set_node(pointed_thing.above, above)
itemstack:take_item(1)
return itemstack
end
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:orange_1")
end
})
@ -81,7 +84,7 @@ minetest.register_node("farming_plus:orange", {
})
minetest.register_craftitem("farming_plus:orange_item", {
description = "Orange",
description = S("Orange"),
inventory_image = "farming_orange.png",
on_use = minetest.item_eat(4),
})

View File

@ -1,14 +1,17 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_craftitem("farming_plus:potato_seed", {
description = "Potato Seeds",
description = ("Potato Seeds"),
inventory_image = "farming_potato_seed.png",
on_place = function(itemstack, placer, pointed_thing)
local above = minetest.env:get_node(pointed_thing.above)
if above.name == "air" then
above.name = "farming_plus:potato_1"
minetest.env:set_node(pointed_thing.above, above)
itemstack:take_item(1)
return itemstack
end
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:potato_1")
end
})
@ -65,7 +68,7 @@ minetest.register_node("farming_plus:potato", {
})
minetest.register_craftitem("farming_plus:potato_item", {
description = "Potato",
description = S("Potato"),
inventory_image = "farming_potato.png",
})

View File

@ -1,14 +1,17 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_craftitem(":farming:pumpkin_seed", {
description = "Pumpkin Seed",
description = S("Pumpkin Seed"),
inventory_image = "farming_pumpkin_seed.png",
on_place = function(itemstack, placer, pointed_thing)
local above = minetest.env:get_node(pointed_thing.above)
if above.name == "air" then
above.name = "farming:pumpkin_1"
minetest.env:set_node(pointed_thing.above, above)
itemstack:take_item(1)
return itemstack
end
return farming:place_seed(itemstack, placer, pointed_thing, "farming:pumpkin_1")
end
})
@ -57,7 +60,7 @@ minetest.register_node(":farming:pumpkin_2", {
})
minetest.register_node(":farming:pumpkin", {
description = "Pumpkin",
description = S("Pumpkin"),
paramtype2 = "facedir",
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"},
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, plant=1},
@ -67,7 +70,7 @@ minetest.register_node(":farming:pumpkin", {
local tool = puncher:get_wielded_item():get_name()
if tool and tool == "default:sword_wood" or tool == "default:sword_stone" or tool == "default:sword_steel" then
node.name = "farming:pumpkin_face"
minetest.env:set_node(pos, node)
minetest.set_node(pos, node)
puncher:get_inventory():add_item("main", ItemStack("farming:pumpkin_seed"))
if math.random(1, 5) == 1 then
puncher:get_inventory():add_item("main", ItemStack("farming:pumpkin_seed"))
@ -79,7 +82,7 @@ minetest.register_node(":farming:pumpkin", {
farming:add_plant("farming:pumpkin", {"farming:pumpkin_1", "farming:pumpkin_2"}, 80, 20)
minetest.register_node(":farming:pumpkin_face", {
description = "Pumpkin",
description = S("Pumpkin Face"),
paramtype2 = "facedir",
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face.png"},
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, plant=1},
@ -87,7 +90,7 @@ minetest.register_node(":farming:pumpkin_face", {
})
minetest.register_node(":farming:pumpkin_face_light", {
description = "Pumpkin",
description = S("Pumpkin Face With Light"),
paramtype2 = "facedir",
light_source = LIGHT_MAX-2,
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_light.png"},
@ -103,7 +106,7 @@ minetest.register_craft({
-- ========= BIG PUMPKIN =========
minetest.register_node(":farming:big_pumpkin", {
description = "Big Pumpkin",
description = S("Big Pumpkin"),
paramtype2 = "facedir",
tiles = {"farming_pumpkin_big_side.png"},
selection_box = {
@ -123,11 +126,11 @@ minetest.register_node(":farming:big_pumpkin", {
pos.y = pos.y+dy
pos.z = pos.z+dz
if dx ~= 0 or dy ~= 0 or dz ~= 0 then
if minetest.env:get_node(pos).name ~= "air" then
if minetest.get_node(pos).name ~= "air" then
pos.x = pos.x-dx
pos.y = pos.y-dy
pos.z = pos.z-dz
minetest.env:remove_node(pos)
minetest.remove_node(pos)
minetest.after(0.1, function(placer)
local inv = placer:get_inventory()
local index = placer:get_wield_index()
@ -145,29 +148,29 @@ minetest.register_node(":farming:big_pumpkin", {
for dy=0,1 do
pos.y = pos.y+dy
pos.z = pos.z+1
minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=2})
minetest.set_node(pos, {name="farming:big_pumpkin_side", param2=2})
pos.x = pos.x-1
minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=2})
minetest.set_node(pos, {name="farming:big_pumpkin_corner", param2=2})
pos.x = pos.x+1
pos.z = pos.z-2
minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=4})
minetest.set_node(pos, {name="farming:big_pumpkin_side", param2=4})
pos.x = pos.x+1
minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=4})
minetest.set_node(pos, {name="farming:big_pumpkin_corner", param2=4})
pos.z = pos.z+1
minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=3})
minetest.set_node(pos, {name="farming:big_pumpkin_side", param2=3})
pos.z = pos.z+1
minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=3})
minetest.set_node(pos, {name="farming:big_pumpkin_corner", param2=3})
pos.z = pos.z-1
pos.x = pos.x-2
minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=1})
minetest.set_node(pos, {name="farming:big_pumpkin_side", param2=1})
pos.z = pos.z-1
minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=1})
minetest.set_node(pos, {name="farming:big_pumpkin_corner", param2=1})
pos.z = pos.z+1
pos.x = pos.x+1
pos.y = pos.y-dy
end
pos.y = pos.y+1
minetest.env:set_node(pos, {name="farming:big_pumpkin_top"})
minetest.set_node(pos, {name="farming:big_pumpkin_top"})
end,
after_destruct = function(pos, oldnode)
@ -177,9 +180,9 @@ minetest.register_node(":farming:big_pumpkin", {
pos.x = pos.x+dx
pos.y = pos.y+dy
pos.z = pos.z+dz
local name = minetest.env:get_node(pos).name
local name = minetest.get_node(pos).name
if string.find(name, "farming:big_pumpkin") then
minetest.env:remove_node(pos)
minetest.remove_node(pos)
end
pos.x = pos.x-dx
pos.y = pos.y-dy
@ -279,7 +282,7 @@ for j,list in ipairs(box2) do
end
minetest.register_node(":farming:scarecrow", {
description = "Scarecrow",
description = S("Scarecrow"),
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
@ -298,12 +301,12 @@ minetest.register_node(":farming:scarecrow", {
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
after_place_node = function(pos, placer)
local node = minetest.env:get_node(pos)
local node = minetest.get_node(pos)
local param2 = node.param2
pos.y = pos.y+1
if minetest.env:get_node(pos).name ~= "air" then
if minetest.get_node(pos).name ~= "air" then
pos.y = pos.y-1
minetest.env:remove_node(pos)
minetest.remove_node(pos)
minetest.after(0.1, function(placer)
local inv = placer:get_inventory()
local index = placer:get_wield_index()
@ -311,16 +314,16 @@ minetest.register_node(":farming:scarecrow", {
end, placer)
return
end
minetest.env:set_node(pos, node)
minetest.set_node(pos, node)
pos.y = pos.y-1
node.name = "farming:scarecrow_bottom"
minetest.env:set_node(pos, node)
minetest.set_node(pos, node)
end,
after_destruct = function(pos, oldnode)
pos.y = pos.y-1
if minetest.env:get_node(pos).name == "farming:scarecrow_bottom" then
minetest.env:remove_node(pos)
if minetest.get_node(pos).name == "farming:scarecrow_bottom" then
minetest.remove_node(pos)
end
end
})
@ -354,7 +357,7 @@ minetest.register_craft({
})
minetest.register_node(":farming:scarecrow_light", {
description = "Scarecrow",
description = S("Scarecrow With light"),
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
@ -374,12 +377,12 @@ minetest.register_node(":farming:scarecrow_light", {
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
after_place_node = function(pos, placer)
local node = minetest.env:get_node(pos)
local node = minetest.get_node(pos)
local param2 = node.param2
pos.y = pos.y+1
if minetest.env:get_node(pos).name ~= "air" then
if minetest.get_node(pos).name ~= "air" then
pos.y = pos.y-1
minetest.env:remove_node(pos)
minetest.remove_node(pos)
minetest.after(0.1, function(placer)
local inv = placer:get_inventory()
local index = placer:get_wield_index()
@ -387,16 +390,16 @@ minetest.register_node(":farming:scarecrow_light", {
end, placer)
return
end
minetest.env:set_node(pos, node)
minetest.set_node(pos, node)
pos.y = pos.y-1
node.name = "farming:scarecrow_bottom"
minetest.env:set_node(pos, node)
minetest.set_node(pos, node)
end,
after_destruct = function(pos, oldnode)
pos.y = pos.y-1
if minetest.env:get_node(pos).name == "farming:scarecrow_bottom" then
minetest.env:remove_node(pos)
if minetest.get_node(pos).name == "farming:scarecrow_bottom" then
minetest.remove_node(pos)
end
end
})
@ -412,7 +415,7 @@ minetest.register_craft({
--===============
minetest.register_craftitem(":farming:pumpkin_bread", {
description = "Pumpkin Bread",
description = S("Pumpkin Bread"),
inventory_image = "farming_bread_pumpkin.png",
stack_max = 1,
on_use = minetest.item_eat(8)

View File

@ -1,14 +1,17 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_craftitem("farming_plus:rhubarb_seed", {
description = "Rhubarb Seeds",
description = S("Rhubarb Seeds"),
inventory_image = "farming_rhubarb_seed.png",
on_place = function(itemstack, placer, pointed_thing)
local above = minetest.env:get_node(pointed_thing.above)
if above.name == "air" then
above.name = "farming_plus:rhubarb_1"
minetest.env:set_node(pointed_thing.above, above)
itemstack:take_item(1)
return itemstack
end
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:rhubarb_1")
end
})
@ -65,7 +68,7 @@ minetest.register_node("farming_plus:rhubarb", {
})
minetest.register_craftitem("farming_plus:rhubarb_item", {
description = "Rhubarb",
description = S("Rhubarb"),
inventory_image = "farming_rhubarb.png",
})

View File

@ -1,14 +1,17 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_craftitem("farming_plus:strawberry_seed", {
description = "Strawberry Seeds",
description = S("Strawberry Seeds"),
inventory_image = "farming_strawberry_seed.png",
on_place = function(itemstack, placer, pointed_thing)
local above = minetest.env:get_node(pointed_thing.above)
if above.name == "air" then
above.name = "farming_plus:strawberry_1"
minetest.env:set_node(pointed_thing.above, above)
itemstack:take_item(1)
return itemstack
end
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:strawberry_1")
end
})
@ -81,7 +84,7 @@ minetest.register_node("farming_plus:strawberry", {
})
minetest.register_craftitem("farming_plus:strawberry_item", {
description = "Strawberry",
description = S("Strawberry"),
inventory_image = "farming_strawberry.png",
on_use = minetest.item_eat(2),
})

View File

@ -1,14 +1,17 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_craftitem("farming_plus:tomato_seed", {
description = "Tomato Seeds",
description = S("Tomato Seeds"),
inventory_image = "farming_tomato_seed.png",
on_place = function(itemstack, placer, pointed_thing)
local above = minetest.env:get_node(pointed_thing.above)
if above.name == "air" then
above.name = "farming_plus:tomato_1"
minetest.env:set_node(pointed_thing.above, above)
itemstack:take_item(1)
return itemstack
end
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:tomato_1")
end
})
@ -81,7 +84,7 @@ minetest.register_node("farming_plus:tomato", {
})
minetest.register_craftitem("farming_plus:tomato_item", {
description = "Tomato",
description = S("Tomato"),
inventory_image = "farming_tomato.png",
on_use = minetest.item_eat(4),
})

View File

@ -1,5 +1,14 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
minetest.register_node(":farming:weed", {
description = "Weed",
description = S("Weed"),
paramtype = "light",
sunlight_propagates = true,
walkable = false,
@ -21,13 +30,13 @@ minetest.register_abm({
interval = 50,
chance = 10,
action = function(pos, node)
if minetest.env:find_node_near(pos, 4, {"farming:scarecrow", "farming:scarecrow_light"}) ~= nil then
if minetest.find_node_near(pos, 4, {"farming:scarecrow", "farming:scarecrow_light"}) ~= nil then
return
end
pos.y = pos.y+1
if minetest.env:get_node(pos).name == "air" then
if minetest.get_node(pos).name == "air" then
node.name = "farming:weed"
minetest.env:set_node(pos, node)
minetest.set_node(pos, node)
end
end
})
@ -37,4 +46,4 @@ minetest.register_craft({
type = "fuel",
recipe = "farming:weed",
burntime = 1
})
})