Include stripped-down treecapitator, chainsaw and harvester now cuts trees

This commit is contained in:
Evert Prants 2018-08-04 22:10:07 +03:00
parent 37bd7c9c54
commit 93ed7eeeaa
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
13 changed files with 1534 additions and 5 deletions

View File

@ -1,5 +1,4 @@
elepower_papi
elepower_tools
elepower_fapi
bucket
farming
@ -7,3 +6,5 @@ fluid_tanks
mobs?
mobs_animal?
mobs_monster?
moretrees?
ethereal?

View File

@ -6,6 +6,7 @@ local modpath = minetest.get_modpath(minetest.get_current_modname())
elefarm = rawget(_G, "elefarm") or {}
elefarm.modpath = modpath
dofile(modpath.."/treecutter.lua")
dofile(modpath.."/craftitems.lua")
dofile(modpath.."/nodes/init.lua")
dofile(modpath.."/crafting.lua")

View File

@ -1,4 +1,4 @@
name = elepower_farming
description = Electric Farming Automation!
depends = elepower_papi, elepower_tools, elepower_fapi, bucket, farming, fluid_tanks
optional_depends = mobs, mobs_animal, mobs_monster
depends = elepower_papi, elepower_fapi, bucket, farming, fluid_tanks
optional_depends = mobs, mobs_animal, mobs_monster, moretrees, ethereal

View File

@ -64,6 +64,14 @@ local function harvest(pos, harvested, fdir)
shots = shots - 1
end
end
elseif check_node and ele.helpers.get_item_group(check_node.name, "tree") then
local success = elefarm.tc.capitate_tree(vector.subtract(check_pos, {x=0,y=1,z=0}))
if success then
shots = 0
for _,i in pairs(success) do
harvested[#harvested + 1] = i
end
end
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -82,8 +82,14 @@ function ele.register_tool(toolname, tooldef)
end
end
local original_after_use = tooldef.after_use
-- Apply wear
tooldef.after_use = function (itemstack, user, node, digparams)
if original_after_use then
itemstack = original_after_use(itemstack, user, node, digparams)
end
local meta = itemstack:get_meta()
local storage = ele.tools.get_tool_property(itemstack, "storage")
local usage = ele.tools.get_tool_property(itemstack, "usage")
@ -103,5 +109,34 @@ function ele.register_tool(toolname, tooldef)
return itemstack
end
-- Special uses tools
if tooldef.on_use then
local original_on_use = tooldef.on_use
tooldef.on_use = function (itemstack, player, pointed_thing)
if not player or minetest.is_protected(pos, player:get_player_name()) then
return itemstack
end
local storage = ele.tools.get_tool_property(itemstack, "storage")
local usage = ele.tools.get_tool_property(itemstack, "usage")
local pos = pointed_thing.under
if not pos or storage < usage then
return nil
end
local original_stack = ItemStack(itemstack)
itemstack = original_on_use(itemstack, player, pointed_thing)
if not itemstack then
return nil
end
local node = minetest.get_node(pos)
return tooldef.after_use(itemstack, player, node, {wear = 1, time = 0, diggable = true})
end
end
minetest.register_tool(toolname, tooldef)
end

View File

@ -1,4 +1,5 @@
-- Drill
minetest.register_craft({
output = "elepower_tools:drill_bit",
recipe = {
@ -15,3 +16,22 @@ minetest.register_craft({
{"elepower_dynamics:motor", "elepower_dynamics:capacitor", ""},
}
})
-- Chainsaw
minetest.register_craft({
output = "elepower_tools:chain",
recipe = {
{"", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "elepower_dynamics:steel_plate", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", ""},
}
})
minetest.register_craft({
output = "elepower_tools:chainsaw",
recipe = {
{"", "elepower_dynamics:wound_copper_coil", "elepower_tools:chain"},
{"default:steel_ingot", "elepower_dynamics:battery", "default:steel_ingot"},
{"elepower_dynamics:motor", "elepower_dynamics:capacitor", ""},
}
})

View File

@ -3,3 +3,8 @@ minetest.register_craftitem("elepower_tools:drill_bit", {
description = "Drill Bit",
inventory_image = "eletools_drill_bit.png",
})
minetest.register_craftitem("elepower_tools:chain", {
description = "Chainsaw Chain",
inventory_image = "eletools_chain.png",
})

View File

@ -1 +1,2 @@
elepower_papi
elepower_farming

View File

@ -1,3 +1,3 @@
name = elepower_tools
description = Elepower powered tools!
depends = elepower_papi
depends = elepower_papi,elepower_farming

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B

View File

@ -11,5 +11,38 @@ ele.register_tool("elepower_tools:hand_drill", {
},
damage_groups = {fleshy=4},
},
ele_capacity = 8000
ele_capacity = 8000,
})
ele.register_tool("elepower_tools:chainsaw", {
description = "Chainsaw",
inventory_image = "eletools_chainsaw.png",
wield_image = "eletools_chainsaw.png^[transformFX",
ele_capacity = 8000,
ele_usage = 250,
on_use = function (itemstack, user, pointed_thing)
local pos = pointed_thing.under
local node = minetest.get_node(pos)
if not ele.helpers.get_item_group(node.name, "tree") then
return nil
end
local drops = elefarm.tc.capitate_tree(vector.subtract(pos, {x=0,y=1,z=0}), user)
if not drops or #drops == 0 then
return nil
end
local inv = user:get_inventory()
for _,drop in pairs(drops) do
local st = ItemStack(drop)
if inv:room_for_item("main", st) then
inv:add_item("main", st)
else
minetest.item_drop(st, user, pos)
end
end
return itemstack
end
})