parent
9f1a46d836
commit
b41709600b
22
register.lua
22
register.lua
|
@ -691,8 +691,6 @@ farming.step_on_punch = function(pos, node, puncher, pointed_thing)
|
||||||
placenode.param2 = def.place_param2
|
placenode.param2 = def.place_param2
|
||||||
end
|
end
|
||||||
minetest.swap_node(pos, placenode)
|
minetest.swap_node(pos, placenode)
|
||||||
print(dump(puncher))
|
|
||||||
print(dump(puncher:get_player_name()))
|
|
||||||
|
|
||||||
if puncher ~= nil and puncher:get_player_name() ~= "" then
|
if puncher ~= nil and puncher:get_player_name() ~= "" then
|
||||||
puncher:get_inventory():add_item('main',def.drop_item)
|
puncher:get_inventory():add_item('main',def.drop_item)
|
||||||
|
@ -903,33 +901,26 @@ farming.wilt_on_timer = function(pos, elapsed)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local name = node.name
|
local name = node.name
|
||||||
local def = minetest.registered_nodes[name]
|
local def = minetest.registered_nodes[name]
|
||||||
-- print(dump(def))
|
|
||||||
if def.groups.wiltable <= 2 then -- normal crop
|
if def.groups.wiltable <= 2 then -- normal crop
|
||||||
minetest.swap_node(pos, {name="air"})
|
minetest.swap_node(pos, {name="air"})
|
||||||
end
|
end
|
||||||
if def.groups.wiltable == 3 then -- nettle or weed
|
if def.groups.wiltable == 3 then -- nettle or weed
|
||||||
print("nettle")
|
|
||||||
-- determine all nearby nodes with soil
|
-- determine all nearby nodes with soil
|
||||||
local pos0=vector.subtract(pos,2)
|
local pos0=vector.subtract(pos,2)
|
||||||
local pos1=vector.add(pos,2)
|
local pos1=vector.add(pos,2)
|
||||||
local neighb=minetest.find_nodes_in_area(pos0,pos1,"group:soil")
|
local neighb=minetest.find_nodes_in_area(pos0,pos1,"group:soil")
|
||||||
-- print(dump(neighb))
|
|
||||||
if neighb ~= nil then
|
if neighb ~= nil then
|
||||||
local freen={}
|
local freen={}
|
||||||
-- get soil nodes with air above
|
-- get soil nodes with air above
|
||||||
for j=1,#neighb do
|
for j=1,#neighb do
|
||||||
local jpos=neighb[j]
|
local jpos=neighb[j]
|
||||||
-- print(dump(minetest.get_node({x=jpos.x,y=jpos.y+1,z=jpos.z})))
|
|
||||||
if farming.has_value({"air","default:grass_1","default:grass_2","default:grass_3","default:grass_4","default:grass_5"},minetest.get_node({x=jpos.x,y=jpos.y+1,z=jpos.z}).name) then
|
if farming.has_value({"air","default:grass_1","default:grass_2","default:grass_3","default:grass_4","default:grass_5"},minetest.get_node({x=jpos.x,y=jpos.y+1,z=jpos.z}).name) then
|
||||||
table.insert(freen,1,jpos)
|
table.insert(freen,1,jpos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- randomly pick one and spread
|
-- randomly pick one and spread
|
||||||
if #freen >= 1 then
|
if #freen >= 1 then
|
||||||
print(#freen)
|
|
||||||
local jpos=freen[math.random(1,#freen)]
|
local jpos=freen[math.random(1,#freen)]
|
||||||
print(name.." spread "..dump(jpos))
|
|
||||||
-- print(dump(def))
|
|
||||||
minetest.add_node({x=jpos.x,y=jpos.y+1,z=jpos.z}, {name = def.seed_name, param2 = 1})
|
minetest.add_node({x=jpos.x,y=jpos.y+1,z=jpos.z}, {name = def.seed_name, param2 = 1})
|
||||||
minetest.get_node_timer({x=jpos.x,y=jpos.y+1,z=jpos.z}):start(def.grow_time_min or 10)
|
minetest.get_node_timer({x=jpos.x,y=jpos.y+1,z=jpos.z}):start(def.grow_time_min or 10)
|
||||||
end
|
end
|
||||||
|
@ -937,13 +928,10 @@ farming.wilt_on_timer = function(pos, elapsed)
|
||||||
-- after spreading the source has a one third change to be removed, to go one step back or stay
|
-- after spreading the source has a one third change to be removed, to go one step back or stay
|
||||||
local wran=math.random(1,3)
|
local wran=math.random(1,3)
|
||||||
if wran == 1 then
|
if wran == 1 then
|
||||||
print("remove")
|
|
||||||
minetest.swap_node(pos, {name="air"})
|
minetest.swap_node(pos, {name="air"})
|
||||||
end
|
end
|
||||||
if wran == 2 then
|
if wran == 2 then
|
||||||
print("try to go one step back")
|
|
||||||
if def.pre_step ~= nil then
|
if def.pre_step ~= nil then
|
||||||
print("done")
|
|
||||||
minetest.swap_node(pos, {name=def.pre_step, param2=1})
|
minetest.swap_node(pos, {name=def.pre_step, param2=1})
|
||||||
minetest.get_node_timer(pos):start(math.random(def.grow_time_min or 10,def.grow_time_max or 20))
|
minetest.get_node_timer(pos):start(math.random(def.grow_time_min or 10,def.grow_time_max or 20))
|
||||||
end
|
end
|
||||||
|
@ -1187,18 +1175,22 @@ farming.billhook_on_use = function(itemstack, user, pointed_thing, uses)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local tdef=itemstack:get_definition()
|
||||||
if not (creative and creative.is_enabled_for
|
if not (creative and creative.is_enabled_for
|
||||||
and creative.is_enabled_for(user:get_player_name())) then
|
and creative.is_enabled_for(user:get_player_name())) then
|
||||||
-- wear tool
|
-- wear tool
|
||||||
local wdef = itemstack:get_definition()
|
|
||||||
itemstack:add_wear(65535/(uses-1))
|
itemstack:add_wear(65535/(uses-1))
|
||||||
-- tool break sound
|
-- tool break sound
|
||||||
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
if itemstack:get_count() == 0 and tdef.sound and tdef.sound.breaks then
|
||||||
minetest.sound_play(wdef.sound.breaks, {pos = pt.above, gain = 0.5})
|
minetest.sound_play(tdef.sound.breaks, {pos = pt.above, gain = 0.5})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
user:get_inventory():add_item('main',pdef.drop_item)
|
user:get_inventory():add_item('main',pdef.drop_item)
|
||||||
|
if tdef.farming_change ~= nil then
|
||||||
|
if math.random(1,tdef.farming_change)==1 then
|
||||||
user:get_inventory():add_item('main',pdef.drop_item)
|
user:get_inventory():add_item('main',pdef.drop_item)
|
||||||
|
end
|
||||||
|
end
|
||||||
-- minetest.node_punch(pt.under, under, user, pointed_thing)
|
-- minetest.node_punch(pt.under, under, user, pointed_thing)
|
||||||
minetest.punch_node(pt.under)
|
minetest.punch_node(pt.under)
|
||||||
return itemstack
|
return itemstack
|
||||||
|
|
12
tools.lua
12
tools.lua
|
@ -23,7 +23,8 @@ farming.register_hoe(":farming:hoe_steel", {
|
||||||
farming.register_scythe(":farming:scythe_wood", {
|
farming.register_scythe(":farming:scythe_wood", {
|
||||||
description = "Wooden Scythe",
|
description = "Wooden Scythe",
|
||||||
inventory_image = "farming_tool_scythe_wood.png",
|
inventory_image = "farming_tool_scythe_wood.png",
|
||||||
-- max_uses = 30,
|
max_uses = 30,
|
||||||
|
farming_change = 20,
|
||||||
material = "group:wood",
|
material = "group:wood",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
|
@ -38,7 +39,8 @@ farming.register_scythe(":farming:scythe_wood", {
|
||||||
farming.register_scythe(":farming:scythe_stone", {
|
farming.register_scythe(":farming:scythe_stone", {
|
||||||
description = "Stone Scythe",
|
description = "Stone Scythe",
|
||||||
inventory_image = "farming_tool_scythe_stone.png",
|
inventory_image = "farming_tool_scythe_stone.png",
|
||||||
-- max_uses = 60,
|
max_uses = 60,
|
||||||
|
farming_change = 10,
|
||||||
material = "group:stone",
|
material = "group:stone",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
|
@ -54,13 +56,15 @@ farming.register_scythe(":farming:scythe_steel", {
|
||||||
description = "Steel Scythe",
|
description = "Steel Scythe",
|
||||||
inventory_image = "farming_tool_scythe_steel.png",
|
inventory_image = "farming_tool_scythe_steel.png",
|
||||||
max_uses = 500,
|
max_uses = 500,
|
||||||
|
farming_change = 6,
|
||||||
material = "default:steel_ingot",
|
material = "default:steel_ingot",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2},
|
||||||
})
|
})
|
||||||
farming.register_billhook(":farming:billhook_wood", {
|
farming.register_billhook(":farming:billhook_wood", {
|
||||||
description = "Wooden Billhook",
|
description = "Wooden Billhook",
|
||||||
inventory_image = "farming_tool_billhook_wood.png",
|
inventory_image = "farming_tool_billhook_wood.png",
|
||||||
-- max_uses = 30,
|
max_uses = 30,
|
||||||
|
farming_change = 20,
|
||||||
material = "group:wood",
|
material = "group:wood",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
|
@ -76,6 +80,7 @@ farming.register_billhook(":farming:billhook_stone", {
|
||||||
description = "Stone Billhook",
|
description = "Stone Billhook",
|
||||||
inventory_image = "farming_tool_billhook_stone.png",
|
inventory_image = "farming_tool_billhook_stone.png",
|
||||||
max_uses = 60,
|
max_uses = 60,
|
||||||
|
farming_change = 10,
|
||||||
material = "group:stone",
|
material = "group:stone",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2},
|
||||||
})
|
})
|
||||||
|
@ -83,6 +88,7 @@ farming.register_billhook(":farming:billhook_steel", {
|
||||||
description = "Steel Billhook",
|
description = "Steel Billhook",
|
||||||
inventory_image = "farming_tool_billhook_steel.png",
|
inventory_image = "farming_tool_billhook_steel.png",
|
||||||
max_uses = 500,
|
max_uses = 500,
|
||||||
|
farming_change = 6,
|
||||||
material = "default:steel_ingot",
|
material = "default:steel_ingot",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue