Compare commits

...

5 Commits

Author SHA1 Message Date
BlockMen b770d33635 Fix for 0.4.10 2014-07-31 13:04:26 +02:00
Ciaran Gultnieks 94c261b8a4 Let right-click handler override seed placement
A customer on_place_node is used for seed planting. This change lets a
node with a custom right-click handler get called instead (as it would
normally) before the seed placement is done. This allows the placement
of seeds in various contains that rely on this, e.g. barrels, item
frames, without impacting on the actual use of the seeds.

Additionally, on_place_node the handler is moved to a common location
rather than being duplicated across every file.
2014-05-23 18:46:48 -04:00
NyankoSensei fa1e9b0454 And again for the orange textures. 2014-05-18 14:54:59 -04:00
NyankoSensei d31ee3b838 Same for the potato textures 2014-05-18 14:51:41 -04:00
NyankoSensei bcc4da2ffd New carrot textures
to better match the colors/style of the default game texture pack
2014-05-18 14:48:15 -04:00
24 changed files with 36 additions and 23 deletions

View File

@ -40,7 +40,7 @@ minetest.register_abm({
interval = 60,
chance = 20,
action = function(pos, node)
farming:generate_tree(pos, "default:tree", "farming_plus:banana_leaves", {"default:dirt", "default:dirt_with_grass"}, {["farming_plus:banana"]=20})
farming.generate_tree(pos, "default:tree", "farming_plus:banana_leaves", {"default:dirt", "default:dirt_with_grass"}, {["farming_plus:banana"]=20})
end
})
@ -51,7 +51,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
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.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})
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)

View File

@ -6,7 +6,7 @@ minetest.register_craftitem("farming_plus:carrot_seed", {
description = S("Carrot Seeds"),
inventory_image = "farming_carrot_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:carrot_1")
return farming.place_seed(itemstack, placer, pointed_thing, "farming_plus:carrot_1")
end
})
@ -84,4 +84,4 @@ minetest.register_craftitem("farming_plus:carrot_item", {
on_use = minetest.item_eat(3),
})
farming:add_plant("farming_plus:carrot", {"farming_plus:carrot_1", "farming_plus:carrot_2", "farming_plus:carrot_3"}, 50, 20)
farming.add_plant("farming_plus:carrot", {"farming_plus:carrot_1", "farming_plus:carrot_2", "farming_plus:carrot_3"}, 50, 20)

View File

@ -40,7 +40,7 @@ minetest.register_abm({
interval = 60,
chance = 20,
action = function(pos, node)
farming:generate_tree(pos, "default:tree", "farming_plus:cocoa_leaves", {"default:sand", "default:desert_sand"}, {["farming_plus:cocoa"]=20})
farming.generate_tree(pos, "default:tree", "farming_plus:cocoa_leaves", {"default:sand", "default:desert_sand"}, {["farming_plus:cocoa"]=20})
end
})
@ -51,7 +51,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
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.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})
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)

View File

@ -8,7 +8,7 @@ else
farming.S = function ( s ) return s end
end
function farming:add_plant(full_grown, names, interval, chance)
function farming.add_plant(full_grown, names, interval, chance)
minetest.register_abm({
nodenames = names,
interval = interval,
@ -51,7 +51,7 @@ function farming:add_plant(full_grown, names, interval, chance)
})
end
function farming:generate_tree(pos, trunk, leaves, underground, replacements)
function farming.generate_tree(pos, trunk, leaves, underground, replacements)
pos.y = pos.y-1
local nodename = minetest.get_node(pos).name
local ret = true
@ -155,6 +155,7 @@ farming.seeds = {
["farming_plus:carrot_seed"]=30,
}
-- ========= GENERATE PLANTS IN THE MAP =========
minetest.register_on_generated(function(minp, maxp, seed)
if maxp.y >= 2 and minp.y <= 0 then
@ -209,7 +210,19 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end)
function farming:place_seed(itemstack, placer, pointed_thing, plantname)
function farming.place_seed(itemstack, placer, pointed_thing, plantname)
-- Call on_rightclick if the pointed node defines it
if pointed_thing.type == "node" and placer and
not placer:get_player_control().sneak then
local n = minetest.get_node(pointed_thing.under)
local nn = n.name
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n,
placer, itemstack, pointed_thing) or itemstack, false
end
end
local pt = pointed_thing
-- check if pointing at a node
if not pt then
@ -241,12 +254,12 @@ function farming:place_seed(itemstack, placer, pointed_thing, plantname)
end
-- check if pointing at soil
if minetest.get_item_group(under.name, "soil") <= 1 then
if minetest.get_item_group(under.name, "soil") < 2 then
return
end
-- add the node and remove 1 item from the itemstack
minetest.add_node(pt.above, {name=plantname})
minetest.add_node(pt.above, {name=plantname, param2 = 1})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end

View File

