From ddaff2d653efb1bebe04b9d316fe1bde26671b82 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 12 Nov 2011 15:22:09 +0200 Subject: [PATCH] Scripting WIP --- data/scripts/default.lua | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/data/scripts/default.lua b/data/scripts/default.lua index 46d9fbf6c..3ec6f8433 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, +}) +--]=] + -- 2.25.1