Navigation Menu

Skip to content

Commit

Permalink
Coding style updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Uberi committed Jul 12, 2014
1 parent 420655b commit 58d7a71
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions worldedit/manipulations.lua
Expand Up @@ -25,12 +25,9 @@ end

--sets a region defined by positions `pos1` and `pos2` to `nodename`, returning the number of nodes filled
worldedit.set = function(pos1, pos2, nodenames)
local oneNode
if type(nodenames) == 'string' then
oneNode = true
else
oneNode = false
end
if type(nodenames) == "string" then
nodenames = {nodenames}
end

local pos1, pos2 = worldedit.sort_pos(pos1, pos2)

Expand All @@ -48,10 +45,10 @@ worldedit.set = function(pos1, pos2, nodenames)

--fill selected area with node
local node_ids = {}
for i,v in ipairs(nodenames) do
node_ids[i] = minetest.get_content_id(nodenames[i])
end
if oneNode then --only one type of node
for i,v in ipairs(nodenames) do
node_ids[i] = minetest.get_content_id(nodenames[i])
end
if #node_ids then --only one type of node

This comment has been minimized.

Copy link
@sfan5

sfan5 Jul 13, 2014

Collaborator

if with a number always evaluates to true.

This comment has been minimized.

Copy link
@Uberi

Uberi Jul 14, 2014

Author Owner

Oops, fixed in d8aa7e7

local id = node_ids
for i in area:iterp(pos1, pos2) do nodes[i] = id end --fill area with node
else --several types of nodes specified
Expand Down Expand Up @@ -420,19 +417,19 @@ worldedit.stack = function(pos1, pos2, axis, count)
if count < 0 then
count = -count
length = -length
end
local amount = 0
local copy = worldedit.copy
local i = 1
function nextone()
if i <= count then
i = i + 1
amount = amount + length
copy(pos1, pos2, axis, amount)
minetest.after(0,nextone)
end
end
nextone()
end
local amount = 0
local copy = worldedit.copy
local i = 1
function nextone()
if i <= count then
i = i + 1
amount = amount + length
copy(pos1, pos2, axis, amount)
minetest.after(0, nextone)
end
end
nextone()
return worldedit.volume(pos1, pos2) * count
end

Expand Down

0 comments on commit 58d7a71

Please sign in to comment.