]> git.lizzy.rs Git - Crafter.git/blob - mods/hand/init.lua
Make players use same damage mechanics as mobs
[Crafter.git] / mods / hand / init.lua
1 -- The hand
2
3 --Create an initial hand tool
4 minetest.register_item(":", {
5         type = "none",
6         wield_image = "wieldhand.png",
7         wield_scale = {x=1,y=1,z=2.5},
8         tool_capabilities = {
9                 full_punch_interval = 0.9,
10                 max_drop_level = 0,
11                 groupcaps = {           
12                         stone = {times={[1]=7.5,[2]=16,[3]=32,[4]=64,[5]=128},  uses=0, maxlevel=1}, --
13                         dirt =  {times={[1]=0.75,[2]=1.5,[3]=3,[4]=6,[5]=12},   uses=0, maxlevel=1}, --
14                         snow =  {times={[1]=0.75,[2]=1.5,[3]=3,[4]=6,[5]=12},   uses=0, maxlevel=1}, --
15                         grass = {times={[1]=0.9,[2]=1.5,[3]=3,[4]=6,[5]=12},    uses=0, maxlevel=1}, --
16                         sand =  {times={[1]=0.75,[2]=1.5,[3]=3,[4]=6,[5]=12},   uses=0, maxlevel=1}, --
17                         wood =  {times={[1]=3,[2]=6,[3]=9,[4]=12,[5]=15},       uses=0, maxlevel=1}, --
18                         leaves ={times={[1]=0.75,[2]=1.5,[3]=3,[4]=6,[5]=12},   uses=0, maxlevel=1}, --
19                         wool =  {times={[1]=0.75,[2]=1.5,[3]=3,[4]=6,[5]=12},   uses=0, maxlevel=1}, --
20                         glass = {times={[1]=0.5,[2]=1.5,[3]=3,[4]=6,[5]=12},   uses=0, maxlevel=1}, --
21                         netherrack = {times={[1]=0.4,[2]=1.5,[3]=3,[4]=6,[5]=12},   uses=0, maxlevel=1}, --
22                         
23                         unbreakable = {times={[1]=63072000000000},   uses=0, maxlevel=1}, -- 2 million years
24                         
25                         --instant = {times={[1]=0.1,},uses=0,maxlevel=1},
26                         dig_immediate = {times={[2]=0,[3]=0,[1]=0,},uses=0,maxlevel=1},
27                 },
28                 damage_groups = {damage=1},
29         }
30 })
31
32 -- This is a fake node that should never be placed in the world
33 local def = minetest.registered_items[""]
34 minetest.register_node("hand:player", {
35         description = "",
36         tiles = {"player.png"},
37         visual_scale = 1,
38         wield_scale = {x=1,y=1,z=1},
39         paramtype = "light",
40         drawtype = "mesh",
41         mesh = "hand.b3d",
42         -- Prevent construction
43         node_placement_prediction = "",
44         on_construct = function(pos)
45                 minetest.log("error", "Tried to place hand at "..minetest.pos_to_string(pos))
46                 minetest.remove_node(pos)
47         end,
48         drop = "",
49         on_drop = function()
50                 return ""
51         end,
52         groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
53         range = def.range,
54 })
55
56
57 --Create a hand list and then enable the hand node
58 minetest.register_on_joinplayer(function(player)
59         player:get_inventory():set_size("hand", 1)
60         player:get_inventory():set_stack("hand", 1, "hand:player")
61 end)
62