[Mod] Timber [0.1] [timber]

User avatar
cactuz_pl
Member
 
Posts: 874
Joined: Tue Jun 05, 2012 16:34

by cactuz_pl » Wed Jul 18, 2012 10:06

Can anyone combine these two codes? To get the mod timber operation when the mese axe is wielded.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_tool("timber:axe",{
 type="tool",
   
    description = "Mese axe",
    groups = {},
    inventory_image = "mese_axe.png",
    wield_image = "mese_axe.png",
    wield_scale = {x=1,y=1,z=1},
    stack_max = 1,
    liquids_pointable = false,
    tool_capabilities = {
        full_punch_interval=1.5,
        max_drop_level=1,
        groupcaps={
        crumbly={maxlevel=2, uses=20, times={[1]=1.60, [2]=1.20, [3]=0.80}}
        }
    },
})


minetest.register_craft({
    output = 'timber:axe 1',
    recipe = {
        {'default:mese', 'default:mese'},
        {'default:mese', 'default:stick'},
        {'', 'default:stick'}
       
    },
})


and Jeija code

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree"}

minetest.register_on_dignode(function(pos, node, digger)
    local i=1
    while timber_nodenames[i]~=nil do
        if node.name==timber_nodenames[i] then
            np={x=pos.x, y=pos.y+1, z=pos.z}
            while minetest.env:get_node(np).name==timber_nodenames[i] do
                minetest.env:remove_node(np)
                digger:get_inventory():add_item('main', timber_nodenames[i])
                np={x=np.x, y=np.y+1, z=np.z}
            end
        end
        i=i+1
    end
end)


This may prove to be helpful:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
- get_wield_list(): returns the name of the inventory list the wielded item is in
- get_wield_index(): returns the index of the wielded item
- get_wielded_item() -> ItemStack
- set_wielded_item(item): replaces the wielded item, returns true if successful
Nope
 

jin_xi
Member
 
Posts: 165
Joined: Mon Jul 02, 2012 18:19

by jin_xi » Wed Jul 18, 2012 10:38

maybe put something like this at the beginning of the register_on_dignode function:

if digger:get_wielded_item():get_name() ~= "timber:axe" then
return
end
 

User avatar
cactuz_pl
Member
 
Posts: 874
Joined: Tue Jun 05, 2012 16:34

by cactuz_pl » Wed Jul 18, 2012 11:07

jin_xi wrote:maybe put something like this at the beginning of the register_on_dignode function:

if digger:get_wielded_item():get_name() ~= "timber:axe" then
return
end

Thanks for help.

Jeija's timber mod, mod operation when the mese axe is wielded.
The amount to use an axe: 60
Mese axe craft: like steel axe, but with mese instead steel.

DOWNLOAD
Preview http://pastebin.com/Zk44BTW0
Last edited by cactuz_pl on Wed Jul 18, 2012 11:09, edited 1 time in total.
Nope
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Jul 30, 2012 08:53

 

User avatar
Cooper
Member
 
Posts: 73
Joined: Sat Jun 02, 2012 00:43

by Cooper » Wed Aug 01, 2012 04:11

Jeija wrote:This is the equivalent to the minecraft timber mod.
An easy 2-minute-coding mod.

YouTube (of Minecraft Version)
Works with
- Jungletree
- Tree
- Papyrus
- Cactus

Download
V 0.1 as .zip

License: GPLv3

Jeija your epic
TACOS!!!!!!!!!!!!!!!!!!!!!!!!!
 

chlue
Member
 
Posts: 19
Joined: Wed Dec 21, 2011 23:08

by chlue » Tue Sep 04, 2012 16:13

Hello I have played a bit with the code and created a variant which instead of only going straight upward searches in an upward cone for similar nodes. Additionally nodes are only removed if no similar node is in a 3x3 grid below. I left out the leafs part, because they are removed automatically anyways in recent versions.

I primary did this change so that trees from the nature mod can be chopped down in a reasonable way.

As a result is is possible to timber more complex trees and at the same time is is save to remove a piece of wood from a wall without getting the whole wall timbered down.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree", "conifers:trunk", "irontrees:irontree"}

