Version 0.4

master
BlockMen 2013-10-01 14:37:40 +02:00
parent f64171b2a8
commit b0d4fdd1d9
5 changed files with 108 additions and 18 deletions

View File

@ -1,6 +1,6 @@
Minetest mod "Pyramids"
=======================
version: 0.3 Beta
version: 0.4 Beta
License of source code and textures: WTFPL
------------------------------------------

View File

@ -86,20 +86,33 @@ local function make(pos)
for iz=iy,22-iy,1 do
if iy <1 then underground({x=pos.x+ix,y=pos.y,z=pos.z+iz}) end
minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name="default:sandstonebrick"})
for yy=1,10-iy,1 do
local n = minetest.get_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
if n and n.name and n.name == "default:desert_stone" then minetest.set_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz},{name="default:desert_sand"}) end
end
end
end
end
pyramids.make_room(pos)
minetest.after(2, pyramids.make_traps, pos)
add_spawner({x=pos.x+11,y=pos.y+2, z=pos.z+17})
make_entrance(pos)
make_entrance({x=pos.x,y=pos.y, z=pos.z})
end
local perl1 = {SEED1 = 9130, OCTA1 = 3, PERS1 = 0.5, SCAL1 = 250} -- Values should match minetest mapgen V6 desert noise.
local function hlp_fnct(pos, name)
local n = minetest.get_node_or_nil(pos)
if n and n.name and n.name == name then
return true
else
return false
end
end
local function ground(pos, old)
local p2 = pos
while minetest.get_node_or_nil(p2).name == "air" do
while hlp_fnct(p2, "air") do
p2.y = p2.y -1
end
if p2.y < old.y then
@ -134,23 +147,23 @@ minetest.register_on_generated(function(minp, maxp, seed)
local opos1 = {x=p2.x+22,y=p2.y-1,z=p2.z+22}
local opos2 = {x=p2.x+22,y=p2.y-1,z=p2.z}
local opos3 = {x=p2.x,y=p2.y-1,z=p2.z+22}
local opos1_n = minetest.get_node(opos1).name
local opos2_n = minetest.get_node(opos2).name
local opos3_n = minetest.get_node(opos3).name
if opos1_n == "air" then
local opos1_n = minetest.get_node_or_nil(opos1)
local opos2_n = minetest.get_node_or_nil(opos2)
local opos3_n = minetest.get_node_or_nil(opos3)
if opos1_n and opos1_n.name and opos1_n.name == "air" then
p2 = ground(opos1, p2)
end
if opos2_n == "air" then
if opos2_n and opos2_n.name and opos2_n.name == "air" then
p2 = ground(opos2, p2)
end
if opos3_n == "air" then
if opos3_n and opos3_n.name and opos3_n.name == "air" then
p2 = ground(opos3, p2)
end
p2.y = p2.y - 4
p2.y = p2.y - 3
if p2.y < 0 then p2.y = 0 end
if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil or minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or minetest.find_node_near(p2, 52, {"default:sandstonebrick"}) ~= nil then return end
if math.random(0,10) > 7 then return end
minetest.after(0.3,make,p2)
minetest.after(0.8,make,p2)
end
end)

View File

