[Mod] Technic [0.4.16-dev] [technic]

User avatar
Excalibur Zero
Member
 
Posts: 142
Joined: Tue Apr 02, 2013 19:45
Location: United States
GitHub: ExcaliburZero

by Excalibur Zero » Sat Apr 06, 2013 17:51

RealBadAngel wrote:
Excalibur Zero wrote:I have one question. How exactly do you set the music files for the music player? I put an ogg file named "technic_track1.ogg" in ".../minetest-0.4.5-8d4b768-rc0-win32\mods\minetest\technic-master\technic\sounds", but it won't play as track one. What am I doing wrong with it?

Place and name is ok. Is your music player powered properly?

Yep, it is at full power.
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Mon Apr 08, 2013 17:16

The water mill have a reference to the technic:diamond in the recipe, I think.
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Wed Apr 10, 2013 13:21

The sonic screwdriver have a technic:diamond in the recipe to. The water mill is working now. :)
I have unknown blocks from the rubber tree (technic). I found one or two in my game.
 

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

by VanessaE » Wed Apr 10, 2013 21:40

Moretrees now covers the rubber tree functionality needed by the technic mod.

Grab that here: http://forum.minetest.net/viewtopic.php?id=4394

(You can turn off the trees you don't want)
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Wed Apr 10, 2013 22:24

I already have more trees here... But the new version don't erase any old version from the map, is a alias thing?
 

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

by VanessaE » Wed Apr 10, 2013 23:32

Indeed, moretrees just needed a couple of aliases. Technic may need some minor code changes to accommodate it, also.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D
 

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

by RealBadAngel » Sun Apr 14, 2013 04:39

technic from now on is splitted into 2 trees
stable, which will be updated with every stable release of the game (or bugfxes and hotfixes)
indev, where we gonna have new functionality thx to evolving core. also things we would like to test and try before they go stable.

I realize some parts of the mod can cross those borders at its current state and im sorry for it.
This is rather big change for the mod, and it cannot be done in a blink.
Things shall stabilize with next stable release of the game, 0.4.7

I made this decision to avoid problems for new users tryin just to play.
All vets can as ususal pick indev and have fun ;)

New in indev: improved CraftingGuide thx to core changes i made.No more hooks are needed to get them all. Soon groups in recipes solution and back of grinding and alloy recipes.
Last edited by RealBadAngel on Sun Apr 14, 2013 04:45, edited 1 time in total.
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Tue Apr 16, 2013 11:33

The Geothermal generator still with the technic diamond in the recipe, like the sonic screwdriver.
You plan some type of manual generator? Like a "jump generator" or "run generator"? Fixed in a place or a item, if you is running of jumping and have the item a battery inside gain power. :D
 

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

by VanessaE » Tue Apr 16, 2013 12:42

Those recipes have already been fixed in the 'indev' branch.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Tue Apr 16, 2013 12:44

I have the git version here, have another one?
 

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

by VanessaE » Tue Apr 16, 2013 12:55

go to the technic folder, git pull; git checkout indev

then install it into your mods folder like usual.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Tue Apr 16, 2013 13:22

I have a message here... "Already is update".

Have a alias inside the unified inventory? I split the technic mod in two stages to don't have the unified here. Maybe is this the cause of my problem.

Well, I have a alias in my library to cover my problem here, anyway...
minetest.register_alias("technic:diamond","default:diamond")
Last edited by deivan on Wed Apr 17, 2013 12:39, edited 1 time in total.
 

kpo
Member
 
Posts: 38
Joined: Sun Mar 31, 2013 19:01

by kpo » Sat Apr 20, 2013 22:28

Let me start out by saying I am really impressed wih this mod!