digupwards = function(pos, searchname, player)
    for dx = -1, 1 do
        for dz = -1, 1 do
            local timerallowed = 1
            timber_pos={x=pos.x+dx, y=pos.y, z=pos.z+dz}

            if minetest.env:get_node(timber_pos).name ~= searchname then
                -- early abort for invalid nodes
                --print("early abort")
                timerallowed = 0
                --continue --check next dz position <-- lua does not have such a command?!
            end

            if timerallowed == 1 then  -- (one additional check to spare the 9 checks)
                for ddx = -1, 1 do
                    for ddz = -1, 1 do
                        local pillar_pos={x=timber_pos.x+ddx, y=timber_pos.y-1, z=timber_pos.z+ddz}
                        --print(minetest.env:get_node(pillar_pos).name)
                        if minetest.env:get_node(pillar_pos).name == searchname then
                            --print("aborting timber because there is a similar node below")
                            timerallowed = 0
                        end
                    end
                end
            end

            if timerallowed == 1 then
                -- Node is of type 'seachname' and no similar node is below in a 3x3 area
                minetest.env:remove_node(timber_pos)

                -- direct addition to inventory
                --player:get_inventory():add_item('main', searchname)

                -- drop item in place (only usefull with autopickup mod)
                local timber_item = minetest.env:add_item(timber_pos, searchname)
                timber_item:get_luaentity().dug_by = player:get_player_name()

                -- increase recursion depth
                timber_pos.y = timber_pos.y + 1
                digupwards(timber_pos, searchname, player)
            end

        end
    end
end

minetest.register_on_dignode(function(pos, node, player)
    for _,timber_nodename in ipairs(timber_nodenames) do
        if node.name==timber_nodename then
            timber_pos={x=pos.x, y=pos.y+1, z=pos.z}
            digupwards(timber_pos, node.name, player)
            return -- there can be only one match
        end
    end
end)
 

Spots
Member
 
Posts: 124
Joined: Tue Jul 24, 2012 12:12

by Spots » Thu Sep 06, 2012 03:15

any way we can get this to work with growing_trees mod? http://minetest.net/forum/viewtopic.php?id=978
 

chlue
Member
 
Posts: 19
Joined: Wed Dec 21, 2011 23:08

by chlue » Thu Sep 06, 2012 11:36

Spots wrote:any way we can get this to work with growing_trees mod? http://minetest.net/forum/viewtopic.php?id=978


I stitched something together, but it is really brute force. --> inefficient as hell, but seem to get this monsters down.

complete content of init.lua:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree", "conifers:trunk", "irontrees:irontree", "growing_trees:trunk"}

growingTreesPartsTable={"growing_trees:trunk", "growing_trees:branch", "growing_trees:branch_xmzm", "growing_trees:branch_xpzm", "growing_trees:branch_xmzp", "growing_trees:branch_xpzp", "growing_trees:branch_zz", "growing_trees:branch_xx", "growing_trees:sprout", "growing_trees:branch_sprout"}

function table.contains(table, element)
  for _, value in pairs(table) do
    if value == element then
      return true
    end
  end
  return false
end

digupwards = function(pos, searchname, player)
    for dx = -1, 1 do
        for dz = -1, 1 do
            for dy = 0, 1 do
                local timerallowed = 1
                timber_pos={x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}

                if searchname == "growing_trees:trunk" then
                    if table.contains(growingTreesPartsTable, minetest.env:get_node(timber_pos).name) == false  then
                        timerallowed = 0
                    end
                else

                    if minetest.env:get_node(timber_pos).name ~= searchname then
                        -- early abort for invalid nodes
                        --print("early abort")
                        timerallowed = 0
                        --continue --check next dz position <-- lua does not have such a command?!
                    end

                end

                if timerallowed == 1 then  -- (one additional check to spare the 9 checks)
                    for ddx = -1, 1 do
                        for ddz = -1, 1 do
                            local pillar_pos={x=timber_pos.x+ddx, y=timber_pos.y-1, z=timber_pos.z+ddz}
                            --print(minetest.env:get_node(pillar_pos).name)
                            if minetest.env:get_node(pillar_pos).name == searchname then
                                --print("aborting timber because there is a similar node below")
                                timerallowed = 0
                            end
                        end
                    end
                end

                if timerallowed == 1 then
                    -- Node is of type 'seachname' and no similar node is below in a 3x3 area
                    local dugname = minetest.env:get_node(timber_pos).name
                    minetest.env:remove_node(timber_pos)

                    -- drop item in place and use get_node_drops function
                    local itemstacks = minetest.get_node_drops(dugname)
                    for _, itemname in ipairs(itemstacks) do
                        if itemname ~= "default:leaves" then
                            local p_drop = {
                                x = timber_pos.x - 0.5 + math.random(),
                                y = timber_pos.y - 0.5 + math.random(),
                                z = timber_pos.z - 0.5 + math.random(),
                            }
                            minetest.env:add_item(p_drop, itemname)
                        end
                    end

                    -- increase recursion depth
                    --timber_pos.y = timber_pos.y + 1
                    digupwards(timber_pos, searchname, player)
                end
            end
        end
    end
