Scripting WIP
authorPerttu Ahola <celeron55@gmail.com>
Sat, 12 Nov 2011 13:22:09 +0000 (15:22 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 17:13:40 +0000 (19:13 +0200)
data/scripts/default.lua

index 46d9fbf6cb30f5a6e9573bcfeaed7f8b6b7f575a..3ec6f84332e6bca72cf10f4adc0565eeff069cbf 100644 (file)
@@ -192,3 +192,48 @@ minetest.register_entity("TNT", TNT)
 print("minetest.registered_entities:")
 dump2(minetest.registered_entities)
 
+--[=[
+
+register_block(0, {
+       textures = "stone.png",
+       makefacetype = 0,
+       get_dig_duration = function(env, pos, digger)
+               -- Check stuff like digger.current_tool
+               return 1.5
+       end,
+       on_dig = function(env, pos, digger)
+               env:remove_node(pos)
+               digger.inventory.put("MaterialItem2 0");
+       end,
+})
+
+register_block(1, {
+       textures = {"grass.png","mud.png","mud_grass_side.png","mud_grass_side.png","mud_grass_side.png","mud_grass_side.png"},
+       makefacetype = 0,
+       get_dig_duration = function(env, pos, digger)
+               -- Check stuff like digger.current_tool
+               return 0.5
+       end,
+       on_dig = function(env, pos, digger)
+               env:remove_node(pos)
+               digger.inventory.put("MaterialItem2 1");
+       end,
+})
+
+-- Consider the "miscellaneous block namespace" to be 0xc00...0xfff = 3072...4095
+register_block(3072, {
+       textures = {"tnt_top.png","tnt_bottom.png","tnt_side.png","tnt_side.png","tnt_side.png","tnt_side.png"},
+       makefacetype = 0,
+       get_dig_duration = function(env, pos, digger)
+               -- Cannot be dug
+               return nil
+       end,
+       -- on_dig = function(env, pos, digger) end, -- Not implemented
+       on_hit = function(env, pos, hitter)
+               -- Replace with TNT object, which will explode after timer, follow gravity, blink and stuff
+               env:add_object("tnt", pos)
+               env:remove_node(pos)
+       end,
+})
+--]=]
+