I have some suggestions for you I think could make it even better:
  • The various technic tools have batteries. I would have liked them to be made with battery compartments, and a right click formspec to let me put fresh batteries in them and take out depleted ones. This way I can carry a stack of charged batteries and only one tool.
  • Let fully charged and fully discharged batteries be stacked. Anything in between should not be stackable. Maybe have a portable battery box with some slots for the batteries. It would make sense as carrying around loose batteries could cause electrical chock and possibly death :-) A battery box might make things easier to code as the batteries can still be at individual positions.
  • A new tool: Minieral detector. Again a battery powered tool which with a guage and tiers of upgrades can detect minerals in the underground in front of the player. I think of this like a HxWxD: 3x3xD detection area where the depth could be fixed or configurable and a guage reporting the mineral richness in front of the player. Have different tiers like the mining drill enabling detection of first coal and iron, copper and, tin, later silver, gold, mithril, uranium, chrome, zinc etc.
  • A suggestion on tool tiers: Now that we can make formspecs on items (using minetest.show_formspec()) I suggest the tiering to be in the form of tool upgrades. For example the mining drill would be produced in the basic version. Then upgraded with a better drill head and energy source but still essentially the same tool you built to start with. Upgrades could even be extended to a choice between extra batteries or better drill head or other properties of the tool at hand becaue the upgrade sockets would be limited perhaps.

I have experimented with the "on_place()" call back on a craft_item to call up a formspec and it works nicely.
I haven't figured how to change the inventory image dynamically when wieldig the item, so my guage idea got me stumped on this. Reporting in the chat area is just not as sexy .-)

There is a mineral detector mod out there but it is a placeable node and needs some hefty updates (which are not hard to do though) to support all the different mineral types. I just think the technic mod could solve this in a much much nicer and coherent way.

I hope you or someone else more knowing of the Lua language can use these ideas in this mod or in another one. The ideas are out there now and free to use.
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Sat Apr 20, 2013 22:49

I already have the mineral detector in "renew state"... This mod already exist a some time ago and is the first mod repaired by me when discovered the minetest but my current version is experimental and have many bugs.

I like the idea about batteries, is very logic.
 

1244
Member
 
Posts: 45
Joined: Fri Jul 13, 2012 16:40
Location: Poland

by 1244 » Sun Apr 21, 2013 07:22

What do you think about single-use battery. Crafting it will be cheaper than RE battery but when you craft it this battery will be charged. You could use this battery only one time. To storing large amount of energy we can add energy crystal box. This thing facilitate storing large amount of energy.
Last edited by 1244 on Sun Apr 21, 2013 07:23, edited 1 time in total.
 

chamweisheng
Member
 
Posts: 25
Joined: Tue Feb 19, 2013 14:18
Location: EARTH: MALAYSIA

by chamweisheng » Sun Apr 21, 2013 07:46

they say fail to load and run
 

kpo
Member
 
Posts: 38
Joined: Sun Mar 31, 2013 19:01

by kpo » Tue Apr 23, 2013 20:49

Hi RealBadAngel

Okay so I really _really_ like this mod. In fact so much that I dabbled a bit with your chainsaw code.
Basically I rewrote a lot of it. Here it is if you want to use it oranyone else wants to.
Simply replace the whole chainsaw.lua file with this.

Features:
Supports "moretrees", "growing_trees", "growing '_cactus" without depending on them.
Supports cutting down *entire* trees - leaves and all.
The cutting of each node costs power on the saw and the default setting allows for cutting 500 nodes or about 6 normal trees.
There are some configuration variables in the top to set the cost and wether to cut down leaves or not.

Major changes to your code:
Instead of performing a (lua) linear search to find the node being cut I use a dictionary key which is faster.
I check recursively for nodes to cut down meaning the tree will (if we could do slow motion) will desintegrate from the starting point outwards and upwards.
Finally each node cut down will suck power from the saw.

I hope you like it and maybe want to include it in your mod as an official part. Give credit if you want to.

chainsaw.lua
Code: Select all
-- Configuration
local chainsaw_max_charge      = 30000 -- 30000 - Maximum charge of the saw
local chainsaw_charge_per_node = 60    -- 60    - Gives 500 nodes on a single charge (about 6 complete trees)
local chainsaw_leaves          = true  -- true  - Cut down entire trees, leaves and all