end

minetest.register_on_dignode(function(pos, node, player)
    for _,timber_nodename in ipairs(timber_nodenames) do
        if node.name==timber_nodename then
            timber_pos={x=pos.x, y=pos.y+1, z=pos.z}
            digupwards(timber_pos, node.name, player)
            return -- there can be only one match
        end
    end
end)
 

sysedit
Member
 
Posts: 27
Joined: Sun Aug 12, 2012 10:53

by sysedit » Sat Sep 15, 2012 07:49

chlue wrote:
Spots wrote:any way we can get this to work with growing_trees mod? http://minetest.net/forum/viewtopic.php?id=978


I stitched something together, but it is really brute force. --> inefficient as hell, but seem to get this monsters down.

complete content of init.lua:

chlue your solution seems to leave the tip of the tree intact.
 

User avatar
qwrwed
Member
 
Posts: 323
Joined: Sun Jul 22, 2012 20:56
In-game: qwrwed or Nitro

by qwrwed » Sun Oct 21, 2012 17:12

cactuz_pl wrote:
jin_xi wrote:maybe put something like this at the beginning of the register_on_dignode function:

if digger:get_wielded_item():get_name() ~= "timber:axe" then
return
end

Thanks for help.

Jeija's timber mod, mod operation when the mese axe is wielded.
The amount to use an axe: 60
Mese axe craft: like steel axe, but with mese instead steel.

DOWNLOAD
Preview http://pastebin.com/Zk44BTW0


Folder is corrupted or invalid.
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Sun Oct 21, 2012 21:00

cornernote wrote:chainsaw!

and THATS a perfect idea :)
going to add it as another powered tool
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Wed Feb 13, 2013 12:40

License: GPLv3


Yes you can.
 

BZab
Member
 
Posts: 126
Joined: Mon Jan 28, 2013 10:04

by BZab » Wed Feb 13, 2013 20:23

What with moretrees?
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Thu Feb 14, 2013 02:14

I don't know the code in the timber mod, but I doubt it will work with moretrees - they're just too complex. Now if someone wants to write a mod to walk a tree manually...
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

by jojoa1997 » Thu Feb 14, 2013 02:21

it only works with the blocks set in it. this is literally the entire code.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree"}

minetest.register_on_dignode(function(pos, node)
    local i=1
    while timber_nodenames[i]~=nil do
        if node.name==timber_nodenames[i] then
            np={x=pos.x, y=pos.y+1, z=pos.z}
            while minetest.env:get_node(np).name==timber_nodenames[i] do
                minetest.env:remove_node(np)
                minetest.env:add_item(np, timber_nodenames[i])
                np={x=np.x, y=np.y+1, z=np.z}
            end
        end
        i=i+1
    end
end)


and this is the blocks it works with

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree"}
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Thu Feb 14, 2013 03:28

Yup, that won't work with moretrees. You'll have to walk the tree manually then to fell it.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Thu Feb 14, 2013 03:33

I'm working on a small mod that places huts close to trees and offers a way to trade other things for wood so that you don't have to cut down the trees. The trader from Sapiers animals mod is well capable of selling wood when modified. It's still a lot of work until everything will work as I intend it to.
A list of my mods can be found here.
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16

by deivan » Fri Feb 15, 2013 10:31

Hello.

I make a change here:
This line: timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree"}

to this line:
local timber_nodenames={"irontrees:irontree","bamboo:bamboo","bamboo:bamboo_dry","default:jungletree", "default:papyrus", "default:cactus", "default:tree", "vines:vine", "vines:vine_rotten"}

Without the "local" I detected some problems with variables in other mods. Is working fine now. Nice mod.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Feb 15, 2013 16:02

