Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix leaking globals in flowers and default mapgen.lua
Signed-off-by: Craig Robbins <kde.psych@gmail.com>
  • Loading branch information
PenguinDad authored and Zeno- committed Nov 21, 2014
1 parent e71b71c commit 3bf3249
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 6 additions & 8 deletions mods/default/mapgen.lua
Expand Up @@ -278,7 +278,7 @@ function default.mgv6_ongen(minp, maxp, seed)
end
end
end

function default.make_cactus(pos, size)
for y=0,size-1 do
local p = {x=pos.x, y=pos.y+y, z=pos.z}
Expand Down Expand Up @@ -377,7 +377,7 @@ function default.mgv6_ongen(minp, maxp, seed)
break
end
end

if ground_y then
local p = {x=x,y=ground_y+1,z=z}
local nn = minetest.get_node(p).name
Expand All @@ -388,14 +388,14 @@ function default.mgv6_ongen(minp, maxp, seed)
-- If desert sand, add dry shrub
if nn == "default:desert_sand" then
minetest.set_node(p,{name="default:dry_shrub"})

-- If dirt with grass, add grass
elseif nn == "default:dirt_with_grass" then
minetest.set_node(p,{name="default:grass_"..pr:next(1, 5)})
end
end
end

end
end
end
Expand All @@ -406,9 +406,8 @@ end
-- Detect mapgen and register suitable on-generated function
--

minetest.register_on_mapgen_init(function(MapgenParams)
mgname = MapgenParams.mgname
if mgname == "v6" then
minetest.register_on_mapgen_init(function(mg_params)
if mg_params.mgname == "v6" then
minetest.register_on_generated(default.mgv6_ongen)
end
end)
Expand Down Expand Up @@ -466,4 +465,3 @@ function default.generate_nyancats(minp, maxp, seed)
end

minetest.register_on_generated(default.generate_nyancats)

10 changes: 4 additions & 6 deletions mods/flowers/mapgen.lua
Expand Up @@ -26,7 +26,7 @@ function flowers.mgv6ongen(minp, maxp, seed)
break
end
end

if ground_y then
local p = {x=x,y=ground_y+1,z=z}
local nn = minetest.get_node(p).name
Expand Down Expand Up @@ -54,7 +54,7 @@ function flowers.mgv6ongen(minp, maxp, seed)
end
end
end

end
end
end
Expand All @@ -63,10 +63,8 @@ end

-- Enable in mapgen v6 only

minetest.register_on_mapgen_init(function(MapgenParams)
mgname = MapgenParams.mgname
if mgname == "v6" then
minetest.register_on_mapgen_init(function(mg_params)
if mg_params.mgname == "v6" then
minetest.register_on_generated(flowers.mgv6ongen)
end
end)

2 comments on commit 3bf3249

@HybridDog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What shall I do if something global could be defined before?
https://github.com/HybridDog/nuke/blob/master/init.lua#L9
this causes a warning message

@ShadowNinja
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HybridDog: The warning is from the global existence check (the = nuke or part).
I have a PR to fix this warning.

Please sign in to comment.