register_power_tool ("technic:chainsaw",chainsaw_max_charge)

minetest.register_tool("technic:chainsaw", {
    description = "Chainsaw",
    inventory_image = "technic_chainsaw.png",
    stack_max = 1,
    on_use = function(itemstack, user, pointed_thing)
        if pointed_thing.type=="node" then
          item=itemstack:to_table()
          local meta=get_item_meta(item["metadata"])
          if meta==nil then return end --tool not charged
          if meta["charge"]==nil then return end
                  -- Send current charge to digging function so that the chainsaw will stop after digging a number of nodes.
          local charge=meta["charge"]
                  if charge < chainsaw_charge_per_node then return end -- only cut if charged

                  charge=chainsaw_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,charge)
          set_RE_wear(item,charge,chainsaw_max_charge)
          meta["charge"]=charge
          item["metadata"]=set_item_meta(meta)
          itemstack:replace(item)
          return itemstack
        end
    end,
})

minetest.register_craft({
    output = 'technic:chainsaw',
    recipe = {
        {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'},
        {'technic:stainless_steel_ingot', 'technic:motor', 'technic:battery'},
        {'','','moreores:copper_ingot'},
    }
})

-- The default stuff
local timber_nodenames={["default:jungletree"] = true,
                        ["default:papyrus"]    = true,
                ["default:cactus"]     = true,
                ["default:tree"]       = true
}

if chainsaw_leaves == true then
  timber_nodenames["default:leaves"] = true
end

-- Support moretrees if it is there
if( minetest.get_modpath("moretrees") ~= nil ) then
  timber_nodenames["moretrees:apple_tree_trunk"]                 = true
  timber_nodenames["moretrees:apple_tree_trunk_sideways"]        = true
  timber_nodenames["moretrees:beech_tree_trunk"]                 = true
  timber_nodenames["moretrees:beech_tree_trunk_sideways"]        = true
  timber_nodenames["moretrees:birch_tree_trunk"]                 = true
  timber_nodenames["moretrees:birch_tree_trunk_sideways"]        = true
  timber_nodenames["moretrees:fir_tree_trunk"]                   = true
  timber_nodenames["moretrees:fir_tree_trunk_sideways"]          = true
  timber_nodenames["moretrees:oak_tree_trunk"]                   = true
  timber_nodenames["moretrees:oak_tree_trunk_sideways"]          = true
  timber_nodenames["moretrees:palm_tree_trunk"]                  = true
  timber_nodenames["moretrees:palm_tree_trunk_sideways"]         = true
  timber_nodenames["moretrees:pine_tree_trunk"]                  = true
  timber_nodenames["moretrees:pine_tree_trunk_sideways"]         = true
  timber_nodenames["moretrees:rubber_tree_trunk"]                = true
  timber_nodenames["moretrees:rubber_tree_trunk_sideways"]       = true
  timber_nodenames["moretrees:rubber_tree_trunk_empty"]          = true
  timber_nodenames["moretrees:rubber_tree_trunk_sideways_empty"] = true
  timber_nodenames["moretrees:sequoia_tree_trunk"]               = true
  timber_nodenames["moretrees:sequoia_tree_trunk_sideways"]      = true
  timber_nodenames["moretrees:spruce_tree_trunk"]                = true
  timber_nodenames["moretrees:spruce_tree_trunk_sideways"]       = true
  timber_nodenames["moretrees:willow_tree_trunk"]                = true
  timber_nodenames["moretrees:willow_tree_trunk_sideways"]       = true
  timber_nodenames["moretrees:sequoia_trunk"]                    = true
  timber_nodenames["moretrees:sequoia_trunk_sideways"]           = true

  if chainsaw_leaves == true then
    timber_nodenames["moretrees:apple_tree_leaves"]        = true
    timber_nodenames["moretrees:oak_leaves"]               = true
    timber_nodenames["moretrees:sequoia_leaves"]           = true
    timber_nodenames["moretrees:birch_leaves"]             = true
    timber_nodenames["moretrees:birch_leaves"]             = true
    timber_nodenames["moretrees:palm_leaves"]              = true
    timber_nodenames["moretrees:spruce_leaves"]            = true
    timber_nodenames["moretrees:spruce_leaves"]            = true
    timber_nodenames["moretrees:pine_leaves"]              = true
    timber_nodenames["moretrees:willow_leaves"]            = true
    timber_nodenames["moretrees:rubber_tree_leaves"]       = true
    timber_nodenames["moretrees:jungletree_leaves_green"]  = true
    timber_nodenames["moretrees:jungletree_leaves_yellow"] = true
    timber_nodenames["moretrees:jungletree_leaves_red"]    = true
  end
end

-- Support growing_trees if it is there
if( minetest.get_modpath("growing_trees") ~= nil ) then
  timber_nodenames["growing_trees:trunk"]         = true
  timber_nodenames["growing_trees:medium_trunk"]  = true
  timber_nodenames["growing_trees:big_trunk"]     = true
  timber_nodenames["growing_trees:trunk_top"]     = true
  timber_nodenames["growing_trees:trunk_sprout"]  = true
  timber_nodenames["growing_trees:branch_sprout"] = true
  timber_nodenames["growing_trees:branch"]        = true
  timber_nodenames["growing_trees:branch_xmzm"]   = true
  timber_nodenames["growing_trees:branch_xpzm"]   = true
  timber_nodenames["growing_trees:branch_xmzp"]   = true
  timber_nodenames["growing_trees:branch_xpzp"]   = true
  timber_nodenames["growing_trees:branch_zz"]     = true
  timber_nodenames["growing_trees:branch_xx"]     = true

  if chainsaw_leaves == true then
    timber_nodenames["growing_trees:leaves"] = true
  end
end

-- Support growing_cactus if it is there
if( minetest.get_modpath("growing_cactus") ~= nil ) then
  timber_nodenames["growing_cactus:sprout"]                       = true
  timber_nodenames["growing_cactus:branch_sprout_vertical"]       = true
  timber_nodenames["growing_cactus:branch_sprout_vertical_fixed"] = true
  timber_nodenames["growing_cactus:branch_sprout_xp"]             = true
  timber_nodenames["growing_cactus:branch_sprout_xm"]             = true
  timber_nodenames["growing_cactus:branch_sprout_zp"]             = true
  timber_nodenames["growing_cactus:branch_sprout_zm"]             = true
  timber_nodenames["growing_cactus:trunk"]                        = true
  timber_nodenames["growing_cactus:branch_trunk"]                 = true
  timber_nodenames["growing_cactus:branch"]                       = true
  timber_nodenames["growing_cactus:branch_xp"]                    = true
  timber_nodenames["growing_cactus:branch_xm"]                    = true
  timber_nodenames["growing_cactus:branch_zp"]                    = true
  timber_nodenames["growing_cactus:branch_zm"]                    = true
  timber_nodenames["growing_cactus:branch_zz"]                    = true
  timber_nodenames["growing_cactus:branch_xx"]                    = true
end

-- Saw down trees entry point
function chainsaw_dig_it (pos, player,current_charge)       
    local remaining_charge=current_charge
    remaining_charge = recursive_dig(pos, remaining_charge)
        return remaining_charge
end

-- This function does all the hard work. Recursively we dig the node at hand
-- if it is in the table and then search the surroundings for more stuff to dig.
function recursive_dig(pos, remaining_charge)
    local node=minetest.env:get_node(pos)
    local i=1
    -- Lookup node name in timber table:
    if timber_nodenames[node.name] ~= nil then
                -- Return if we are out of power
        if remaining_charge < chainsaw_charge_per_node then
          return 0
        end
            local np
                -- wood found - cut it
            minetest.env:dig_node(pos)
            remaining_charge=remaining_charge-chainsaw_charge_per_node
                        -- check surroundings and run recursively if any charge left
             np={x=pos.x+1, y=pos.y, z=pos.z}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end
             np={x=pos.x+1, y=pos.y, z=pos.z+1}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end
             np={x=pos.x+1, y=pos.y, z=pos.z-1}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end

             np={x=pos.x-1, y=pos.y, z=pos.z}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end
             np={x=pos.x-1, y=pos.y, z=pos.z+1}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end
             np={x=pos.x-1, y=pos.y, z=pos.z-1}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end

             np={x=pos.x, y=pos.y+1, z=pos.z}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end

             np={x=pos.x, y=pos.y, z=pos.z+1}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end
             np={x=pos.x, y=pos.y, z=pos.z-1}
            if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
              remaining_charge = recursive_dig(np, remaining_charge)
            end
            minetest.sound_play("chainsaw", {pos = pos, gain = 1.0, max_hear_distance = 10,})
            return remaining_charge   
    end
    -- Nothing sawed down
    return remaining_charge
end


Regards!
Last edited by kpo on Tue Apr 23, 2013 20:51, edited 1 time in total.
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Tue Apr 23, 2013 22:38

Is the timber mod in a tool?
 

kpo
Member
 
Posts: 38
Joined: Sun Mar 31, 2013 19:01

by kpo » Tue Apr 23, 2013 22:44

deivan wrote:Is the timber mod in a tool?


I think the chainsaw covers your timber mod with my suggestion above yes.
As far as I understand your code you try to get all the wood in the tree and let the leaves decay.
Basically I do the same except I have the option of bringing the whole thing down... and I use the Technic chainsaw to do the action.
 

deivan
Member
 
Posts: 452
Joined: Fri Feb 15, 2013 10:16
Location: Brazil. :D

by deivan » Tue Apr 23, 2013 22:54

Don't is my mod... I only repaired this. Have some problems at my first contact.
 

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

by RealBadAngel » Tue Apr 23, 2013 23:15

@kpo
Thx for support :)
idea looks cool, i propose some changes tho
(tested it on moretrees)
it should rather group dug items and drop them in stacks, cutting bigger trees can jam the game (in fact it did it a few times)

