Fix and tune things, add tool "recharge" animation, add dummyball
[oweals/minetest.git] / data / mods / default / init.lua
1 -- default (Minetest 0.4 mod)
2 -- Most default stuff
3
4 -- Quick documentation about the API
5 -- =================================
6 --
7 -- Helper functions defined by builtin.lua:
8 -- dump2(obj, name="_", dumped={})
9 -- dump(obj, dumped={})
10 --
11 -- Mod load path
12 -- -------------
13 -- Generic:
14 -- $path_data/mods/
15 -- $path_userdata/usermods/
16 -- $mapdir/worldmods/
17 --
18 -- On a run-in-place version (eg. the distributed windows version):
19 -- minetest-0.4.x/data/mods/
20 -- minetest-0.4.x/usermods/
21 -- minetest-0.4.x/world/worldmods/
22 --
23 -- On an installed version on linux:
24 -- /usr/share/minetest/mods/
25 -- ~/.minetest/usermods
26 -- ~/.minetest/world/worldmods
27 --
28 -- Naming convention for registered textual names
29 -- ----------------------------------------------
30 -- "modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
31 --
32 -- This is to prevent conflicting names from corrupting maps and is
33 -- enforced by the mod loader.
34 --
35 -- Example: mod "experimental", ideal item/node/entity name "tnt":
36 --          -> the name should be "experimental:tnt".
37 --
38 -- Enforcement can be overridden by prefixing the name with ":". This can
39 -- be used for overriding the registrations of some other mod.
40 --
41 -- Example: Any mod can redefine experimental:tnt by using the name
42 --          ":experimental:tnt" when registering it.
43 -- (also that mods is required to have "experimental" as a dependency)
44 --
45 -- The legacy mod uses ":" for maintaining backwards compatibility.
46 --
47 -- Textures
48 -- --------
49 -- Mods should generally prefix their textures with modname_, eg. given
50 -- the mod name "foomod", a texture could be called "default_foomod_superfurnace.png"
51 --
52 -- This is not crucial and a conflicting name will not corrupt maps.
53 --
54 -- Representations of simple things
55 -- --------------------------------
56 --
57 -- MapNode representation:
58 -- {name="name", param1=num, param2=num}
59 --
60 -- param1 and param2 are 8 bit and 4 bit integers, respectively. They
61 -- are reserved for certain automated functions. If you don't use these
62 -- functions, you can use them to store arbitrary values.
63 --
64 -- param1 is reserved for the engine when:
65 --   paramtype != "none"
66 -- param2 is reserved for the engine when any of these are used:
67 --   liquidtype == "flowing"
68 --   drawtype == "flowingliquid"
69 --   drawtype == "torchlike"
70 --   drawtype == "signlike"
71 --
72 -- Position representation:
73 -- {x=num, y=num, z=num}
74 --
75 -- stackstring/itemstring: A stack of items in serialized format.
76 -- eg. 'node "default:dirt" 5'
77 -- eg. 'tool "default:pick_wood" 21323'
78 -- eg. 'craft "default:apple" 2'
79 --
80 -- item: A stack of items in Lua table format.
81 -- eg. {name="default:dirt", count=1, wear=0, metadata=""} 
82 --     ^ a single dirt node
83 -- eg. {name="default:pick_wood", count=1, wear=21323, metadata=""}
84 --     ^ a wooden pick about 1/3 weared out
85 -- eg. {name="default:apple", count=1, wear=0, metadata=""}
86 --     ^ an apple.
87 --
88 -- Any time an item must be passed to a function, it can be an
89 -- ItemStack (see below), an itemstring or a table in the above format.
90 --
91 -- Global functions:
92 -- minetest.register_entity(name, prototype table)
93 -- minetest.register_abm(abm definition)
94 -- minetest.register_node(name, node definition)
95 -- minetest.register_tool(name, item definition)
96 -- minetest.register_craftitem(name, item definition)
97 -- minetest.register_alias(name, convert_to)
98 -- minetest.register_craft(recipe)
99 -- minetest.register_globalstep(func(dtime))
100 -- minetest.register_on_placenode(func(pos, newnode, placer))
101 -- minetest.register_on_dignode(func(pos, oldnode, digger))
102 -- minetest.register_on_punchnode(func(pos, node, puncher))
103 -- minetest.register_on_generated(func(minp, maxp))
104 -- minetest.register_on_newplayer(func(ObjectRef))
105 -- minetest.register_on_dieplayer(func(ObjectRef))
106 -- minetest.register_on_respawnplayer(func(ObjectRef))
107 -- ^ return true in func to disable regular player placement
108 -- ^ currently called _before_ repositioning of player occurs
109 -- minetest.register_on_chat_message(func(name, message))
110 -- minetest.add_to_creative_inventory(itemstring)
111 -- minetest.setting_get(name) -> string or nil
112 -- minetest.setting_getbool(name) -> boolean value or nil
113 -- minetest.chat_send_all(text)
114 -- minetest.chat_send_player(name, text)
115 -- minetest.get_player_privs(name) -> set of privs
116 -- minetest.get_inventory(location) -> InvRef
117 -- ^ location = eg. {type="player", name="celeron55"}
118 --                  {type="node", pos={x=, y=, z=}}
119 -- minetest.get_current_modname() -> string
120 -- minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
121 -- ^ Useful for loading additional .lua modules or static data from mod
122 -- minetest.get_worldpath(modname) -> eg. "/home/user/.minetest/world"
123 -- ^ Useful for storing custom data
124 --
125 -- minetest.debug(line)
126 -- ^ Goes to dstream
127 -- minetest.log(line)
128 -- minetest.log(loglevel, line)
129 -- ^ loglevel one of "error", "action", "info", "verbose"
130 --
131 -- minetest.digprop_constanttime(time)
132 -- minetest.digprop_stonelike(toughness)
133 -- minetest.digprop_dirtlike(toughness)
134 -- minetest.digprop_gravellike(toughness)
135 -- minetest.digprop_woodlike(toughness)
136 -- minetest.digprop_leaveslike(toughness)
137 -- minetest.digprop_glasslike(toughness)
138 --
139 -- Global objects:
140 -- minetest.env - environment reference
141 --
142 -- Global tables:
143 -- minetest.registered_items
144 -- ^ List of registered items, indexed by name
145 -- minetest.registered_nodes
146 -- ^ List of registered node definitions, indexed by name
147 -- minetest.registered_craftitems
148 -- ^ List of registered craft item definitions, indexed by name
149 -- minetest.registered_tools
150 -- ^ List of registered tool definitions, indexed by name
151 -- minetest.registered_entities
152 -- ^ List of registered entity prototypes, indexed by name
153 -- minetest.object_refs
154 -- ^ List of object references, indexed by active object id
155 -- minetest.luaentities
156 -- ^ List of lua entities, indexed by active object id
157 --
158 -- EnvRef is basically ServerEnvironment and ServerMap combined.
159 -- EnvRef methods:
160 -- - add_node(pos, node)
161 -- - remove_node(pos)
162 -- - get_node(pos)
163 --   ^ Returns {name="ignore", ...} for unloaded area
164 -- - get_node_or_nil(pos)
165 --   ^ Returns nil for unloaded area
166 -- - get_node_light(pos, timeofday) -> 0...15 or nil
167 --   ^ timeofday: nil = current time, 0 = night, 0.5 = day
168 -- - add_entity(pos, name): Returns ObjectRef or nil if failed
169 -- - add_item(pos, itemstring)
170 -- - add_rat(pos)
171 -- - add_firefly(pos)
172 -- - get_meta(pos) -- Get a NodeMetaRef at that position
173 -- - get_player_by_name(name) -- Get an ObjectRef to a player
174 -- - get_objects_inside_radius(pos, radius)
175 -- - set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
176 -- - get_timeofday()
177 --
178 -- NodeMetaRef (this stuff is subject to change in a future version)
179 -- - get_type()
180 -- - allows_text_input()
181 -- - set_text(text) -- eg. set the text of a sign
182 -- - get_text()
183 -- - get_owner()
184 -- - set_owner(string)
185 -- Generic node metadata specific:
186 -- - set_infotext(infotext)
187 -- - get_inventory() -> InvRef
188 -- - set_inventory_draw_spec(string)
189 -- - set_allow_text_input(bool)
190 -- - set_allow_removal(bool)
191 -- - set_enforce_owner(bool)
192 -- - is_inventory_modified()
193 -- - reset_inventory_modified()
194 -- - is_text_modified()
195 -- - reset_text_modified()
196 -- - set_string(name, value)
197 -- - get_string(name)
198 --
199 -- ObjectRef is basically ServerActiveObject.
200 -- ObjectRef methods:
201 -- - remove(): remove object (after returning from Lua)
202 -- - getpos() -> {x=num, y=num, z=num}
203 -- - setpos(pos); pos={x=num, y=num, z=num}
204 -- - moveto(pos, continuous=false): interpolated move
205 -- - punch(puncher, time_from_last_punch, tool_capabilities, direction)
206 --   ^ puncher = an another ObjectRef,
207 --   ^ time_from_last_punch = time since last punch action of the puncher
208 -- - right_click(clicker); clicker = an another ObjectRef
209 -- - get_hp(): returns number of hitpoints (2 * number of hearts)
210 -- - set_hp(hp): set number of hitpoints (2 * number of hearts)
211 -- - get_inventory() -> InvRef
212 -- - get_wield_list(): returns the name of the inventory list the wielded item is in
213 -- - get_wield_index(): returns the index of the wielded item
214 -- - get_wielded_item() -> ItemStack
215 -- - set_wielded_item(item): replaces the wielded item, returns true if successful
216 -- LuaEntitySAO-only: (no-op for other objects)
217 -- - setvelocity({x=num, y=num, z=num})
218 -- - getvelocity() -> {x=num, y=num, z=num}
219 -- - setacceleration({x=num, y=num, z=num})
220 -- - getacceleration() -> {x=num, y=num, z=num}
221 -- - setyaw(radians)
222 -- - getyaw() -> radians
223 -- - settexturemod(mod)
224 -- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
225 -- -           select_horiz_by_yawpitch=false)
226 -- - ^ Select sprite from spritesheet with optional animation and DM-style
227 -- -   texture selection based on yaw relative to camera
228 -- - set_armor_groups({group1=rating, group2=rating, ...})
229 -- - get_entity_name() (DEPRECATED: Will be removed in a future version)
230 -- - get_luaentity()
231 -- Player-only: (no-op for other objects)
232 -- - get_player_name(): will return nil if is not a player
233 -- - get_look_dir(): get camera direction as a unit vector
234 -- - get_look_pitch(): pitch in radians
235 -- - get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
236 --
237 -- InvRef methods:
238 -- - get_size(listname): get size of a list
239 -- - set_size(listname, size): set size of a list
240 -- - get_stack(listname, i): get a copy of stack index i in list
241 -- - set_stack(listname, i, stack): copy stack to index i in list
242 -- - get_list(listname): return full list
243 -- - set_list(listname, list): set full list (size will not change)
244 -- - add_item(listname, stack): add item somewhere in list, returns leftover ItemStack
245 -- - room_for_item(listname, stack): returns true if the stack of items
246 --     can be fully added to the list
247 -- - contains_item(listname, stack): returns true if the stack of items
248 --     can be fully taken from the list
249 --   remove_item(listname, stack): take as many items as specified from the list,
250 --     returns the items that were actually removed (as an ItemStack)
251 --
252 -- ItemStack methods:
253 -- - is_empty(): return true if stack is empty
254 -- - get_name(): returns item name (e.g. "default:stone")
255 -- - get_count(): returns number of items on the stack
256 -- - get_wear(): returns tool wear (0-65535), 0 for non-tools
257 -- - get_metadata(): returns metadata (a string attached to an item stack)
258 -- - clear(): removes all items from the stack, making it empty
259 -- - replace(item): replace the contents of this stack (item can also
260 --     be an itemstring or table)
261 -- - to_string(): returns the stack in itemstring form
262 -- - to_table(): returns the stack in Lua table form
263 -- - get_stack_max(): returns the maximum size of the stack (depends on the item)
264 -- - get_free_space(): returns get_stack_max() - get_count()
265 -- - is_known(): returns true if the item name refers to a defined item type
266 -- - get_definition(): returns the item definition table
267 -- - get_tool_capabilities(): returns the digging properties of the item,
268 --   ^ or those of the hand if none are defined for this item type
269 -- - add_wear(amount): increases wear by amount if the item is a tool
270 -- - add_item(item): put some item or stack onto this stack,
271 --   ^ returns leftover ItemStack
272 -- - item_fits(item): returns true if item or stack can be fully added to this one
273 -- - take_item(n): take (and remove) up to n items from this stack
274 --   ^ returns taken ItemStack
275 --   ^ if n is omitted, n=1 is used
276 -- - peek_item(n): copy (don't remove) up to n items from this stack
277 --   ^ returns copied ItemStack
278 --   ^ if n is omitted, n=1 is used
279 --
280 -- Registered entities:
281 -- - Functions receive a "luaentity" as self:
282 --   - It has the member .name, which is the registered name ("mod:thing")
283 --   - It has the member .object, which is an ObjectRef pointing to the object
284 --   - The original prototype stuff is visible directly via a metatable
285 -- - Callbacks:
286 --   - on_activate(self, staticdata)
287 --   - on_step(self, dtime)
288 --   - on_punch(self, hitter)
289 --   - on_rightclick(self, clicker)
290 --   - get_staticdata(self)
291 --     ^ return string that will be passed to on_activate when the object
292 --       is created next time
293 --
294 -- Entity prototype table:
295 -- {
296 --     physical = true,
297 --     collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
298 --     visual = "cube"/"sprite",
299 --     visual_size = {x=1, y=1},
300 --     textures = {texture,texture,texture,texture,texture,texture},
301 --     spritediv = {x=1, y=1},
302 --     initial_sprite_basepos = {x=0, y=0},
303 --     on_activate = function(self, staticdata),
304 --     on_step = function(self, dtime),
305 --     on_punch = function(self, hitter),
306 --     on_rightclick = function(self, clicker),
307 --     get_staticdata = function(self),
308 --     # Also you can define arbitrary member variables here
309 --     myvariable = whatever,
310 -- }
311 --
312 -- Item definition options (register_node, register_craftitem, register_tool)
313 -- {
314 --     description = "Steel Axe",
315 --     groups = {}, -- key=name, value=rating; rating=1..3.
316 --                     if rating not applicable, use 1.
317 --                     eg. {wool=1, fluffy=3}
318 --                         {soil=2, outerspace=1, crumbly=1}
319 --                         {hard=3, brittle=3, spikes=2
320 --                         {hard=1, metal=1, spikes=1}
321 --     inventory_image = "default_tool_steelaxe.png",
322 --     wield_image = "",
323 --     wield_scale = {x=1,y=1,z=1},
324 --     stack_max = 99,
325 --     liquids_pointable = false,
326 --     tool_capabilities = {
327 --         full_punch_interval = 1.0,
328 --         basetime = 1.0,
329 --         dt_weight = 0.5,
330 --         dt_crackiness = -0.2,
331 --         dt_crumbliness = 1,
332 --         dt_cuttability = -0.5,
333 --         basedurability = 330,
334 --         dd_weight = 0,
335 --         dd_crackiness = 0,
336 --         dd_crumbliness = 0,
337 --         dd_cuttability = 0,
338 --     }
339 --     on_drop = func(item, dropper, pos),
340 --     on_place = func(item, placer, pointed_thing),
341 --     on_use = func(item, user, pointed_thing),
342 -- }
343 --
344 -- Node definition options (register_node):
345 -- {
346 --     <all fields allowed in item definitions>,
347 --     drawtype = "normal",
348 --     visual_scale = 1.0,
349 --     tile_images = {"default_unknown_block.png"},
350 --     special_materials = {
351 --         {image="", backface_culling=true},
352 --         {image="", backface_culling=true},
353 --     },
354 --     alpha = 255,
355 --     post_effect_color = {a=0, r=0, g=0, b=0},
356 --     paramtype = "none",
357 --     paramtype2 = "none",
358 --     is_ground_content = false,
359 --     sunlight_propagates = false,
360 --     walkable = true,
361 --     pointable = true,
362 --     diggable = true,
363 --     climbable = false,
364 --     buildable_to = false,
365 --     drop = "",
366 --     -- alternatively drop = { max_items = ..., items = { ... } }
367 --     metadata_name = "",
368 --     liquidtype = "none",
369 --     liquid_alternative_flowing = "",
370 --     liquid_alternative_source = "",
371 --     liquid_viscosity = 0,
372 --     light_source = 0,
373 --     damage_per_second = 0,
374 --     selection_box = {type="regular"},
375 --     legacy_facedir_simple = false, -- Support maps made in and before January 2012
376 --     legacy_wallmounted = false, -- Support maps made in and before January 2012
377 -- }
378 --
379 -- Recipe:
380 -- {
381 --     output = 'default:pick_stone',
382 --     recipe = {
383 --         {'default:cobble', 'default:cobble', 'default:cobble'},
384 --         {'', 'default:stick', ''},
385 --         {'', 'default:stick', ''},
386 --     },
387 --     replacements = <optional list of item pairs,
388 --                     replace one input item with another item on crafting>
389 -- }
390 --
391 -- Recipe (shapeless):
392 -- {
393 --     type = "shapeless",
394 --     output = 'mushrooms:mushroom_stew',
395 --     recipe = {
396 --         "mushrooms:bowl",
397 --         "mushrooms:mushroom_brown",
398 --         "mushrooms:mushroom_red",
399 --     },
400 --     replacements = <optional list of item pairs,
401 --                     replace one input item with another item on crafting>
402 -- }
403 --
404 -- Recipe (tool repair):
405 -- {
406 --     type = "toolrepair",
407 --     additional_wear = -0.02,
408 -- }
409 --
410 -- Recipe (cooking):
411 -- {
412 --     type = "cooking",
413 --     output = "default:glass",
414 --     recipe = "default:sand",
415 --     cooktime = 3,
416 -- }
417 --
418 -- Recipe (furnace fuel):
419 -- {
420 --     type = "fuel",
421 --     recipe = "default:leaves",
422 --     burntime = 1,
423 -- }
424 --
425 -- ABM (ActiveBlockModifier) definition:
426 -- {
427 --     nodenames = {"default:lava_source"},
428 --     neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
429 --      ^ If left out or empty, any neighbor will do
430 --      ^ This might get removed in the future
431 --     interval = 1.0, -- (operation interval)
432 --     chance = 1, -- (chance of trigger is 1.0/this)
433 --     action = func(pos, node, active_object_count, active_object_count_wider),
434 -- }
435
436 WATER_ALPHA = 160
437 WATER_VISC = 1
438 LAVA_VISC = 7
439 LIGHT_MAX = 14
440
441 -- Definitions made by this mod that other mods can use too
442 default = {}
443
444 --
445 -- Tool definition
446 --
447
448 -- The hand
449 minetest.register_item(":", {
450         type = "none",
451         wield_image = "wieldhand.png",
452         wield_scale = {x=1,y=1,z=2.5},
453         tool_capabilities = {
454                 full_punch_interval = 1.0,
455                 max_drop_level = 0,
456                 groupcaps = {
457                         fleshy = {times={[2]=2.00, [3]=1.00}, maxwear=0, maxlevel=1},
458                         crumbly = {times={[3]=0.70}, maxwear=0, maxlevel=1},
459                         snappy = {times={[3]=0.70}, maxwear=0, maxlevel=1},
460                 }
461         }
462 })
463
464 minetest.register_tool("default:pick_wood", {
465         description = "Wooden Pickaxe",
466         inventory_image = "default_tool_woodpick.png",
467         tool_capabilities = {
468                 max_drop_level=0,
469                 groupcaps={
470                         cracky={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1}
471                 }
472         },
473 })
474 minetest.register_tool("default:pick_stone", {
475         description = "Stone Pickaxe",
476         inventory_image = "default_tool_stonepick.png",
477         tool_capabilities = {
478                 max_drop_level=0,
479                 groupcaps={
480                         cracky={times={[1]=1.50, [2]=0.80, [3]=0.60}, maxwear=0.05, maxlevel=1}
481                 }
482         },
483 })
484 minetest.register_tool("default:pick_steel", {
485         description = "Steel Pickaxe",
486         inventory_image = "default_tool_steelpick.png",
487         tool_capabilities = {
488                 max_drop_level=1,
489                 groupcaps={
490                         cracky={times={[1]=1.00, [2]=0.60, [3]=0.40}, maxwear=0.1, maxlevel=2}
491                 }
492         },
493 })
494 minetest.register_tool("default:pick_mese", {
495         description = "Mese Pickaxe",
496         inventory_image = "default_tool_mesepick.png",
497         tool_capabilities = {
498                 max_drop_level=3,
499                 groupcaps={
500                         cracky={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3},
501                         crumbly={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3},
502                         snappy={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3}
503                 }
504         },
505 })
506 minetest.register_tool("default:shovel_wood", {
507         description = "Wooden Shovel",
508         inventory_image = "default_tool_woodshovel.png",
509         tool_capabilities = {
510                 max_drop_level=0,
511                 groupcaps={
512                         crumbly={times={[1]=1.50, [2]=0.80, [3]=0.50}, maxwear=0.1, maxlevel=1}
513                 }
514         },
515 })
516 minetest.register_tool("default:shovel_stone", {
517         description = "Stone Shovel",
518         inventory_image = "default_tool_stoneshovel.png",
519         tool_capabilities = {
520                 max_drop_level=0,
521                 groupcaps={
522                         crumbly={times={[1]=0.80, [2]=0.50, [3]=0.30}, maxwear=0.05, maxlevel=1}
523                 }
524         },
525 })
526 minetest.register_tool("default:shovel_steel", {
527         description = "Steel Shovel",
528         inventory_image = "default_tool_steelshovel.png",
529         tool_capabilities = {
530                 max_drop_level=1,
531                 groupcaps={
532                         crumbly={times={[1]=0.50, [2]=0.35, [3]=0.30}, maxwear=0.1, maxlevel=2}
533                 }
534         },
535 })
536 minetest.register_tool("default:axe_wood", {
537         description = "Wooden Axe",
538         inventory_image = "default_tool_woodaxe.png",
539         tool_capabilities = {
540                 max_drop_level=0,
541                 groupcaps={
542                         choppy={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1},
543                         fleshy={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1}
544                 }
545         },
546 })
547 minetest.register_tool("default:axe_stone", {
548         description = "Stone Axe",
549         inventory_image = "default_tool_stoneaxe.png",
550         tool_capabilities = {
551                 max_drop_level=0,
552                 groupcaps={
553                         choppy={times={[1]=1.50, [2]=1.00, [3]=0.60}, maxwear=0.05, maxlevel=1},
554                         fleshy={times={[2]=1.30, [3]=0.70}, maxwear=0.05, maxlevel=1}
555                 }
556         },
557 })
558 minetest.register_tool("default:axe_steel", {
559         description = "Steel Axe",
560         inventory_image = "default_tool_steelaxe.png",
561         tool_capabilities = {
562                 max_drop_level=1,
563                 groupcaps={
564                         choppy={times={[1]=1.00, [2]=0.80, [3]=0.50}, maxwear=0.1, maxlevel=2},
565                         fleshy={times={[2]=1.10, [3]=0.60}, maxwear=0.03, maxlevel=1}
566                 }
567         },
568 })
569 minetest.register_tool("default:sword_wood", {
570         description = "Wooden Sword",
571         inventory_image = "default_tool_woodsword.png",
572         tool_capabilities = {
573                 full_punch_interval = 1.0,
574                 max_drop_level=0,
575                 groupcaps={
576                         fleshy={times={[2]=1.10, [3]=0.60}, maxwear=0.1, maxlevel=1},
577                         snappy={times={[2]=1.00, [3]=0.50}, maxwear=0.1, maxlevel=1},
578                         choppy={times={[3]=1.00}, maxwear=0.05, maxlevel=0}
579                 }
580         }
581 })
582 minetest.register_tool("default:sword_stone", {
583         description = "Stone Sword",
584         inventory_image = "default_tool_stonesword.png",
585         tool_capabilities = {
586                 full_punch_interval = 1.0,
587                 max_drop_level=0,
588                 groupcaps={
589                         fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
590                         snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
591                         choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
592                 }
593         }
594 })
595 minetest.register_tool("default:sword_steel", {
596         description = "Steel Sword",
597         inventory_image = "default_tool_steelsword.png",
598         tool_capabilities = {
599                 full_punch_interval = 1.0,
600                 max_drop_level=1,
601                 groupcaps={
602                         fleshy={times={[1]=1.00, [2]=0.40, [3]=0.20}, maxwear=0.1, maxlevel=2},
603                         snappy={times={[2]=0.70, [3]=0.30}, maxwear=0.03, maxlevel=1},
604                         choppy={times={[3]=0.70}, maxwear=0.03, maxlevel=0}
605                 }
606         }
607 })
608
609 --
610 -- Crafting definition
611 --
612
613 minetest.register_craft({
614         output = 'default:wood 4',
615         recipe = {
616                 {'default:tree'},
617         }
618 })
619
620 minetest.register_craft({
621         output = 'default:stick 4',
622         recipe = {
623                 {'default:wood'},
624         }
625 })
626
627 minetest.register_craft({
628         output = 'default:fence_wood 2',
629         recipe = {
630                 {'default:stick', 'default:stick', 'default:stick'},
631                 {'default:stick', 'default:stick', 'default:stick'},
632         }
633 })
634
635 minetest.register_craft({
636         output = 'default:sign_wall',
637         recipe = {
638                 {'default:wood', 'default:wood', 'default:wood'},
639                 {'default:wood', 'default:wood', 'default:wood'},
640                 {'', 'default:stick', ''},
641         }
642 })
643
644 minetest.register_craft({
645         output = 'default:torch 4',
646         recipe = {
647                 {'default:coal_lump'},
648                 {'default:stick'},
649         }
650 })
651
652 minetest.register_craft({
653         output = 'default:pick_wood',
654         recipe = {
655                 {'default:wood', 'default:wood', 'default:wood'},
656                 {'', 'default:stick', ''},
657                 {'', 'default:stick', ''},
658         }
659 })
660
661 minetest.register_craft({
662         output = 'default:pick_stone',
663         recipe = {
664                 {'default:cobble', 'default:cobble', 'default:cobble'},
665                 {'', 'default:stick', ''},
666                 {'', 'default:stick', ''},
667         }
668 })
669
670 minetest.register_craft({
671         output = 'default:pick_steel',
672         recipe = {
673                 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
674                 {'', 'default:stick', ''},
675                 {'', 'default:stick', ''},
676         }
677 })
678
679 minetest.register_craft({
680         output = 'default:pick_mese',
681         recipe = {
682                 {'default:mese', 'default:mese', 'default:mese'},
683                 {'', 'default:stick', ''},
684                 {'', 'default:stick', ''},
685         }
686 })
687
688 minetest.register_craft({
689         output = 'default:shovel_wood',
690         recipe = {
691                 {'default:wood'},
692                 {'default:stick'},
693                 {'default:stick'},
694         }
695 })
696
697 minetest.register_craft({
698         output = 'default:shovel_stone',
699         recipe = {
700                 {'default:cobble'},
701                 {'default:stick'},
702                 {'default:stick'},
703         }
704 })
705
706 minetest.register_craft({
707         output = 'default:shovel_steel',
708         recipe = {
709                 {'default:steel_ingot'},
710                 {'default:stick'},
711                 {'default:stick'},
712         }
713 })
714
715 minetest.register_craft({
716         output = 'default:axe_wood',
717         recipe = {
718                 {'default:wood', 'default:wood'},
719                 {'default:wood', 'default:stick'},
720                 {'', 'default:stick'},
721         }
722 })
723
724 minetest.register_craft({
725         output = 'default:axe_stone',
726         recipe = {
727                 {'default:cobble', 'default:cobble'},
728                 {'default:cobble', 'default:stick'},
729                 {'', 'default:stick'},
730         }
731 })
732
733 minetest.register_craft({
734         output = 'default:axe_steel',
735         recipe = {
736                 {'default:steel_ingot', 'default:steel_ingot'},
737                 {'default:steel_ingot', 'default:stick'},
738                 {'', 'default:stick'},
739         }
740 })
741
742 minetest.register_craft({
743         output = 'default:sword_wood',
744         recipe = {
745                 {'default:wood'},
746                 {'default:wood'},
747                 {'default:stick'},
748         }
749 })
750
751 minetest.register_craft({
752         output = 'default:sword_stone',
753         recipe = {
754                 {'default:cobble'},
755                 {'default:cobble'},
756                 {'default:stick'},
757         }
758 })
759
760 minetest.register_craft({
761         output = 'default:sword_steel',
762         recipe = {
763                 {'default:steel_ingot'},
764                 {'default:steel_ingot'},
765                 {'default:stick'},
766         }
767 })
768
769 minetest.register_craft({
770         output = 'default:rail 15',
771         recipe = {
772                 {'default:steel_ingot', '', 'default:steel_ingot'},
773                 {'default:steel_ingot', 'default:stick', 'default:steel_ingot'},
774                 {'default:steel_ingot', '', 'default:steel_ingot'},
775         }
776 })
777
778 minetest.register_craft({
779         output = 'default:chest',
780         recipe = {
781                 {'default:wood', 'default:wood', 'default:wood'},
782                 {'default:wood', '', 'default:wood'},
783                 {'default:wood', 'default:wood', 'default:wood'},
784         }
785 })
786
787 minetest.register_craft({
788         output = 'default:chest_locked',
789         recipe = {
790                 {'default:wood', 'default:wood', 'default:wood'},
791                 {'default:wood', 'default:steel_ingot', 'default:wood'},
792                 {'default:wood', 'default:wood', 'default:wood'},
793         }
794 })
795
796 minetest.register_craft({
797         output = 'default:furnace',
798         recipe = {
799                 {'default:cobble', 'default:cobble', 'default:cobble'},
800                 {'default:cobble', '', 'default:cobble'},
801                 {'default:cobble', 'default:cobble', 'default:cobble'},
802         }
803 })
804
805 minetest.register_craft({
806         output = 'default:steelblock',
807         recipe = {
808                 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
809                 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
810                 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
811         }
812 })
813
814 minetest.register_craft({
815         output = 'default:sandstone',
816         recipe = {
817                 {'default:sand', 'default:sand'},
818                 {'default:sand', 'default:sand'},
819         }
820 })
821
822 minetest.register_craft({
823         output = 'default:clay',
824         recipe = {
825                 {'default:clay_lump', 'default:clay_lump'},
826                 {'default:clay_lump', 'default:clay_lump'},
827         }
828 })
829
830 minetest.register_craft({
831         output = 'default:brick',
832         recipe = {
833                 {'default:clay_brick', 'default:clay_brick'},
834                 {'default:clay_brick', 'default:clay_brick'},
835         }
836 })
837
838 minetest.register_craft({
839         output = 'default:paper',
840         recipe = {
841                 {'default:papyrus', 'default:papyrus', 'default:papyrus'},
842         }
843 })
844
845 minetest.register_craft({
846         output = 'default:book',
847         recipe = {
848                 {'default:paper'},
849                 {'default:paper'},
850                 {'default:paper'},
851         }
852 })
853
854 minetest.register_craft({
855         output = 'default:bookshelf',
856         recipe = {
857                 {'default:wood', 'default:wood', 'default:wood'},
858                 {'default:book', 'default:book', 'default:book'},
859                 {'default:wood', 'default:wood', 'default:wood'},
860         }
861 })
862
863 minetest.register_craft({
864         output = 'default:ladder',
865         recipe = {
866                 {'default:stick', '', 'default:stick'},
867                 {'default:stick', 'default:stick', 'default:stick'},
868                 {'default:stick', '', 'default:stick'},
869         }
870 })
871
872 --
873 -- Crafting (tool repair)
874 --
875 minetest.register_craft({
876         type = "toolrepair",
877         additional_wear = -0.02,
878 })
879
880 --
881 -- Cooking recipes
882 --
883
884 minetest.register_craft({
885         type = "cooking",
886         output = "default:glass",
887         recipe = "default:sand",
888 })
889
890 minetest.register_craft({
891         type = "cooking",
892         output = "default:coal_lump",
893         recipe = "default:tree",
894 })
895
896 minetest.register_craft({
897         type = "cooking",
898         output = "default:coal_lump",
899         recipe = "default:jungletree",
900 })
901
902 minetest.register_craft({
903         type = "cooking",
904         output = "default:stone",
905         recipe = "default:cobble",
906 })
907
908 minetest.register_craft({
909         type = "cooking",
910         output = "default:steel_ingot",
911         recipe = "default:iron_lump",
912 })
913
914 minetest.register_craft({
915         type = "cooking",
916         output = "default:clay_brick",
917         recipe = "default:clay_lump",
918 })
919
920 --
921 -- Fuels
922 --
923
924 minetest.register_craft({
925         type = "fuel",
926         recipe = "default:tree",
927         burntime = 30,
928 })
929
930 minetest.register_craft({
931         type = "fuel",
932         recipe = "default:jungletree",
933         burntime = 30,
934 })
935
936 minetest.register_craft({
937         type = "fuel",
938         recipe = "default:junglegrass",
939         burntime = 2,
940 })
941
942 minetest.register_craft({
943         type = "fuel",
944         recipe = "default:leaves",
945         burntime = 1,
946 })
947
948 minetest.register_craft({
949         type = "fuel",
950         recipe = "default:cactus",
951         burntime = 15,
952 })
953
954 minetest.register_craft({
955         type = "fuel",
956         recipe = "default:papyrus",
957         burntime = 1,
958 })
959
960 minetest.register_craft({
961         type = "fuel",
962         recipe = "default:bookshelf",
963         burntime = 30,
964 })
965
966 minetest.register_craft({
967         type = "fuel",
968         recipe = "default:fence_wood",
969         burntime = 15,
970 })
971
972 minetest.register_craft({
973         type = "fuel",
974         recipe = "default:ladder",
975         burntime = 5,
976 })
977
978 minetest.register_craft({
979         type = "fuel",
980         recipe = "default:wood",
981         burntime = 7,
982 })
983
984 minetest.register_craft({
985         type = "fuel",
986         recipe = "default:mese",
987         burntime = 30,
988 })
989
990 minetest.register_craft({
991         type = "fuel",
992         recipe = "default:lava_source",
993         burntime = 60,
994 })
995
996 minetest.register_craft({
997         type = "fuel",
998         recipe = "default:torch",
999         burntime = 4,
1000 })
1001
1002 minetest.register_craft({
1003         type = "fuel",
1004         recipe = "default:sign_wall",
1005         burntime = 10,
1006 })
1007
1008 minetest.register_craft({
1009         type = "fuel",
1010         recipe = "default:chest",
1011         burntime = 30,
1012 })
1013
1014 minetest.register_craft({
1015         type = "fuel",
1016         recipe = "default:chest_locked",
1017         burntime = 30,
1018 })
1019
1020 minetest.register_craft({
1021         type = "fuel",
1022         recipe = "default:nyancat",
1023         burntime = 1,
1024 })
1025
1026 minetest.register_craft({
1027         type = "fuel",
1028         recipe = "default:nyancat_rainbow",
1029         burntime = 1,
1030 })
1031
1032 minetest.register_craft({
1033         type = "fuel",
1034         recipe = "default:sapling",
1035         burntime = 10,
1036 })
1037
1038 minetest.register_craft({
1039         type = "fuel",
1040         recipe = "default:apple",
1041         burntime = 3,
1042 })
1043
1044 minetest.register_craft({
1045         type = "fuel",
1046         recipe = "default:coal_lump",
1047         burntime = 40,
1048 })
1049
1050 --
1051 -- Node definitions
1052 --
1053
1054 minetest.register_node("default:stone", {
1055         description = "Stone",
1056         tile_images = {"default_stone.png"},
1057         is_ground_content = true,
1058         groups = {cracky=3},
1059         drop = 'default:cobble',
1060         legacy_mineral = true,
1061 })
1062
1063 minetest.register_node("default:stone_with_coal", {
1064         description = "Stone with coal",
1065         tile_images = {"default_stone.png^default_mineral_coal.png"},
1066         is_ground_content = true,
1067         groups = {cracky=3},
1068         drop = 'default:coal_lump',
1069 })
1070
1071 minetest.register_node("default:stone_with_iron", {
1072         description = "Stone with iron",
1073         tile_images = {"default_stone.png^default_mineral_iron.png"},
1074         is_ground_content = true,
1075         groups = {cracky=3},
1076         drop = 'default:iron_lump',
1077 })
1078
1079 minetest.register_node("default:dirt_with_grass", {
1080         description = "Dirt with grass",
1081         tile_images = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
1082         is_ground_content = true,
1083         groups = {crumbly=3},
1084         drop = 'default:dirt',
1085 })
1086
1087 minetest.register_node("default:dirt_with_grass_footsteps", {
1088         description = "Dirt with grass and footsteps",
1089         tile_images = {"default_grass_footsteps.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
1090         is_ground_content = true,
1091         groups = {crumbly=3},
1092         drop = 'default:dirt',
1093 })
1094
1095 minetest.register_node("default:dirt", {
1096         description = "Dirt",
1097         tile_images = {"default_dirt.png"},
1098         is_ground_content = true,
1099         groups = {crumbly=3},
1100 })
1101
1102 minetest.register_node("default:sand", {
1103         description = "Sand",
1104         tile_images = {"default_sand.png"},
1105         is_ground_content = true,
1106         groups = {crumbly=3},
1107 })
1108
1109 minetest.register_node("default:gravel", {
1110         description = "Gravel",
1111         tile_images = {"default_gravel.png"},
1112         is_ground_content = true,
1113         groups = {crumbly=2},
1114 })
1115
1116 minetest.register_node("default:sandstone", {
1117         description = "Sandstone",
1118         tile_images = {"default_sandstone.png"},
1119         is_ground_content = true,
1120         groups = {crumbly=2,cracky=2},
1121         drop = 'default:sand',
1122 })
1123
1124 minetest.register_node("default:clay", {
1125         description = "Clay",
1126         tile_images = {"default_clay.png"},
1127         is_ground_content = true,
1128         groups = {crumbly=3},
1129         drop = 'default:clay_lump 4',
1130 })
1131
1132 minetest.register_node("default:brick", {
1133         description = "Brick",
1134         tile_images = {"default_brick.png"},
1135         is_ground_content = true,
1136         groups = {cracky=3},
1137         drop = 'default:clay_brick 4',
1138 })
1139
1140 minetest.register_node("default:tree", {
1141         description = "Tree",
1142         tile_images = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
1143         is_ground_content = true,
1144         groups = {snappy=2,choppy=2},
1145 })
1146
1147 minetest.register_node("default:jungletree", {
1148         description = "Jungle Tree",
1149         tile_images = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
1150         is_ground_content = true,
1151         groups = {snappy=2,choppy=2},
1152 })
1153
1154 minetest.register_node("default:junglegrass", {
1155         description = "Jungle Grass",
1156         drawtype = "plantlike",
1157         visual_scale = 1.3,
1158         tile_images = {"default_junglegrass.png"},
1159         inventory_image = "default_junglegrass.png",
1160         wield_image = "default_junglegrass.png",
1161         paramtype = "light",
1162         walkable = false,
1163         groups = {snappy=3},
1164 })
1165
1166 minetest.register_node("default:leaves", {
1167         description = "Leaves",
1168         drawtype = "allfaces_optional",
1169         visual_scale = 1.3,
1170         tile_images = {"default_leaves.png"},
1171         paramtype = "light",
1172         groups = {snappy=3},
1173         drop = {
1174                 max_items = 1,
1175                 items = {
1176                         {
1177                                 -- player will get sapling with 1/20 chance
1178                                 items = {'default:sapling'},
1179                                 rarity = 20,
1180                         },
1181                         {
1182                                 -- player will get leaves only if he get no saplings,
1183                                 -- this is because max_items is 1
1184                                 items = {'default:leaves'},
1185                         }
1186                 }
1187         },
1188 })
1189
1190 minetest.register_node("default:cactus", {
1191         description = "Cactus",
1192         tile_images = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
1193         is_ground_content = true,
1194         groups = {snappy=2,choppy=3},
1195 })
1196
1197 minetest.register_node("default:papyrus", {
1198         description = "Papyrus",
1199         drawtype = "plantlike",
1200         tile_images = {"default_papyrus.png"},
1201         inventory_image = "default_papyrus.png",
1202         wield_image = "default_papyrus.png",
1203         paramtype = "light",
1204         is_ground_content = true,
1205         walkable = false,
1206         groups = {snappy=3},
1207 })
1208
1209 minetest.register_node("default:bookshelf", {
1210         description = "Bookshelf",
1211         tile_images = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
1212         is_ground_content = true,
1213         groups = {snappy=2,choppy=3},
1214 })
1215
1216 minetest.register_node("default:glass", {
1217         description = "Glass",
1218         drawtype = "glasslike",
1219         tile_images = {"default_glass.png"},
1220         inventory_image = minetest.inventorycube("default_glass.png"),
1221         paramtype = "light",
1222         sunlight_propagates = true,
1223         is_ground_content = true,
1224         groups = {snappy=2,cracky=3},
1225 })
1226
1227 minetest.register_node("default:fence_wood", {
1228         description = "Wooden Fence",
1229         drawtype = "fencelike",
1230         tile_images = {"default_wood.png"},
1231         inventory_image = "default_fence.png",
1232         wield_image = "default_fence.png",
1233         paramtype = "light",
1234         is_ground_content = true,
1235         selection_box = {
1236                 type = "fixed",
1237                 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
1238         },
1239         groups = {snappy=2,choppy=2},
1240 })
1241
1242 minetest.register_node("default:rail", {
1243         description = "Rail",
1244         drawtype = "raillike",
1245         tile_images = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
1246         inventory_image = "default_rail.png",
1247         wield_image = "default_rail.png",
1248         paramtype = "light",
1249         is_ground_content = true,
1250         walkable = false,
1251         selection_box = {
1252                 type = "fixed",
1253                 --fixed = <default>
1254         },
1255         groups = {bendy=2,snappy=1},
1256 })
1257
1258 minetest.register_node("default:ladder", {
1259         description = "Ladder",
1260         drawtype = "signlike",
1261         tile_images = {"default_ladder.png"},
1262         inventory_image = "default_ladder.png",
1263         wield_image = "default_ladder.png",
1264         paramtype = "light",
1265         paramtype2 = "wallmounted",
1266         is_ground_content = true,
1267         walkable = false,
1268         climbable = true,
1269         selection_box = {
1270                 type = "wallmounted",
1271                 --wall_top = = <default>
1272                 --wall_bottom = = <default>
1273                 --wall_side = = <default>
1274         },
1275         groups = {snappy=2,choppy=2},
1276         legacy_wallmounted = true,
1277 })
1278
1279 minetest.register_node("default:wood", {
1280         description = "Wood",
1281         tile_images = {"default_wood.png"},
1282         is_ground_content = true,
1283         groups = {snappy=2,choppy=2},
1284 })
1285
1286 minetest.register_node("default:mese", {
1287         description = "Mese",
1288         tile_images = {"default_mese.png"},
1289         is_ground_content = true,
1290         groups = {cracky=1},
1291 })
1292
1293 minetest.register_node("default:cloud", {
1294         description = "Cloud",
1295         tile_images = {"default_cloud.png"},
1296         is_ground_content = true,
1297 })
1298
1299 minetest.register_node("default:water_flowing", {
1300         description = "Water (flowing)",
1301         inventory_image = minetest.inventorycube("default_water.png"),
1302         drawtype = "flowingliquid",
1303         tile_images = {"default_water.png"},
1304         alpha = WATER_ALPHA,
1305         paramtype = "light",
1306         walkable = false,
1307         pointable = false,
1308         diggable = false,
1309         buildable_to = true,
1310         liquidtype = "flowing",
1311         liquid_alternative_flowing = "default:water_flowing",
1312         liquid_alternative_source = "default:water_source",
1313         liquid_viscosity = WATER_VISC,
1314         post_effect_color = {a=64, r=100, g=100, b=200},
1315         special_materials = {
1316                 {image="default_water.png", backface_culling=false},
1317                 {image="default_water.png", backface_culling=true},
1318         },
1319         groups = {water=3, liquid=3},
1320 })
1321
1322 minetest.register_node("default:water_source", {
1323         description = "Water",
1324         inventory_image = minetest.inventorycube("default_water.png"),
1325         drawtype = "liquid",
1326         tile_images = {"default_water.png"},
1327         alpha = WATER_ALPHA,
1328         paramtype = "light",
1329         walkable = false,
1330         pointable = false,
1331         diggable = false,
1332         buildable_to = true,
1333         liquidtype = "source",
1334         liquid_alternative_flowing = "default:water_flowing",
1335         liquid_alternative_source = "default:water_source",
1336         liquid_viscosity = WATER_VISC,
1337         post_effect_color = {a=64, r=100, g=100, b=200},
1338         special_materials = {
1339                 -- New-style water source material (mostly unused)
1340                 {image="default_water.png", backface_culling=false},
1341         },
1342         groups = {water=3, liquid=3},
1343 })
1344
1345 minetest.register_node("default:lava_flowing", {
1346         description = "Lava (flowing)",
1347         inventory_image = minetest.inventorycube("default_lava.png"),
1348         drawtype = "flowingliquid",
1349         tile_images = {"default_lava.png"},
1350         paramtype = "light",
1351         light_source = LIGHT_MAX - 1,
1352         walkable = false,
1353         pointable = false,
1354         diggable = false,
1355         buildable_to = true,
1356         liquidtype = "flowing",
1357         liquid_alternative_flowing = "default:lava_flowing",
1358         liquid_alternative_source = "default:lava_source",
1359         liquid_viscosity = LAVA_VISC,
1360         damage_per_second = 4*2,
1361         post_effect_color = {a=192, r=255, g=64, b=0},
1362         special_materials = {
1363                 {image="default_lava.png", backface_culling=false},
1364                 {image="default_lava.png", backface_culling=true},
1365         },
1366         groups = {lava=3, liquid=2, hot=3},
1367 })
1368
1369 minetest.register_node("default:lava_source", {
1370         description = "Lava",
1371         inventory_image = minetest.inventorycube("default_lava.png"),
1372         drawtype = "liquid",
1373         tile_images = {"default_lava.png"},
1374         paramtype = "light",
1375         light_source = LIGHT_MAX - 1,
1376         walkable = false,
1377         pointable = false,
1378         diggable = false,
1379         buildable_to = true,
1380         liquidtype = "source",
1381         liquid_alternative_flowing = "default:lava_flowing",
1382         liquid_alternative_source = "default:lava_source",
1383         liquid_viscosity = LAVA_VISC,
1384         damage_per_second = 4*2,
1385         post_effect_color = {a=192, r=255, g=64, b=0},
1386         special_materials = {
1387                 -- New-style lava source material (mostly unused)
1388                 {image="default_lava.png", backface_culling=false},
1389         },
1390         groups = {lava=3, liquid=2, hot=3},
1391 })
1392
1393 minetest.register_node("default:torch", {
1394         description = "Torch",
1395         drawtype = "torchlike",
1396         tile_images = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
1397         inventory_image = "default_torch_on_floor.png",
1398         wield_image = "default_torch_on_floor.png",
1399         paramtype = "light",
1400         paramtype2 = "wallmounted",
1401         sunlight_propagates = true,
1402         walkable = false,
1403         light_source = LIGHT_MAX-1,
1404         selection_box = {
1405                 type = "wallmounted",
1406                 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
1407                 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
1408                 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
1409         },
1410         groups = {dig_immediate=1},
1411         legacy_wallmounted = true,
1412 })
1413
1414 minetest.register_node("default:sign_wall", {
1415         description = "Sign",
1416         drawtype = "signlike",
1417         tile_images = {"default_sign_wall.png"},
1418         inventory_image = "default_sign_wall.png",
1419         wield_image = "default_sign_wall.png",
1420         paramtype = "light",
1421         paramtype2 = "wallmounted",
1422         sunlight_propagates = true,
1423         walkable = false,
1424         metadata_name = "sign",
1425         selection_box = {
1426                 type = "wallmounted",
1427                 --wall_top = <default>
1428                 --wall_bottom = <default>
1429                 --wall_side = <default>
1430         },
1431         groups = {dig_immediate=2},
1432         legacy_wallmounted = true,
1433 })
1434
1435 minetest.register_node("default:chest", {
1436         description = "Chest",
1437         tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
1438                 "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
1439         paramtype2 = "facedir",
1440         metadata_name = "chest",
1441         groups = {snappy=2,choppy=2},
1442         legacy_facedir_simple = true,
1443 })
1444
1445 minetest.register_node("default:chest_locked", {
1446         description = "Locked Chest",
1447         tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
1448                 "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
1449         paramtype2 = "facedir",
1450         metadata_name = "locked_chest",
1451         groups = {snappy=2,choppy=2},
1452         legacy_facedir_simple = true,
1453 })
1454
1455 minetest.register_node("default:furnace", {
1456         description = "Furnace",
1457         tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
1458                 "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
1459         paramtype2 = "facedir",
1460         metadata_name = "furnace",
1461         groups = {cracky=2},
1462         legacy_facedir_simple = true,
1463 })
1464
1465 minetest.register_node("default:cobble", {
1466         description = "Cobble",
1467         tile_images = {"default_cobble.png"},
1468         is_ground_content = true,
1469         groups = {cracky=3},
1470 })
1471
1472 minetest.register_node("default:mossycobble", {
1473         description = "Mossy Cobble",
1474         tile_images = {"default_mossycobble.png"},
1475         is_ground_content = true,
1476         groups = {cracky=3},
1477 })
1478
1479 minetest.register_node("default:steelblock", {
1480         description = "Steel Block",
1481         tile_images = {"default_steel_block.png"},
1482         is_ground_content = true,
1483         groups = {snappy=1,bendy=2},
1484 })
1485
1486 minetest.register_node("default:nyancat", {
1487         description = "Nyancat",
1488         tile_images = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
1489                 "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
1490         inventory_image = "default_nc_front.png",
1491         paramtype2 = "facedir",
1492         groups = {cracky=2},
1493         legacy_facedir_simple = true,
1494 })
1495
1496 minetest.register_node("default:nyancat_rainbow", {
1497         description = "Nyancat Rainbow",
1498         tile_images = {"default_nc_rb.png"},
1499         inventory_image = "default_nc_rb.png",
1500         groups = {cracky=2},
1501 })
1502
1503 minetest.register_node("default:sapling", {
1504         description = "Sapling",
1505         drawtype = "plantlike",
1506         visual_scale = 1.0,
1507         tile_images = {"default_sapling.png"},
1508         inventory_image = "default_sapling.png",
1509         wield_image = "default_sapling.png",
1510         paramtype = "light",
1511         walkable = false,
1512         groups = {dig_immediate=1},
1513 })
1514
1515 minetest.register_node("default:apple", {
1516         description = "Apple",
1517         drawtype = "plantlike",
1518         visual_scale = 1.0,
1519         tile_images = {"default_apple.png"},
1520         inventory_image = "default_apple.png",
1521         paramtype = "light",
1522         sunlight_propagates = true,
1523         walkable = false,
1524         groups = {dig_immediate=1},
1525         on_use = minetest.item_eat(4),
1526 })
1527
1528 --
1529 -- Crafting items
1530 --
1531
1532 minetest.register_craftitem("default:stick", {
1533         description = "Stick",
1534         inventory_image = "default_stick.png",
1535 })
1536
1537 minetest.register_craftitem("default:paper", {
1538         description = "Paper",
1539         inventory_image = "default_paper.png",
1540 })
1541
1542 minetest.register_craftitem("default:book", {
1543         description = "Book",
1544         inventory_image = "default_book.png",
1545 })
1546
1547 minetest.register_craftitem("default:coal_lump", {
1548         description = "Lump of coal",
1549         inventory_image = "default_coal_lump.png",
1550 })
1551
1552 minetest.register_craftitem("default:iron_lump", {
1553         description = "Lump of iron",
1554         inventory_image = "default_iron_lump.png",
1555 })
1556
1557 minetest.register_craftitem("default:clay_lump", {
1558         description = "Lump of clay",
1559         inventory_image = "default_clay_lump.png",
1560 })
1561
1562 minetest.register_craftitem("default:steel_ingot", {
1563         description = "Steel ingot",
1564         inventory_image = "default_steel_ingot.png",
1565 })
1566
1567 minetest.register_craftitem("default:clay_brick", {
1568         description = "Clay brick",
1569         inventory_image = "default_steel_ingot.png",
1570         inventory_image = "default_clay_brick.png",
1571 })
1572
1573 minetest.register_craftitem("default:scorched_stuff", {
1574         description = "Scorched stuff",
1575         inventory_image = "default_scorched_stuff.png",
1576 })
1577
1578 --
1579 -- Creative inventory
1580 --
1581
1582 minetest.add_to_creative_inventory('default:pick_mese')
1583 minetest.add_to_creative_inventory('default:pick_steel')
1584 minetest.add_to_creative_inventory('default:axe_steel')
1585 minetest.add_to_creative_inventory('default:shovel_steel')
1586
1587 minetest.add_to_creative_inventory('default:torch')
1588 minetest.add_to_creative_inventory('default:cobble')
1589 minetest.add_to_creative_inventory('default:dirt')
1590 minetest.add_to_creative_inventory('default:stone')
1591 minetest.add_to_creative_inventory('default:sand')
1592 minetest.add_to_creative_inventory('default:sandstone')
1593 minetest.add_to_creative_inventory('default:clay')
1594 minetest.add_to_creative_inventory('default:brick')
1595 minetest.add_to_creative_inventory('default:tree')
1596 minetest.add_to_creative_inventory('default:wood')
1597 minetest.add_to_creative_inventory('default:leaves')
1598 minetest.add_to_creative_inventory('default:cactus')
1599 minetest.add_to_creative_inventory('default:papyrus')
1600 minetest.add_to_creative_inventory('default:bookshelf')
1601 minetest.add_to_creative_inventory('default:glass')
1602 minetest.add_to_creative_inventory('default:fence_wood')
1603 minetest.add_to_creative_inventory('default:rail')
1604 minetest.add_to_creative_inventory('default:mese')
1605 minetest.add_to_creative_inventory('default:chest')
1606 minetest.add_to_creative_inventory('default:furnace')
1607 minetest.add_to_creative_inventory('default:sign_wall')
1608 minetest.add_to_creative_inventory('default:water_source')
1609 minetest.add_to_creative_inventory('default:lava_source')
1610 minetest.add_to_creative_inventory('default:ladder')
1611
1612 --
1613 -- Some common functions
1614 --
1615
1616 default.falling_node_names = {}
1617
1618 function nodeupdate_single(p)
1619         n = minetest.env:get_node(p)
1620         if default.falling_node_names[n.name] ~= nil then
1621                 p_bottom = {x=p.x, y=p.y-1, z=p.z}
1622                 n_bottom = minetest.env:get_node(p_bottom)
1623                 if n_bottom.name == "air" then
1624                         minetest.env:remove_node(p)
1625                         minetest.env:add_entity(p, "default:falling_"..n.name)
1626                         nodeupdate(p)
1627                 end
1628         end
1629 end
1630
1631 function nodeupdate(p)
1632         for x = -1,1 do
1633         for y = -1,1 do
1634         for z = -1,1 do
1635                 p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
1636                 nodeupdate_single(p2)
1637         end
1638         end
1639         end
1640 end
1641
1642 --
1643 -- Falling stuff
1644 --
1645
1646 function default.register_falling_node(nodename, texture)
1647         default.falling_node_names[nodename] = true
1648         -- Override naming conventions for stuff like :default:falling_default:sand
1649         minetest.register_entity(":default:falling_"..nodename, {
1650                 -- Static definition
1651                 physical = true,
1652                 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1653                 visual = "cube",
1654                 textures = {texture,texture,texture,texture,texture,texture},
1655                 -- State
1656                 -- Methods
1657                 on_step = function(self, dtime)
1658                         -- Set gravity
1659                         self.object:setacceleration({x=0, y=-10, z=0})
1660                         -- Turn to actual sand when collides to ground or just move
1661                         local pos = self.object:getpos()
1662                         local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
1663                         local bcn = minetest.env:get_node(bcp)
1664                         if bcn.name ~= "air" then
1665                                 -- Turn to a sand node
1666                                 local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
1667                                 minetest.env:add_node(np, {name=nodename})
1668                                 self.object:remove()
1669                         else
1670                                 -- Do nothing
1671                         end
1672                 end
1673         })
1674 end
1675
1676 default.register_falling_node("default:sand", "default_sand.png")
1677 default.register_falling_node("default:gravel", "default_gravel.png")
1678
1679 --
1680 -- Global callbacks
1681 --
1682
1683 -- Global environment step function
1684 function on_step(dtime)
1685         -- print("on_step")
1686 end
1687 minetest.register_globalstep(on_step)
1688
1689 function on_placenode(p, node)
1690         --print("on_placenode")
1691         nodeupdate(p)
1692 end
1693 minetest.register_on_placenode(on_placenode)
1694
1695 function on_dignode(p, node)
1696         --print("on_dignode")
1697         nodeupdate(p)
1698 end
1699 minetest.register_on_dignode(on_dignode)
1700
1701 function on_punchnode(p, node)
1702 end
1703 minetest.register_on_punchnode(on_punchnode)
1704
1705 local function handle_give_command(cmd, giver, receiver, stackstring)
1706         if not minetest.get_player_privs(giver)["give"] then
1707                 minetest.chat_send_player(giver, "error: you don't have permission to give")
1708                 return
1709         end
1710         minetest.debug("DEBUG: "..cmd..' invoked, stackstring="'..stackstring..'"')
1711         minetest.log(cmd..' invoked, stackstring="'..stackstring..'"')
1712         local itemstack = ItemStack(stackstring)
1713         if itemstack:is_empty() then
1714                 minetest.chat_send_player(giver, 'error: cannot give an empty item')
1715                 return
1716         elseif not itemstack:is_known() then
1717                 minetest.chat_send_player(giver, 'error: cannot give an unknown item')
1718                 return
1719         end
1720         local receiverref = minetest.env:get_player_by_name(receiver)
1721         if receiverref == nil then
1722                 minetest.chat_send_player(giver, receiver..' is not a known player')
1723                 return
1724         end
1725         local leftover = receiverref:get_inventory():add_item("main", itemstack)
1726         if leftover:is_empty() then
1727                 partiality = ""
1728         elseif leftover:get_count() == itemstack:get_count() then
1729                 partiality = "could not be "
1730         else
1731                 partiality = "partially "
1732         end
1733         -- The actual item stack string may be different from what the "giver"
1734         -- entered (e.g. big numbers are always interpreted as 2^16-1).
1735         stackstring = itemstack:to_string()
1736         if giver == receiver then
1737                 minetest.chat_send_player(giver, '"'..stackstring
1738                         ..'" '..partiality..'added to inventory.');
1739         else
1740                 minetest.chat_send_player(giver, '"'..stackstring
1741                         ..'" '..partiality..'added to '..receiver..'\'s inventory.');
1742                 minetest.chat_send_player(receiver, '"'..stackstring
1743                         ..'" '..partiality..'added to inventory.');
1744         end
1745 end
1746
1747 minetest.register_on_chat_message(function(name, message)
1748         --print("default on_chat_message: name="..dump(name).." message="..dump(message))
1749         local cmd = "/giveme"
1750         if message:sub(0, #cmd) == cmd then
1751                 local stackstring = string.match(message, cmd.." (.*)")
1752                 if stackstring == nil then
1753                         minetest.chat_send_player(name, 'usage: '..cmd..' stackstring')
1754                         return true -- Handled chat message
1755                 end
1756                 handle_give_command(cmd, name, name, stackstring)
1757                 return true
1758         end
1759         local cmd = "/give"
1760         if message:sub(0, #cmd) == cmd then
1761                 local receiver, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)")
1762                 if receiver == nil or stackstring == nil then
1763                         minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring')
1764                         return true -- Handled chat message
1765                 end
1766                 handle_give_command(cmd, name, receiver, stackstring)
1767                 return true
1768         end
1769         local cmd = "/spawnentity"
1770         if message:sub(0, #cmd) == cmd then
1771                 if not minetest.get_player_privs(name)["give"] then
1772                         minetest.chat_send_player(name, "you don't have permission to spawn (give)")
1773                         return true -- Handled chat message
1774                 end
1775                 if not minetest.get_player_privs(name)["interact"] then
1776                         minetest.chat_send_player(name, "you don't have permission to interact")
1777                         return true -- Handled chat message
1778                 end
1779                 local entityname = string.match(message, cmd.." (.*)")
1780                 if entityname == nil then
1781                         minetest.chat_send_player(name, 'usage: '..cmd..' entityname')
1782                         return true -- Handled chat message
1783                 end
1784                 print(cmd..' invoked, entityname="'..entityname..'"')
1785                 local player = minetest.env:get_player_by_name(name)
1786                 if player == nil then
1787                         print("Unable to spawn entity, player is nil")
1788                         return true -- Handled chat message
1789                 end
1790                 local p = player:getpos()
1791                 p.y = p.y + 1
1792                 minetest.env:add_entity(p, entityname)
1793                 minetest.chat_send_player(name, '"'..entityname
1794                                 ..'" spawned.');
1795                 return true -- Handled chat message
1796         end
1797         local cmd = "/pulverize"
1798         if message:sub(0, #cmd) == cmd then
1799                 local player = minetest.env:get_player_by_name(name)
1800                 if player == nil then
1801                         print("Unable to pulverize, player is nil")
1802                         return true -- Handled chat message
1803                 end
1804                 if player:get_wielded_item():is_empty() then
1805                         minetest.chat_send_player(name, 'Unable to pulverize, no item in hand.')
1806                 else
1807                         player:set_wielded_item(nil)
1808                         minetest.chat_send_player(name, 'An item was pulverized.')
1809                 end
1810                 return true
1811         end
1812 end)
1813
1814 --
1815 -- Done, print some random stuff
1816 --
1817
1818 --print("minetest.registered_entities:")
1819 --dump2(minetest.registered_entities)
1820
1821 -- END