]> git.lizzy.rs Git - minetest.git/blob - builtin/game/item.lua
Builtin: Forward old return values
[minetest.git] / builtin / game / item.lua
1 -- Minetest: builtin/item.lua
2
3 local builtin_shared = ...
4
5 local function copy_pointed_thing(pointed_thing)
6         return {
7                 type  = pointed_thing.type,
8                 above = vector.new(pointed_thing.above),
9                 under = vector.new(pointed_thing.under),
10                 ref   = pointed_thing.ref,
11         }
12 end
13
14 --
15 -- Item definition helpers
16 --
17
18 function core.inventorycube(img1, img2, img3)
19         img2 = img2 or img1
20         img3 = img3 or img1
21         return "[inventorycube"
22                         .. "{" .. img1:gsub("%^", "&")
23                         .. "{" .. img2:gsub("%^", "&")
24                         .. "{" .. img3:gsub("%^", "&")
25 end
26
27 function core.get_pointed_thing_position(pointed_thing, above)
28         if pointed_thing.type == "node" then
29                 if above then
30                         -- The position where a node would be placed
31                         return pointed_thing.above
32                 end
33                 -- The position where a node would be dug
34                 return pointed_thing.under
35         elseif pointed_thing.type == "object" then
36                 return pointed_thing.ref and pointed_thing.ref:get_pos()
37         end
38 end
39
40 function core.dir_to_facedir(dir, is6d)
41         --account for y if requested
42         if is6d and math.abs(dir.y) > math.abs(dir.x) and math.abs(dir.y) > math.abs(dir.z) then
43
44                 --from above
45                 if dir.y < 0 then
46                         if math.abs(dir.x) > math.abs(dir.z) then
47                                 if dir.x < 0 then
48                                         return 19
49                                 else
50                                         return 13
51                                 end
52                         else
53                                 if dir.z < 0 then
54                                         return 10
55                                 else
56                                         return 4
57                                 end
58                         end
59
60                 --from below
61                 else
62                         if math.abs(dir.x) > math.abs(dir.z) then
63                                 if dir.x < 0 then
64                                         return 15
65                                 else
66                                         return 17
67                                 end
68                         else
69                                 if dir.z < 0 then
70                                         return 6
71                                 else
72                                         return 8
73                                 end
74                         end
75                 end
76
77         --otherwise, place horizontally
78         elseif math.abs(dir.x) > math.abs(dir.z) then
79                 if dir.x < 0 then
80                         return 3
81                 else
82                         return 1
83                 end
84         else
85                 if dir.z < 0 then
86                         return 2
87                 else
88                         return 0
89                 end
90         end
91 end
92
93 -- Table of possible dirs
94 local facedir_to_dir = {
95         {x= 0, y=0,  z= 1},
96         {x= 1, y=0,  z= 0},
97         {x= 0, y=0,  z=-1},
98         {x=-1, y=0,  z= 0},
99         {x= 0, y=-1, z= 0},
100         {x= 0, y=1,  z= 0},
101 }
102 -- Mapping from facedir value to index in facedir_to_dir.
103 local facedir_to_dir_map = {
104         [0]=1, 2, 3, 4,
105         5, 2, 6, 4,
106         6, 2, 5, 4,
107         1, 5, 3, 6,
108         1, 6, 3, 5,
109         1, 4, 3, 2,
110 }
111 function core.facedir_to_dir(facedir)
112         return facedir_to_dir[facedir_to_dir_map[facedir % 32]]
113 end
114
115 function core.dir_to_wallmounted(dir)
116         if math.abs(dir.y) > math.max(math.abs(dir.x), math.abs(dir.z)) then
117                 if dir.y < 0 then
118                         return 1
119                 else
120                         return 0
121                 end
122         elseif math.abs(dir.x) > math.abs(dir.z) then
123                 if dir.x < 0 then
124                         return 3
125                 else
126                         return 2
127                 end
128         else
129                 if dir.z < 0 then
130                         return 5
131                 else
132                         return 4
133                 end
134         end
135 end
136
137 -- table of dirs in wallmounted order
138 local wallmounted_to_dir = {
139         [0] = {x = 0, y = 1, z = 0},
140         {x =  0, y = -1, z =  0},
141         {x =  1, y =  0, z =  0},
142         {x = -1, y =  0, z =  0},
143         {x =  0, y =  0, z =  1},
144         {x =  0, y =  0, z = -1},
145 }
146 function core.wallmounted_to_dir(wallmounted)
147         return wallmounted_to_dir[wallmounted % 8]
148 end
149
150 function core.dir_to_yaw(dir)
151         return -math.atan2(dir.x, dir.z)
152 end
153
154 function core.yaw_to_dir(yaw)
155         return {x = -math.sin(yaw), y = 0, z = math.cos(yaw)}
156 end
157
158 function core.is_colored_paramtype(ptype)
159         return (ptype == "color") or (ptype == "colorfacedir") or
160                 (ptype == "colorwallmounted")
161 end
162
163 function core.strip_param2_color(param2, paramtype2)
164         if not core.is_colored_paramtype(paramtype2) then
165                 return nil
166         end
167         if paramtype2 == "colorfacedir" then
168                 param2 = math.floor(param2 / 32) * 32
169         elseif paramtype2 == "colorwallmounted" then
170                 param2 = math.floor(param2 / 8) * 8
171         end
172         -- paramtype2 == "color" requires no modification.
173         return param2
174 end
175
176 function core.get_node_drops(node, toolname)
177         -- Compatibility, if node is string
178         local nodename = node
179         local param2 = 0
180         -- New format, if node is table
181         if (type(node) == "table") then
182                 nodename = node.name
183                 param2 = node.param2
184         end
185         local def = core.registered_nodes[nodename]
186         local drop = def and def.drop
187         local ptype = def and def.paramtype2
188         -- get color, if there is color (otherwise nil)
189         local palette_index = core.strip_param2_color(param2, ptype)
190         if drop == nil then
191                 -- default drop
192                 if palette_index then
193                         local stack = ItemStack(nodename)
194                         stack:get_meta():set_int("palette_index", palette_index)
195                         return {stack:to_string()}
196                 end
197                 return {nodename}
198         elseif type(drop) == "string" then
199                 -- itemstring drop
200                 return drop ~= "" and {drop} or {}
201         elseif drop.items == nil then
202                 -- drop = {} to disable default drop
203                 return {}
204         end
205
206         -- Extended drop table
207         local got_items = {}
208         local got_count = 0
209         local _, item, tool
210         for _, item in ipairs(drop.items) do
211                 local good_rarity = true
212                 local good_tool = true
213                 if item.rarity ~= nil then
214                         good_rarity = item.rarity < 1 or math.random(item.rarity) == 1
215                 end
216                 if item.tools ~= nil then
217                         good_tool = false
218                 end
219                 if item.tools ~= nil and toolname then
220                         for _, tool in ipairs(item.tools) do
221                                 if tool:sub(1, 1) == '~' then
222                                         good_tool = toolname:find(tool:sub(2)) ~= nil
223                                 else
224                                         good_tool = toolname == tool
225                                 end
226                                 if good_tool then
227                                         break
228                                 end
229                         end
230                 end
231                 if good_rarity and good_tool then
232                         got_count = got_count + 1
233                         for _, add_item in ipairs(item.items) do
234                                 -- add color, if necessary
235                                 if item.inherit_color and palette_index then
236                                         local stack = ItemStack(add_item)
237                                         stack:get_meta():set_int("palette_index", palette_index)
238                                         add_item = stack:to_string()
239                                 end
240                                 got_items[#got_items+1] = add_item
241                         end
242                         if drop.max_items ~= nil and got_count == drop.max_items then
243                                 break
244                         end
245                 end
246         end
247         return got_items
248 end
249
250 local function user_name(user)
251         return user and user:get_player_name() or ""
252 end
253
254 -- Returns a logging function. For empty names, does not log.
255 local function make_log(name)
256         return name ~= "" and core.log or function() end
257 end
258
259 function core.item_place_node(itemstack, placer, pointed_thing, param2,
260                 prevent_after_place)
261         local def = itemstack:get_definition()
262         if def.type ~= "node" or pointed_thing.type ~= "node" then
263                 return itemstack, false
264         end
265
266         local under = pointed_thing.under
267         local oldnode_under = core.get_node_or_nil(under)
268         local above = pointed_thing.above
269         local oldnode_above = core.get_node_or_nil(above)
270         local playername = user_name(placer)
271         local log = make_log(playername)
272
273         if not oldnode_under or not oldnode_above then
274                 log("info", playername .. " tried to place"
275                         .. " node in unloaded position " .. core.pos_to_string(above))
276                 return itemstack, false
277         end
278
279         local olddef_under = core.registered_nodes[oldnode_under.name]
280         olddef_under = olddef_under or core.nodedef_default
281         local olddef_above = core.registered_nodes[oldnode_above.name]
282         olddef_above = olddef_above or core.nodedef_default
283
284         if not olddef_above.buildable_to and not olddef_under.buildable_to then
285                 log("info", playername .. " tried to place"
286                         .. " node in invalid position " .. core.pos_to_string(above)
287                         .. ", replacing " .. oldnode_above.name)
288                 return itemstack, false
289         end
290
291         -- Place above pointed node
292         local place_to = {x = above.x, y = above.y, z = above.z}
293
294         -- If node under is buildable_to, place into it instead (eg. snow)
295         if olddef_under.buildable_to then
296                 log("info", "node under is buildable to")
297                 place_to = {x = under.x, y = under.y, z = under.z}
298         end
299
300         if core.is_protected(place_to, playername) then
301                 log("action", playername
302                                 .. " tried to place " .. def.name
303                                 .. " at protected position "
304                                 .. core.pos_to_string(place_to))
305                 core.record_protection_violation(place_to, playername)
306                 return itemstack
307         end
308
309         log("action", playername .. " places node "
310                 .. def.name .. " at " .. core.pos_to_string(place_to))
311
312         local oldnode = core.get_node(place_to)
313         local newnode = {name = def.name, param1 = 0, param2 = param2 or 0}
314
315         -- Calculate direction for wall mounted stuff like torches and signs
316         if def.place_param2 ~= nil then
317                 newnode.param2 = def.place_param2
318         elseif (def.paramtype2 == "wallmounted" or
319                         def.paramtype2 == "colorwallmounted") and not param2 then
320                 local dir = {
321                         x = under.x - above.x,
322                         y = under.y - above.y,
323                         z = under.z - above.z
324                 }
325                 newnode.param2 = core.dir_to_wallmounted(dir)
326         -- Calculate the direction for furnaces and chests and stuff
327         elseif (def.paramtype2 == "facedir" or
328                         def.paramtype2 == "colorfacedir") and not param2 then
329                 local placer_pos = placer and placer:get_pos()
330                 if placer_pos then
331                         local dir = {
332                                 x = above.x - placer_pos.x,
333                                 y = above.y - placer_pos.y,
334                                 z = above.z - placer_pos.z
335                         }
336                         newnode.param2 = core.dir_to_facedir(dir)
337                         log("action", "facedir: " .. newnode.param2)
338                 end
339         end
340
341         local metatable = itemstack:get_meta():to_table().fields
342
343         -- Transfer color information
344         if metatable.palette_index and not def.place_param2 then
345                 local color_divisor = nil
346                 if def.paramtype2 == "color" then
347                         color_divisor = 1
348                 elseif def.paramtype2 == "colorwallmounted" then
349                         color_divisor = 8
350                 elseif def.paramtype2 == "colorfacedir" then
351                         color_divisor = 32
352                 end
353                 if color_divisor then
354                         local color = math.floor(metatable.palette_index / color_divisor)
355                         local other = newnode.param2 % color_divisor
356                         newnode.param2 = color * color_divisor + other
357                 end
358         end
359
360         -- Check if the node is attached and if it can be placed there
361         if core.get_item_group(def.name, "attached_node") ~= 0 and
362                 not builtin_shared.check_attached_node(place_to, newnode) then
363                 log("action", "attached node " .. def.name ..
364                         " can not be placed at " .. core.pos_to_string(place_to))
365                 return itemstack, false
366         end
367
368         -- Add node and update
369         core.add_node(place_to, newnode)
370
371         local take_item = true
372
373         -- Run callback
374         if def.after_place_node and not prevent_after_place then
375                 -- Deepcopy place_to and pointed_thing because callback can modify it
376                 local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
377                 local pointed_thing_copy = copy_pointed_thing(pointed_thing)
378                 if def.after_place_node(place_to_copy, placer, itemstack,
379                                 pointed_thing_copy) then
380                         take_item = false
381                 end
382         end
383
384         -- Run script hook
385         for _, callback in ipairs(core.registered_on_placenodes) do
386                 -- Deepcopy pos, node and pointed_thing because callback can modify them
387                 local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z}
388                 local newnode_copy = {name=newnode.name, param1=newnode.param1, param2=newnode.param2}
389                 local oldnode_copy = {name=oldnode.name, param1=oldnode.param1, param2=oldnode.param2}
390                 local pointed_thing_copy = copy_pointed_thing(pointed_thing)
391                 if callback(place_to_copy, newnode_copy, placer, oldnode_copy, itemstack, pointed_thing_copy) then
392                         take_item = false
393                 end
394         end
395
396         if take_item then
397                 itemstack:take_item()
398         end
399         return itemstack, true
400 end
401
402 function core.item_place_object(itemstack, placer, pointed_thing)
403         local pos = core.get_pointed_thing_position(pointed_thing, true)
404         if pos ~= nil then
405                 local item = itemstack:take_item()
406                 core.add_item(pos, item)
407         end
408         return itemstack
409 end
410
411 function core.item_place(itemstack, placer, pointed_thing, param2)
412         -- Call on_rightclick if the pointed node defines it
413         if pointed_thing.type == "node" and placer and
414                         not placer:get_player_control().sneak then
415                 local n = core.get_node(pointed_thing.under)
416                 local nn = n.name
417                 if core.registered_nodes[nn] and core.registered_nodes[nn].on_rightclick then
418                         return core.registered_nodes[nn].on_rightclick(pointed_thing.under, n,
419                                         placer, itemstack, pointed_thing) or itemstack, false
420                 end
421         end
422
423         if itemstack:get_definition().type == "node" then
424                 return core.item_place_node(itemstack, placer, pointed_thing, param2)
425         end
426         return itemstack
427 end
428
429 function core.item_secondary_use(itemstack, placer)
430         return itemstack
431 end
432
433 function core.item_drop(itemstack, dropper, pos)
434         local dropper_is_player = dropper and dropper:is_player()
435         local p = table.copy(pos)
436         local cnt = itemstack:get_count()
437         if dropper_is_player then
438                 p.y = p.y + 1.2
439         end
440         local item = itemstack:take_item(cnt)
441         local obj = core.add_item(p, item)
442         if obj then
443                 if dropper_is_player then
444                         local dir = dropper:get_look_dir()
445                         dir.x = dir.x * 2.9
446                         dir.y = dir.y * 2.9 + 2
447                         dir.z = dir.z * 2.9
448                         obj:set_velocity(dir)
449                         obj:get_luaentity().dropped_by = dropper:get_player_name()
450                 end
451                 return itemstack
452         end
453         -- If we reach this, adding the object to the
454         -- environment failed
455 end
456
457 function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
458         for _, callback in pairs(core.registered_on_item_eats) do
459                 local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing)
460                 if result then
461                         return result
462                 end
463         end
464         if itemstack:take_item() ~= nil then
465                 user:set_hp(user:get_hp() + hp_change)
466
467                 local def = itemstack:get_definition()
468                 if def and def.sound and def.sound.eat then
469                         minetest.sound_play(def.sound.eat, { pos = user:get_pos(), max_hear_distance = 16 })
470                 end
471
472                 if replace_with_item then
473                         if itemstack:is_empty() then
474                                 itemstack:add_item(replace_with_item)
475                         else
476                                 local inv = user:get_inventory()
477                                 -- Check if inv is null, since non-players don't have one
478                                 if inv and inv:room_for_item("main", {name=replace_with_item}) then
479                                         inv:add_item("main", replace_with_item)
480                                 else
481                                         local pos = user:get_pos()
482                                         pos.y = math.floor(pos.y + 0.5)
483                                         core.add_item(pos, replace_with_item)
484                                 end
485                         end
486                 end
487         end
488         return itemstack
489 end
490
491 function core.item_eat(hp_change, replace_with_item)
492         return function(itemstack, user, pointed_thing)  -- closure
493                 if user then
494                         return core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
495                 end
496         end
497 end
498
499 function core.node_punch(pos, node, puncher, pointed_thing)
500         -- Run script hook
501         for _, callback in ipairs(core.registered_on_punchnodes) do
502                 -- Copy pos and node because callback can modify them
503                 local pos_copy = vector.new(pos)
504                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
505                 local pointed_thing_copy = pointed_thing and copy_pointed_thing(pointed_thing) or nil
506                 callback(pos_copy, node_copy, puncher, pointed_thing_copy)
507         end
508 end
509
510 function core.handle_node_drops(pos, drops, digger)
511         -- Add dropped items to object's inventory
512         local inv = digger and digger:get_inventory()
513         local give_item
514         if inv then
515                 give_item = function(item)
516                         return inv:add_item("main", item)
517                 end
518         else
519                 give_item = function(item)
520                         -- itemstring to ItemStack for left:is_empty()
521                         return ItemStack(item)
522                 end
523         end
524
525         for _, dropped_item in pairs(drops) do
526                 local left = give_item(dropped_item)
527                 if not left:is_empty() then
528                         local p = {
529                                 x = pos.x + math.random()/2-0.25,
530                                 y = pos.y + math.random()/2-0.25,
531                                 z = pos.z + math.random()/2-0.25,
532                         }
533                         core.add_item(p, left)
534                 end
535         end
536 end
537
538 function core.node_dig(pos, node, digger)
539         local diggername = user_name(digger)
540         local log = make_log(diggername)
541         local def = core.registered_nodes[node.name]
542         if def and (not def.diggable or
543                         (def.can_dig and not def.can_dig(pos, digger))) then
544                 log("info", diggername .. " tried to dig "
545                         .. node.name .. " which is not diggable "
546                         .. core.pos_to_string(pos))
547                 return
548         end
549
550         if core.is_protected(pos, diggername) then
551                 log("action", diggername
552                                 .. " tried to dig " .. node.name
553                                 .. " at protected position "
554                                 .. core.pos_to_string(pos))
555                 core.record_protection_violation(pos, diggername)
556                 return
557         end
558
559         log('action', diggername .. " digs "
560                 .. node.name .. " at " .. core.pos_to_string(pos))
561
562         local wielded = digger and digger:get_wielded_item()
563         local drops = core.get_node_drops(node, wielded and wielded:get_name())
564
565         if wielded then
566                 local wdef = wielded:get_definition()
567                 local tp = wielded:get_tool_capabilities()
568                 local dp = core.get_dig_params(def and def.groups, tp)
569                 if wdef and wdef.after_use then
570                         wielded = wdef.after_use(wielded, digger, node, dp) or wielded
571                 else
572                         -- Wear out tool
573                         if not core.settings:get_bool("creative_mode") then
574                                 wielded:add_wear(dp.wear)
575                                 if wielded:get_count() == 0 and wdef.sound and wdef.sound.breaks then
576                                         core.sound_play(wdef.sound.breaks, {pos = pos, gain = 0.5})
577                                 end
578                         end
579                 end
580                 digger:set_wielded_item(wielded)
581         end
582
583         -- Check to see if metadata should be preserved.
584         if def and def.preserve_metadata then
585                 local oldmeta = core.get_meta(pos):to_table().fields
586                 -- Copy pos and node because the callback can modify them.
587                 local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
588                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
589                 local drop_stacks = {}
590                 for k, v in pairs(drops) do
591                         drop_stacks[k] = ItemStack(v)
592                 end
593                 drops = drop_stacks
594                 def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
595         end
596
597         -- Handle drops
598         core.handle_node_drops(pos, drops, digger)
599
600         local oldmetadata = nil
601         if def and def.after_dig_node then
602                 oldmetadata = core.get_meta(pos):to_table()
603         end
604
605         -- Remove node and update
606         core.remove_node(pos)
607
608         -- Run callback
609         if def and def.after_dig_node then
610                 -- Copy pos and node because callback can modify them
611                 local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
612                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
613                 def.after_dig_node(pos_copy, node_copy, oldmetadata, digger)
614         end
615
616         -- Run script hook
617         local _, callback
618         for _, callback in ipairs(core.registered_on_dignodes) do
619                 local origin = core.callback_origins[callback]
620                 if origin then
621                         core.set_last_run_mod(origin.mod)
622                         --print("Running " .. tostring(callback) ..
623                         --      " (a " .. origin.name .. " callback in " .. origin.mod .. ")")
624                 else
625                         --print("No data associated with callback")
626                 end
627
628                 -- Copy pos and node because callback can modify them
629                 local pos_copy = {x=pos.x, y=pos.y, z=pos.z}
630                 local node_copy = {name=node.name, param1=node.param1, param2=node.param2}
631                 callback(pos_copy, node_copy, digger)
632         end
633 end
634
635 function core.itemstring_with_palette(item, palette_index)
636         local stack = ItemStack(item) -- convert to ItemStack
637         stack:get_meta():set_int("palette_index", palette_index)
638         return stack:to_string()
639 end
640
641 function core.itemstring_with_color(item, colorstring)
642         local stack = ItemStack(item) -- convert to ItemStack
643         stack:get_meta():set_string("color", colorstring)
644         return stack:to_string()
645 end
646
647 -- This is used to allow mods to redefine core.item_place and so on
648 -- NOTE: This is not the preferred way. Preferred way is to provide enough
649 --       callbacks to not require redefining global functions. -celeron55
650 local function redef_wrapper(table, name)
651         return function(...)
652                 return table[name](...)
653         end
654 end
655
656 --
657 -- Item definition defaults
658 --
659
660 core.nodedef_default = {
661         -- Item properties
662         type="node",
663         -- name intentionally not defined here
664         description = "",
665         groups = {},
666         inventory_image = "",
667         wield_image = "",
668         wield_scale = {x=1,y=1,z=1},
669         stack_max = 99,
670         usable = false,
671         liquids_pointable = false,
672         tool_capabilities = nil,
673         node_placement_prediction = nil,
674
675         -- Interaction callbacks
676         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
677         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
678         on_use = nil,
679         can_dig = nil,
680
681         on_punch = redef_wrapper(core, 'node_punch'), -- core.node_punch
682         on_rightclick = nil,
683         on_dig = redef_wrapper(core, 'node_dig'), -- core.node_dig
684
685         on_receive_fields = nil,
686
687         on_metadata_inventory_move = core.node_metadata_inventory_move_allow_all,
688         on_metadata_inventory_offer = core.node_metadata_inventory_offer_allow_all,
689         on_metadata_inventory_take = core.node_metadata_inventory_take_allow_all,
690
691         -- Node properties
692         drawtype = "normal",
693         visual_scale = 1.0,
694         -- Don't define these because otherwise the old tile_images and
695         -- special_materials wouldn't be read
696         --tiles ={""},
697         --special_tiles = {
698         --      {name="", backface_culling=true},
699         --      {name="", backface_culling=true},
700         --},
701         alpha = 255,
702         post_effect_color = {a=0, r=0, g=0, b=0},
703         paramtype = "none",
704         paramtype2 = "none",
705         is_ground_content = true,
706         sunlight_propagates = false,
707         walkable = true,
708         pointable = true,
709         diggable = true,
710         climbable = false,
711         buildable_to = false,
712         floodable = false,
713         liquidtype = "none",
714         liquid_alternative_flowing = "",
715         liquid_alternative_source = "",
716         liquid_viscosity = 0,
717         drowning = 0,
718         light_source = 0,
719         damage_per_second = 0,
720         selection_box = {type="regular"},
721         legacy_facedir_simple = false,
722         legacy_wallmounted = false,
723 }
724
725 core.craftitemdef_default = {
726         type="craft",
727         -- name intentionally not defined here
728         description = "",
729         groups = {},
730         inventory_image = "",
731         wield_image = "",
732         wield_scale = {x=1,y=1,z=1},
733         stack_max = 99,
734         liquids_pointable = false,
735         tool_capabilities = nil,
736
737         -- Interaction callbacks
738         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
739         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
740         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
741         on_use = nil,
742 }
743
744 core.tooldef_default = {
745         type="tool",
746         -- name intentionally not defined here
747         description = "",
748         groups = {},
749         inventory_image = "",
750         wield_image = "",
751         wield_scale = {x=1,y=1,z=1},
752         stack_max = 1,
753         liquids_pointable = false,
754         tool_capabilities = nil,
755
756         -- Interaction callbacks
757         on_place = redef_wrapper(core, 'item_place'), -- core.item_place
758         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
759         on_drop = redef_wrapper(core, 'item_drop'), -- core.item_drop
760         on_use = nil,
761 }
762
763 core.noneitemdef_default = {  -- This is used for the hand and unknown items
764         type="none",
765         -- name intentionally not defined here
766         description = "",
767         groups = {},
768         inventory_image = "",
769         wield_image = "",
770         wield_scale = {x=1,y=1,z=1},
771         stack_max = 99,
772         liquids_pointable = false,
773         tool_capabilities = nil,
774
775         -- Interaction callbacks
776         on_place = redef_wrapper(core, 'item_place'),
777         on_secondary_use = redef_wrapper(core, 'item_secondary_use'),
778         on_drop = nil,
779         on_use = nil,
780 }