heres version with some changes to format and proper moretrees trunk names
http://realbadangel.pl/chainsaw.lua

Try to tune it a bit and i will merge the changes.
 

kpo
Member
 
Posts: 38
Joined: Sun Mar 31, 2013 19:01

by kpo » Wed Apr 24, 2013 20:29

RealBadAngel wrote:@kpo
Thx for support :)
idea looks cool, i propose some changes tho
(tested it on moretrees)
it should rather group dug items and drop them in stacks, cutting bigger trees can jam the game (in fact it did it a few times)

heres version with some changes to format and proper moretrees trunk names
http://realbadangel.pl/chainsaw.lua

Try to tune it a bit and i will merge the changes.


I know. That is partly why I set it to 500 nodes. But using Adam's item_drop mod can bring a slower serer to it's knees for a while :-)
What I figured was that I have to call dig_node() to get the right output instead of just adding the node to the inventory. Especially the growing mods have various branch types which all drop default:<stuff> when dug.
Do you have any knowledge o how to collect the right outputs and stack them up?

My idea so far is to count up all the different types, while removing them and somehow drop a stack on the ground once all the recursiveness is finished. Not as spectacular as it is now but less taxing on the server definitely.
Any suggestions?

Edit: the dig_node() is also needed because some of these nodes can actually additionally drop other things like saplings etc. If I simply add the resulting node to the inventory, none of those will be generated. If only there was a way to "pseudo dig" non-existing nodes (to get the right droppings calcualted)...
Last edited by kpo on Wed Apr 24, 2013 20:44, edited 1 time in total.
 