@ -6,7 +6,7 @@ minetest.register_craftitem("farming_plus:orange_seed", {
description = S("Orange Seeds"),
inventory_image = "farming_orange_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:orange_1")
return farming.place_seed(itemstack, placer, pointed_thing, "farming_plus:orange_1")
end
})
@ -84,4 +84,4 @@ minetest.register_craftitem("farming_plus:orange_item", {
on_use = minetest.item_eat(4),
})
farming:add_plant("farming_plus:orange", {"farming_plus:orange_1", "farming_plus:orange_2", "farming_plus:orange_3"}, 50, 20)
farming.add_plant("farming_plus:orange", {"farming_plus:orange_1", "farming_plus:orange_2", "farming_plus:orange_3"}, 50, 20)

View File

@ -6,7 +6,7 @@ minetest.register_craftitem("farming_plus:potato_seed", {
description = ("Potato Seeds"),
inventory_image = "farming_potato_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:potato_1")
return farming.place_seed(itemstack, placer, pointed_thing, "farming_plus:potato_1")
end
})
@ -67,7 +67,7 @@ minetest.register_craftitem("farming_plus:potato_item", {
inventory_image = "farming_potato.png",
})
farming:add_plant("farming_plus:potato", {"farming_plus:potato_1", "farming_plus:potato_2"}, 50, 20)
farming.add_plant("farming_plus:potato", {"farming_plus:potato_1", "farming_plus:potato_2"}, 50, 20)
minetest.register_alias("farming_plus:potatoe_item", "farming_plus:potato_item")
minetest.register_alias("farming_plus:potatoe_seed", "farming_plus:potato_seed")

View File

@ -6,7 +6,7 @@ minetest.register_craftitem(":farming:pumpkin_seed", {
description = S("Pumpkin Seed"),
inventory_image = "farming_pumpkin_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming:pumpkin_1")
return farming.place_seed(itemstack, placer, pointed_thing, "farming:pumpkin_1")
end
})
@ -74,7 +74,7 @@ minetest.register_node(":farming:pumpkin", {
end
})
farming:add_plant("farming:pumpkin", {"farming:pumpkin_1", "farming:pumpkin_2"}, 80, 20)
farming.add_plant("farming:pumpkin", {"farming:pumpkin_1", "farming:pumpkin_2"}, 80, 20)
minetest.register_node(":farming:pumpkin_face", {
description = S("Pumpkin Face"),

View File

@ -6,7 +6,7 @@ minetest.register_craftitem("farming_plus:rhubarb_seed", {
description = S("Rhubarb Seeds"),
inventory_image = "farming_rhubarb_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:rhubarb_1")
return farming.place_seed(itemstack, placer, pointed_thing, "farming_plus:rhubarb_1")
end
})
@ -67,4 +67,4 @@ minetest.register_craftitem("farming_plus:rhubarb_item", {
inventory_image = "farming_rhubarb.png",
})
farming:add_plant("farming_plus:rhubarb", {"farming_plus:rhubarb_1", "farming_plus:rhubarb_2"}, 50, 20)
farming.add_plant("farming_plus:rhubarb", {"farming_plus:rhubarb_1", "farming_plus:rhubarb_2"}, 50, 20)

View File

@ -6,7 +6,7 @@ minetest.register_craftitem("farming_plus:strawberry_seed", {
description = S("Strawberry Seeds"),
inventory_image = "farming_strawberry_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:strawberry_1")
return farming.place_seed(itemstack, placer, pointed_thing, "farming_plus:strawberry_1")
end
})
@ -84,4 +84,4 @@ minetest.register_craftitem("farming_plus:strawberry_item", {
on_use = minetest.item_eat(2),
})
farming:add_plant("farming_plus:strawberry", {"farming_plus:strawberry_1", "farming_plus:strawberry_2", "farming_plus:strawberry_3"}, 50, 20)
farming.add_plant("farming_plus:strawberry", {"farming_plus:strawberry_1", "farming_plus:strawberry_2", "farming_plus:strawberry_3"}, 50, 20)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 575 B

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 507 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 B

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 B

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 415 B

View File

@ -6,7 +6,7 @@ minetest.register_craftitem("farming_plus:tomato_seed", {
description = S("Tomato Seeds"),
inventory_image = "farming_tomato_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming_plus:tomato_1")
return farming.place_seed(itemstack, placer, pointed_thing, "farming_plus:tomato_1")
end
})
@ -84,4 +84,4 @@ minetest.register_craftitem("farming_plus:tomato_item", {
on_use = minetest.item_eat(4),
})
farming:add_plant("farming_plus:tomato", {"farming_plus:tomato_1", "farming_plus:tomato_2", "farming_plus:tomato_3"}, 50, 20)
farming.add_plant("farming_plus:tomato", {"farming_plus:tomato_1", "farming_plus:tomato_2", "farming_plus:tomato_3"}, 50, 20)