@ -71,7 +71,7 @@ function npc_update_visuals_def(self)
self.object:set_properties(prop)
end
NPC_ENTITY_DEF = {
MUMMY_DEF = {
physical = true,
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
visual = "mesh",
@ -118,13 +118,19 @@ end
spawner_DEF.on_step = function(self, dtime)
self.timer = self.timer + 0.01
local n = minetest.get_node_or_nil(self.object:getpos())
if self.timer > 1 then
if n and n.name and n.name ~= "pyramids:spawner_mummy" then
self.object:remove()
end
end
end
spawner_DEF.on_punch = function(self, hitter)
end
NPC_ENTITY_DEF.on_activate = function(self)
MUMMY_DEF.on_activate = function(self)
npc_update_visuals_def(self)
self.anim = get_animations_def()
self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, animation_speed, animation_blend)
@ -135,7 +141,7 @@ NPC_ENTITY_DEF.on_activate = function(self)
self.object:set_armor_groups({fleshy=130})
end
NPC_ENTITY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
--attack as group
--[[for _,object in ipairs(minetest.env:get_objects_inside_radius(self.object:getpos(), 5)) do
@ -179,7 +185,7 @@ end
local cnt1 = 0
local cnt2 = 0
NPC_ENTITY_DEF.on_step = function(self, dtime)
MUMMY_DEF.on_step = function(self, dtime)
self.timer = self.timer + 0.01
self.turn_timer = self.turn_timer + 0.01
self.jump_timer = self.jump_timer + 0.01
@ -326,7 +332,7 @@ NPC_ENTITY_DEF.on_step = function(self, dtime)
end
end
minetest.register_entity("pyramids:mummy", NPC_ENTITY_DEF)
minetest.register_entity("pyramids:mummy", MUMMY_DEF)
minetest.register_entity("pyramids:mummy_spawner", spawner_DEF)

View File

@ -2,10 +2,47 @@ local img = {"eye", "men", "sun"}
for i=1,3 do
minetest.register_node("pyramids:deco_stone"..i, {
description = "Sandstone",
description = "Sandstone with "..img[i],
tiles = {"default_sandstone.png^pyramids_"..img[i]..".png"},
is_ground_content = true,
groups = {crumbly=2,cracky=3},
sounds = default.node_sound_stone_defaults(),
})
end
end
trap_on_timer = function (pos, elapsed)
local objs = minetest.env:get_objects_inside_radius(pos, 2)
for i, obj in pairs(objs) do
if obj:is_player() then
local n = minetest.get_node(pos)
if n and n.name and minetest.registered_nodes[n.name].crack < 2 then
minetest.set_node(pos, {name="pyramids:trap_2"})
nodeupdate(pos)
end
end
end
return true
end
minetest.register_node("pyramids:trap", {
description = "Cracked sandstone brick",
tiles = {"default_sandstone_brick.png^pyramids_crack.png"},
is_ground_content = true,
groups = {crumbly=2,cracky=3},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
minetest.env:get_node_timer(pos):start(0.1)
end,
crack = 1,
on_timer = trap_on_timer,
drop = "",
})
minetest.register_node("pyramids:trap_2", {
description = "trapstone",
tiles = {"default_sandstone_brick.png^pyramids_crack.png^[transformR90"},
is_ground_content = true,
groups = {crumbly=2,cracky=3,falling_node=1,not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(),
drop = "",
})

View File

@ -8,6 +8,16 @@ local room = {"a","a","a","a","a","a","a","a","a",
"a","c","a","c","a","c","a","c","a",
"a","a","a","a","a","a","a","a","a"}
local trap = {"b","b","b","b","b","b","b","b","b",
"l","b","l","b","l","b","l","b","b",
"l","b","l","b","l","b","l","b","b",
"l","b","l","l","l","b","l","l","b",
"l","l","b","l","b","l","l","b","b",
"l","b","l","l","l","l","l","l","b",
"l","b","l","b","l","b","l","b","b",
"l","b","l","b","l","b","l","b","b",
"b","b","b","b","b","b","b","b","b"}
local code = {}
code["s"] = "sandstone"
code["eye"] = "deco_stone1"
@ -16,6 +26,8 @@ code["sun"] = "deco_stone3"
code["c"] = "chest"
code["b"] = "sandstonebrick"
code["a"] = "air"
code["l"] = "lava_source"
code["t"] = "trap"
local function replace(str,iy)
local out = "default:"
@ -26,6 +38,15 @@ local function replace(str,iy)
return out..code[str]
end
local function replace2(str,iy)
local out = "default:"
if iy == 0 and str == "l" then out = "pyramids:" str = "t"
elseif iy < 3 and str == "l" then str = "a" end
if str == "a" then out = "" end
return out..code[str]
end
function pyramids.make_room(pos)
local loch = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
for iy=0,4,1 do
@ -42,3 +63,16 @@ function pyramids.make_room(pos)
end
end
end
function pyramids.make_traps(pos)
local loch = {x=pos.x+7,y=pos.y, z=pos.z+7}
for iy=0,4,1 do
for ix=0,8,1 do
for iz=0,8,1 do
local n_str = trap[tonumber(ix*9+iz+1)]
local p2 = 0
minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace2(n_str,iy), param2=p2})
end
end
end
end