kpo
Member
 
Posts: 38
Joined: Sun Mar 31, 2013 19:01

by kpo » Fri Apr 26, 2013 22:34

Hi RealBadAngel

Here's the updated code which is massively less server killing. I am using a few tricks to make the magic happen but the effect is nice:
Now the chainsaw uses 12 charge per node. A normal MT tree has about 50 nodes including leaves to by that I stick to your original setting of about 50 normal trees per charge.
Furthermore the correct drops are calculated and dropped in the area in stacks or 99 or less.
The chainsaw sound is played only once, not once per node removed :-)

Here's the code for you to include in the technic mod. I hope the indentation doesn't go bust (8 space indents):
Code: Select all
-- Configuration
local chainsaw_max_charge      = 30000 -- 30000 - Maximum charge of the saw
local chainsaw_charge_per_node = 12    -- 12    - Gives 2500 nodes on a single charge (about 50 complete normal trees)
local chainsaw_leaves          = true  -- true  - Cut down entire trees, leaves and all

register_power_tool ("technic:chainsaw",chainsaw_max_charge)

minetest.register_tool("technic:chainsaw", {
        description = "Chainsaw",
        inventory_image = "technic_chainsaw.png",
        stack_max = 1,
        on_use = function(itemstack, user, pointed_thing)
                if pointed_thing.type=="node" then
                        item=itemstack:to_table()
                        local meta=get_item_meta(item["metadata"])
                        if meta==nil then return end --tool not charged
                        if meta["charge"]==nil then return end
                        -- Send current charge to digging function so that the chainsaw will stop after digging a number of nodes.
                        local charge=meta["charge"]
                        if charge < chainsaw_charge_per_node then return end -- only cut if charged

                        charge=chainsaw_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,charge)
                        set_RE_wear(item,charge,chainsaw_max_charge)
                        meta["charge"]=charge
                        item["metadata"]=set_item_meta(meta)
                        itemstack:replace(item)
                        return itemstack
                end
        end,
})

