5ffed25ff63b519c73417ccf42806ff08aeef9be
[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 minetest.register_tool("default:pick_wood", {
449         description = "Wooden Pickaxe",
450         inventory_image = "default_tool_woodpick.png",
451         tool_capabilities = {
452                 max_drop_level=0,
453                 groupcaps={
454                         cracky={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1}
455                 }
456         },
457 })
458 minetest.register_tool("default:pick_stone", {
459         description = "Stone Pickaxe",
460         inventory_image = "default_tool_stonepick.png",
461         tool_capabilities = {
462                 max_drop_level=0,
463                 groupcaps={
464                         cracky={times={[1]=1.50, [2]=0.80, [3]=0.60}, maxwear=0.05, maxlevel=1}
465                 }
466         },
467 })
468 minetest.register_tool("default:pick_steel", {
469         description = "Steel Pickaxe",
470         inventory_image = "default_tool_steelpick.png",
471         tool_capabilities = {
472                 max_drop_level=1,
473                 groupcaps={
474                         cracky={times={[1]=1.00, [2]=0.60, [3]=0.40}, maxwear=0.1, maxlevel=2}
475                 }
476         },
477 })
478 minetest.register_tool("default:pick_mese", {
479         description = "Mese Pickaxe",
480         inventory_image = "default_tool_mesepick.png",
481         tool_capabilities = {
482                 max_drop_level=3,
483                 groupcaps={
484                         cracky={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3},
485                         crumbly={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3},
486                         snappy={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3}
487                 }
488         },
489 })
490 minetest.register_tool("default:shovel_wood", {
491         description = "Wooden Shovel",
492         inventory_image = "default_tool_woodshovel.png",
493         tool_capabilities = {
494                 max_drop_level=0,
495                 groupcaps={
496                         crumbly={times={[1]=1.50, [2]=0.80, [3]=0.50}, maxwear=0.1, maxlevel=1}
497                 }
498         },
499 })
500 minetest.register_tool("default:shovel_stone", {
501         description = "Stone Shovel",
502         inventory_image = "default_tool_stoneshovel.png",
503         tool_capabilities = {
504                 max_drop_level=0,
505                 groupcaps={
506                         crumbly={times={[1]=0.80, [2]=0.50, [3]=0.30}, maxwear=0.05, maxlevel=1}
507                 }
508         },
509 })
510 minetest.register_tool("default:shovel_steel", {
511         description = "Steel Shovel",
512         inventory_image = "default_tool_steelshovel.png",
513         tool_capabilities = {
514                 max_drop_level=1,
515                 groupcaps={
516                         crumbly={times={[1]=0.50, [2]=0.35, [3]=0.30}, maxwear=0.1, maxlevel=2}
517                 }
518         },
519 })
520 minetest.register_tool("default:axe_wood", {
521         description = "Wooden Axe",
522         inventory_image = "default_tool_woodaxe.png",
523         tool_capabilities = {
524                 max_drop_level=0,
525                 groupcaps={
526                         choppy={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1},
527                         fleshy={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1}
528                 }
529         },
530 })
531 minetest.register_tool("default:axe_stone", {
532         description = "Stone Axe",
533         inventory_image = "default_tool_stoneaxe.png",
534         tool_capabilities = {
535                 max_drop_level=0,
536                 groupcaps={
537                         choppy={times={[1]=1.50, [2]=1.00, [3]=0.60}, maxwear=0.05, maxlevel=1},
538                         fleshy={times={[2]=1.30, [3]=0.70}, maxwear=0.05, maxlevel=1}
539                 }
540         },
541 })
542 minetest.register_tool("default:axe_steel", {
543         description = "Steel Axe",
544         inventory_image = "default_tool_steelaxe.png",
545         tool_capabilities = {
546                 max_drop_level=1,
547                 groupcaps={
548                         choppy={times={[1]=1.00, [2]=0.80, [3]=0.50}, maxwear=0.1, maxlevel=2},
549                         fleshy={times={[2]=1.10, [3]=0.60}, maxwear=0.03, maxlevel=1}
550                 }
551         },
552 })
553 minetest.register_tool("default:sword_wood", {
554         description = "Wooden Sword",
555         inventory_image = "default_tool_woodsword.png",
556         tool_capabilities = {
557                 full_punch_interval = 2.0,
558                 max_drop_level=0,
559                 groupcaps={
560                         fleshy={times={[2]=1.10, [3]=0.60}, maxwear=0.1, maxlevel=1},
561                         snappy={times={[2]=1.00, [3]=0.50}, maxwear=0.1, maxlevel=1},
562                         choppy={times={[3]=1.00}, maxwear=0.05, maxlevel=0}
563                 }
564         }
565 })
566 minetest.register_tool("default:sword_stone", {
567         description = "Stone Sword",
568         inventory_image = "default_tool_stonesword.png",
569         tool_capabilities = {
570                 full_punch_interval = 2.0,
571                 max_drop_level=0,
572                 groupcaps={
573                         fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
574                         snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
575                         choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
576                 }
577         }
578 })
579 minetest.register_tool("default:sword_steel", {
580         description = "Steel Sword",
581         inventory_image = "default_tool_steelsword.png",
582         tool_capabilities = {
583                 full_punch_interval = 2.0,
584                 max_drop_level=1,
585                 groupcaps={
586                         fleshy={times={[1]=1.00, [2]=0.40, [3]=0.20}, maxwear=0.1, maxlevel=2},
587                         snappy={times={[2]=0.70, [3]=0.30}, maxwear=0.03, maxlevel=1},
588                         choppy={times={[3]=0.70}, maxwear=0.03, maxlevel=0}
589                 }
590         }
591 })
592
593 --
594 -- Crafting definition
595 --
596
597 minetest.register_craft({
598         output = 'default:wood 4',
599         recipe = {
600                 {'default:tree'},
601         }
602 })
603
604 minetest.register_craft({
605         output = 'default:stick 4',
606         recipe = {
607                 {'default:wood'},
608         }
609 })
610
611 minetest.register_craft({
612         output = 'default:fence_wood 2',
613         recipe = {
614                 {'default:stick', 'default:stick', 'default:stick'},
615                 {'default:stick', 'default:stick', 'default:stick'},
616         }
617 })
618
619 minetest.register_craft({
620         output = 'default:sign_wall',
621         recipe = {
622                 {'default:wood', 'default:wood', 'default:wood'},
623                 {'default:wood', 'default:wood', 'default:wood'},
624                 {'', 'default:stick', ''},
625         }
626 })
627
628 minetest.register_craft({
629         output = 'default:torch 4',
630         recipe = {
631                 {'default:coal_lump'},
632                 {'default:stick'},
633         }
634 })
635
636 minetest.register_craft({
637         output = 'default:pick_wood',
638         recipe = {
639                 {'default:wood', 'default:wood', 'default:wood'},
640                 {'', 'default:stick', ''},
641                 {'', 'default:stick', ''},
642         }
643 })
644
645 minetest.register_craft({
646         output = 'default:pick_stone',
647         recipe = {
648                 {'default:cobble', 'default:cobble', 'default:cobble'},
649                 {'', 'default:stick', ''},
650                 {'', 'default:stick', ''},
651         }
652 })
653
654 minetest.register_craft({
655         output = 'default:pick_steel',
656         recipe = {
657                 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
658                 {'', 'default:stick', ''},
659                 {'', 'default:stick', ''},
660         }
661 })
662
663 minetest.register_craft({
664         output = 'default:pick_mese',
665         recipe = {
666                 {'default:mese', 'default:mese', 'default:mese'},
667                 {'', 'default:stick', ''},
668                 {'', 'default:stick', ''},
669         }
670 })
671
672 minetest.register_craft({
673         output = 'default:shovel_wood',
674         recipe = {
675                 {'default:wood'},
676                 {'default:stick'},
677                 {'default:stick'},
678         }
679 })
680
681 minetest.register_craft({
682         output = 'default:shovel_stone',
683         recipe = {
684                 {'default:cobble'},
685                 {'default:stick'},
686                 {'default:stick'},
687         }
688 })
689
690 minetest.register_craft({
691         output = 'default:shovel_steel',
692         recipe = {
693                 {'default:steel_ingot'},
694                 {'default:stick'},
695                 {'default:stick'},
696         }
697 })
698
699 minetest.register_craft({
700         output = 'default:axe_wood',
701         recipe = {
702                 {'default:wood', 'default:wood'},
703                 {'default:wood', 'default:stick'},
704                 {'', 'default:stick'},
705         }
706 })
707
708 minetest.register_craft({
709         output = 'default:axe_stone',
710         recipe = {
711                 {'default:cobble', 'default:cobble'},
712                 {'default:cobble', 'default:stick'},
713                 {'', 'default:stick'},
714         }
715 })
716
717 minetest.register_craft({
718         output = 'default:axe_steel',
719         recipe = {
720                 {'default:steel_ingot', 'default:steel_ingot'},
721                 {'default:steel_ingot', 'default:stick'},
722                 {'', 'default:stick'},
723         }
724 })
725
726 minetest.register_craft({
727         output = 'default:sword_wood',
728         recipe = {
729                 {'default:wood'},
730                 {'default:wood'},
731                 {'default:stick'},
732         }
733 })
734
735 minetest.register_craft({
736         output = 'default:sword_stone',
737         recipe = {
738                 {'default:cobble'},
739                 {'default:cobble'},
740                 {'default:stick'},
741         }
742 })
743
744 minetest.register_craft({
745         output = 'default:sword_steel',
746         recipe = {
747                 {'default:steel_ingot'},
748                 {'default:steel_ingot'},
749                 {'default:stick'},
750         }
751 })
752
753 minetest.register_craft({
754         output = 'default:rail 15',
755         recipe = {
756                 {'default:steel_ingot', '', 'default:steel_ingot'},
757                 {'default:steel_ingot', 'default:stick', 'default:steel_ingot'},
758                 {'default:steel_ingot', '', 'default:steel_ingot'},
759         }
760 })
761
762 minetest.register_craft({
763         output = 'default:chest',
764         recipe = {
765                 {'default:wood', 'default:wood', 'default:wood'},
766                 {'default:wood', '', 'default:wood'},
767                 {'default:wood', 'default:wood', 'default:wood'},
768         }
769 })
770
771 minetest.register_craft({
772         output = 'default:chest_locked',
773         recipe = {
774                 {'default:wood', 'default:wood', 'default:wood'},
775                 {'default:wood', 'default:steel_ingot', 'default:wood'},
776                 {'default:wood', 'default:wood', 'default:wood'},
777         }
778 })
779
780 minetest.register_craft({
781         output = 'default:furnace',
782         recipe = {
783                 {'default:cobble', 'default:cobble', 'default:cobble'},
784                 {'default:cobble', '', 'default:cobble'},
785                 {'default:cobble', 'default:cobble', 'default:cobble'},
786         }
787 })
788
789 minetest.register_craft({
790         output = 'default:steelblock',
791         recipe = {
792                 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
793                 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
794                 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
795         }
796 })
797
798 minetest.register_craft({
799         output = 'default:sandstone',
800         recipe = {
801                 {'default:sand', 'default:sand'},
802                 {'default:sand', 'default:sand'},
803         }
804 })
805
806 minetest.register_craft({
807         output = 'default:clay',
808         recipe = {
809                 {'default:clay_lump', 'default:clay_lump'},
810                 {'default:clay_lump', 'default:clay_lump'},
811         }
812 })
813
814 minetest.register_craft({
815         output = 'default:brick',
816         recipe = {
817                 {'default:clay_brick', 'default:clay_brick'},
818                 {'default:clay_brick', 'default:clay_brick'},
819         }
820 })
821
822 minetest.register_craft({
823         output = 'default:paper',
824         recipe = {
825                 {'default:papyrus', 'default:papyrus', 'default:papyrus'},
826         }
827 })
828
829 minetest.register_craft({
830         output = 'default:book',
831         recipe = {
832                 {'default:paper'},
833                 {'default:paper'},
834                 {'default:paper'},
835         }
836 })
837
838 minetest.register_craft({
839         output = 'default:bookshelf',
840         recipe = {
841                 {'default:wood', 'default:wood', 'default:wood'},
842                 {'default:book', 'default:book', 'default:book'},
843                 {'default:wood', 'default:wood', 'default:wood'},
844         }
845 })
846
847 minetest.register_craft({
848         output = 'default:ladder',
849         recipe = {
850                 {'default:stick', '', 'default:stick'},
851                 {'default:stick', 'default:stick', 'default:stick'},
852                 {'default:stick', '', 'default:stick'},
853         }
854 })
855
856 --
857 -- Crafting (tool repair)
858 --
859 minetest.register_craft({
860         type = "toolrepair",
861         additional_wear = -0.02,
862 })
863
864 --
865 -- Cooking recipes
866 --
867
868 minetest.register_craft({
869         type = "cooking",
870         output = "default:glass",
871         recipe = "default:sand",
872 })
873
874 minetest.register_craft({
875         type = "cooking",
876         output = "default:coal_lump",
877         recipe = "default:tree",
878 })
879
880 minetest.register_craft({
881         type = "cooking",
882         output = "default:coal_lump",
883         recipe = "default:jungletree",
884 })
885
886 minetest.register_craft({
887         type = "cooking",
888         output = "default:stone",
889         recipe = "default:cobble",
890 })
891
892 minetest.register_craft({
893         type = "cooking",
894         output = "default:steel_ingot",
895         recipe = "default:iron_lump",
896 })
897
898 minetest.register_craft({
899         type = "cooking",
900         output = "default:clay_brick",
901         recipe = "default:clay_lump",
902 })
903
904 --
905 -- Fuels
906 --
907
908 minetest.register_craft({
909         type = "fuel",
910         recipe = "default:tree",
911         burntime = 30,
912 })
913
914 minetest.register_craft({
915         type = "fuel",
916         recipe = "default:jungletree",
917         burntime = 30,
918 })
919
920 minetest.register_craft({
921         type = "fuel",
922         recipe = "default:junglegrass",
923         burntime = 2,
924 })
925
926 minetest.register_craft({
927         type = "fuel",
928         recipe = "default:leaves",
929         burntime = 1,
930 })
931
932 minetest.register_craft({
933         type = "fuel",
934         recipe = "default:cactus",
935         burntime = 15,
936 })
937
938 minetest.register_craft({
939         type = "fuel",
940         recipe = "default:papyrus",
941         burntime = 1,
942 })
943
944 minetest.register_craft({
945         type = "fuel",
946         recipe = "default:bookshelf",
947         burntime = 30,
948 })
949
950 minetest.register_craft({
951         type = "fuel",
952         recipe = "default:fence_wood",
953         burntime = 15,
954 })
955
956 minetest.register_craft({
957         type = "fuel",
958         recipe = "default:ladder",
959         burntime = 5,
960 })
961
962 minetest.register_craft({
963         type = "fuel",
964         recipe = "default:wood",
965         burntime = 7,
966 })
967
968 minetest.register_craft({
969         type = "fuel",
970         recipe = "default:mese",
971         burntime = 30,
972 })
973
974 minetest.register_craft({
975         type = "fuel",
976         recipe = "default:lava_source",
977         burntime = 60,
978 })
979
980 minetest.register_craft({
981         type = "fuel",
982         recipe = "default:torch",
983         burntime = 4,
984 })
985
986 minetest.register_craft({
987         type = "fuel",
988         recipe = "default:sign_wall",
989         burntime = 10,
990 })
991
992 minetest.register_craft({
993         type = "fuel",
994         recipe = "default:chest",
995         burntime = 30,
996 })
997
998 minetest.register_craft({
999         type = "fuel",
1000         recipe = "default:chest_locked",
1001         burntime = 30,
1002 })
1003
1004 minetest.register_craft({
1005         type = "fuel",
1006         recipe = "default:nyancat",
1007         burntime = 1,
1008 })
1009
1010 minetest.register_craft({
1011         type = "fuel",
1012         recipe = "default:nyancat_rainbow",
1013         burntime = 1,
1014 })
1015
1016 minetest.register_craft({
1017         type = "fuel",
1018         recipe = "default:sapling",
1019         burntime = 10,
1020 })
1021
1022 minetest.register_craft({
1023         type = "fuel",
1024         recipe = "default:apple",
1025         burntime = 3,
1026 })
1027
1028 minetest.register_craft({
1029         type = "fuel",
1030         recipe = "default:coal_lump",
1031         burntime = 40,
1032 })
1033
1034 --
1035 -- Node definitions
1036 --
1037
1038 minetest.register_node("default:stone", {
1039         description = "Stone",
1040         tile_images = {"default_stone.png"},
1041         is_ground_content = true,
1042         groups = {cracky=3},
1043         drop = 'default:cobble',
1044         legacy_mineral = true,
1045 })
1046
1047 minetest.register_node("default:stone_with_coal", {
1048         description = "Stone with coal",
1049         tile_images = {"default_stone.png^default_mineral_coal.png"},
1050         is_ground_content = true,
1051         groups = {cracky=3},
1052         drop = 'default:coal_lump',
1053 })
1054
1055 minetest.register_node("default:stone_with_iron", {
1056         description = "Stone with iron",
1057         tile_images = {"default_stone.png^default_mineral_iron.png"},
1058         is_ground_content = true,
1059         groups = {cracky=3},
1060         drop = 'default:iron_lump',
1061 })
1062
1063 minetest.register_node("default:dirt_with_grass", {
1064         description = "Dirt with grass",
1065         tile_images = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
1066         is_ground_content = true,
1067         groups = {crumbly=3},
1068         drop = 'default:dirt',
1069 })
1070
1071 minetest.register_node("default:dirt_with_grass_footsteps", {
1072         description = "Dirt with grass and footsteps",
1073         tile_images = {"default_grass_footsteps.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
1074         is_ground_content = true,
1075         groups = {crumbly=3},
1076         drop = 'default:dirt',
1077 })
1078
1079 minetest.register_node("default:dirt", {
1080         description = "Dirt",
1081         tile_images = {"default_dirt.png"},
1082         is_ground_content = true,
1083         groups = {crumbly=3},
1084 })
1085
1086 minetest.register_node("default:sand", {
1087         description = "Sand",
1088         tile_images = {"default_sand.png"},
1089         is_ground_content = true,
1090         groups = {crumbly=3},
1091 })
1092
1093 minetest.register_node("default:gravel", {
1094         description = "Gravel",
1095         tile_images = {"default_gravel.png"},
1096         is_ground_content = true,
1097         groups = {crumbly=2},
1098 })
1099
1100 minetest.register_node("default:sandstone", {
1101         description = "Sandstone",
1102         tile_images = {"default_sandstone.png"},
1103         is_ground_content = true,
1104         groups = {crumbly=2,cracky=2},
1105         drop = 'default:sand',
1106 })
1107
1108 minetest.register_node("default:clay", {
1109         description = "Clay",
1110         tile_images = {"default_clay.png"},
1111         is_ground_content = true,
1112         groups = {crumbly=3},
1113         drop = 'default:clay_lump 4',
1114 })
1115
1116 minetest.register_node("default:brick", {
1117         description = "Brick",
1118         tile_images = {"default_brick.png"},
1119         is_ground_content = true,
1120         groups = {cracky=3},
1121         drop = 'default:clay_brick 4',
1122 })
1123
1124 minetest.register_node("default:tree", {
1125         description = "Tree",
1126         tile_images = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
1127         is_ground_content = true,
1128         groups = {snappy=2,choppy=2},
1129 })
1130
1131 minetest.register_node("default:jungletree", {
1132         description = "Jungle Tree",
1133         tile_images = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
1134         is_ground_content = true,
1135         groups = {snappy=2,choppy=2},
1136 })
1137
1138 minetest.register_node("default:junglegrass", {
1139         description = "Jungle Grass",
1140         drawtype = "plantlike",
1141         visual_scale = 1.3,
1142         tile_images = {"default_junglegrass.png"},
1143         inventory_image = "default_junglegrass.png",
1144         wield_image = "default_junglegrass.png",
1145         paramtype = "light",
1146         walkable = false,
1147         groups = {snappy=3},
1148 })
1149
1150 minetest.register_node("default:leaves", {
1151         description = "Leaves",
1152         drawtype = "allfaces_optional",
1153         visual_scale = 1.3,
1154         tile_images = {"default_leaves.png"},
1155         paramtype = "light",
1156         groups = {snappy=3},
1157         drop = {
1158                 max_items = 1,
1159                 items = {
1160                         {
1161                                 -- player will get sapling with 1/20 chance
1162                                 items = {'default:sapling'},
1163                                 rarity = 20,
1164                         },
1165                         {
1166                                 -- player will get leaves only if he get no saplings,
1167                                 -- this is because max_items is 1
1168                                 items = {'default:leaves'},
1169                         }
1170                 }
1171         },
1172 })
1173
1174 minetest.register_node("default:cactus", {
1175         description = "Cactus",
1176         tile_images = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
1177         is_ground_content = true,
1178         groups = {snappy=2,choppy=3},
1179 })
1180
1181 minetest.register_node("default:papyrus", {
1182         description = "Papyrus",
1183         drawtype = "plantlike",
1184         tile_images = {"default_papyrus.png"},
1185         inventory_image = "default_papyrus.png",
1186         wield_image = "default_papyrus.png",
1187         paramtype = "light",
1188         is_ground_content = true,
1189         walkable = false,
1190         groups = {snappy=3},
1191 })
1192
1193 minetest.register_node("default:bookshelf", {
1194         description = "Bookshelf",
1195         tile_images = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
1196         is_ground_content = true,
1197         groups = {snappy=2,choppy=3},
1198 })
1199
1200 minetest.register_node("default:glass", {
1201         description = "Glass",
1202         drawtype = "glasslike",
1203         tile_images = {"default_glass.png"},
1204         inventory_image = minetest.inventorycube("default_glass.png"),
1205         paramtype = "light",
1206         sunlight_propagates = true,
1207         is_ground_content = true,
1208         groups = {snappy=2,cracky=3},
1209 })
1210
1211 minetest.register_node("default:fence_wood", {
1212         description = "Wooden Fence",
1213         drawtype = "fencelike",
1214         tile_images = {"default_wood.png"},
1215         inventory_image = "default_fence.png",
1216         wield_image = "default_fence.png",
1217         paramtype = "light",
1218         is_ground_content = true,
1219         selection_box = {
1220                 type = "fixed",
1221                 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
1222         },
1223         groups = {snappy=2,choppy=2},
1224 })
1225
1226 minetest.register_node("default:rail", {
1227         description = "Rail",
1228         drawtype = "raillike",
1229         tile_images = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
1230         inventory_image = "default_rail.png",
1231         wield_image = "default_rail.png",
1232         paramtype = "light",
1233         is_ground_content = true,
1234         walkable = false,
1235         selection_box = {
1236                 type = "fixed",
1237                 --fixed = <default>
1238         },
1239         groups = {bendy=2,snappy=1},
1240 })
1241
1242 minetest.register_node("default:ladder", {
1243         description = "Ladder",
1244         drawtype = "signlike",
1245         tile_images = {"default_ladder.png"},
1246         inventory_image = "default_ladder.png",
1247         wield_image = "default_ladder.png",
1248         paramtype = "light",
1249         paramtype2 = "wallmounted",
1250         is_ground_content = true,
1251         walkable = false,
1252         climbable = true,
1253         selection_box = {
1254                 type = "wallmounted",
1255                 --wall_top = = <default>
1256                 --wall_bottom = = <default>
1257                 --wall_side = = <default>
1258         },
1259         groups = {snappy=2,choppy=2},
1260         legacy_wallmounted = true,
1261 })
1262
1263 minetest.register_node("default:wood", {
1264         description = "Wood",
1265         tile_images = {"default_wood.png"},
1266         is_ground_content = true,
1267         groups = {snappy=2,choppy=2},
1268 })
1269
1270 minetest.register_node("default:mese", {
1271         description = "Mese",
1272         tile_images = {"default_mese.png"},
1273         is_ground_content = true,
1274         groups = {cracky=1},
1275 })
1276
1277 minetest.register_node("default:cloud", {
1278         description = "Cloud",
1279         tile_images = {"default_cloud.png"},
1280         is_ground_content = true,
1281 })
1282
1283 minetest.register_node("default:water_flowing", {
1284         description = "Water (flowing)",
1285         inventory_image = minetest.inventorycube("default_water.png"),
1286         drawtype = "flowingliquid",
1287         tile_images = {"default_water.png"},
1288         alpha = WATER_ALPHA,
1289         paramtype = "light",
1290         walkable = false,
1291         pointable = false,
1292         diggable = false,
1293         buildable_to = true,
1294         liquidtype = "flowing",
1295         liquid_alternative_flowing = "default:water_flowing",
1296         liquid_alternative_source = "default:water_source",
1297         liquid_viscosity = WATER_VISC,
1298         post_effect_color = {a=64, r=100, g=100, b=200},
1299         special_materials = {
1300                 {image="default_water.png", backface_culling=false},
1301                 {image="default_water.png", backface_culling=true},
1302         },
1303         groups = {water=3, liquid=3},
1304 })
1305
1306 minetest.register_node("default:water_source", {
1307         description = "Water",
1308         inventory_image = minetest.inventorycube("default_water.png"),
1309         drawtype = "liquid",
1310         tile_images = {"default_water.png"},
1311         alpha = WATER_ALPHA,
1312         paramtype = "light",
1313         walkable = false,
1314         pointable = false,
1315         diggable = false,
1316         buildable_to = true,
1317         liquidtype = "source",
1318         liquid_alternative_flowing = "default:water_flowing",
1319         liquid_alternative_source = "default:water_source",
1320         liquid_viscosity = WATER_VISC,
1321         post_effect_color = {a=64, r=100, g=100, b=200},
1322         special_materials = {
1323                 -- New-style water source material (mostly unused)
1324                 {image="default_water.png", backface_culling=false},
1325         },
1326         groups = {water=3, liquid=3},
1327 })
1328
1329 minetest.register_node("default:lava_flowing", {
1330         description = "Lava (flowing)",
1331         inventory_image = minetest.inventorycube("default_lava.png"),
1332         drawtype = "flowingliquid",
1333         tile_images = {"default_lava.png"},
1334         paramtype = "light",
1335         light_source = LIGHT_MAX - 1,
1336         walkable = false,
1337         pointable = false,
1338         diggable = false,
1339         buildable_to = true,
1340         liquidtype = "flowing",
1341         liquid_alternative_flowing = "default:lava_flowing",
1342         liquid_alternative_source = "default:lava_source",
1343         liquid_viscosity = LAVA_VISC,
1344         damage_per_second = 4*2,
1345         post_effect_color = {a=192, r=255, g=64, b=0},
1346         special_materials = {
1347                 {image="default_lava.png", backface_culling=false},
1348                 {image="default_lava.png", backface_culling=true},
1349         },
1350         groups = {lava=3, liquid=2, hot=3},
1351 })
1352
1353 minetest.register_node("default:lava_source", {
1354         description = "Lava",
1355         inventory_image = minetest.inventorycube("default_lava.png"),
1356         drawtype = "liquid",
1357         tile_images = {"default_lava.png"},
1358         paramtype = "light",
1359         light_source = LIGHT_MAX - 1,
1360         walkable = false,
1361         pointable = false,
1362         diggable = false,
1363         buildable_to = true,
1364         liquidtype = "source",
1365         liquid_alternative_flowing = "default:lava_flowing",
1366         liquid_alternative_source = "default:lava_source",
1367         liquid_viscosity = LAVA_VISC,
1368         damage_per_second = 4*2,
1369         post_effect_color = {a=192, r=255, g=64, b=0},
1370         special_materials = {
1371                 -- New-style lava source material (mostly unused)
1372                 {image="default_lava.png", backface_culling=false},
1373         },
1374         groups = {lava=3, liquid=2, hot=3},
1375 })
1376
1377 minetest.register_node("default:torch", {
1378         description = "Torch",
1379         drawtype = "torchlike",
1380         tile_images = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
1381         inventory_image = "default_torch_on_floor.png",
1382         wield_image = "default_torch_on_floor.png",
1383         paramtype = "light",
1384         paramtype2 = "wallmounted",
1385         sunlight_propagates = true,
1386         walkable = false,
1387         light_source = LIGHT_MAX-1,
1388         selection_box = {
1389                 type = "wallmounted",
1390                 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
1391                 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
1392                 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
1393         },
1394         groups = {dig_immediate=1},
1395         legacy_wallmounted = true,
1396 })
1397
1398 minetest.register_node("default:sign_wall", {
1399         description = "Sign",
1400         drawtype = "signlike",
1401         tile_images = {"default_sign_wall.png"},
1402         inventory_image = "default_sign_wall.png",
1403         wield_image = "default_sign_wall.png",
1404         paramtype = "light",
1405         paramtype2 = "wallmounted",
1406         sunlight_propagates = true,
1407         walkable = false,
1408         metadata_name = "sign",
1409         selection_box = {
1410                 type = "wallmounted",
1411                 --wall_top = <default>
1412                 --wall_bottom = <default>
1413                 --wall_side = <default>
1414         },
1415         groups = {dig_immediate=2},
1416         legacy_wallmounted = true,
1417 })
1418
1419 minetest.register_node("default:chest", {
1420         description = "Chest",
1421         tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
1422                 "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
1423         paramtype2 = "facedir",
1424         metadata_name = "chest",
1425         groups = {snappy=2,choppy=2},
1426         legacy_facedir_simple = true,
1427 })
1428
1429 minetest.register_node("default:chest_locked", {
1430         description = "Locked Chest",
1431         tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
1432                 "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
1433         paramtype2 = "facedir",
1434         metadata_name = "locked_chest",
1435         groups = {snappy=2,choppy=2},
1436         legacy_facedir_simple = true,
1437 })
1438
1439 minetest.register_node("default:furnace", {
1440         description = "Furnace",
1441         tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
1442                 "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
1443         paramtype2 = "facedir",
1444         metadata_name = "furnace",
1445         groups = {cracky=2},
1446         legacy_facedir_simple = true,
1447 })
1448
1449 minetest.register_node("default:cobble", {
1450         description = "Cobble",
1451         tile_images = {"default_cobble.png"},
1452         is_ground_content = true,
1453         groups = {cracky=3},
1454 })
1455
1456 minetest.register_node("default:mossycobble", {
1457         description = "Mossy Cobble",
1458         tile_images = {"default_mossycobble.png"},
1459         is_ground_content = true,
1460         groups = {cracky=3},
1461 })
1462
1463 minetest.register_node("default:steelblock", {
1464         description = "Steel Block",
1465         tile_images = {"default_steel_block.png"},
1466         is_ground_content = true,
1467         groups = {snappy=1,bendy=2},
1468 })
1469
1470 minetest.register_node("default:nyancat", {
1471         description = "Nyancat",
1472         tile_images = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
1473                 "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
1474         inventory_image = "default_nc_front.png",
1475         paramtype2 = "facedir",
1476         groups = {cracky=2},
1477         legacy_facedir_simple = true,
1478 })
1479
1480 minetest.register_node("default:nyancat_rainbow", {
1481         description = "Nyancat Rainbow",
1482         tile_images = {"default_nc_rb.png"},
1483         inventory_image = "default_nc_rb.png",
1484         groups = {cracky=2},
1485 })
1486
1487 minetest.register_node("default:sapling", {
1488         description = "Sapling",
1489         drawtype = "plantlike",
1490         visual_scale = 1.0,
1491         tile_images = {"default_sapling.png"},
1492         inventory_image = "default_sapling.png",
1493         wield_image = "default_sapling.png",
1494         paramtype = "light",
1495         walkable = false,
1496         groups = {dig_immediate=1},
1497 })
1498
1499 minetest.register_node("default:apple", {
1500         description = "Apple",
1501         drawtype = "plantlike",
1502         visual_scale = 1.0,
1503         tile_images = {"default_apple.png"},
1504         inventory_image = "default_apple.png",
1505         paramtype = "light",
1506         sunlight_propagates = true,
1507         walkable = false,
1508         groups = {dig_immediate=1},
1509         on_use = minetest.item_eat(4),
1510 })
1511
1512 --
1513 -- Crafting items
1514 --
1515
1516 minetest.register_craftitem("default:stick", {
1517         description = "Stick",
1518         inventory_image = "default_stick.png",
1519 })
1520
1521 minetest.register_craftitem("default:paper", {
1522         description = "Paper",
1523         inventory_image = "default_paper.png",
1524 })
1525
1526 minetest.register_craftitem("default:book", {
1527         description = "Book",
1528         inventory_image = "default_book.png",
1529 })
1530
1531 minetest.register_craftitem("default:coal_lump", {
1532         description = "Lump of coal",
1533         inventory_image = "default_coal_lump.png",
1534 })
1535
1536 minetest.register_craftitem("default:iron_lump", {
1537         description = "Lump of iron",
1538         inventory_image = "default_iron_lump.png",
1539 })
1540
1541 minetest.register_craftitem("default:clay_lump", {
1542         description = "Lump of clay",
1543         inventory_image = "default_clay_lump.png",
1544 })
1545
1546 minetest.register_craftitem("default:steel_ingot", {
1547         description = "Steel ingot",
1548         inventory_image = "default_steel_ingot.png",
1549 })
1550
1551 minetest.register_craftitem("default:clay_brick", {
1552         description = "Clay brick",
1553         inventory_image = "default_steel_ingot.png",
1554         inventory_image = "default_clay_brick.png",
1555 })
1556
1557 minetest.register_craftitem("default:scorched_stuff", {
1558         description = "Scorched stuff",
1559         inventory_image = "default_scorched_stuff.png",
1560 })
1561
1562 --
1563 -- Creative inventory
1564 --
1565
1566 minetest.add_to_creative_inventory('default:pick_mese')
1567 minetest.add_to_creative_inventory('default:pick_steel')
1568 minetest.add_to_creative_inventory('default:axe_steel')
1569 minetest.add_to_creative_inventory('default:shovel_steel')
1570
1571 minetest.add_to_creative_inventory('default:torch')
1572 minetest.add_to_creative_inventory('default:cobble')
1573 minetest.add_to_creative_inventory('default:dirt')
1574 minetest.add_to_creative_inventory('default:stone')
1575 minetest.add_to_creative_inventory('default:sand')
1576 minetest.add_to_creative_inventory('default:sandstone')
1577 minetest.add_to_creative_inventory('default:clay')
1578 minetest.add_to_creative_inventory('default:brick')
1579 minetest.add_to_creative_inventory('default:tree')
1580 minetest.add_to_creative_inventory('default:wood')
1581 minetest.add_to_creative_inventory('default:leaves')
1582 minetest.add_to_creative_inventory('default:cactus')
1583 minetest.add_to_creative_inventory('default:papyrus')
1584 minetest.add_to_creative_inventory('default:bookshelf')
1585 minetest.add_to_creative_inventory('default:glass')
1586 minetest.add_to_creative_inventory('default:fence_wood')
1587 minetest.add_to_creative_inventory('default:rail')
1588 minetest.add_to_creative_inventory('default:mese')
1589 minetest.add_to_creative_inventory('default:chest')
1590 minetest.add_to_creative_inventory('default:furnace')
1591 minetest.add_to_creative_inventory('default:sign_wall')
1592 minetest.add_to_creative_inventory('default:water_source')
1593 minetest.add_to_creative_inventory('default:lava_source')
1594 minetest.add_to_creative_inventory('default:ladder')
1595
1596 --
1597 -- Some common functions
1598 --
1599
1600 default.falling_node_names = {}
1601
1602 function nodeupdate_single(p)
1603         n = minetest.env:get_node(p)
1604         if default.falling_node_names[n.name] ~= nil then
1605                 p_bottom = {x=p.x, y=p.y-1, z=p.z}
1606                 n_bottom = minetest.env:get_node(p_bottom)
1607                 if n_bottom.name == "air" then
1608                         minetest.env:remove_node(p)
1609                         minetest.env:add_entity(p, "default:falling_"..n.name)
1610                         nodeupdate(p)
1611                 end
1612         end
1613 end
1614
1615 function nodeupdate(p)
1616         for x = -1,1 do
1617         for y = -1,1 do
1618         for z = -1,1 do
1619                 p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
1620                 nodeupdate_single(p2)
1621         end
1622         end
1623         end
1624 end
1625
1626 --
1627 -- Falling stuff
1628 --
1629
1630 function default.register_falling_node(nodename, texture)
1631         default.falling_node_names[nodename] = true
1632         -- Override naming conventions for stuff like :default:falling_default:sand
1633         minetest.register_entity(":default:falling_"..nodename, {
1634                 -- Static definition
1635                 physical = true,
1636                 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1637                 visual = "cube",
1638                 textures = {texture,texture,texture,texture,texture,texture},
1639                 -- State
1640                 -- Methods
1641                 on_step = function(self, dtime)
1642                         -- Set gravity
1643                         self.object:setacceleration({x=0, y=-10, z=0})
1644                         -- Turn to actual sand when collides to ground or just move
1645                         local pos = self.object:getpos()
1646                         local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
1647                         local bcn = minetest.env:get_node(bcp)
1648                         if bcn.name ~= "air" then
1649                                 -- Turn to a sand node
1650                                 local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
1651                                 minetest.env:add_node(np, {name=nodename})
1652                                 self.object:remove()
1653                         else
1654                                 -- Do nothing
1655                         end
1656                 end
1657         })
1658 end
1659
1660 default.register_falling_node("default:sand", "default_sand.png")
1661 default.register_falling_node("default:gravel", "default_gravel.png")
1662
1663 --
1664 -- Global callbacks
1665 --
1666
1667 -- Global environment step function
1668 function on_step(dtime)
1669         -- print("on_step")
1670 end
1671 minetest.register_globalstep(on_step)
1672
1673 function on_placenode(p, node)
1674         --print("on_placenode")
1675         nodeupdate(p)
1676 end
1677 minetest.register_on_placenode(on_placenode)
1678
1679 function on_dignode(p, node)
1680         --print("on_dignode")
1681         nodeupdate(p)
1682 end
1683 minetest.register_on_dignode(on_dignode)
1684
1685 function on_punchnode(p, node)
1686 end
1687 minetest.register_on_punchnode(on_punchnode)
1688
1689 local function handle_give_command(cmd, giver, receiver, stackstring)
1690         if not minetest.get_player_privs(giver)["give"] then
1691                 minetest.chat_send_player(giver, "error: you don't have permission to give")
1692                 return
1693         end
1694         minetest.debug("DEBUG: "..cmd..' invoked, stackstring="'..stackstring..'"')
1695         minetest.log(cmd..' invoked, stackstring="'..stackstring..'"')
1696         local itemstack = ItemStack(stackstring)
1697         if itemstack:is_empty() then
1698                 minetest.chat_send_player(giver, 'error: cannot give an empty item')
1699                 return
1700         elseif not itemstack:is_known() then
1701                 minetest.chat_send_player(giver, 'error: cannot give an unknown item')
1702                 return
1703         end
1704         local receiverref = minetest.env:get_player_by_name(receiver)
1705         if receiverref == nil then
1706                 minetest.chat_send_player(giver, receiver..' is not a known player')
1707                 return
1708         end
1709         local leftover = receiverref:get_inventory():add_item("main", itemstack)
1710         if leftover:is_empty() then
1711                 partiality = ""
1712         elseif leftover:get_count() == itemstack:get_count() then
1713                 partiality = "could not be "
1714         else
1715                 partiality = "partially "
1716         end
1717         -- The actual item stack string may be different from what the "giver"
1718         -- entered (e.g. big numbers are always interpreted as 2^16-1).
1719         stackstring = itemstack:to_string()
1720         if giver == receiver then
1721                 minetest.chat_send_player(giver, '"'..stackstring
1722                         ..'" '..partiality..'added to inventory.');
1723         else
1724                 minetest.chat_send_player(giver, '"'..stackstring
1725                         ..'" '..partiality..'added to '..receiver..'\'s inventory.');
1726                 minetest.chat_send_player(receiver, '"'..stackstring
1727                         ..'" '..partiality..'added to inventory.');
1728         end
1729 end
1730
1731 minetest.register_on_chat_message(function(name, message)
1732         --print("default on_chat_message: name="..dump(name).." message="..dump(message))
1733         local cmd = "/giveme"
1734         if message:sub(0, #cmd) == cmd then
1735                 local stackstring = string.match(message, cmd.." (.*)")
1736                 if stackstring == nil then
1737                         minetest.chat_send_player(name, 'usage: '..cmd..' stackstring')
1738                         return true -- Handled chat message
1739                 end
1740                 handle_give_command(cmd, name, name, stackstring)
1741                 return true
1742         end
1743         local cmd = "/give"
1744         if message:sub(0, #cmd) == cmd then
1745                 local receiver, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)")
1746                 if receiver == nil or stackstring == nil then
1747                         minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring')
1748                         return true -- Handled chat message
1749                 end
1750                 handle_give_command(cmd, name, receiver, stackstring)
1751                 return true
1752         end
1753         local cmd = "/spawnentity"
1754         if message:sub(0, #cmd) == cmd then
1755                 if not minetest.get_player_privs(name)["give"] then
1756                         minetest.chat_send_player(name, "you don't have permission to spawn (give)")
1757                         return true -- Handled chat message
1758                 end
1759                 if not minetest.get_player_privs(name)["interact"] then
1760                         minetest.chat_send_player(name, "you don't have permission to interact")
1761                         return true -- Handled chat message
1762                 end
1763                 local entityname = string.match(message, cmd.." (.*)")
1764                 if entityname == nil then
1765                         minetest.chat_send_player(name, 'usage: '..cmd..' entityname')
1766                         return true -- Handled chat message
1767                 end
1768                 print(cmd..' invoked, entityname="'..entityname..'"')
1769                 local player = minetest.env:get_player_by_name(name)
1770                 if player == nil then
1771                         print("Unable to spawn entity, player is nil")
1772                         return true -- Handled chat message
1773                 end
1774                 local p = player:getpos()
1775                 p.y = p.y + 1
1776                 minetest.env:add_entity(p, entityname)
1777                 minetest.chat_send_player(name, '"'..entityname
1778                                 ..'" spawned.');
1779                 return true -- Handled chat message
1780         end
1781         local cmd = "/pulverize"
1782         if message:sub(0, #cmd) == cmd then
1783                 local player = minetest.env:get_player_by_name(name)
1784                 if player == nil then
1785                         print("Unable to pulverize, player is nil")
1786                         return true -- Handled chat message
1787                 end
1788                 if player:get_wielded_item():is_empty() then
1789                         minetest.chat_send_player(name, 'Unable to pulverize, no item in hand.')
1790                 else
1791                         player:set_wielded_item(nil)
1792                         minetest.chat_send_player(name, 'An item was pulverized.')
1793                 end
1794                 return true
1795         end
1796 end)
1797
1798 --
1799 -- Done, print some random stuff
1800 --
1801
1802 --print("minetest.registered_entities:")
1803 --dump2(minetest.registered_entities)
1804
1805 -- END