From 306c025713487b20a20e32e33277d2f215a70832 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sun, 5 Jun 2016 11:39:20 +0100 Subject: Code tweak and tidy --- bonemeal.lua | 8 ++++---- dirt.lua | 6 +++--- extra.lua | 16 +++++++++------- flowers.lua | 1 + init.lua | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/bonemeal.lua b/bonemeal.lua index 4f7979b..b1a0174 100644 --- a/bonemeal.lua +++ b/bonemeal.lua @@ -170,14 +170,14 @@ local function growth(pointed_thing) local stage = "" -- grow registered crops - for _, row in pairs(crops) do + for n = 1, #crops do - if string.find(node.name, row[1]) then + if string.find(node.name, crops[n][1]) then stage = tonumber( node.name:split("_")[2] ) - stage = math.min(stage + math.random(1, 4), row[2]) + stage = math.min(stage + math.random(1, 4), crops[n][2]) - minetest.set_node(pos, {name = row[1] .. stage}) + minetest.set_node(pos, {name = crops[n][1] .. stage}) return diff --git a/dirt.lua b/dirt.lua index c3f4c46..f68cb8d 100644 --- a/dirt.lua +++ b/dirt.lua @@ -108,13 +108,13 @@ minetest.register_abm({ "group:ethereal_grass") -- count new grass nodes - for _,p in pairs(dirts) do + for n = 1, #dirts do - num = grasses[p] or 0 + num = grasses[dirts[n]] or 0 if num > curr_max then curr_max = num - curr_type = p + curr_type = dirts[n] end end diff --git a/extra.lua b/extra.lua index ebb216f..6dfd552 100644 --- a/extra.lua +++ b/extra.lua @@ -41,20 +41,22 @@ minetest.register_craft({ }) -- X pattern craft recipes (5x 'a' in X pattern gives 5 of 'b') -for _,items in pairs({ +local cheat = { {"default:cobble", "default:gravel"}, {"default:gravel", "default:dirt"}, {"default:dirt", "default:sand"}, {"default:ice", "default:snow"}, {"ethereal:dry_dirt", "default:desert_sand"}, -}) do - local a, b = unpack(items) +} + +for n = 1, #cheat do + minetest.register_craft({ - output = b.." 5", + output = cheat[n][2] .. " 5", recipe = { - {a, "", a}, - {"", a, ""}, - {a, "", a}, + {cheat[n][1], "", cheat[n][1]}, + {"", cheat[n][1], ""}, + {cheat[n][1], "", cheat[n][1]}, } }) end diff --git a/flowers.lua b/flowers.lua index eb58102..79672e6 100644 --- a/flowers.lua +++ b/flowers.lua @@ -1,3 +1,4 @@ + -- Flowers spread over all types of soil minetest.register_abm({ nodenames = {"group:flora"}, diff --git a/init.lua b/init.lua index 942a0b9..757d4c5 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ --[[ - Minetest Ethereal Mod (17th May 2016) + Minetest Ethereal Mod (5th June 2016) Created by ChinChow -- cgit v1.2.3