BuckarooBanzay 6acaae0f32
Some checks failed
luacheck / build (push) Has been cancelled
test / build (5.3.0) (push) Has been cancelled
test / build (5.4.0) (push) Has been cancelled
test / build (5.5.0) (push) Has been cancelled
test / build (5.6.1) (push) Has been cancelled
test / build (latest) (push) Has been cancelled
remove stray print
2023-04-28 14:23:00 +02:00
2023-03-05 17:19:17 +01:00
2023-04-25 14:19:11 +02:00
2023-04-28 10:43:34 +02:00
2023-04-28 14:22:41 +02:00
2023-04-25 14:06:56 +02:00
2023-04-25 14:06:56 +02:00
2023-04-28 14:23:00 +02:00
2023-03-05 17:19:17 +01:00
2023-04-20 10:43:30 +02:00
2023-04-25 14:19:11 +02:00
2023-03-05 17:19:17 +01:00
2023-04-25 14:56:01 +02:00

mtscad

Or: How I Learned to Stop Worrying and Love minetest.set_node()

OpenSCAD inspired minetest mod

Status: WIP

License Download

Required engine-version: 5.3.0

Example

Simple cube

${worldpath}/mtscad/example.lua

return function(ctx)
    ctx
    :with({ name="default:cobble" }) -- material to use
    :translate(1, 2, 3) -- move context
    :cube(5,5,5) -- draw cube with 5 nodes sidelength
end

Execute with:

  • /scad_origin
  • /scad example

Composition

functions can be composed and reused

local function mycube(ctx)
    ctx:cube(5,5,5)
    -- TODO other magic for my-cube
end

return function(ctx)
    ctx
    :with({ name="default:cobble" }) -- material to use
    :translate(1, 2, 3) -- move context
    :execute(mycube) -- execute mycube function
    :translate(10, 0, 0) -- move context again by 10 nodes to x+
    :execute(mycube) -- execute mycube function on the new position
end

NOTE:: the ctx:execute(fn, opts...) function executes the passed function asynchronously

Modules

TODO

Api

ctx:with(node_spec)

Specify which nodes to use:

-- simple node
ctx:with("default:cobble")

-- node-table
ctx:with({ name="default:cobble" })

-- node-table with param2
ctx:with({ name="default:cobble", param2=1 })

-- producer-function
ctx:with(function()
    return { name="default:stone", param2=math.random(10) }
end)

ctx:set_node()

ctx:execute(fn, opts...)

ctx:translate(x,y,z)

ctx:rotate(x,y,z)

ctx:mirror(x,y,z)

ctx:line(x,y,z)

ctx:cube(x,y,z)

ctx:sphere(radius, fill?)

ctx:dome(radius, fill?)

ctx:cylinder(radius, height, fill?)

ctx:polygon(points, fill?)

ctx:char(num, charset?)

ctx:text(txt, charset?)

License

MIT

Description
No description provided
Readme 139 KiB
Languages
Lua 99%
Dockerfile 0.7%
Mathematica 0.3%