update example
This commit is contained in:
parent
80d7f7dc16
commit
4dfffdab8c
37
README.md
37
README.md
@ -10,40 +10,31 @@ Files placed in `<worlddir>/mtscad/`
|
||||
|
||||
stairs.lua
|
||||
```lua
|
||||
-- diagonal line along x and y with "count" nodes
|
||||
local function diag_x_line(ctx, count)
|
||||
for x=0, count do
|
||||
ctx
|
||||
:translate(x, x, 0)
|
||||
:set_node()
|
||||
end
|
||||
end
|
||||
|
||||
return function(ctx, opts)
|
||||
-- filler
|
||||
ctx
|
||||
:with(opts.filler)
|
||||
:execute(diag_x_line, opts.height-1)
|
||||
:line(opts.height-1, opts.height-1, 0)
|
||||
:translate(0, 0, opts.width-1)
|
||||
:execute(diag_x_line, opts.height-1)
|
||||
:line(opts.height-1, opts.height-1, 0)
|
||||
|
||||
-- slopes above
|
||||
ctx
|
||||
:with(opts.slopes)
|
||||
:slope(-1, 1, 0)
|
||||
:translate(0, 1, 0)
|
||||
:execute(diag_x_line, opts.height-2)
|
||||
:line(opts.height-2, opts.height-2, 0)
|
||||
:translate(0, 0, opts.width-1)
|
||||
:execute(diag_x_line, opts.height-2)
|
||||
:line(opts.height-2, opts.height-2, 0)
|
||||
|
||||
-- slopes below
|
||||
ctx
|
||||
:with(opts.slopes)
|
||||
:slope(1, -1, 0)
|
||||
:translate(1, 0, 0)
|
||||
:execute(diag_x_line, opts.height-2)
|
||||
:line(opts.height-2, opts.height-2, 0)
|
||||
:translate(0, 0, opts.width-1)
|
||||
:execute(diag_x_line, opts.height-2)
|
||||
:line(opts.height-2, opts.height-2, 0)
|
||||
|
||||
-- stairs
|
||||
for z=1,opts.width-2 do
|
||||
@ -51,18 +42,28 @@ return function(ctx, opts)
|
||||
:with(opts.stairs)
|
||||
:slope(-1, 1, 0)
|
||||
:translate(0, 0, z)
|
||||
:execute(diag_x_line, opts.height-1)
|
||||
:line(opts.height-1, opts.height-1, 0)
|
||||
end
|
||||
end
|
||||
end, {
|
||||
defaults = {
|
||||
height = 4,
|
||||
width = 5,
|
||||
slopes = "moreblocks:slope_stone",
|
||||
stairs = "moreblocks:stair_stone_alt_4",
|
||||
filler = "default:stone"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
test.lua
|
||||
```lua
|
||||
-- load function from module
|
||||
local stairs = load("stairs")
|
||||
|
||||
return function(ctx)
|
||||
ctx
|
||||
:rotate(0, 0, 0)
|
||||
:translate(0, 0, 0) -- apply translations here
|
||||
:rotate(0, 0, 0) -- apply rotations here
|
||||
:execute(stairs, {
|
||||
height = 4,
|
||||
width = 5,
|
||||
|
Loading…
x
Reference in New Issue
Block a user