From 045e9641d23c3d8660ea6c729cea7452ffd7829f Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Fri, 20 Jun 2014 15:12:46 +1000 Subject: [PATCH 1/4] Began moving values to config.lua so they can be specified in the .conf file --- config.lua | 24 ++++++++++++++++++++++++ init.lua | 52 +++++++++++++++++++++++++++------------------------- 2 files changed, 51 insertions(+), 25 deletions(-) create mode 100644 config.lua diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..794bd39 --- /dev/null +++ b/config.lua @@ -0,0 +1,24 @@ + +local CONFIG_FILE_PREFIX = "caverealms." + +caverealms.config = {} + +-- This function based on kaeza/minetest-irc/config.lua and used under the +-- terms of BSD 2-clause license. +local function setting(stype, name, default) + local value + if stype == "bool" then + value = minetest.setting_getbool(CONFIG_FILE_PREFIX..name) + elseif stype == "string" then + value = minetest.setting_get(CONFIG_FILE_PREFIX..name) + elseif stype == "number" then + value = tonumber(minetest.setting_get(CONFIG_FILE_PREFIX..name)) + end + if value == nil then + value = default + end + caverealms.config[name] = value +end + +setting("number", "ymin", -33000) +setting("number", "ymax", -700) diff --git a/init.lua b/init.lua index 530b23b..2152884 100644 --- a/init.lua +++ b/init.lua @@ -3,10 +3,16 @@ -- Depends default -- License: code WTFPL --- Parameters +caverealms = {} -local YMIN = -33000 -- Approximate realm limits. -local YMAX = -700 +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +dofile(modpath.."/config.lua") + +-- Parameters (see also config.lua) + +local YMIN = caverealms.config.ymin -- Approximate realm limits. +local YMAX = caverealms.config.ymax local XMIN = -33000 local XMAX = 33000 local ZMIN = -33000 @@ -64,10 +70,6 @@ local np_wave = { persist = 0.5 } --- Stuff - -caverealms = {} - -- Nodes --glowing crystal @@ -136,7 +138,7 @@ minetest.register_node("caverealms:stone_with_moss", { function caverealms:stalagmite(x,y,z, area, data) --contest ids local c_stone = minetest.get_content_id("default:stone") - + local top = math.random(6,H_LAG) --grab a random height for the stalagmite for j = 0, top do --y for k = -3, 3 do @@ -169,7 +171,7 @@ end function caverealms:stalactite(x,y,z, area, data) --contest ids local c_stone = minetest.get_content_id("default:stone")--("caverealms:limestone") - + local bot = math.random(-H_LAC, -6) --grab a random height for the stalagmite for j = bot, 0 do --y for k = -3, 3 do @@ -204,7 +206,7 @@ function caverealms:crystal_stalagmite(x,y,z, area, data) local c_stone = minetest.get_content_id("default:stone") local c_crystal = minetest.get_content_id("caverealms:glow_crystal") local c_crystore = minetest.get_content_id("caverealms:glow_ore") - + local top = math.random(5,H_CRY) --grab a random height for the stalagmite for j = 0, top do --y for k = -3, 3 do @@ -243,13 +245,13 @@ minetest.register_on_generated(function(minp, maxp, seed) or minp.z < ZMIN or maxp.z > ZMAX then return end - + --determine if there's enough spacing between layers to start a realm local chulay = math.floor((minp.y + 32) / 80) -- chunk layer number, 0 = surface chunk if math.fmod(chulay, CHUINT) ~= 0 then -- if chulay / CHUINT has a remainder return end - + --easy to reference variables for limits and time local t1 = os.clock() local x1 = maxp.x @@ -258,21 +260,21 @@ minetest.register_on_generated(function(minp, maxp, seed) local x0 = minp.x local y0 = minp.y local z0 = minp.z - + --let people know you're generating a realm print ("[caverealms] chunk minp ("..x0.." "..y0.." "..z0..")") - + --fire up the LVM local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax} local data = vm:get_data() - + --grab content IDs local c_air = minetest.get_content_id("air") local c_crystal = minetest.get_content_id("caverealms:glow_crystal") local c_gem = minetest.get_content_id("caverealms:glow_gem") local c_moss = minetest.get_content_id("caverealms:stone_with_moss") - + --some mandatory values local sidelen = x1 - x0 + 1 --usually equals 80 with default mapgen values. Always a multiple of 16. local chulens = {x=sidelen, y=sidelen, z=sidelen} --position table to pass to get3dMap_flat @@ -284,7 +286,7 @@ minetest.register_on_generated(function(minp, maxp, seed) local nvals_cluster = minetest.get_perlin_map(np_cluster, chulens):get3dMap_flat(minposxyz) local nvals_wave = minetest.get_perlin_map(np_wave, chulens):get2dMap_flat(minposxz) - + --more values local nixyz = 1 --short for node index xyz local nixz = 1 --node index xz @@ -295,9 +297,9 @@ minetest.register_on_generated(function(minp, maxp, seed) local nixyz2 = 1 local nixz2 = 1 local stable2 = {} - + for z = z0, z1 do --for each xy plane progressing northwards - for x = x0, x1 do + for x = x0, x1 do local si = x - x0 + 1 --stability index dirt[si] = 0 --no dirt here... yet roof[si] = 0 @@ -333,7 +335,7 @@ minetest.register_on_generated(function(minp, maxp, seed) else stable[si] = stable[si] + 1 end - + elseif dirt[si] >= 1 then -- node above surface --place dirt on floor, add plants data[vi] = c_moss @@ -361,7 +363,7 @@ minetest.register_on_generated(function(minp, maxp, seed) nixz = nixz - sidelen --shift the 2D index down a layer end nixz = nixz + sidelen --shift the 2D index up a layer - + --second loop to obtain ceiling for y = y0, y1 do -- for each x row progressing downwards local vi = area:index(x0, y, z) --grab the index of the node to edit @@ -382,7 +384,7 @@ minetest.register_on_generated(function(minp, maxp, seed) else stable2[si] = stable2[si] + 1 end - + elseif roof[si] >= 1 then --and stable2[si] >= 2 then -- node above surface if math.random() <= STALCHA then local ai = area:index(x,y+1,z) @@ -402,8 +404,8 @@ minetest.register_on_generated(function(minp, maxp, seed) end nixz2 = nixz2 + sidelen end - - + + --write these changes to the world vm:set_data(data) vm:set_lighting({day=0, night=0}) @@ -411,4 +413,4 @@ minetest.register_on_generated(function(minp, maxp, seed) vm:write_to_map(data) local chugent = math.ceil((os.clock() - t1) * 1000) --grab how long this took print ("[caverealms] "..chugent.." ms") --tell people how long it took -end) \ No newline at end of file +end) From 843fddb7ba6796e15582aee95718d1145541ab11 Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Fri, 20 Jun 2014 16:46:49 +1000 Subject: [PATCH 2/4] Very minor tweak to texture --- textures/caverealms_glow_gem.png | Bin 483 -> 368 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/textures/caverealms_glow_gem.png b/textures/caverealms_glow_gem.png index 29e2f75493466e24492204ffc60acb1b4573e0fe..91ed423ecc0439ab13fac19c54fd73d285f516e1 100644 GIT binary patch delta 341 zcmV-b0jmDv1MmWnB!3xnMObuGZ)S9NVRB^vL1b@YWgtmyVP|DhWnpA_ami&o0003J zNklY(>`y10b;* z0c+ra2sQv@v--v`23c8Iu!2=8jSOLT>cNUYiZwQbK)k``3o%6w;T=YXs0IIFf*?&W z+h7Li>1Z>6yiNu463ifYEPxnb4$wr9=03J0xYLV%%|p=)G7y}9kOGns8V+Dr6c-o& nNA@cWAiD|%KmiE?009O7#9z)2xo~ML00000NkvXXu0mjf+n|eg delta 457 zcmV;)0XF{d0^6+6Hh*n;h@gc{P>X>cAy=(p zUZ6(^T-=4D3qx?(6A0npL}U~WZdw{aAjoNvGioW8b>YJOI{$P3zjKs`@Rza1AIDMw zMB*E%Dl9hiDcA|e^5VsayWqzA|no0Wvm01dJD!ZeRuoFStLbRtATKH-3Tnj1j z@x!CTq5uS)-G6Vv0BX7u9gT#|G63$d0f1rI^yA*lx>BvFxm5_8Wkh?*9X2p58-RY? z!?5ghpCn3qL_}~jvUTlZnkN0YM^Nx_A1?s7Kd7-?F9Hx`_dgY^iJf)7o0pevo4fom z=5rmxve_Hm@;Vq06nr*wIc}cb*%>{gGkV*YR6(?-L_&LtxP@WaTxL&G&u7Cc!e%+; z5fprY8IWphLjX#pQc5%tN#K1wt5j=BDWyID9iyfjLRr!v00000NkvXXu0mjfs$#jB From 8deaef628a683ba38fc7f44b00e2073630fc6bc1 Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Fri, 20 Jun 2014 16:54:33 +1000 Subject: [PATCH 3/4] Fixed description for caverealms:stone_with_moss --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 2152884..fd5a715 100644 --- a/init.lua +++ b/init.lua @@ -119,11 +119,11 @@ minetest.register_node("caverealms:glow_gem", { }) --cave mossy cobble - bluish? minetest.register_node("caverealms:stone_with_moss", { - description = "Cave Dirt with Grass", + description = "Cave Stone with Moss", tiles = {"default_cobble.png^caverealms_moss.png", "default_cobble.png", "default_cobble.png^caverealms_moss_side.png"}, is_ground_content = true, groups = {crumbly=3}, - drop = 'default:dirt', + drop = 'default:cobblestone', sounds = default.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.25}, }), From 89b140f950c9cd6f3e04b8f7619e2b37f43be8de Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Fri, 20 Jun 2014 17:22:28 +1000 Subject: [PATCH 4/4] Did not like the gem texture --- textures/caverealms_glow_gem.png | Bin 368 -> 436 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/textures/caverealms_glow_gem.png b/textures/caverealms_glow_gem.png index 91ed423ecc0439ab13fac19c54fd73d285f516e1..a18de2426f1fbd3b49d361a192f91f7a44f6c60e 100644 GIT binary patch delta 372 zcmV-)0gL|d0<;5=Nq<&JL_t(|+G70w|33pIfQgWT(!&h@ftWl4^p`S#o!7JN>VL8f zaFYXTCf^IY9zhw8&frwTg3o|USFYmp76@F7W?*C@3VgNQI zl|h?3D0VDEsu!o--p_y471 zdl{~+yb9KQQf-F;tQndD!SuDAkWkn2if0I5(MJhfL@WRWL4gGdX^=r605S*^WuWi? zi6N&8SU`dZCZIR|F-9-^FTo-USMck{8#tSdLj*(Y?aDAlAYfubH<45T5MTf&ouAr$ SgIA;g0000kPw3}JWb!HPhNH8zAmyus!R zF+~pH9Y%(z1^;1!AWbmaUwXfuGk1@jWjAb2c*7+?<2M3Ck_wj{XIi+;^R(F`&W zoPUr4k`WpXU@2D=7Z?9W_A3k^y9x$C0SN*C0R{lXU(OG?aA_<60000