Posted 22 January 2014 - 03:58 PM
I am using coordinates in a for loop for setting blocks, and it seems that lua does not understand in this program that -227>-251. It should always use the lower number as the first number in the for loop, and then the higher one. (as otherwise it wouldn't work because for loops work in a range!)
(More fun with the worldedit program, I just implemented /pos1 from worldedit instead!)
Relevant code:
Full Program for the curious:
(More fun with the worldedit program, I just implemented /pos1 from worldedit instead!)
Relevant code:
Spoiler
if x2<x1 then
x3=x2
x4=x1
else
x3=x1
x4=x2
end
if y2<y1 then
y3=y2
y4=y1
else
y3=y1
y4=y2
end
if z2<z1 then
z3=z2
z4=z1
else
z3=z1
z4=z2
end
for x=x3,x4 do
for y=y3,y4 do
for z=z3,z4 do
Spoiler
tArgs={...}
username=tostring(tArgs[1])
x1=tArgs[2]
y1=tArgs[3]
z1=tArgs[4]
x2=tArgs[5]
y2=tArgs[6]
z2=tArgs[7]
block=tArgs[8]
meta=tArgs[9]
count=0
iterations=0
p=peripheral.wrap("right")
pl=p.getPlayerByName(username)
w=p.getWorld(p.getPeripheralWorldID())
if x1~=nil and x2~=nil and y1~=nil and y2~=nil and z1~=nil and z2~=nil then
if x2<x1 then
x3=x2
x4=x1
else
x3=x1
x4=x2
end
if y2<y1 then
y3=y2
y4=y1
else
y3=y1
y4=y2
end
if z2<z1 then
z3=z2
z4=z1
else
z3=z1
z4=z2
end
print("x: "..x3.." - "..x4)
print("y: "..y3.." - "..y4)
print("z: "..z3.." - "..z4)
for x=x3,x4 do
for y=y3,y4 do
for z=z3,z4 do
count=count+1
iterations=iterations+1
if count>=10000 then
count=0
sleep(0.05)
end
w.setBlockWithoutNotify(x,y,z,tonumber(block),tonumber(meta))
if iterations==1 then
pl.sendChat("Setting blocks...")
end
end
end
end
end
if iterations==0 then
pl.sendChat("For loop not executed.")
end
pl.sendChat(iterations.." blocks changed in "..math.floor(iterations/10000).." seconds.")