grid stub
This commit is contained in:
parent
0503f1ca51
commit
7b9112ad6e
@ -1,8 +1,7 @@
|
||||
function mtscad.Context:cube(x, y, z)
|
||||
-- TODO: deal with negative sizes
|
||||
local pos2 = vector.add(self.pos, {x=x-1, y=y-1, z=z-1})
|
||||
-- TODO: prevent negative sizes
|
||||
local pos1 = vector.copy(self.pos)
|
||||
pos1, pos2 = mtscad.sort_pos(pos1, pos2)
|
||||
local pos2 = vector.add(self.pos, {x=x-1, y=y-1, z=z-1})
|
||||
|
||||
for xi=pos1.x,pos2.x do
|
||||
for yi=pos1.y,pos2.y do
|
||||
|
20
context/grid.lua
Normal file
20
context/grid.lua
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
function mtscad.Context:grid(x, y, z)
|
||||
-- TODO: prevent negative sizes
|
||||
local pos1 = vector.copy(self.pos)
|
||||
local pos2 = vector.add(self.pos, {x=x-1, y=y-1, z=z-1})
|
||||
|
||||
-- TODO: lines between outer positions
|
||||
for xi=pos1.x,pos2.x,x-1 do
|
||||
for yi=pos1.y,pos2.y,y-1 do
|
||||
for zi=pos1.z,pos2.z,z-1 do
|
||||
local ipos = { x=xi, y=yi, z=zi }
|
||||
local tpos = mtscad.transform_pos(pos1, ipos, self.rotation)
|
||||
local tnode = mtscad.transform_node(self.node, self.rotation)
|
||||
minetest.set_node(tpos, tnode)
|
||||
end
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
1
init.lua
1
init.lua
@ -8,6 +8,7 @@ dofile(MP .. "/context/execute.lua")
|
||||
dofile(MP .. "/context/translate.lua")
|
||||
dofile(MP .. "/context/rotate.lua")
|
||||
dofile(MP .. "/context/cube.lua")
|
||||
dofile(MP .. "/context/grid.lua")
|
||||
dofile(MP .. "/context/slope.lua")
|
||||
dofile(MP .. "/util.lua")
|
||||
dofile(MP .. "/test.lua")
|
13
test.lua
13
test.lua
@ -1,15 +1,4 @@
|
||||
|
||||
local function cube_outliers(ctx, size)
|
||||
ctx
|
||||
:cube(size, 1, 1)
|
||||
:cube(1, size, 1)
|
||||
:cube(1, 1, size)
|
||||
:translate(size-1, 0, size-1)
|
||||
:cube(-size, 1, 1)
|
||||
:cube(1, size, 1)
|
||||
:cube(1, 1, -size)
|
||||
end
|
||||
|
||||
local function rot_test(ctx)
|
||||
ctx
|
||||
:with({ name="wool:red" })
|
||||
@ -43,7 +32,7 @@ local function test_code(ctx)
|
||||
ctx
|
||||
:with({ name="default:copperblock" })
|
||||
:translate(2,2,2)
|
||||
:execute(cube_outliers, 5)
|
||||
:grid(5, 5, 5)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("test", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user