[Mod] Timber [0.1] [timber]

User avatar
Topywo
Member
 
Posts: 1720
Joined: Fri May 18, 2012 20:27

by Topywo » Tue Jul 10, 2012 15:17

Jeija wrote:Topywo, I think that is caused by a "bug" in minetest, to be more precise:
Minetest only loads some chunks around you.
If a mod tries to acces a node that is too far away, in an unloaded chunk, minetest simply ignores that. That happens in this mod, as the stone below you seems to be unloaded as well as in the mesecons mod where too big structures don`t work.


Thanks for explaining it!
 

neo
Member
 
Posts: 56
Joined: Fri Jun 15, 2012 07:50
Location: france
 

User avatar
redcrab
Member
 
Posts: 831
Joined: Tue Dec 13, 2011 13:45
Location: France

by redcrab » Wed Jul 11, 2012 19:01

love it ... should be working only with a special tool ... for instance a mese axe
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net

It's nice to be important but it is more important to be nice.
 

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

neo
Member
 
Posts: 56
Joined: Fri Jun 15, 2012 07:50
Location: france

by neo » Fri Jul 13, 2012 07:20

cornernote wrote:chainsaw!


MUhahahaha.... YAY !
 

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

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.
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

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:
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
Location: Poland

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
 

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.

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
Location: Outta my mind someplace.

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:
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: 325
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
Moderator
 
Posts: 3145
Joined: Mon Aug 01, 2011 14:26
Location: Troyes, France
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
Location: Poland

by BZab » Wed Feb 13, 2013 20:23

What with moretrees?
 

User avatar
VanessaE
Moderator
 
Posts: 4309
Joined: Sun Apr 01, 2012 12:38
Location: Waynesville, NC
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE

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)
 

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

by jojoa1997 » Thu Feb 14, 2013 02:21

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

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

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
Moderator
 
Posts: 4309
Joined: Sun Apr 01, 2012 12:38
Location: Waynesville, NC
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE

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)
 

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

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
Location: Brazil. :D

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
Location: Germany
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
Location: Brazil. :D

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... :-/
 

PreviousNext

Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 9 guests