deivan wrote:Hello.

I make a change here:
This line: timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree"}

to this line:
local timber_nodenames={"irontrees:irontree","bamboo:bamboo","bamboo:bamboo_dry","default:jungletree", "default:papyrus", "default:cactus", "default:tree", "vines:vine", "vines:vine_rotten"}

Without the "local" I detected some problems with variables in other mods. Is working fine now. Nice mod.

Rather check for the group "tree".
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16

by deivan » Thu Apr 04, 2013 15:56

This mod, I love this mod, don't is working any more, I think the "minetest.register_on_dignode" is overwrite by the common/init.lua.

Have a plan to make this operational again? I try some tests when I have some time... :-/
 

Axel
Member
 
Posts: 15
Joined: Wed Sep 05, 2012 18:50

by Axel » Thu Apr 04, 2013 16:46

deivan wrote:This mod, I love this mod, don't is working any more, I think the "minetest.register_on_dignode" is overwrite by the common/init.lua.

Have a plan to make this operational again? I try some tests when I have some time... :-/


There was a change in the api, so I've adapted to the new api

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local timber_nodenames={"default:jungletree", "default:papyrus", "default:cactus", "default:tree"}

minetest.register_on_dignode(function(pos, oldnode, digger)
    local i=1
    while timber_nodenames[i] ~= nil do
        if oldnode.name == timber_nodenames[i] then
            local npos = { x=pos.x, y=pos.y+1, z=pos.z }
            local nnode = minetest.env:get_node(npos)
            if nnode.name == timber_nodenames[i] then
                minetest.node_dig(npos, nnode, digger)
            end
        end
        i = i+1
    end
end)
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16

by deivan » Thu Apr 04, 2013 17:15

Thanks, I test it ASAP. :D
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16

by deivan » Wed Apr 10, 2013 01:21

I updated this mod to give the product of a node when this one is dig, the current version clone the node in the scenario and this don't is the correct, a example, the vines:vine drop vines:vines but this mod make a vines:vine again.
I have a plan to counter-attack the growing trees mod, I think, who make bigger (and evil) trees with many side trunks, my plan is to hunt every neighbour of a trunk if is going up, like a natural tree. :D
Last edited by deivan on Wed Apr 10, 2013 01:26, edited 1 time in total.
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Wed Apr 10, 2013 01:33

Maybe you can make this work with trees from the Moretrees mod also, as its tree models also have many branches in all directions (including diagonal)
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16

by deivan » Wed Apr 10, 2013 01:40

I am working to cover any from the group trees and more vines and other natural growing plant's mods. :D
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16

by deivan » Wed Apr 10, 2013 05:34

Ok, I have another mod. :D nt (new timber). Making a new topic to it.
 

User avatar
VoidLord
Member
 
Posts: 46
Joined: Sun Jan 20, 2013 16:07

by VoidLord » Sat Jul 20, 2013 15:42

Great Mod! Saves tools, saves time.
</randomtextcrap>
</forumposthing>
</body>
</html>
/0
 

Soudon
Member
 
Posts: 167
Joined: Wed Apr 08, 2015 17:14
In-game: Soudon

Re:

by Soudon » Wed Oct 21, 2015 05:05

cornernote wrote:Added a change so the leaves fall too:
https://github.com/cornernote/minetest-megapack/blob/master/mods/timber/init.lua


How do I make it that it sends the leaves and the wood to my inventory without dropping to the ground, its a pain running around clicking each one that drops.
 

User avatar
LionsDen
Member
 
Posts: 525
Joined: Thu Jun 06, 2013 03:19

Re: Re:

by LionsDen » Thu Oct 22, 2015 17:18

Soudon wrote:How do I make it that it sends the leaves and the wood to my inventory without dropping to the ground, its a pain running around clicking each one that drops.


Sounds like you need the item_drop mod by PilzAdam.

viewtopic.php?t=2656
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Re:

by Hybrid Dog » Thu Oct 22, 2015 17:56

LionsDen wrote:
Soudon wrote:How do I make it that it sends the leaves and the wood to my inventory without dropping to the ground, its a pain running around clicking each one that drops.


Sounds like you need the item_drop mod by PilzAdam.

viewtopic.php?t=2656

Don't use PilzAdam's one, it's not up to date.
 

PreviousNext

Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 9 guests

cron