From: Perttu Ahola Date: Sat, 12 Nov 2011 13:22:09 +0000 (+0200) Subject: Scripting WIP X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=ddaff2d653efb1bebe04b9d316fe1bde26671b82;p=zefram%2Fminetest%2Fminetest_engine.git Scripting WIP --- diff --git a/data/scripts/default.lua b/data/scripts/default.lua index 46d9fbf6..3ec6f843 100644 --- a/data/scripts/default.lua +++ b/data/scripts/default.lua @@ -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, +}) +--]=] +