minetest.register_craft({
        output = 'technic:chainsaw',
        recipe = {
                {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'},
                {'technic:stainless_steel_ingot', 'technic:motor', 'technic:battery'},
                {'','','moreores:copper_ingot'},
        }
})

-- The default stuff
local timber_nodenames={["default:jungletree"] = true,
                        ["default:papyrus"]    = true,
                        ["default:cactus"]     = true,
                        ["default:tree"]       = true,
                        ["default:apple"]      = true
}

if chainsaw_leaves == true then
        timber_nodenames["default:leaves"] = true
end

-- Support moretrees if it is there
if( minetest.get_modpath("moretrees") ~= nil ) then
        timber_nodenames["moretrees:apple_tree_trunk"]                 = true
        timber_nodenames["moretrees:apple_tree_trunk_sideways"]        = true
        timber_nodenames["moretrees:beech_trunk"]                      = true
        timber_nodenames["moretrees:beech_trunk_sideways"]             = true
        timber_nodenames["moretrees:birch_trunk"]                      = true
        timber_nodenames["moretrees:birch_trunk_sideways"]             = true
        timber_nodenames["moretrees:fir_trunk"]                        = true
        timber_nodenames["moretrees:fir_trunk_sideways"]               = true
        timber_nodenames["moretrees:oak_trunk"]                        = true
        timber_nodenames["moretrees:oak_trunk_sideways"]               = true
        timber_nodenames["moretrees:palm_trunk"]                       = true
        timber_nodenames["moretrees:palm_trunk_sideways"]              = true
        timber_nodenames["moretrees:pine_trunk"]                       = true
        timber_nodenames["moretrees:pine_trunk_sideways"]              = true
        timber_nodenames["moretrees:rubber_tree_trunk"]                = true
        timber_nodenames["moretrees:rubber_tree_trunk_sideways"]       = true
        timber_nodenames["moretrees:rubber_tree_trunk_empty"]          = true
        timber_nodenames["moretrees:rubber_tree_trunk_sideways_empty"] = true
        timber_nodenames["moretrees:sequoia_trunk"]                    = true
        timber_nodenames["moretrees:sequoia_trunk_sideways"]           = true
        timber_nodenames["moretrees:spruce_trunk"]                     = true
        timber_nodenames["moretrees:spruce_trunk_sideways"]            = true
        timber_nodenames["moretrees:willow_trunk"]                     = true
        timber_nodenames["moretrees:willow_trunk_sideways"]            = true
        timber_nodenames["moretrees:jungletree_trunk"]                 = true
        timber_nodenames["moretrees:jungletree_trunk_sideways"]        = true

        if chainsaw_leaves == true then
                timber_nodenames["moretrees:apple_tree_leaves"]        = true
                timber_nodenames["moretrees:oak_leaves"]               = true
                timber_nodenames["moretrees:sequoia_leaves"]           = true
                timber_nodenames["moretrees:birch_leaves"]             = true
                timber_nodenames["moretrees:birch_leaves"]             = true
                timber_nodenames["moretrees:palm_leaves"]              = true
                timber_nodenames["moretrees:spruce_leaves"]            = true
                timber_nodenames["moretrees:spruce_leaves"]            = true
                timber_nodenames["moretrees:pine_leaves"]              = true
                timber_nodenames["moretrees:willow_leaves"]            = true
                timber_nodenames["moretrees:rubber_tree_leaves"]       = true
                timber_nodenames["moretrees:jungletree_leaves_green"]  = true
                timber_nodenames["moretrees:jungletree_leaves_yellow"] = true
                timber_nodenames["moretrees:jungletree_leaves_red"]    = true
        end
end

-- Support growing_trees if it is there
if( minetest.get_modpath("growing_trees") ~= nil ) then
        timber_nodenames["growing_trees:trunk"]         = true
        timber_nodenames["growing_trees:medium_trunk"]  = true
        timber_nodenames["growing_trees:big_trunk"]     = true
        timber_nodenames["growing_trees:trunk_top"]     = true
        timber_nodenames["growing_trees:trunk_sprout"]  = true
        timber_nodenames["growing_trees:branch_sprout"] = true
        timber_nodenames["growing_trees:branch"]        = true
        timber_nodenames["growing_trees:branch_xmzm"]   = true
        timber_nodenames["growing_trees:branch_xpzm"]   = true
        timber_nodenames["growing_trees:branch_xmzp"]   = true
        timber_nodenames["growing_trees:branch_xpzp"]   = true
        timber_nodenames["growing_trees:branch_zz"]     = true
        timber_nodenames["growing_trees:branch_xx"]     = true

        if chainsaw_leaves == true then
                timber_nodenames["growing_trees:leaves"] = true
        end
end

-- Support growing_cactus if it is there
if( minetest.get_modpath("growing_cactus") ~= nil ) then
        timber_nodenames["growing_cactus:sprout"]                       = true
        timber_nodenames["growing_cactus:branch_sprout_vertical"]       = true
        timber_nodenames["growing_cactus:branch_sprout_vertical_fixed"] = true
        timber_nodenames["growing_cactus:branch_sprout_xp"]             = true
        timber_nodenames["growing_cactus:branch_sprout_xm"]             = true
        timber_nodenames["growing_cactus:branch_sprout_zp"]             = true
        timber_nodenames["growing_cactus:branch_sprout_zm"]             = true
        timber_nodenames["growing_cactus:trunk"]                        = true
        timber_nodenames["growing_cactus:branch_trunk"]                 = true
        timber_nodenames["growing_cactus:branch"]                       = true
        timber_nodenames["growing_cactus:branch_xp"]                    = true
        timber_nodenames["growing_cactus:branch_xm"]                    = true
        timber_nodenames["growing_cactus:branch_zp"]                    = true
        timber_nodenames["growing_cactus:branch_zm"]                    = true
        timber_nodenames["growing_cactus:branch_zz"]                    = true
        timber_nodenames["growing_cactus:branch_xx"]                    = true
end

-- Table for saving what was sawed down
local produced

-- Saw down trees entry point
chainsaw_dig_it = function(pos, player,current_charge)
        local remaining_charge=current_charge

        -- A bit of trickery here: use a different node drop callback
        -- and restore the original afterwards.
        minetest.handle_node_drops = chainsaw_handle_node_drops

        -- clear result and start sawing things down
        produced = {}
        remaining_charge = recursive_dig(pos, remaining_charge, player)
        minetest.sound_play("chainsaw", {pos = pos, gain = 1.0, max_hear_distance = 10,})

        -- Restore the original noder drop handler
        minetest.handle_node_drops = original_handle_node_drops

        -- Now drop items for the player
        local number, produced_item, p
        for produced_item,number in pairs(produced) do
                --print("ADDING ITEM: " .. produced_item .. " " .. number)
                -- Drop stacks of 99 or less
                p = {
                        x = pos.x + math.random()*4,
                        y = pos.y,
                        z = pos.z + math.random()*4
                }
                while number > 99 do
                        minetest.env:add_item(p, produced_item .. " 99")
                        p = {
                                x = pos.x + math.random()*4,
                                y = pos.y,
                                z = pos.z + math.random()*4
                        }
                        number = number - 99
                end
                minetest.env:add_item(p, produced_item .. " " .. number)
        end
        return remaining_charge
end

-- Override the default handling routine to be able to count up the
-- items sawed down so that we can drop them i an nice single stack
chainsaw_handle_node_drops = function(pos, drops, digger)
        -- Add dropped items to list of collected nodes
        local _, dropped_item
        for _, dropped_item in ipairs(drops) do
                if produced[dropped_item] == nil then
                        produced[dropped_item] = 1
                else
                        produced[dropped_item] = produced[dropped_item] + 1
                end
        end
end

-- Save the currently installed dropping mechanism so we can restore it.
local original_handle_node_drops = minetest.handle_node_drops

-- This function does all the hard work. Recursively we dig the node at hand
-- if it is in the table and then search the surroundings for more stuff to dig.
recursive_dig = function(pos, remaining_charge, player)
        local node=minetest.env:get_node(pos)
        local i=1
        -- Lookup node name in timber table:
        if timber_nodenames[node.name] ~= nil then
                -- Return if we are out of power
                if remaining_charge < chainsaw_charge_per_node then
                        return 0
                end
                local np
                -- wood found - cut it.
                minetest.env:dig_node(pos)

                remaining_charge=remaining_charge-chainsaw_charge_per_node
                -- check surroundings and run recursively if any charge left
                np={x=pos.x+1, y=pos.y, z=pos.z}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end
                np={x=pos.x+1, y=pos.y, z=pos.z+1}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end
                np={x=pos.x+1, y=pos.y, z=pos.z-1}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end

                np={x=pos.x-1, y=pos.y, z=pos.z}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end
                np={x=pos.x-1, y=pos.y, z=pos.z+1}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end
                np={x=pos.x-1, y=pos.y, z=pos.z-1}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end

                np={x=pos.x, y=pos.y+1, z=pos.z}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end

                np={x=pos.x, y=pos.y, z=pos.z+1}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end
                np={x=pos.x, y=pos.y, z=pos.z-1}
                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
                        remaining_charge = recursive_dig(np, remaining_charge)
                end
                return remaining_charge
        end
        -- Nothing sawed down
        return remaining_charge
end
 

rulion.burg
Member
 
Posts: 31
Joined: Mon Feb 25, 2013 05:02
Location: Indonesia

by rulion.burg » Mon Apr 29, 2013 06:25

Can i make quarry like mc tekkit from this technic mods ..????? Some have a tutorial video maybe
Just play game and want have a friend


Sorry my bad english
 

PreviousNext

Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 4 guests