From f64171b2a8100b3e6dab6a65efedc8893d1383c0 Mon Sep 17 00:00:00 2001 From: BlockMen Date: Thu, 26 Sep 2013 01:37:24 +0200 Subject: [PATCH] Version 0.3 Fix floating, add better room, improve spawning --- README.txt | 11 ++- init.lua | 148 +++++++++++++++++++++++--------------- mummy.lua | 2 +- nodes.lua | 11 +++ room.lua | 44 ++++++++++++ textures/pyramids_eye.png | Bin 0 -> 248 bytes textures/pyramids_men.png | Bin 0 -> 240 bytes textures/pyramids_sun.png | Bin 0 -> 231 bytes 8 files changed, 157 insertions(+), 59 deletions(-) create mode 100644 nodes.lua create mode 100644 room.lua create mode 100644 textures/pyramids_eye.png create mode 100644 textures/pyramids_men.png create mode 100644 textures/pyramids_sun.png diff --git a/README.txt b/README.txt index 2160417..702fddb 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,6 @@ Minetest mod "Pyramids" ======================= -version: 0.2 Beta +version: 0.3 Beta License of source code and textures: WTFPL ------------------------------------------ @@ -12,6 +12,15 @@ License of mesh model: WTFPL (c) Copyright Pavel_S (2013) +License of textures +------------------- +-pyramids_eye.png by bas080, CC-BY-SA 3.0 +-pyramids_men.png by bas080, CC-BY-SA 3.0 +-pyramids_sun.png by bas080, CC-BY-SA 3.0 + +all other: BlockMen, WTFPL + + Licenses of sounds ------------------ The authors are : (freesound.org) diff --git a/init.lua b/init.lua index d9b5799..9a418d9 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,8 @@ +pyramids = {} + dofile(minetest.get_modpath("pyramids").."/mummy.lua") ---dofile(minetest.get_modpath("pyramids").."/traps.lua") +dofile(minetest.get_modpath("pyramids").."/nodes.lua") +dofile(minetest.get_modpath("pyramids").."/room.lua") local chest_stuff = { {name="default:apple", max = 3}, @@ -12,52 +15,60 @@ local chest_stuff = { } -local function fill_chest(pos) - minetest.set_node(pos, {name="default:chest"}) - minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z}, {name="pyramids:spawner_mummy"}) - if not minetest.setting_getbool("only_peaceful_mobs") then pyramids.spawn_mummy({x=pos.x+1,y=pos.y,z=pos.z},2) end +function pyramids.fill_chest(pos) minetest.after(2, function() local n = minetest.get_node(pos) - if n ~= nil then - if n.name == "default:chest" then - local meta = minetest.get_meta(pos) - meta:set_string("formspec",default.chest_formspec) - meta:set_string("infotext", "Chest") - local inv = meta:get_inventory() - inv:set_size("main", 8*4) - for i=0,4,1 do - local stuff = chest_stuff[math.random(1,#chest_stuff)] - local stack = {name=stuff.name, count = math.random(1,stuff.max)} - if not inv:contains_item("main", stack) then - inv:set_stack("main", math.random(1,32), stack) - end + if n and n.name and n.name == "default:chest" then + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + if math.random(1,10) < 7 then return end + for i=0,2,1 do + local stuff = chest_stuff[math.random(1,#chest_stuff)] + if stuff.name == "farming:bread" and not minetest.get_modpath("farming") then stuff = chest_stuff[1] end + local stack = {name=stuff.name, count = math.random(1,stuff.max)} + if not inv:contains_item("main", stack) then + inv:set_stack("main", math.random(1,32), stack) end end end end) end +local function add_spawner(pos) + minetest.set_node(pos, {name="pyramids:spawner_mummy"}) + if not minetest.setting_getbool("only_peaceful_mobs") then pyramids.spawn_mummy({x=pos.x,y=pos.y,z=pos.z-2},2) end +end -local function make_room(pos) -local loch = {x=pos.x+8,y=pos.y+5, z=pos.z+8} - -for iy=0,4,1 do - for ix=0,6,1 do - for iz=0,6,1 do - minetest.remove_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}) - end +local function can_replace(pos) + local n = minetest.get_node_or_nil(pos) + if n and n.name and minetest.registered_nodes[n.name] and not minetest.registered_nodes[n.name].walkable then + return true + elseif not n then + return true + else + return false end end -fill_chest({x=pos.x+10+math.random(0,2),y=pos.y+1,z=pos.z+10+math.random(0,2)}) - +local function underground(pos) + local p2 = pos + local cnt = 0 + local mat = "desert_sand" + p2.y = p2.y-1 + while can_replace(p2)==true do + cnt = cnt+1 + if cnt > 25 then break end + if cnt>math.random(2,4) then mat = "desert_stone"end + minetest.set_node(p2, {name="default:"..mat}) + p2.y = p2.y-1 + end end local function make_entrance(pos) -local gang = {x=pos.x+10,y=pos.y, z=pos.z} -for iy=2,3,1 do - for iz=0,7,1 do - --minetest.remove_node({x=gang.x,y=gang.y+iy,z=gang.z+iz}) + local gang = {x=pos.x+10,y=pos.y, z=pos.z} + for iy=2,3,1 do + for iz=0,6,1 do minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz}) if iz >=3 and iy == 3 then minetest.set_node({x=gang.x,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"}) @@ -65,58 +76,81 @@ for iy=2,3,1 do minetest.set_node({x=gang.x+2,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"}) end end -end + end end local function make(pos) -minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")") -for iy=0,10,1 do + minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")") + for iy=0,10,1 do for ix=iy,22-iy,1 do 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"}) end end -end -make_room(pos) -make_entrance(pos) + end + + pyramids.make_room(pos) + add_spawner({x=pos.x+11,y=pos.y+2, z=pos.z+17}) + make_entrance(pos) end -local perl1 = { - SEED1 = 9130, -- Values should match minetest mapgen V6 desert noise. - OCTA1 = 3, - PERS1 = 0.5, - SCAL1 = 250, -} +local perl1 = {SEED1 = 9130, OCTA1 = 3, PERS1 = 0.5, SCAL1 = 250} -- Values should match minetest mapgen V6 desert noise. -local function ground(pos) +local function ground(pos, old) local p2 = pos - while minetest.get_node(p2).name == "air" do + while minetest.get_node_or_nil(p2).name == "air" do p2.y = p2.y -1 end - return p2 + if p2.y < old.y then + return p2 + else + return old + end end minetest.register_on_generated(function(minp, maxp, seed) + if maxp.y < 0 then return end + math.randomseed(seed) + local cnt = 0 local perlin1 = minetest.env:get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1) - local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)} - local noise1 = perlin1:get2d({x=mpos.x,y=mpos.y}) + local noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z}) + + if noise1 > 0.25 or noise1 < -0.26 then + local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)} - if noise1 > 0.45 or math.random(0,10) > (0.45 - noise1) * 100 then -- Smooth transition 0.35 to 0.45 p2 = minetest.find_node_near(mpos, 25, {"default:desert_sand"}) - + while p2 == nil and cnt < 5 do + cnt = cnt+1 + mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)} + p2 = minetest.find_node_near(mpos, 25, {"default:desert_sand"}) + end if p2 == nil then return end if p2.y < 0 then return end - if math.random(0,18) < 17 then return end local off = 0 - opos = {x=p2.x+22,y=p2.y-1,z=p2.z+22} - if minetest.get_node(opos).name == "air" then - p2 = ground(opos) + 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 + p2 = ground(opos1, p2) + end + if opos2_n == "air" then + p2 = ground(opos2, p2) + end + if opos3_n == "air" then + p2 = ground(opos3, p2) end p2.y = p2.y - 4 if p2.y < 0 then p2.y = 0 end - minetest.after(0.3,make,p2) + 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) end -end) \ No newline at end of file +end) diff --git a/mummy.lua b/mummy.lua index 3861c2d..9c77a74 100644 --- a/mummy.lua +++ b/mummy.lua @@ -1,4 +1,4 @@ -pyramids = {} +--pyramids = {} walk_limit = 1 chillaxin_speed = 1 diff --git a/nodes.lua b/nodes.lua new file mode 100644 index 0000000..311a27b --- /dev/null +++ b/nodes.lua @@ -0,0 +1,11 @@ +local img = {"eye", "men", "sun"} + +for i=1,3 do + minetest.register_node("pyramids:deco_stone"..i, { + description = "Sandstone", + tiles = {"default_sandstone.png^pyramids_"..img[i]..".png"}, + is_ground_content = true, + groups = {crumbly=2,cracky=3}, + sounds = default.node_sound_stone_defaults(), + }) +end \ No newline at end of file diff --git a/room.lua b/room.lua new file mode 100644 index 0000000..c16a7f7 --- /dev/null +++ b/room.lua @@ -0,0 +1,44 @@ +local room = {"a","a","a","a","a","a","a","a","a", + "a","c","a","c","a","c","a","c","a", + "a","s","a","s","a","s","a","s","a", + "a","a","a","a","a","a","a","a","a", + "a","a","a","a","a","a","a","a","a", + "a","a","a","a","a","a","a","a","a", + "a","s","a","s","a","s","a","s","a", + "a","c","a","c","a","c","a","c","a", + "a","a","a","a","a","a","a","a","a"} + +local code = {} +code["s"] = "sandstone" +code["eye"] = "deco_stone1" +code["men"] = "deco_stone2" +code["sun"] = "deco_stone3" +code["c"] = "chest" +code["b"] = "sandstonebrick" +code["a"] = "air" + +local function replace(str,iy) + local out = "default:" + if iy < 4 and str == "c" then str = "a" end + if iy == 0 and str == "s" then out = "pyramids:" str = "sun" end + if iy == 3 and str == "s" then out = "pyramids:" str = "men" 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 + for ix=0,8,1 do + for iz=0,8,1 do + local n_str = room[tonumber(ix*9+iz+1)] + local p2 = 0 + if n_str == "c" then + if ix < 3 then p2 = 1 else p2 = 3 end + pyramids.fill_chest({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}) + end + minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace(n_str,iy), param2=p2}) + end + end + end +end diff --git a/textures/pyramids_eye.png b/textures/pyramids_eye.png new file mode 100644 index 0000000000000000000000000000000000000000..4445dff31f2afbf2ea8db37b26ca973419619db1 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5he4R}c>anMpkRxq zi(^Q|oTZZv@--;%I8Xmk`L7{;{V&a!y+1a8H8IjUD#_=ouwnbw1cn?pwgcO;GfSp3 z>)CZzG46SB=eiqL7-P%{anUtQI}D;8yc4{(^}yrf=MMAiu~@g$`2B32DXddl=OlNCdAOJy^zV$lEp>dcbmVPApnkt%VGC~+(; r$;dBa2+c`NOi>7~EG|jSE!I)+%uCigDQi~-RK?)w>gTe~DWM4fSMysH literal 0 HcmV?d00001 diff --git a/textures/pyramids_men.png b/textures/pyramids_men.png new file mode 100644 index 0000000000000000000000000000000000000000..69cd4de114e2a95146beb111421f224cbbb3bbdf GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5he4R}c>anMpkR%s zi(^Q|oa7(>|JyUG&UpC$|9>9A;F*RWE~(A`e?lU%PlLJV(6oQ^uTJ*e$7tz!?|=H& zl*7D=HyLIq0(mXG4L93P3zQf(u_;)~&TLCu6X)>F_{_@}vl5dm4l^thyz8)t_kbuj zb2>v+){+|xn}U?AX4|nTEN4zJGh=25-Nkiui^7QsKzB%$xJHyXmX>7X7cqq9q$Z{) h1XmW9q~;duD0t>2>z$OfD+8)x@O1TaS?83{1OU)gRiOX? literal 0 HcmV?d00001 diff --git a/textures/pyramids_sun.png b/textures/pyramids_sun.png new file mode 100644 index 0000000000000000000000000000000000000000..63d3b957d592c1ed713b2ff4b3a8eccc0ed4f154 GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5he4R}c>anMpkT45 zi(^Q|oa7(>|JyUG&UpC$|9>9A;F%jA%~5&(-_rBm|H6}tB^rDc_0Ad;@`yj!%sX3Z zPTY*ElmE)MCEh!bW)a4G!E}+d+Z4tdIft_uHnAA89f)a9V(^(1A-+JuVWap8sSXiW zWmnG5fK94env>_w)Huk{e)~X-+v6z;Kt>Tc)I$ztaD0e0suW@QD^`F literal 0 HcmV?d00001