123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658 |
- --[[
- More Blocks: slope definitions
- Copyright (c) 2011-2015 Calinou and contributors.
- Licensed under the zlib license. See LICENSE.md for more information.
- --]]
- local S = function(str) return str end
- local box_regular = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
- }
- }
- local box_slope = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
- {-0.5, -0.25, -0.25, 0.5, 0, 0.5},
- {-0.5, 0, 0, 0.5, 0.25, 0.5},
- {-0.5, 0.25, 0.25, 0.5, 0.5, 0.5}
- }
- }
- local box_slope_half = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
- {-0.5, -0.375, -0.25, 0.5, -0.25, 0.5},
- {-0.5, -0.25, 0, 0.5, -0.125, 0.5},
- {-0.5, -0.125, 0.25, 0.5, 0, 0.5},
- }
- }
- local box_slope_half_raised = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
- {-0.5, 0.125, -0.25, 0.5, 0.25, 0.5},
- {-0.5, 0.25, 0, 0.5, 0.375, 0.5},
- {-0.5, 0.375, 0.25, 0.5, 0.5, 0.5},
- }
- }
- local box_slope_lh = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0, -0.25, 0.5},
- {-0.5, -0.25, -0.25, 0, 0, 0.5},
- {-0.5, 0, 0, 0, 0.25, 0.5},
- {-0.5, 0.25, 0.25, 0, 0.5, 0.5}
- }
- }
- local box_slope_half_lh = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0, -0.375, 0.5},
- {-0.5, -0.375, -0.25, 0, -0.25, 0.5},
- {-0.5, -0.25, 0, 0, -0.125, 0.5},
- {-0.5, -0.125, 0.25, 0, 0, 0.5},
- }
- }
- local box_slope_half_raised_lh = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0, 0.125, 0.5},
- {-0.5, 0.125, -0.25, 0, 0.25, 0.5},
- {-0.5, 0.25, 0, 0, 0.375, 0.5},
- {-0.5, 0.375, 0.25, 0, 0.5, 0.5},
- }
- }
- local box_slope_rh = {
- type = "fixed",
- fixed = {
- {0, -0.5, -0.5, 0.5, -0.25, 0.5},
- {0, -0.25, -0.25, 0.5, 0, 0.5},
- {0, 0, 0, 0.5, 0.25, 0.5},
- {0, 0.25, 0.25, 0.5, 0.5, 0.5}
- }
- }
- local box_slope_half_rh = {
- type = "fixed",
- fixed = {
- {0, -0.5, -0.5, 0.5, -0.375, 0.5},
- {0, -0.375, -0.25, 0.5, -0.25, 0.5},
- {0, -0.25, 0, 0.5, -0.125, 0.5},
- {0, -0.125, 0.25, 0.5, 0, 0.5},
- }
- }
- local box_slope_half_raised_rh = {
- type = "fixed",
- fixed = {
- {0, -0.5, -0.5, 0.5, 0.125, 0.5},
- {0, 0.125, -0.25, 0.5, 0.25, 0.5},
- {0, 0.25, 0, 0.5, 0.375, 0.5},
- {0, 0.375, 0.25, 0.5, 0.5, 0.5},
- }
- }
- --==============================================================
- local box_slope_inner = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
- {-0.5, -0.5, -0.25, 0.5, 0, 0.5},
- {-0.5, -0.5, -0.5, 0.25, 0, 0.5},
- {-0.5, 0, -0.5, 0, 0.25, 0.5},
- {-0.5, 0, 0, 0.5, 0.25, 0.5},
- {-0.5, 0.25, 0.25, 0.5, 0.5, 0.5},
- {-0.5, 0.25, -0.5, -0.25, 0.5, 0.5},
- }
- }
- local box_slope_inner_half = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
- {-0.5, -0.375, -0.25, 0.5, -0.25, 0.5},
- {-0.5, -0.375, -0.5, 0.25, -0.25, 0.5},
- {-0.5, -0.25, -0.5, 0, -0.125, 0.5},
- {-0.5, -0.25, 0, 0.5, -0.125, 0.5},
- {-0.5, -0.125, 0.25, 0.5, 0, 0.5},
- {-0.5, -0.125, -0.5, -0.25, 0, 0.5},
- }
- }
- local box_slope_inner_half_raised = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
- {-0.5, 0.125, -0.25, 0.5, 0.25, 0.5},
- {-0.5, 0.125, -0.5, 0.25, 0.25, 0.5},
- {-0.5, 0.25, -0.5, 0, 0.375, 0.5},
- {-0.5, 0.25, 0, 0.5, 0.375, 0.5},
- {-0.5, 0.375, 0.25, 0.5, 0.5, 0.5},
- {-0.5, 0.375, -0.5, -0.25, 0.5, 0.5},
- }
- }
- --==============================================================
- local box_slope_outer = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
- {-0.5, -0.25, -0.25, 0.25, 0, 0.5},
- {-0.5, 0, 0, 0, 0.25, 0.5},
- {-0.5, 0.25, 0.25, -0.25, 0.5, 0.5}
- }
- }
- local box_slope_outer_half = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
- {-0.5, -0.375, -0.25, 0.25, -0.25, 0.5},
- {-0.5, -0.25, 0, 0, -0.125, 0.5},
- {-0.5, -0.125, 0.25, -0.25, 0, 0.5}
- }
- }
- local box_slope_outer_half_raised = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0.125, 0.5},
- {-0.5, 0.125, -0.25, 0.25, 0.25, 0.5},
- {-0.5, 0.25, 0, 0, 0.375, 0.5},
- {-0.5, 0.375, 0.25, -0.25, 0.5, 0.5}
- }
- }
- local xslope_quarter = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, 0.5, 0, 0, 0},
- {-0.25, -0.25, 0, -0.5, -0.5, -0.5},
- }
- }
- local xslope_quarter2 = {
- type = "fixed",
- fixed = {
- {0.0, -0.5, 0.5, 0.5, 0, 0},
- {0.5, -0.25, 0, 0.25, -0.5, -0.5},
- }
- }
- local xslope_three_quarter = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, 0.5, 0.5, 0.5, 0},
- {0.25, 0.25, 0, -0.5, -0.5, -0.5},
- }
- }
- local xslope_three_quarter_half = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, 0.5, 0.5, 0.5, 0},
- }
- }
- local xslope_cut = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, 0.5, 0.5, 0.5, 0},
- }
- }
- local xslope_slope = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, 0.5, 0.5, 0, 0},
- }
- }
- local xslope_peak = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- {-0.5, 0, -0.25, 0.5, 0.5, 0.25},
- }
- }
- local xslope_peak_half = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
- {-0.5, -0.25, -0.25, 0.5, 0, 0.25},
- }
- }
- local xslope_slope_lh = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, 0.5, 0, 0, 0},
- }
- }
- local xslope_slope_rh = {
- type = "fixed",
- fixed = {
- {0, -0.5, 0.5, 0.5, 0, 0},
- }
- }
- local xslope_peak_lh = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0, 0, 0.5},
- {-0.5, 0, -0.25, 0, 0.5, 0.25},
- }
- }
- local xslope_peak_half_lh = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0, -0.25, 0.5},
- {-0.5, -0.25, -0.25, 0, 0, 0.25},
- }
- }
- local astair_1 = {
- type = "fixed",
- fixed = {
- -- Big angle.
- {-0.5, -0.5, 0.5, 0.5, 0, 0.25},
- {-0.5, -0.5, 0.25, 0.25, 0, 0},
- {-0.5, -0.5, 0, 0, 0, -0.25},
- {-0.5, -0.5, -0.25, -0.25, 0, -0.5},
- -- Corner angle.
- {-0.5, 0, 0.5, 0, 0.5, 0.25},
- {-0.5, 0, 0.25, -0.25, 0.5, 0},
- }
- }
- local astair_2 = {
- type = "fixed",
- fixed = {
- -- Box.
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- -- Angle.
- {-0.5, 0, 0.5, 0.5, 0.5, 0.25},
- {-0.5, 0, 0.25, 0.25, 0.5, 0},
- {-0.5, 0, 0, 0, 0.5, -0.25},
- {-0.5, 0, -0.25, -0.25, 0.5, -0.5},
- }
- }
- local astair_3 = {
- type = "fixed",
- fixed = {
- -- Box.
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- -- Corner angle.
- {-0.5, 0, 0.5, 0, 0.5, 0.25},
- {-0.5, 0, 0.25, -0.25, 0.5, 0},
- }
- }
- local astair_4 = {
- type = "fixed",
- fixed = {
- -- Box.
- {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
- -- Corner angle.
- {-0.5, 0, 0.5, 0, 0.5, 0.25},
- {-0.5, 0, 0.25, -0.25, 0.5, 0},
- }
- }
- -- Node will be called <modname>:slope_<subname>
- local slopes_defs = {
- [""] = {
- mesh = "moreblocks_slope.obj",
- collision_box = box_slope,
- selection_box = box_slope,
- light=1/2,
- },
- ["_half"] = {
- mesh = "moreblocks_slope_half.obj",
- collision_box = box_slope_half,
- selection_box = box_slope_half,
- light=1/4,
- },
- ["_half_raised"] = {
- mesh = "moreblocks_slope_half_raised.obj",
- collision_box = box_slope_half_raised,
- selection_box = box_slope_half_raised,
- light=3/4,
- },
- --==============================================================
- ["_inner"] = {
- mesh = "moreblocks_slope_inner.obj",
- collision_box = box_slope_inner,
- selection_box = box_slope_inner,
- light=3/4,
- },
- ["_inner_half"] = {
- mesh = "moreblocks_slope_inner_half.obj",
- collision_box = box_slope_inner_half,
- selection_box = box_slope_inner_half,
- light=2/5,
- },
- ["_inner_half_raised"] = {
- mesh = "moreblocks_slope_inner_half_raised.obj",
- collision_box = box_slope_inner_half_raised,
- selection_box = box_slope_inner_half_raised,
- light=4/5,
- },
- --==============================================================
- ["_inner_cut"] = {
- mesh = "moreblocks_slope_inner_cut.obj",
- collision_box = box_slope_inner,
- selection_box = box_slope_inner,
- light=4/5,
- },
- ["_inner_cut2"] = {
- mesh = "moreblocks_slope_inner_cut2.obj",
- collision_box = box_regular,
- selection_box = box_regular,
- light=4/5,
- },
- ["_inner_cut3"] = {
- mesh = "moreblocks_slope_inner_cut3.obj",
- collision_box = box_regular,
- selection_box = box_regular,
- light=4/5,
- },
- ["_inner_cut4"] = {
- mesh = "moreblocks_slope_inner_cut4.obj",
- collision_box = box_slope_inner,
- selection_box = box_slope_inner,
- light=4/5,
- },
- ["_inner_cut5"] = {
- mesh = "moreblocks_slope_inner_cut5.obj",
- collision_box = box_slope_inner,
- selection_box = box_slope_inner,
- light=4/5,
- },
- ["_inner_cut6"] = {
- mesh = "moreblocks_slope_inner_cut6.obj",
- collision_box = box_slope_inner,
- selection_box = box_slope_inner,
- light=4/5,
- },
- ["_inner_cut7"] = {
- mesh = "moreblocks_slope_inner_cut7.obj",
- collision_box = box_regular,
- selection_box = box_regular,
- light=4/5,
- },
- ["_inner_cut_half"] = {
- mesh = "moreblocks_slope_inner_cut_half.obj",
- collision_box = box_slope_inner_half,
- selection_box = box_slope_inner_half,
- light=2/5,
- },
- ["_inner_cut_half_raised"] = {
- mesh = "moreblocks_slope_inner_cut_half_raised.obj",
- collision_box = box_slope_inner_half_raised,
- selection_box = box_slope_inner_half_raised,
- light=4/5,
- },
- --==============================================================
- ["_outer"] = {
- mesh = "moreblocks_slope_outer.obj",
- collision_box = box_slope_outer,
- selection_box = box_slope_outer,
- light=2/5,
- },
- ["_outer_half"] = {
- mesh = "moreblocks_slope_outer_half.obj",
- collision_box = box_slope_outer_half,
- selection_box = box_slope_outer_half,
- light=1/5,
- },
- ["_outer_half_raised"] = {
- mesh = "moreblocks_slope_outer_half_raised.obj",
- collision_box = box_slope_outer_half_raised,
- selection_box = box_slope_outer_half_raised,
- light=4/5,
- },
- --==============================================================
- ["_outer_cut"] = {
- mesh = "moreblocks_slope_outer_cut.obj",
- collision_box = box_slope_outer,
- selection_box = box_slope_outer,
- light=1/4,
- },
- ["_outer_cut_half"] = {
- mesh = "moreblocks_slope_outer_cut_half.obj",
- collision_box = box_slope_outer_half,
- selection_box = box_slope_outer_half,
- light=1/8,
- },
- ["_outer_cut_half_raised"] = {
- mesh = "moreblocks_slope_outer_cut_half_raised.obj",
- collision_box = box_slope_outer_half_raised,
- selection_box = box_slope_outer_half_raised,
- light=3/8,
- },
- ["_cut"] = {
- mesh = "moreblocks_slope_cut.obj",
- collision_box = box_slope_outer,
- selection_box = box_slope_outer,
- light=1/2,
- },
- -- Additional custom slopes.
- ["_xslope_quarter"] = {
- mesh = "xslopes_quarter.obj",
- collision_box = xslope_quarter,
- selection_box = xslope_quarter,
- light=1/5,
- },
- ["_xslope_quarter2"] = {
- mesh = "xslopes_quarter2.obj",
- collision_box = xslope_quarter2,
- selection_box = xslope_quarter2,
- light=1/5,
- },
- ["_xslope_three_quarter"] = {
- mesh = "xslopes_three_quarter.obj",
- collision_box = xslope_three_quarter,
- selection_box = xslope_three_quarter,
- light=3/5,
- },
- ["_xslope_three_quarter_half"] = {
- mesh = "xslopes_three_quarter_half.obj",
- collision_box = xslope_three_quarter_half,
- selection_box = xslope_three_quarter_half,
- light=2/5,
- },
- ["_xslope_cut"] = {
- mesh = "xslopes_cut.obj",
- collision_box = xslope_cut,
- selection_box = xslope_cut,
- light=1/2,
- },
- ["_xslope_slope"] = {
- mesh = "xslopes_slope.obj",
- collision_box = xslope_slope,
- selection_box = xslope_slope,
- light=1/4,
- },
- ["_xslope_peak"] = {
- mesh = "xslopes_peak.obj",
- collision_box = xslope_peak,
- selection_box = xslope_peak,
- light=2/4,
- },
- ["_xslope_peak_half"] = {
- mesh = "xslopes_peak_half.obj",
- collision_box = xslope_peak_half,
- selection_box = xslope_peak_half,
- light=1/4,
- },
- ["_lh"] = {
- mesh = "moreblocks_slope_lh.obj",
- collision_box = box_slope_lh,
- selection_box = box_slope_lh,
- light=1/4,
- },
- ["_half_lh"] = {
- mesh = "moreblocks_slope_half_lh.obj",
- collision_box = box_slope_half_lh,
- selection_box = box_slope_half_lh,
- light=1/8,
- },
- ["_half_raised_lh"] = {
- mesh = "moreblocks_slope_half_raised_lh.obj",
- collision_box = box_slope_half_raised_lh,
- selection_box = box_slope_half_raised_lh,
- light=3/8,
- },
- ["_xslope_slope_lh"] = {
- mesh = "xslopes_slope_lh.obj",
- collision_box = xslope_slope_lh,
- selection_box = xslope_slope_lh,
- light=1/8,
- },
- ["_xslope_peak_lh"] = {
- mesh = "xslopes_peak_lh.obj",
- collision_box = xslope_peak_lh,
- selection_box = xslope_peak_lh,
- light=2/8,
- },
- ["_xslope_peak_half_lh"] = {
- mesh = "xslopes_peak_half_lh.obj",
- collision_box = xslope_peak_half_lh,
- selection_box = xslope_peak_half_lh,
- light=1/8,
- },
- ["_rh"] = {
- mesh = "moreblocks_slope_rh.obj",
- collision_box = box_slope_rh,
- selection_box = box_slope_rh,
- light=1/4,
- },
- ["_half_rh"] = {
- mesh = "moreblocks_slope_half_rh.obj",
- collision_box = box_slope_half_rh,
- selection_box = box_slope_half_rh,
- light=1/8,
- },
- ["_half_raised_rh"] = {
- mesh = "moreblocks_slope_half_raised_rh.obj",
- collision_box = box_slope_half_raised_rh,
- selection_box = box_slope_half_raised_rh,
- light=3/8,
- },
- ["_xslope_slope_rh"] = {
- mesh = "xslopes_slope_rh.obj",
- collision_box = xslope_slope_rh,
- selection_box = xslope_slope_rh,
- light=1/8,
- },
- ["_astair_1"] = {
- mesh = "astair_1.obj",
- collision_box = astair_1,
- selection_box = astair_1,
- light=1/3,
- },
- ["_astair_2"] = {
- mesh = "astair_2.obj",
- collision_box = astair_2,
- selection_box = astair_2,
- light=1/3,
- },
- ["_astair_3"] = {
- mesh = "astair_3.obj",
- collision_box = astair_3,
- selection_box = astair_3,
- light=1/3,
- },
- ["_astair_4"] = {
- mesh = "astair_4.obj",
- collision_box = astair_4,
- selection_box = astair_4,
- light=1/3,
- },
- ["_astair_5"] = {
- mesh = "moreblocks_slope_inner_cut8.obj",
- collision_box = box_regular,
- selection_box = box_regular,
- light=4/5,
- },
- }
- function stairs.register_slopes(subname, recipeitem, groups, images, description, sounds)
- local stair_images = {}
- for i, image in ipairs(images) do
- if type(image) == "string" then
- stair_images[i] = {
- name = image,
- backface_culling = true,
- }
- elseif image.backface_culling == nil then -- override using any other value
- stair_images[i] = table.copy(image)
- stair_images[i].backface_culling = true
- end
- end
- local defs = table.copy(slopes_defs)
- -- Do not modify function argument.
- local groups = table.copy(groups)
- groups.stairs_slope = 1
- groups.not_in_craft_guide = 1
- groups.stairs_node = 1
- local ndef = minetest.registered_items[recipeitem]
- assert(ndef)
-
- for alternate, def in pairs(defs) do
- --if not alternate:find("_xslope_") or minetest.settings:get("port") == "30001" then
- def.drawtype = "mesh"
- def.paramtype = "light"
- def.paramtype2 = "facedir"
- def.on_place = function(...) return stairs.rotate_and_place(...) end
- def.groups = groups
- def.sounds = sounds
- def.description = description
- def.tiles = stair_images
- def.light_source = math.ceil(ndef.light_source*(def.light or 0))
- def.light = nil
- stairs.setup_nodedef_callbacks(subname, def)
-
- minetest.register_node(":stairs:slope_" ..subname..alternate, def)
- --end
- end
- if recipeitem then
- circular_saw.known_nodes[recipeitem] = {"stairs", subname}
- end
- end
|