spleef game

master
rnd 2015-05-14 17:26:30 +02:00
parent c24340f49c
commit ba71dd4fcb
2 changed files with 39 additions and 0 deletions

View File

@ -1,6 +1,7 @@
-- rnd: collection of puzzle games for minetest
dofile(minetest.get_modpath("games").."/maze.lua")
dofile(minetest.get_modpath("games").."/sokoban.lua")
dofile(minetest.get_modpath("games").."/spleef.lua")
dofile(minetest.get_modpath("games").."/checkers.lua")
dofile(minetest.get_modpath("games").."/life.lua")
print("[games] loaded")

38
spleef.lua Normal file
View File

@ -0,0 +1,38 @@
-- SPLEEF GAME
local spleef_size = 15;
minetest.register_node("games:spleef", {
description = "spleef game",
tiles = {"default_copper_block.png"},
groups = {oddly_breakable_by_hand=1},
is_ground_content = false,
paramtype = "light",
light_source = 10,
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos, node, player)
local name = player:get_player_name(); if name==nil then return end
for i = 1, spleef_size do -- init game area
for j = 1, spleef_size do
minetest.set_node({x=pos.x+i+1,y=pos.y,z=pos.z+j+1},{name = "games:spleefblock"})
end
end
end
}
)
minetest.register_node("games:spleefblock", {
description = "spleef game block",
tiles = {"default_copper_block.png"},
groups = {dig_immediate=3},
is_ground_content = false,
paramtype = "light",
light_source = 10,
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer, itemstack, pointed_thing)
local inv = placer:get_inventory();
inv:remove_item("main", ItemStack("games:spleefblock 90"))
minetest.set_node(pos,{name = "air"})
itemstack:clear();
end
}
)