diff --git a/.editorconfig b/.editorconfig index a41c6970..609e645a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,5 @@ +# See https://editorconfig.org/ + root = true [*] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8f4bda8..6780b3bc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,16 +9,17 @@ jobs: - uses: actions/checkout@master - uses: actions/setup-python@master - - run: | - sudo apt-get update -qq - sudo apt-get install -qqq luarocks - name: Install pre-commit run: pip3 install pre-commit - - name: Install LuaCheck + - name: install luarocks + run: sudo apt-get install -qq luarocks + + - name: install luacheck via luarocks run: luarocks install --local luacheck - - name: Run LuaCheck using pre-commit - run: | - pre-commit run --all-files - $HOME/.luarocks/bin/luacheck . + - name: add luacheck path + run: echo "$HOME/.luarocks/bin" >> $GITHUB_PATH + + - name: Run pre-commit + run: pre-commit run --all-files diff --git a/.luacheckrc b/.luacheckrc deleted file mode 100644 index 78ebf0bd..00000000 --- a/.luacheckrc +++ /dev/null @@ -1,34 +0,0 @@ -std = "lua51+minetest" -unused_args = false -allow_defined_top = true -max_line_length = 999 - -stds.minetest = { - read_globals = { - "DIR_DELIM", - "minetest", - "core", - "dump", - "vector", - "nodeupdate", - "VoxelManip", - "VoxelArea", - "PseudoRandom", - "ItemStack", - "default", - table = { - fields = { - "copy", - }, - }, - } -} - -read_globals = { - "protector", - "isprotect", - "IsPlayerNodeOwner", - "HasOwner", - "getLastOwner", - "GetNodeOwnerName", -} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a52dbb27..d7acf250 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,4 +7,43 @@ repos: - id: trailing-whitespace - id: mixed-line-ending - args: [--fix=lf] + args: [ --fix=lf ] + + - repo: local + hooks: + - id: luacheck_invsaw + name: luacheck_invsaw + language: system + entry: luacheck + pass_filenames: false + args: [--config,./invsaw/.luacheckrc,-q,./invsaw] + - id: luacheck_moreblocks + name: luacheck_moreblocks + language: system + entry: luacheck + pass_filenames: false + args: [--config,./moreblocks/.luacheckrc,-q,./moreblocks] + - id: luacheck_moreblocks_legacy_recipes + name: luacheck_moreblocks_legacy_recipes + language: system + entry: luacheck + pass_filenames: false + args: [--config,./moreblocks_legacy_recipes/.luacheckrc,-q,./moreblocks_legacy_recipes] + - id: luacheck_stairs + name: luacheck_stairs + language: system + entry: luacheck + pass_filenames: false + args: [--config,./stairs/.luacheckrc,-q,./stairs] + - id: luacheck_stairsplus + name: luacheck_stairsplus + language: system + entry: luacheck + pass_filenames: false + args: [--config,./stairsplus/.luacheckrc,-q,./stairsplus] + - id: luacheck_stairsplus_legacy + name: luacheck_stairsplus_legacy + language: system + entry: luacheck + pass_filenames: false + args: [--config,./stairsplus_legacy/.luacheckrc,-q,./stairsplus_legacy] diff --git a/CHANGELOG.md b/CHANGELOG.md index a441fdbd..64237ff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [3.0.0] - 2022-06-11 + +### Changed + +- turned into a modpack (i.e. properly separated moreblocks and stairsplus) +- refactored and rewrote a ton of stuff +- got rid of some dead code (e.g. "ownership.lua") +- parameterized resources (sounds, textures, craft materials) to make it easier to integrate w/ other minetest "games" +- actually implement luachecking - stop ignoring problems +- fix some unreported bugs (e.g. dependencies which weren't declared, unused code) +- i'm rewriting large parts of the mod and creating a saner API, i'm bumping the version +- \[moreblocks] more API for creating node variants, e.g. trap nodes, all_faces, shapes +- \[stairsplus] create a default-on "legacy" mode to allow new servers to not commit to creating so many useless nodes and shapes by default + +### Fixed + +- [stairsplus:register_custom_subset computes the wrong "cost" for elements](https://github.com/minetest-mods/moreblocks/issues/190) +- [Material disappears from Recycle output slot](https://github.com/minetest-mods/moreblocks/issues/189) +- [Would it be possible to port to mineclone?](https://github.com/minetest-mods/moreblocks/issues/188) - no plan to + actually make moreblocks mineclone-aware, but laid the groundwork to make this very easy. +- [Minor issue causing warnings in MT 5.5.0 with texture alpha clipping](https://github.com/minetest-mods/moreblocks/issues/187) +- maybe: [world aligned textures](https://github.com/minetest-mods/moreblocks/issues/179) +- maybe: [Make microblocks work for nodes with layered textures](https://github.com/minetest-mods/moreblocks/issues/178) +- [Make variants of nodes that can burn also burnable](https://github.com/minetest-mods/moreblocks/issues/177) +- [Add screenshot in README.md](https://github.com/minetest-mods/moreblocks/issues/151) +- [Slab back to full block](https://github.com/minetest-mods/moreblocks/issues/112) +- [Conserve left-over microblocks](https://github.com/minetest-mods/moreblocks/pull/108) +- maybe some of the other bugs/PRS, but they mostly either seem to be fixed or unfixable + +\* not yet fixed, but planned + ## [2.2.0] - 2021-06-28 ### Changed @@ -133,10 +164,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Initial versioned release. -[Unreleased]: https://github.com/minetest-mods/moreblocks/compare/v2.2.0...HEAD +[Unreleased]: https://github.com/minetest-mods/moreblocks/compare/v3.0.0...HEAD + +[3.0.0]: https://github.com/minetest-mods/moreblocks/compare/v2.2.0...v3.0.0 + [2.2.0]: https://github.com/minetest-mods/moreblocks/compare/v2.1.0...v2.2.0 + [2.1.0]: https://github.com/minetest-mods/moreblocks/compare/v2.0.0...v2.1.0 + [2.0.0]: https://github.com/minetest-mods/moreblocks/compare/v1.3.0...v2.0.0 + [1.3.0]: https://github.com/minetest-mods/moreblocks/compare/v1.2.0...v1.3.0 + [1.2.0]: https://github.com/minetest-mods/moreblocks/compare/v1.1.0...v1.2.0 + [1.1.0]: https://github.com/minetest-mods/moreblocks/compare/v1.0.0...v1.1.0 diff --git a/LICENSE.md b/LICENSE.md index 67f5f7f0..7c4eb713 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -2,12 +2,17 @@ Copyright © 2011-2020 Hugo Locurcio and contributors -**This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.** +**This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held +liable for any damages arising from the use of this software.** -Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it +and redistribute it freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If + you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not + required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original + software. 3. This notice may not be removed or altered from any source distribution. diff --git a/README.md b/README.md index 2d5d575e..2b81a08d 100644 --- a/README.md +++ b/README.md @@ -3,73 +3,110 @@ More Blocks for [Minetest](https://www.minetest.net/), a free and open source infinite world block sandbox game. -[**Forum topic**](https://forum.minetest.net/viewtopic.php?f=11&t=509) +![Screenshot](https://github.com/fluxionary/minetest-moreblocks/raw/bugfixes/screenshot.png) -## Installation +Stairsplus adds a large variety of new shapes for registered nodes: -### Download the mod +![Screenshot](https://github.com/fluxionary/minetest-moreblocks/raw/bugfixes/screenshot2.png) -To install More Blocks, clone this Git repository into your Minetest's `mods/` -directory: +![Screenshot](https://github.com/fluxionary/minetest-moreblocks/raw/bugfixes/screenshot3.png) -```bash -git clone https://github.com/minetest-mods/moreblocks.git -``` +[Forum topic](https://forum.minetest.net/viewtopic.php?f=11&t=509) -You can also -[download a ZIP archive](https://github.com/minetest-mods/moreblocks/archive/master.zip) -of More Blocks. +[Content DB entry](https://content.minetest.net/packages/Calinou/moreblocks/) -### Enable the mod +[Source repo](https://github.com/minetest-mods/moreblocks/) -Once you have installed More Blocks, you need to enable it in Minetest. -The procedure is as follows: +# Mods in the pack -#### Using the client's main menu +## moreblocks -This is the easiest way to enable More Blocks when playing in singleplayer -(or on a server hosted from a client). +Defines a bunch of new kinds of nodes. Provides an API for creating variants of some nodes. -1. Start Minetest and switch to the **Local Game** tab. -2. Select the world you want to enable More Blocks in. -3. Click **Configure**, then enable `moreblocks` by double-clicking it - (or ticking the **Enabled** checkbox). -4. Save the changes, then start a game on the world you enabled More Blocks on. -5. More Blocks should now be running on your world. +## stairsplus -#### Using a text editor +Allows the creation of 49 new shapes for registered nodes. -This is the recommended way to enable the mod on a server without using a GUI. +## stairsplus_legacy -1. Make sure Minetest is not currently running (otherwise, it will overwrite - the changes when exiting). -2. Open the world's `world.mt` file using a text editor. -3. Add the following line at the end of the file: +Stairsplus registrations for various mods which were formerly done automatically as part of moreblocks. -```text -load_mod_moreblocks = true -``` +## invsaw -If the line is already present in the file, then replace `false` with `true` -on that line. +Adds a button in unified_inventory that allows you to use the circular saw interface if you are +playing creatively, or have a circular saw item in your inventory and have the right priv +(`interact`, by default). -4. Save the file, then start a game on the world you enabled More Blocks on. -5. More Blocks should now be running on your world. +Invsaw was taken from [cheapie's invsaw mod](https://forum.minetest.net/viewtopic.php?t=14736), which +itself borrowed heavily from an older version of this mod. Flux decided to just add it here because it +needed to be fully rewritten to be compatible w/ their modifications to the stairsplus API. -## Version compatibility +# Documentation -More Blocks is currently primarily tested with Minetest 5.3.0. -It may or may not work with newer or older versions. Issues arising in older -versions than 5.0.0 will generally not be fixed. +## For players -## License +Use of a decent inventory manager (e.g. +[unified_inventory](https://content.minetest.net/packages/RealBadAngel/unified_inventory/) or +[i3](https://content.minetest.net/packages/jp/i3/)) will help you figure out how to craft various nodes. -Copyright © 2011-2020 Hugo Locurcio and contributors +## For admins + +### Minetest Version compatibility + +More Blocks is currently primarily tested with Minetest 5.5.0+. It may or may not work with newer or +older versions. Issues arising in older versions will generally not be fixed. + +### Legacy mode + +The 3.0.0 release of moreblocks introduces a "legacy" mode, which is on by default, and is meant to +allow new servers to not commit to creating as many nodes as older versions, while not breaking anything +on existing servers. See `settingtypes.txt` for available settings. + +By defaulthe 3.0.0 release disables certain recipe overrides that were part of moreblocks 2.*. To re-enable +them, set `moreblocks_legacy_recipes.enabled = true`. + +### Settings + +See `settingtypes.txt` for available settings. + +### Dependencies + +Moreblocks and stairsplus do not have hard dependencies on other mods. Invsaw depends on `unified_inventory` +and stairsplus. + +### Compatability + +Moreblocks currently supports resources from a number of mods and minetest_game. Without these installed, +some things may not be craftable, may have low-quality textures, or may not have "node sounds" registered. +If available, resources will be used from `bucket`, `default`, `rhotator`, `screwdriver`, and `vessels`. + +If the `stairsplus_legacy` mod is enabled, stairsplus nodes will automatically be registered for the following +mods, if they are available: `basic_materials`, `default`, `farming`, `gloopblocks`, `prefab`, `technic`, +and `wool`. + +## For mod makers + +See moreblocks/API.md and stairsplus/API.md. + +# License + +## moreblocks, stairsplus, stairsplus legacy +Copyright © 2011-2022 Hugo Locurcio and contributors - More Blocks code is licensed under the zlib license, see [`LICENSE.md`](LICENSE.md) for details. +- This is an altered version of the code which is not distributed by Hugo Locurcio. + - Unless otherwise specified, More Blocks textures are licensed under [CC BY-SA 3.0 Unported](https://creativecommons.org/licenses/by-sa/3.0/). +- `moreblocks_copperpatina.png` was created by pithydon, and is licensed under + [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/). +- `stairsplus_saw_button.png` CC BY-SA 3.0 Unported + +## invsaw -`moreblocks_copperpatina.png` was created by pithydon, and is licensed under -[CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/). +Copyright © ?-2022 cheapie and contributors + +- invsaw code is licensed under the zlib license, see + [`LICENSE.md`](LICENSE.md) for details. +- This is an altered version of the code which is not distributed by cheapie. diff --git a/circular_saw.lua b/circular_saw.lua deleted file mode 100644 index 4c5da34c..00000000 --- a/circular_saw.lua +++ /dev/null @@ -1,477 +0,0 @@ ---[[ -More Blocks: circular saw - -Copyright © 2011-2020 Hugo Locurcio, Sokomine and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - -local S = moreblocks.S -local F = minetest.formspec_escape - -circular_saw = {} - -circular_saw.known_stairs = setmetatable({}, { - __newindex = function(k, v) - local modname = minetest.get_current_modname() - print(("WARNING: mod %s tried to add node %s to the circular saw manually."):format(modname, v)) - end, -}) - --- This is populated by stairsplus:register_all: -circular_saw.known_nodes = {} - --- How many microblocks does this shape at the output inventory cost: --- It may cause slight loss, but no gain. -circular_saw.cost_in_microblocks = { - 1, 1, 1, 1, 1, 1, 1, 2, - 2, 3, 2, 4, 2, 4, 5, 6, - 7, 1, 1, 2, 4, 6, 7, 8, - 1, 2, 2, 3, 1, 1, 2, 4, - 4, 2, 6, 7, 3, 7, 7, 4, - 8, 3, 2, 6, 2, 1, 3, 4 -} - -circular_saw.names = { - {"micro", "_1"}, - {"panel", "_1"}, - {"micro", "_2"}, - {"panel", "_2"}, - {"micro", "_4"}, - {"panel", "_4"}, - {"micro", ""}, - {"panel", ""}, - - {"micro", "_12"}, - {"panel", "_12"}, - {"micro", "_14"}, - {"panel", "_14"}, - {"micro", "_15"}, - {"panel", "_15"}, - {"stair", "_outer"}, - {"stair", ""}, - - {"stair", "_inner"}, - {"slab", "_1"}, - {"slab", "_2"}, - {"slab", "_quarter"}, - {"slab", ""}, - {"slab", "_three_quarter"}, - {"slab", "_14"}, - {"slab", "_15"}, - - {"slab", "_two_sides"}, - {"slab", "_three_sides"}, - {"slab", "_three_sides_u"}, - {"stair", "_half"}, - {"stair", "_alt_1"}, - {"stair", "_alt_2"}, - {"stair", "_alt_4"}, - {"stair", "_alt"}, - - {"slope", ""}, - {"slope", "_half"}, - {"slope", "_half_raised"}, - {"slope", "_inner"}, - {"slope", "_inner_half"}, - {"slope", "_inner_half_raised"}, - {"slope", "_inner_cut"}, - {"slope", "_inner_cut_half"}, - - {"slope", "_inner_cut_half_raised"}, - {"slope", "_outer"}, - {"slope", "_outer_half"}, - {"slope", "_outer_half_raised"}, - {"slope", "_outer_cut"}, - {"slope", "_outer_cut_half"}, - {"slope", "_outer_cut_half_raised"}, - {"slope", "_cut"}, -} - -function circular_saw:get_cost(inv, stackname) - local name = minetest.registered_aliases[stackname] or stackname - for i, item in pairs(inv:get_list("output")) do - if item:get_name() == name then - return circular_saw.cost_in_microblocks[i] - end - end -end - -function circular_saw:get_output_inv(modname, material, amount, max) - if (not max or max < 1 or max > 99) then max = 99 end - - local list = {} - local pos = #list - - -- If there is nothing inside, display empty inventory: - if amount < 1 then - return list - end - - for i = 1, #circular_saw.names do - local t = circular_saw.names[i] - local cost = circular_saw.cost_in_microblocks[i] - local balance = math.min(math.floor(amount/cost), max) - local nodename = modname .. ":" .. t[1] .. "_" .. material .. t[2] - if minetest.registered_nodes[nodename] then - pos = pos + 1 - list[pos] = nodename .. " " .. balance - end - end - return list -end - - --- Reset empty circular_saw after last full block has been taken out --- (or the circular_saw has been placed the first time) --- Note: max_offered is not reset: -function circular_saw:reset(pos) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local owned_by = meta:get_string("owner") - - if owned_by and owned_by ~= "" then - owned_by = (" ("..S("owned by @1", meta:get_string("owner"))..")") - else - owned_by = "" - end - - inv:set_list("input", {}) - inv:set_list("micro", {}) - inv:set_list("output", {}) - - meta:set_int("anz", 0) - meta:set_string("infotext", S("Circular Saw is empty") .. owned_by) -end - - --- Player has taken something out of the box or placed something inside --- that amounts to count microblocks: -function circular_saw:update_inventory(pos, amount) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - - amount = meta:get_int("anz") + amount - - -- The material is recycled automatically. - inv:set_list("recycle", {}) - - if amount < 1 then -- If the last block is taken out. - self:reset(pos) - return - end - - local stack = inv:get_stack("input", 1) - -- At least one "normal" block is necessary to see what kind of stairs are requested. - if stack:is_empty() then - -- Any microblocks not taken out yet are now lost. - -- (covers material loss in the machine) - self:reset(pos) - return - - end - local node_name = stack:get_name() or "" - local node_def = stack:get_definition() - local name_parts = circular_saw.known_nodes[node_name] or "" - local modname = name_parts[1] or "" - local material = name_parts[2] or "" - local owned_by = meta:get_string("owner") - - if owned_by and owned_by ~= "" then - owned_by = (" ("..S("owned by @1", meta:get_string("owner"))..")") - else - owned_by = "" - end - - inv:set_list("input", { -- Display as many full blocks as possible: - node_name.. " " .. math.floor(amount / 8) - }) - - -- The stairnodes made of default nodes use moreblocks namespace, other mods keep own: - if modname == "default" then - modname = "moreblocks" - end - -- print("circular_saw set to " .. modname .. " : " - -- .. material .. " with " .. (amount) .. " microblocks.") - - -- 0-7 microblocks may remain left-over: - inv:set_list("micro", { - modname .. ":micro_" .. material .. " " .. (amount % 8) - }) - -- Display: - inv:set_list("output", - self:get_output_inv(modname, material, amount, - meta:get_int("max_offered"))) - -- Store how many microblocks are available: - meta:set_int("anz", amount) - - meta:set_string("infotext", - S("Circular Saw is working on @1", - node_def and node_def.description or material - ) .. owned_by - ) -end - - --- The amount of items offered per shape can be configured: -function circular_saw.on_receive_fields(pos, formname, fields, sender) - local meta = minetest.get_meta(pos) - local max = tonumber(fields.max_offered) - if max and max > 0 then - meta:set_string("max_offered", max) - -- Update to show the correct number of items: - circular_saw:update_inventory(pos, 0) - end -end - - --- Moving the inventory of the circular_saw around is not allowed because it --- is a fictional inventory. Moving inventory around would be rather --- impractical and make things more difficult to calculate: -function circular_saw.allow_metadata_inventory_move( - pos, from_list, from_index, to_list, to_index, count, player) - return 0 -end - - --- Only input- and recycle-slot are intended as input slots: -function circular_saw.allow_metadata_inventory_put( - pos, listname, index, stack, player) - -- The player is not allowed to put something in there: - if listname == "output" or listname == "micro" then - return 0 - end - - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local stackname = stack:get_name() - local count = stack:get_count() - - -- Only allow those items that are offered in the output inventory to be recycled: - if listname == "recycle" then - if not inv:contains_item("output", stackname) then - return 0 - end - local stackmax = stack:get_stack_max() - local instack = inv:get_stack("input", 1) - local microstack = inv:get_stack("micro", 1) - local incount = instack:get_count() - local incost = (incount * 8) + microstack:get_count() - local maxcost = (stackmax * 8) + 7 - local cost = circular_saw:get_cost(inv, stackname) - if (incost + cost) > maxcost then - return math.max((maxcost - incost) / cost, 0) - end - return count - end - - -- Only accept certain blocks as input which are known to be craftable into stairs: - if listname == "input" then - if not inv:is_empty("input") then - if inv:get_stack("input", index):get_name() ~= stackname then - return 0 - end - end - if not inv:is_empty("micro") then - local microstackname = inv:get_stack("micro", 1):get_name():gsub("^.+:micro_", "", 1) - local cutstackname = stackname:gsub("^.+:", "", 1) - if microstackname ~= cutstackname then - return 0 - end - end - for name, t in pairs(circular_saw.known_nodes) do - if name == stackname and inv:room_for_item("input", stack) then - return count - end - end - return 0 - end -end - --- Taking is allowed from all slots (even the internal microblock slot). --- Putting something in is slightly more complicated than taking anything --- because we have to make sure it is of a suitable material: -function circular_saw.on_metadata_inventory_put( - pos, listname, index, stack, player) - -- We need to find out if the circular_saw is already set to a - -- specific material or not: - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local stackname = stack:get_name() - local count = stack:get_count() - - -- Putting something into the input slot is only possible if that had - -- been empty before or did contain something of the same material: - if listname == "input" then - -- Each new block is worth 8 microblocks: - circular_saw:update_inventory(pos, 8 * count) - elseif listname == "recycle" then - -- Lets look which shape this represents: - local cost = circular_saw:get_cost(inv, stackname) - local input_stack = inv:get_stack("input", 1) - -- check if this would not exceed input itemstack max_stacks - if input_stack:get_count() + ((cost * count) / 8) <= input_stack:get_stack_max() then - circular_saw:update_inventory(pos, cost * count) - end - end -end - -function circular_saw.allow_metadata_inventory_take(pos, listname, index, stack, player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local input_stack = inv:get_stack(listname, index) - local player_inv = player:get_inventory() - if not player_inv:room_for_item("main", input_stack) then - return 0 - else return stack:get_count() - end -end - -function circular_saw.on_metadata_inventory_take( - pos, listname, index, stack, player) - - -- Prevent (inbuilt) swapping between inventories with different blocks - -- corrupting player inventory or Saw with 'unknown' items. - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local input_stack = inv:get_stack(listname, index) - if not input_stack:is_empty() and input_stack:get_name()~=stack:get_name() then - local player_inv = player:get_inventory() - - -- Prevent arbitrary item duplication. - inv:remove_item(listname, input_stack) - - if player_inv:room_for_item("main", input_stack) then - player_inv:add_item("main", input_stack) - end - - circular_saw:reset(pos) - return - end - - -- If it is one of the offered stairs: find out how many - -- microblocks have to be subtracted: - if listname == "output" then - -- We do know how much each block at each position costs: - local cost = circular_saw.cost_in_microblocks[index] - * stack:get_count() - - circular_saw:update_inventory(pos, -cost) - elseif listname == "micro" then - -- Each microblock costs 1 microblock: - circular_saw:update_inventory(pos, -stack:get_count()) - elseif listname == "input" then - -- Each normal (= full) block taken costs 8 microblocks: - circular_saw:update_inventory(pos, 8 * -stack:get_count()) - end - -- The recycle field plays no role here since it is processed immediately. -end - -local has_default_mod = minetest.get_modpath("default") - -function circular_saw.on_construct(pos) - local meta = minetest.get_meta(pos) - local fancy_inv = "" - if has_default_mod then - -- prepend background and slot styles from default if available - fancy_inv = default.gui_bg..default.gui_bg_img..default.gui_slots - end - meta:set_string( - --FIXME Not work with @n in this part bug in minetest/minetest#7450. - "formspec", "size[11,10]"..fancy_inv.. - "label[0,0;" ..S("Input material").. "]" .. - "list[current_name;input;1.7,0;1,1;]" .. - "label[0,1;" ..F(S("Left-over")).. "]" .. - "list[current_name;micro;1.7,1;1,1;]" .. - "label[0,2;" ..F(S("Recycle output")).. "]" .. - "list[current_name;recycle;1.7,2;1,1;]" .. - "field[0.3,3.5;1,1;max_offered;" ..F(S("Max")).. ":;${max_offered}]" .. - "button[1,3.2;1.7,1;Set;" ..F(S("Set")).. "]" .. - "list[current_name;output;2.8,0;8,6;]" .. - "list[current_player;main;1.5,6.25;8,4;]" .. - "listring[current_name;output]" .. - "listring[current_player;main]" .. - "listring[current_name;input]" .. - "listring[current_player;main]" .. - "listring[current_name;micro]" .. - "listring[current_player;main]" .. - "listring[current_name;recycle]" .. - "listring[current_player;main]" - ) - - meta:set_int("anz", 0) -- No microblocks inside yet. - meta:set_string("max_offered", 99) -- How many items of this kind are offered by default? - meta:set_string("infotext", S("Circular Saw is empty")) - - local inv = meta:get_inventory() - inv:set_size("input", 1) -- Input slot for full blocks of material x. - inv:set_size("micro", 1) -- Storage for 1-7 surplus microblocks. - inv:set_size("recycle", 1) -- Surplus partial blocks can be placed here. - inv:set_size("output", 6*8) -- 6x8 versions of stair-parts of material x. - - circular_saw:reset(pos) -end - - -function circular_saw.can_dig(pos,player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - if not inv:is_empty("input") or - not inv:is_empty("micro") or - not inv:is_empty("recycle") then - return false - end - -- Can be dug by anyone when empty, not only by the owner: - return true -end - -minetest.register_node("moreblocks:circular_saw", { - description = S("Circular Saw"), - drawtype = "nodebox", - node_box = { - type = "fixed", - fixed = { - {-0.4, -0.5, -0.4, -0.25, 0.25, -0.25}, -- Leg - {0.25, -0.5, 0.25, 0.4, 0.25, 0.4}, -- Leg - {-0.4, -0.5, 0.25, -0.25, 0.25, 0.4}, -- Leg - {0.25, -0.5, -0.4, 0.4, 0.25, -0.25}, -- Leg - {-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- Tabletop - {-0.01, 0.4375, -0.125, 0.01, 0.5, 0.125}, -- Saw blade (top) - {-0.01, 0.375, -0.1875, 0.01, 0.4375, 0.1875}, -- Saw blade (bottom) - {-0.25, -0.0625, -0.25, 0.25, 0.25, 0.25}, -- Motor case - }, - }, - tiles = {"moreblocks_circular_saw_top.png", - "moreblocks_circular_saw_bottom.png", - "moreblocks_circular_saw_side.png"}, - paramtype = "light", - sunlight_propagates = true, - paramtype2 = "facedir", - groups = {choppy = 2,oddly_breakable_by_hand = 2}, - sounds = moreblocks.node_sound_wood_defaults(), - on_construct = circular_saw.on_construct, - can_dig = circular_saw.can_dig, - -- Set the owner of this circular saw. - after_place_node = function(pos, placer) - local meta = minetest.get_meta(pos) - local owner = placer and placer:get_player_name() or "" - local owned_by = owner - - if owner ~= "" then - owned_by = (" (%s)"):format(S("owned by @1", owner)) - end - - meta:set_string("owner", owner) - meta:set_string("infotext", S("Circular Saw is empty") .. owned_by) - end, - - -- The amount of items offered per shape can be configured: - on_receive_fields = circular_saw.on_receive_fields, - allow_metadata_inventory_move = circular_saw.allow_metadata_inventory_move, - -- Only input- and recycle-slot are intended as input slots: - allow_metadata_inventory_put = circular_saw.allow_metadata_inventory_put, - allow_metadata_inventory_take = circular_saw.allow_metadata_inventory_take, - -- Taking is allowed from all slots (even the internal microblock slot). Moving is forbidden. - -- Putting something in is slightly more complicated than taking anything because we have to make sure it is of a suitable material: - on_metadata_inventory_put = circular_saw.on_metadata_inventory_put, - on_metadata_inventory_take = circular_saw.on_metadata_inventory_take, -}) diff --git a/config.lua b/config.lua deleted file mode 100644 index 5a9c72c8..00000000 --- a/config.lua +++ /dev/null @@ -1,29 +0,0 @@ ---[[ -More Blocks: configuration handling - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - -moreblocks.config = {} - -local function getbool_default(setting, default) - local value = minetest.settings:get_bool(setting) - if value == nil then - value = default - end - return value -end - -local function setting(settingtype, name, default) - if settingtype == "bool" then - moreblocks.config[name] = - getbool_default("moreblocks." .. name, default) - else - moreblocks.config[name] = - minetest.settings:get("moreblocks." .. name) or default - end -end - --- Show stairs/slabs/panels/microblocks in creative inventory (true or false): -setting("bool", "stairsplus_in_creative_inventory", true) diff --git a/crafting.lua b/crafting.lua deleted file mode 100644 index 0161a2ed..00000000 --- a/crafting.lua +++ /dev/null @@ -1,648 +0,0 @@ ---[[ -More Blocks: crafting recipes - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - -minetest.register_craft({ - output = "default:stick", - recipe = {{"default:dry_shrub"},} -}) - -minetest.register_craft({ - output = "default:stick", - recipe = {{"group:sapling"},} -}) - -minetest.register_craft({ - output = "default:wood", - recipe = { - {"default:stick", "default:stick"}, - {"default:stick", "default:stick"}, - } -}) - -minetest.register_craft({ - output = "default:dirt_with_grass", - type = "shapeless", - recipe = {"default:junglegrass", "default:dirt"}, -}) - -minetest.register_craft({ - output = "default:mossycobble", - type = "shapeless", - recipe = {"default:junglegrass", "default:cobble"}, -}) - -minetest.register_craft({ - output = "moreblocks:wood_tile 9", - recipe = { - {"group:wood", "group:wood", "group:wood"}, - {"group:wood", "group:wood", "group:wood"}, - {"group:wood", "group:wood", "group:wood"}, - } -}) - --- This must be registered after `moreblocks:wood_tile` to avoid recipe conflicts, --- since `moreblocks:wood_tile` is part of `group:wood` -minetest.register_craft({ - output = "moreblocks:wood_tile_center 9", - recipe = { - {"group:wood", "group:wood", "group:wood"}, - {"group:wood", "moreblocks:wood_tile", "group:wood"}, - {"group:wood", "group:wood", "group:wood"}, - } -}) - -minetest.register_craft({ - type = "shapeless", - output = "moreblocks:wood_tile", - recipe = {"moreblocks:wood_tile_flipped"} -}) - -minetest.register_craft({ - output = "moreblocks:wood_tile_full 4", - recipe = { - {"moreblocks:wood_tile", "moreblocks:wood_tile"}, - {"moreblocks:wood_tile", "moreblocks:wood_tile"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:wood_tile_offset", - recipe = { - {"default:stick"}, - {"moreblocks:wood_tile_center"}, - } -}) - -minetest.register_craft({ - type = "shapeless", - output = "moreblocks:wood_tile_offset", - recipe = {"moreblocks:wood_tile_down"} -}) - -minetest.register_craft({ - type = "shapeless", - output = "moreblocks:wood_tile_offset", - recipe = {"moreblocks:wood_tile_left"} -}) - -minetest.register_craft({ - type = "shapeless", - output = "moreblocks:wood_tile_offset", - recipe = {"moreblocks:wood_tile_right"} -}) - -minetest.register_craft({ - output = "moreblocks:circle_stone_bricks 5", - recipe = { - {"", "default:stone", ""}, - {"default:stone", "default:coal_lump", "default:stone"}, - {"", "default:stone", ""}, - } -}) - -minetest.register_craft({ - output = "moreblocks:all_faces_tree 8", - recipe = { - {"default:tree", "default:tree", "default:tree"}, - {"default:tree", "", "default:tree"}, - {"default:tree", "default:tree", "default:tree"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:all_faces_jungle_tree 8", - recipe = { - {"default:jungletree", "default:jungletree", "default:jungletree"}, - {"default:jungletree", "", "default:jungletree"}, - {"default:jungletree", "default:jungletree", "default:jungletree"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:all_faces_pine_tree 8", - recipe = { - {"default:pine_tree", "default:pine_tree", "default:pine_tree"}, - {"default:pine_tree", "", "default:pine_tree"}, - {"default:pine_tree", "default:pine_tree", "default:pine_tree"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:all_faces_acacia_tree 8", - recipe = { - {"default:acacia_tree", "default:acacia_tree", "default:acacia_tree"}, - {"default:acacia_tree", "", "default:acacia_tree"}, - {"default:acacia_tree", "default:acacia_tree", "default:acacia_tree"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:all_faces_aspen_tree 8", - recipe = { - {"default:aspen_tree", "default:aspen_tree", "default:aspen_tree"}, - {"default:aspen_tree", "", "default:aspen_tree"}, - {"default:aspen_tree", "default:aspen_tree", "default:aspen_tree"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:sweeper 4", - recipe = { - {"default:junglegrass"}, - {"default:stick"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:stone_tile 9", - recipe = { - {"default:cobble", "default:cobble", "default:cobble"}, - {"default:cobble", "default:stone", "default:cobble"}, - {"default:cobble", "default:cobble", "default:cobble"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:split_stone_tile", - recipe = { - {"moreblocks:stone_tile"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:checker_stone_tile", - recipe = { - {"moreblocks:split_stone_tile"}, - } -}) - --- When approaching the below craft, loop back to cobblestone, which can then be used to craft stone tiles again -minetest.register_craft({ - output = "default:cobble", - recipe = { - {"moreblocks:checker_stone_tile"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:grey_bricks 2", - type = "shapeless", - recipe = {"default:stone", "default:brick"}, -}) - -minetest.register_craft({ - output = "moreblocks:grey_bricks 2", - type = "shapeless", - recipe = {"default:stonebrick", "default:brick"}, -}) - -minetest.register_craft({ - output = "moreblocks:empty_shelf", - type = "shapeless", - recipe = {"moreblocks:sweeper", "default:bookshelf"}, - replacements = {{"default:bookshelf", "default:book 3"}}, - -- When obtaining an empty shelf, return the books used in it as well -}) - -minetest.register_craft({ - output = "moreblocks:empty_shelf", - type = "shapeless", - recipe = {"moreblocks:sweeper", "vessels:shelf"}, - replacements = {{"vessels:shelf", "vessels:glass_bottle 3"}}, -}) - -minetest.register_craft({ - type = "shapeless", - output = "default:bookshelf", - recipe = {"moreblocks:empty_shelf", "default:book", "default:book", "default:book"}, -}) - -minetest.register_craft({ - output = "moreblocks:empty_shelf", - recipe = { - {"group:wood", "group:wood", "group:wood"}, - {"", "", ""}, - {"group:wood", "group:wood", "group:wood"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:coal_stone_bricks 4", - recipe = { - {"moreblocks:coal_stone", "moreblocks:coal_stone"}, - {"moreblocks:coal_stone", "moreblocks:coal_stone"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:iron_stone_bricks 4", - recipe = { - {"moreblocks:iron_stone", "moreblocks:iron_stone"}, - {"moreblocks:iron_stone", "moreblocks:iron_stone"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:plankstone 4", - recipe = { - {"group:stone", "group:wood"}, - {"group:wood", "group:stone"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:plankstone 4", - recipe = { - {"group:wood", "group:stone"}, - {"group:stone", "group:wood"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:coal_checker 4", - recipe = { - {"default:stone", "default:coal_lump"}, - {"default:coal_lump", "default:stone"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:coal_checker 4", - recipe = { - {"default:coal_lump", "default:stone"}, - {"default:stone", "default:coal_lump"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:iron_checker 4", - recipe = { - {"default:steel_ingot", "default:stone"}, - {"default:stone", "default:steel_ingot"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:iron_checker 4", - recipe = { - {"default:stone", "default:steel_ingot"}, - {"default:steel_ingot", "default:stone"}, - } -}) - -minetest.register_craft({ - output = "default:chest_locked", - type = "shapeless", - recipe = {"default:steel_ingot", "default:chest"}, -}) -minetest.register_craft({ - output = "default:chest_locked", - type = "shapeless", - recipe = {"default:copper_ingot", "default:chest"}, -}) - -minetest.register_craft({ - output = "default:chest_locked", - type = "shapeless", - recipe = {"default:bronze_ingot", "default:chest"}, -}) - -minetest.register_craft({ - output = "default:chest_locked", - type = "shapeless", - recipe = {"default:gold_ingot", "default:chest"}, -}) - -minetest.register_craft({ - output = "moreblocks:iron_glass", - type = "shapeless", - recipe = {"default:steel_ingot", "default:glass"}, -}) - -minetest.register_craft({ - output = "default:glass", - type = "shapeless", - recipe = {"default:coal_lump", "moreblocks:iron_glass"}, -}) - - -minetest.register_craft({ - output = "moreblocks:coal_glass", - type = "shapeless", - recipe = {"default:coal_lump", "default:glass"}, -}) - -minetest.register_craft({ - output = "default:glass", - type = "shapeless", - recipe = {"default:steel_ingot", "moreblocks:coal_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:clean_glass", - type = "shapeless", - recipe = {"moreblocks:sweeper", "default:glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_clean_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_clean_glass", - type = "shapeless", - recipe = {"moreblocks:sweeper", "moreblocks:trap_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:glow_glass", - type = "shapeless", - recipe = {"default:torch", "default:glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:clean_glow_glass", - type = "shapeless", - recipe = {"default:torch", "moreblocks:clean_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:clean_glow_glass", - type = "shapeless", - recipe = {"moreblocks:sweeper", "moreblocks:glow_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "default:glass", "default:torch"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "moreblocks:glow_glass"}, -}) - --- several recipes are possible for the trap+clean+glow, we only present 3 of them -minetest.register_craft({ - output = "moreblocks:trap_clean_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glow_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_clean_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glass", "default:torch"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_clean_glow_glass", - type = "shapeless", - recipe = {"moreblocks:sweeper", "moreblocks:trap_glow_glass" }, -}) - - -minetest.register_craft({ - output = "moreblocks:super_glow_glass", - type = "shapeless", - recipe = {"default:torch", "default:torch", "default:glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:super_glow_glass", - type = "shapeless", - recipe = {"default:torch", "moreblocks:glow_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:clean_super_glow_glass", - type = "shapeless", - recipe = {"default:torch", "default:torch", "moreblocks:clean_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:clean_super_glow_glass", - type = "shapeless", - recipe = {"default:torch", "moreblocks:clean_glow_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:clean_super_glow_glass", - type = "shapeless", - recipe = {"moreblocks:sweeper", "moreblocks:super_glow_glass"}, -}) - - -minetest.register_craft({ - output = "moreblocks:trap_super_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "default:glass", "default:torch", "default:torch"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_super_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "moreblocks:super_glow_glass"}, -}) - --- several recipes are possible for the trap+clean+glow, we only present 4 of them -minetest.register_craft({ - output = "moreblocks:trap_clean_super_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "moreblocks:clean_super_glow_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_clean_super_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glow_glass", "default:torch"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_clean_super_glow_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "moreblocks:clean_glass", "default:torch", "default:torch"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_clean_super_glow_glass", - type = "shapeless", - recipe = {"moreblocks:sweeper", "moreblocks:trap_super_glow_glass" }, -}) - - -minetest.register_craft({ - output = "moreblocks:coal_stone", - type = "shapeless", - recipe = {"default:coal_lump", "default:stone"}, -}) - -minetest.register_craft({ - output = "default:stone", - type = "shapeless", - recipe = {"default:steel_ingot", "moreblocks:coal_stone"}, -}) - -minetest.register_craft({ - output = "moreblocks:iron_stone", - type = "shapeless", - recipe = {"default:steel_ingot", "default:stone"}, -}) - -minetest.register_craft({ - output = "default:stone", - type = "shapeless", - recipe = {"default:coal_lump", "moreblocks:iron_stone"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_stone", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "default:stone"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_desert_stone", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "default:desert_stone"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "default:glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_obsidian_glass", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "default:obsidian_glass"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_obsidian", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "default:obsidian"}, -}) - -minetest.register_craft({ - output = "moreblocks:trap_sandstone", - type = "shapeless", - recipe = {"default:mese_crystal_fragment", "default:sandstone"}, -}) - -minetest.register_craft({ - output = "moreblocks:cactus_brick", - type = "shapeless", - recipe = {"default:cactus", "default:brick"}, -}) - -minetest.register_craft({ - output = "moreblocks:cactus_checker 4", - recipe = { - {"default:cactus", "default:stone"}, - {"default:stone", "default:cactus"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:cactus_checker 4", - recipe = { - {"default:stone", "default:cactus"}, - {"default:cactus", "default:stone"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:rope 3", - recipe = { - {"default:junglegrass"}, - {"default:junglegrass"}, - {"default:junglegrass"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:dirt_compressed", - recipe = { - {'default:dirt', 'default:dirt', 'default:dirt'}, - {'default:dirt', 'default:dirt', 'default:dirt'}, - {'default:dirt', 'default:dirt', 'default:dirt'}, - } -}) - -minetest.register_craft({ - output = "default:dirt 9", - recipe = {{"moreblocks:dirt_compressed"}}, -}) - -minetest.register_craft({ - output = "moreblocks:cobble_compressed", - recipe = { - {"default:cobble", "default:cobble", "default:cobble"}, - {"default:cobble", "default:cobble", "default:cobble"}, - {"default:cobble", "default:cobble", "default:cobble"}, - } -}) - -minetest.register_craft({ - output = "default:cobble 9", - recipe = { - {"moreblocks:cobble_compressed"}, - } -}) - -minetest.register_craft({ - output = "moreblocks:desert_cobble_compressed", - recipe = { - {"default:desert_cobble", "default:desert_cobble", "default:desert_cobble"}, - {"default:desert_cobble", "default:desert_cobble", "default:desert_cobble"}, - {"default:desert_cobble", "default:desert_cobble", "default:desert_cobble"}, - } -}) - -minetest.register_craft({ - output = "default:desert_cobble 9", - recipe = { - {"moreblocks:desert_cobble_compressed"}, - } -}) - -minetest.register_craft({ - type = "cooking", output = "moreblocks:tar", recipe = "default:pine_tree", -}) - -minetest.register_craft({ - type = "shapeless", - output = "moreblocks:copperpatina", - recipe = {"group:water_bucket", "default:copperblock"}, - replacements = { - {"group:water_bucket", "bucket:bucket_empty"} - } -}) - -minetest.register_craft({ - output = "default:copper_ingot 9", - recipe = { - {"moreblocks:copperpatina"}, - } -}) - -if minetest.settings:get_bool("moreblocks.circular_saw_crafting") ~= false then -- “If nil or true then” - minetest.register_craft({ - output = "moreblocks:circular_saw", - recipe = { - { "", "default:steel_ingot", "" }, - { "group:wood", "group:wood", "group:wood"}, - { "group:wood", "", "group:wood"}, - } - }) -end diff --git a/init.lua b/init.lua deleted file mode 100644 index 28768767..00000000 --- a/init.lua +++ /dev/null @@ -1,27 +0,0 @@ ---[[ -===================================================================== -** More Blocks ** -By Calinou, with the help of ShadowNinja and VanessaE. - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. -===================================================================== ---]] - -moreblocks = {} - -local modpath = minetest.get_modpath("moreblocks") - -moreblocks.S = minetest.get_translator("moreblocks") - -dofile(modpath .. "/config.lua") -dofile(modpath .. "/sounds.lua") -dofile(modpath .. "/circular_saw.lua") -dofile(modpath .. "/stairsplus/init.lua") - -if minetest.get_modpath("default") then - dofile(modpath .. "/nodes.lua") - dofile(modpath .. "/redefinitions.lua") - dofile(modpath .. "/crafting.lua") - dofile(modpath .. "/aliases.lua") -end diff --git a/invsaw/.luacheckrc b/invsaw/.luacheckrc new file mode 100644 index 00000000..cf65173e --- /dev/null +++ b/invsaw/.luacheckrc @@ -0,0 +1,656 @@ +std = "lua51+luajit+minetest+invsaw" +unused_args = false +max_line_length = 120 + +stds.minetest = { + read_globals = { + "DIR_DELIM", + "dump", + "dump2", + + math = { + fields = { + abs = {}, + acos = {}, + asin = {}, + atan = {}, + atan2 = {}, + ceil = {}, + cos = {}, + cosh = {}, + deg = {}, + exp = {}, + factorial = {}, + floor = {}, + fmod = {}, + frexp = {}, + huge = {}, + hypot = {}, + ldexp = {}, + log = {}, + log10 = {}, + max = {}, + min = {}, + modf = {}, + pi = {}, + pow = {}, + rad = {}, + random = {}, + randomseed = {}, + round = {}, + sign = {}, + sin = {}, + sinh = {}, + sqrt = {}, + tan = {}, + tanh = {}, + }, + }, + table = { + fields = { + copy = {}, + concat = {}, + foreach = {}, + foreachi = {}, + getn = {}, + indexof = {}, + insert = {}, + insert_all = {}, + key_value_swap = {}, + maxn = {}, + move = {}, + remove = {}, + shuffle = {}, + sort = {}, + }, + }, + string = { + fields = { + byte = {}, + char = {}, + dump = {}, + find = {}, + format = {}, + gmatch = {}, + len = {}, + lower = {}, + match = {}, + rep = {}, + reverse = {}, + split = {}, + sub = {}, + trim = {}, + upper = {}, + }, + }, + vector = { + fields = { + add = {}, + angle = {}, + apply = {}, + check = {}, + combine = {}, + copy = {}, + cross = {}, + dir_to_rotation = {}, + direction = {}, + distance = {}, + divide = {}, + dot = {}, + equals = {}, + floor = {}, + from_string = {}, + length = {}, + metatable = {}, + multiply = {}, + new = {}, + normalize = {}, + offset = {}, + rotate = {}, + rotate_around_axis = {}, + round = {}, + sort = {}, + subtract = {}, + to_string = {}, + zero = {}, + }, + }, + + ItemStack = { + fields = { + add_item = {}, + add_wear = {}, + add_wear_by_uses = {}, + clear = {}, + get_count = {}, + get_definition = {}, + get_description = {}, + get_free_space = {}, + get_meta = {}, + get_metadata = {}, + get_name = {}, + get_short_description = {}, + get_stack_max = {}, + get_tool_capabilities = {}, + get_wear = {}, + is_empty = {}, + is_known = {}, + item_fits = {}, + peek_item = {}, + replace = {}, + set_count = {}, + set_metadata = {}, + set_name = {}, + set_wear = {}, + take_item = {}, + to_string = {}, + to_table = {}, + }, + }, + PerlinNoise = { + fields = { + get_2d = {}, + get_3d = {}, + }, + }, + PerlinNoiseMap = { + fields = { + calc_2d_map = {}, + calc_3d_map = {}, + get_2d_map = {}, + get_2d_map_flat = {}, + get_3d_map = {}, + get_3d_map_flat = {}, + get_map_slice = {}, + }, + }, + PseudoRandom = { + fields = { + next = {}, + }, + }, + PcgRandom = { + fields = { + next = {}, + rand_normal_dist = {}, + }, + }, + SecureRandom = { + fields = { + next_bytes = {}, + }, + }, + Settings = { + fields = { + get = {}, + get_bool = {}, + get_flags = {}, + get_names = {}, + get_np_group = {}, + remove = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + to_table = {}, + write = {}, + }, + }, + VoxelArea = { + fields = { + MaxEdge = {}, + MinEdge = {}, + contains = {}, + containsi = {}, + containsp = {}, + getExtent = {}, + getVolume = {}, + index = {}, + indexp = {}, + iter = {}, + iterp = {}, + new = {}, + position = {}, + ystride = {}, + zstride = {}, + }, + }, + VoxelManip = { + fields = { + calc_lighting = {}, + get_data = {}, + get_emerged_area = {}, + get_light_data = {}, + get_node_at = {}, + get_param2_data = {}, + read_from_map = {}, + set_data = {}, + set_light_data = {}, + set_lighting = {}, + set_node_at = {}, + set_param2_data = {}, + update_liquids = {}, + update_map = {}, + was_modified = {}, + write_to_map = {}, + }, + }, + + minetest = { + fields = { + CONTENT_AIR = {}, + CONTENT_IGNORE = {}, + CONTENT_UNKNOWN = {}, + EMERGE_CANCELLED = {}, + EMERGE_ERRORED = {}, + EMERGE_FROM_DISK = {}, + EMERGE_FROM_MEMORY = {}, + EMERGE_GENERATED = {}, + LIGHT_MAX = {}, + MAP_BLOCKSIZE = {}, + PLAYER_MAX_BREATH_DEFAULT = {}, + PLAYER_MAX_HP_DEFAULT = {}, + add_entity = {}, + add_item = {}, + add_node = {}, + add_node_level = {}, + add_particle = {}, + add_particlespawner = {}, + after = {}, + async_event_handler = {}, + async_jobs = {}, + auth_reload = {}, + ban_player = {}, + builtin_auth_handler = {}, + bulk_set_node = {}, + calculate_knockback = {}, + callback_origins = {}, + cancel_shutdown_requests = {}, + chat_send_all = {}, + chat_send_player = {}, + chatcommands = {}, + check_for_falling = {}, + check_password_entry = {}, + check_player_privs = {}, + check_single_for_falling = {}, + clear_craft = {}, + clear_objects = {}, + clear_registered_biomes = {}, + clear_registered_decorations = {}, + clear_registered_ores = {}, + clear_registered_schematics = {}, + close_formspec = {}, + colorize = {}, + colorspec_to_bytes = {}, + colorspec_to_colorstring = {}, + compare_block_status = {}, + compress = {}, + cpdir = {}, + craft_predict = {}, + craftitemdef_default = {}, + create_detached_inventory = {}, + create_detached_inventory_raw = {}, + create_schematic = {}, + debug = {}, + decode_base64 = {}, + decompress = {}, + delete_area = {}, + delete_particlespawner = {}, + deserialize = {}, + detached_inventories = {}, + dig_node = {}, + dir_to_facedir = {}, + dir_to_wallmounted = {}, + dir_to_yaw = {}, + disconnect_player = {}, + do_async_callback = {}, + do_item_eat = {}, + dynamic_add_media = {}, + dynamic_media_callbacks = {}, + emerge_area = {}, + encode_base64 = {}, + encode_png = {}, + env = {}, + explode_scrollbar_event = {}, + explode_table_event = {}, + explode_textlist_event = {}, + facedir_to_dir = {}, + features = {}, + find_node_near = {}, + find_nodes_in_area = {}, + find_nodes_in_area_under_air = {}, + find_nodes_with_meta = {}, + find_path = {}, + fix_light = {}, + forceload_block = {}, + forceload_free_block = {}, + format_chat_message = {}, + formspec_escape = {}, + generate_decorations = {}, + generate_ores = {}, + get_all_craft_recipes = {}, + get_artificial_light = {}, + get_auth_handler = {}, + get_background_escape_sequence = {}, + get_ban_description = {}, + get_ban_list = {}, + get_biome_data = {}, + get_biome_id = {}, + get_biome_name = {}, + get_builtin_path = {}, + get_color_escape_sequence = {}, + get_connected_players = {}, + get_content_id = {}, + get_craft_recipe = {}, + get_craft_result = {}, + get_current_modname = {}, + get_day_count = {}, + get_decoration_id = {}, + get_dig_params = {}, + get_dir_list = {}, + get_gametime = {}, + get_gen_notify = {}, + get_heat = {}, + get_hit_params = {}, + get_humidity = {}, + get_inventory = {}, + get_item_group = {}, + get_last_run_mod = {}, + get_mapgen_object = {}, + get_mapgen_params = {}, + get_mapgen_setting = {}, + get_mapgen_setting_noiseparams = {}, + get_meta = {}, + get_mod_storage = {}, + get_modnames = {}, + get_modpath = {}, + get_name_from_content_id = {}, + get_natural_light = {}, + get_node = {}, + get_node_drops = {}, + get_node_group = {}, + get_node_level = {}, + get_node_light = {}, + get_node_max_level = {}, + get_node_or_nil = {}, + get_node_timer = {}, + get_noiseparams = {}, + get_objects_in_area = {}, + get_objects_inside_radius = {}, + get_password_hash = {}, + get_perlin = {}, + get_perlin_map = {}, + get_player_by_name = {}, + get_player_information = {}, + get_player_ip = {}, + get_player_privs = {}, + get_player_radius_area = {}, + get_pointed_thing_position = {}, + get_position_from_hash = {}, + get_server_max_lag = {}, + get_server_status = {}, + get_server_uptime = {}, + get_spawn_level = {}, + get_timeofday = {}, + get_tool_wear_after_use = {}, + get_translated_string = {}, + get_translator = {}, + get_us_time = {}, + get_user_path = {}, + get_version = {}, + get_voxel_manip = {}, + get_worldpath = {}, + global_exists = {}, + handle_async = {}, + handle_node_drops = {}, + has_feature = {}, + hash_node_position = {}, + hud_replace_builtin = {}, + inventorycube = {}, + is_area_protected = {}, + is_colored_paramtype = {}, + is_creative_enabled = {}, + is_nan = {}, + is_player = {}, + is_protected = {}, + is_singleplayer = {}, + is_yes = {}, + item_drop = {}, + item_eat = {}, + item_place = {}, + item_place_node = {}, + item_place_object = {}, + item_secondary_use = {}, + itemstring_with_color = {}, + itemstring_with_palette = {}, + kick_player = {}, + line_of_sight = {}, + load_area = {}, + log = {}, + luaentities = {}, + mkdir = {}, + mod_channel_join = {}, + mvdir = {}, + node_dig = {}, + node_punch = {}, + nodedef_default = {}, + noneitemdef_default = {}, + notify_authentication_modified = {}, + object_refs = {}, + on_craft = {}, + override_chatcommand = {}, + override_item = {}, + parse_coordinates = {}, + parse_json = {}, + parse_relative_number = {}, + place_node = {}, + place_schematic = {}, + place_schematic_on_vmanip = {}, + player_exists = {}, + pointed_thing_to_face_pos = {}, + pos_to_string = {}, + print = {}, + privs_to_string = {}, + punch_node = {}, + raillike_group = {}, + raycast = {}, + read_schematic = {}, + record_protection_violation = {}, + register_abm = {}, + register_alias = {}, + register_alias_force = {}, + register_allow_player_inventory_action = {}, + register_async_dofile = {}, + register_authentication_handler = {}, + register_biome = {}, + register_can_bypass_userlimit = {}, + register_chatcommand = {}, + register_craft = {}, + register_craft_predict = {}, + register_craftitem = {}, + register_decoration = {}, + register_entity = {}, + register_globalstep = {}, + register_item = {}, + register_lbm = {}, + register_node = {}, + register_on_auth_fail = {}, + register_on_authplayer = {}, + register_on_chat_message = {}, + register_on_chatcommand = {}, + register_on_cheat = {}, + register_on_craft = {}, + register_on_dieplayer = {}, + register_on_dignode = {}, + register_on_generated = {}, + register_on_item_eat = {}, + register_on_joinplayer = {}, + register_on_leaveplayer = {}, + register_on_liquid_transformed = {}, + register_on_mapgen_init = {}, + register_on_modchannel_message = {}, + register_on_mods_loaded = {}, + register_on_newplayer = {}, + register_on_placenode = {}, + register_on_player_hpchange = {}, + register_on_player_inventory_action = {}, + register_on_player_receive_fields = {}, + register_on_prejoinplayer = {}, + register_on_priv_grant = {}, + register_on_priv_revoke = {}, + register_on_protection_violation = {}, + register_on_punchnode = {}, + register_on_punchplayer = {}, + register_on_respawnplayer = {}, + register_on_rightclickplayer = {}, + register_on_shutdown = {}, + register_ore = {}, + register_playerevent = {}, + register_privilege = {}, + register_schematic = {}, + register_tool = {}, + registered_abms = {other_fields = true}, + registered_aliases = {other_fields = true}, + registered_allow_player_inventory_actions = {other_fields = true}, + registered_biomes = {other_fields = true}, + registered_can_bypass_userlimit = {other_fields = true}, + registered_chatcommands = {other_fields = true}, + registered_craft_predicts = {other_fields = true}, + registered_craftitems = {other_fields = true}, + registered_decorations = {other_fields = true}, + registered_entities = {other_fields = true}, + registered_globalsteps = {other_fields = true}, + registered_items = {other_fields = true}, + registered_lbms = {other_fields = true}, + registered_nodes = {other_fields = true}, + registered_on_authplayers = {other_fields = true}, + registered_on_chat_messages = {other_fields = true}, + registered_on_chatcommands = {other_fields = true}, + registered_on_cheats = {other_fields = true}, + registered_on_crafts = {other_fields = true}, + registered_on_dieplayers = {other_fields = true}, + registered_on_dignodes = {other_fields = true}, + registered_on_generateds = {other_fields = true}, + registered_on_item_eats = {other_fields = true}, + registered_on_joinplayers = {other_fields = true}, + registered_on_leaveplayers = {other_fields = true}, + registered_on_liquid_transformed = {other_fields = true}, + registered_on_modchannel_message = {other_fields = true}, + registered_on_mods_loaded = {other_fields = true}, + registered_on_newplayers = {other_fields = true}, + registered_on_placenodes = {other_fields = true}, + registered_on_player_hpchange = {other_fields = true}, + registered_on_player_hpchanges = {other_fields = true}, + registered_on_player_inventory_actions = {other_fields = true}, + registered_on_player_receive_fields = {other_fields = true}, + registered_on_prejoinplayers = {other_fields = true}, + registered_on_priv_grant = {other_fields = true}, + registered_on_priv_revoke = {other_fields = true}, + registered_on_protection_violation = {other_fields = true}, + registered_on_punchnodes = {other_fields = true}, + registered_on_punchplayers = {other_fields = true}, + registered_on_respawnplayers = {other_fields = true}, + registered_on_rightclickplayers = {other_fields = true}, + registered_on_shutdown = {other_fields = true}, + registered_ores = {other_fields = true}, + registered_playerevents = {other_fields = true}, + registered_privileges = {other_fields = true}, + registered_tools = {other_fields = true}, + remove_detached_inventory = {}, + remove_detached_inventory_raw = {}, + remove_node = {}, + remove_player = {}, + remove_player_auth = {}, + request_http_api = {}, + request_insecure_environment = {}, + request_shutdown = {}, + rgba = {}, + rmdir = {}, + rollback_get_last_node_actor = {}, + rollback_get_node_actions = {}, + rollback_punch_callbacks = {}, + rollback_revert_actions_by = {}, + rotate_and_place = {}, + rotate_node = {}, + run_callbacks = {}, + run_priv_callbacks = {}, + safe_file_write = {}, + send_join_message = {}, + send_leave_message = {}, + serialize = {}, + serialize_roundtrip = {}, + serialize_schematic = {}, + set_gen_notify = {}, + set_last_run_mod = {}, + set_mapgen_params = {}, + set_mapgen_setting = {}, + set_mapgen_setting_noiseparams = {}, + set_node = {}, + set_node_level = {}, + set_noiseparams = {}, + set_player_password = {}, + set_player_privs = {}, + set_timeofday = {}, + setting_get = {}, + setting_get_pos = {}, + setting_getbool = {}, + setting_save = {}, + setting_set = {}, + setting_setbool = {}, + settings = { + fields = { + get = {}, + get_bool = {}, + get_np_group = {}, + get_flags = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + remove = {}, + get_names = {}, + write = {}, + to_table = {}, + }, + }, + sha1 = {}, + show_formspec = {}, + show_general_help_formspec = {}, + show_privs_help_formspec = {}, + sound_fade = {}, + sound_play = {}, + sound_stop = {}, + spawn_falling_node = {}, + spawn_item = {}, + spawn_tree = {}, + string_to_area = {}, + string_to_pos = {}, + string_to_privs = {}, + strip_background_colors = {}, + strip_colors = {}, + strip_foreground_colors = {}, + strip_param2_color = {}, + swap_node = {}, + tooldef_default = {}, + transforming_liquid_add = {}, + translate = {}, + unban_player_or_ip = {}, + unregister_biome = {}, + unregister_chatcommand = {}, + unregister_item = {}, + wallmounted_to_dir = {}, + wrap_text = {}, + write_json = {}, + yaw_to_dir = {}, + }, + }, + } +} + +stds.invsaw = { + globals = { + "invsaw", + }, + read_globals = { + "stairsplus", + "unified_inventory", + }, +} diff --git a/invsaw/api.lua b/invsaw/api.lua new file mode 100644 index 00000000..f7b982b6 --- /dev/null +++ b/invsaw/api.lua @@ -0,0 +1,33 @@ +local server_is_creative = minetest.settings:get_bool("creative_mode", false) + +function invsaw.has_saw_in_inventory(player) + local inv = player:get_inventory() + return inv:contains_item("main", invsaw.settings.saw_item) +end + +function invsaw.can_use_saw(player) + return ( + server_is_creative or + minetest.check_player_privs(player, invsaw.settings.creative_priv) or + minetest.check_player_privs(player, invsaw.settings.priv) + ) +end + +function invsaw.allow_use_saw(player) + return ( + server_is_creative or + minetest.check_player_privs(player, invsaw.settings.creative_priv) or + (minetest.check_player_privs(player, invsaw.settings.priv) and invsaw.has_saw_in_inventory(player)) + ) +end + +function invsaw.check_use_status(player) + if invsaw.can_use_saw(player) then + invsaw.initialize_inventory(player) + + else + invsaw.drop_inventory(player) + end +end + +minetest.register_on_joinplayer(invsaw.check_use_status) diff --git a/invsaw/formspec.lua b/invsaw/formspec.lua new file mode 100644 index 00000000..2eac0162 --- /dev/null +++ b/invsaw/formspec.lua @@ -0,0 +1,30 @@ +local station = stairsplus.api.station +local circular_saw = stairsplus.api.circular_saw + +function invsaw.show_formspec(player) + local name = player:get_player_name() + local meta = player:get_meta() + local inv = player:get_inventory() + + minetest.show_formspec(name, "invsaw", circular_saw.build_formspec(meta, inv)) +end + +minetest.register_on_player_receive_fields(function(player, formname, fields) + local meta = player:get_meta() + local inv = player:get_inventory() + + if fields.saw then + if invsaw.allow_use_saw(player) then + invsaw.show_formspec(player) + end + + return true + + elseif station.on_receive_fields(meta, inv, formname, fields, player) then + if invsaw.allow_use_saw(player) then + invsaw.show_formspec(player) + end + + return true + end +end) diff --git a/invsaw/init.lua b/invsaw/init.lua new file mode 100644 index 00000000..a145f801 --- /dev/null +++ b/invsaw/init.lua @@ -0,0 +1,30 @@ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +invsaw = { + version = {3, 0, 0}, + fork = "minetest_mods", + + modname = modname, + modpath = modpath, + + S = S, + + log = function(level, messagefmt, ...) + return minetest.log(level, ("[%s] %s"):format(modname, messagefmt:format(...))) + end, + + dofile = function(...) + return dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua") + end, +} + +invsaw.users = {} + +invsaw.dofile("settings") +invsaw.dofile("privs") +invsaw.dofile("api") +invsaw.dofile("inventory") +invsaw.dofile("formspec") +invsaw.dofile("unified_inventory") diff --git a/invsaw/inventory.lua b/invsaw/inventory.lua new file mode 100644 index 00000000..2fa3b2f1 --- /dev/null +++ b/invsaw/inventory.lua @@ -0,0 +1,80 @@ +local station = stairsplus.api.station + +function invsaw.initialize_inventory(player) + local meta = player:get_meta() + local inv = player:get_inventory() + + station.initialize_metadata(meta, inv, {"legacy"}) + station.initialize_inventory(inv, {"legacy"}) +end + +function invsaw.drop_inventory(player) + local pos = player:get_pos() + local inv = player:get_inventory() + for _, listname in ipairs({"stairsplus:input", "stairsplus:micro", "stairsplus:recycle"}) do + for i = 1, inv:get_size(listname) do + local item = inv:get_stack(listname, i) + if not item:is_empty() then + minetest.add_item(pos, item) + end + end + inv:set_size(listname, 0) + end + inv:set_size("stairsplus:output", 0) +end + +local function is_stairsplus_inventory(listname) + return ( + listname == "stairsplus:input" or + listname == "stairsplus:micro" or + listname == "stairsplus:recycle" or + listname == "stairsplus:output" + ) +end + +minetest.register_allow_player_inventory_action(function(player, action, inv, info) + local meta = player:get_meta() + if action == "move" and is_stairsplus_inventory(info.from_list) and is_stairsplus_inventory(info.to_list) then + return station.allow_inventory_move( + meta, inv, info.from_list, info.from_index, info.to_list, info.to_index, info.count, player + ) + + elseif action == "move" and is_stairsplus_inventory(info.to_list) then + local stack = inv:get_stack(info.from_list, info.from_index) + return station.allow_inventory_put( + meta, inv, info.to_list, info.to_index, stack, player + ) + + elseif action == "put" and is_stairsplus_inventory(info.listname) then + return station.allow_inventory_put( + meta, inv, info.listname, info.index, info.stack, player + ) + end +end) + +minetest.register_on_player_inventory_action(function(player, action, inv, info) + local meta = player:get_meta() + if action == "move" and is_stairsplus_inventory(info.from_list) and not is_stairsplus_inventory(info.to_list) then + local stack = inv:get_stack(info.to_list, info.to_index) + stack:set_count(info.count) + station.on_inventory_take( + meta, inv, info.from_list, info.from_index, stack, player + ) + + elseif action == "move" and not is_stairsplus_inventory(info.from_list) and is_stairsplus_inventory(info.to_list) then + local stack = inv:get_stack(info.from_list, info.from_index) + station.on_inventory_put( + meta, inv, info.to_list, info.to_index, stack, player + ) + + elseif action == "put" and is_stairsplus_inventory(info.listname) then + station.on_inventory_put( + meta, inv, info.listname, info.index, info.stack, player + ) + + elseif action == "take" and is_stairsplus_inventory(info.listname) then + station.on_inventory_take( + meta, inv, info.listname, info.index, info.stack, player + ) + end +end) diff --git a/invsaw/mod.conf b/invsaw/mod.conf new file mode 100644 index 00000000..eefb84e1 --- /dev/null +++ b/invsaw/mod.conf @@ -0,0 +1,3 @@ +name = invsaw +description = "circular saw in the unified inventory" +depends = stairsplus, unified_inventory diff --git a/invsaw/privs.lua b/invsaw/privs.lua new file mode 100644 index 00000000..b9057388 --- /dev/null +++ b/invsaw/privs.lua @@ -0,0 +1,50 @@ +-- luacheck: globals minetest + +local creative_priv = invsaw.settings.creative_priv +local priv = invsaw.settings.priv + +local function on_priv_change(name) + local player = minetest.get_player_by_name(name) + if player then + invsaw.check_use_status(player) + end +end + +local function override_on_priv_change(old) + return function(name, cause) + on_priv_change(name) + if old then + old(name, cause) + end + end +end + +if minetest.registered_privileges[priv] then + local def = minetest.registered_privileges[priv] + def.on_grant = override_on_priv_change(def.on_grant) + def.on_revoke = override_on_priv_change(def.on_revoke) + +else + minetest.register_privilege(priv, { + description = "Allow use of the circular saw in inventory", + give_to_singleplayer = true, + give_to_admin = false, + on_grant = on_priv_change, + on_revoke = on_priv_change, + }) +end + +if minetest.registered_privileges[creative_priv] then + local def = minetest.registered_privileges[creative_priv] + def.on_grant = override_on_priv_change(def.on_grant) + def.on_revoke = override_on_priv_change(def.on_revoke) + +else + minetest.register_privilege(creative_priv, { + description = "Allow use of the inventory saw creatively", + give_to_singleplayer = true, + give_to_admin = false, + on_grant = on_priv_change, + on_revoke = on_priv_change, + }) +end diff --git a/invsaw/settings.lua b/invsaw/settings.lua new file mode 100644 index 00000000..bef7e71c --- /dev/null +++ b/invsaw/settings.lua @@ -0,0 +1,7 @@ +local s = minetest.settings + +invsaw.settings = { + priv = s:get("invsaw.priv") or "interact", + creative_priv = s:get("invsaw.creative_priv") or "creative", + saw_item = s:get("invsaw.saw_item") or "stairsplus:circular_saw" +} diff --git a/invsaw/unified_inventory.lua b/invsaw/unified_inventory.lua new file mode 100644 index 00000000..762974f8 --- /dev/null +++ b/invsaw/unified_inventory.lua @@ -0,0 +1,10 @@ +local ui = unified_inventory + +ui.register_button("saw", { + type = "image", + image = "stairsplus_saw_button.png", + tooltip = "Circular Saw", + condition = function(player) + return invsaw.allow_use_saw(player) + end, +}) diff --git a/locale/moreblocks.es.tr b/locale/moreblocks.es.tr deleted file mode 100644 index c07124d6..00000000 --- a/locale/moreblocks.es.tr +++ /dev/null @@ -1,96 +0,0 @@ -# textdomain: moreblocks - -# Spanish translation for More Blocks. -# Copyright © 2011-2020 Hugo Locurcio and contributors -# This file is distributed under the same license as the More Blocks package. -# kaeza, 2013. -# CodeXP , 2018. -# Carlos Barraza 2020. - -#: circular_saw.lua - -Circular Saw=Sierra circular -Input material=Material de@nentrada -Left-over=Sobrante -Max=Maximo -Recycle output=Reciclar@nsalida -Set=Establecer -owned by @1=protegido por @1 -Circular Saw is empty=La sierra circular está vacia -Circular Saw is working on @1=Sierra circular trabajando en @1 - -#: nodes.lua - -Deprecated=Obsoleto -All-faces Acacia Tree=Árbol de Acacia, todas las caras -All-faces Aspen Tree=Álamo temblón, todas las caras -All-faces Jungle Tree=Árbol de Selva, todas las caras -All-faces Pine Tree=Pino, todas las caras -All-faces Tree=Tronco de Árbol -Cactus Brick=Ladrillos de Cactus -Cactus Checker=Cuadros de Cactus -Centered Wooden Tile=Parqué​ Centrado -Checker Stone Tile=Cuadros de Baldosa de Piedra -Circle Stone Bricks=Bloques de Piedra Circulares -Clean Glass=Cristal Limpio -Coal Checker=Cuadros de Carbón -Coal Glass=Cristal con Carbón -Clean Super Glow Glass=Cristal Súper Brillante Limpio -Trap Clean Super Glow Glass=Cristal Súper Brillante Limpio Falso -Trap Clean Glass=Cristal Limpio Falso -Clean Glow Glass=Cristal Brillante Limpio -Trap Clean Glow Glass=Cristal Brillante Limpio Falso -Coal Stone=Carbón y Piedra -Coal Stone Bricks=Ladrillos de Piedra de Carbon -Compressed Cobblestone=Adoquín Comprimido -Compressed Desert Cobblestone=Adoquín del Desierto Comprimido -Compressed Dirt=Tierra Comprimida -Copper Patina Block=Bloque de Pátina de Cobre -Empty Shelf=Estante vacio -Full Wooden Tile=Parqué​ Completo -Glow Glass=Cristal Brillante -Iron Checker=Cuadros de Hierro -Iron Glass=Cristal con Hierro -Iron Stone=Hierro y Piedra -Iron Stone Bricks=Ladrillo de Piedra de Hierro -Plankstone=Tablones de piedra -Rope=Soga -Split Stone Tile=Baldosas de Piedra Partida -Stone Bricks=Ladrillos de Piedra -Stone Tile=Baldosa de Piedra -Super Glow Glass=Cristal Súper Brillante -Sweeper=Limpiador -Tar=Alquitrán -Trap Desert Stone=Piedra del Desierto Falsa -Trap Glass=Cristal Falso -Trap Glow Glass=Cristal Brillante Falso -Trap Obsidian=Obsidiana Falsa -Trap Obsidian Glass=Vidrio de Obsidiana Falso -Trap Sandstone=Arenisca Falsa -Trap Stone=Piedra Falsa -Trap Super Glow Glass=Cristal Súper Brillante Falso -Wooden Tile=Parqué​ -Offset Wooden Tile=Parqué​ Ajustado -Downwards Wooden Tile=Parqué​ hacia Abajo -Leftwards Wooden Tile=Parqué​ hacia la Izquierda -Rightwards Wooden Tile=Parqué​ hacia la Derecha - - -#: ownership.lua - -Sorry, @1 owns that spot.=Lo siento, @1 es dueño de ese lugar. -someone=alguien - -#: stairsplus/common.lua - -@1 Microblock=Microbloque de @1 -@1 Slab=Losa de @1 -@1 Slope=Pendiente de @1 -@1 Panel=Panel de @1 -@1 Stairs=Escalera de @1 - -#: stairsplus/registrations.lua - -Concrete=Concreto -Cement=Cemento -Brass Block=Bloque de latón diff --git a/locale/moreblocks.pl.tr b/locale/moreblocks.pl.tr deleted file mode 100644 index 9f9d86a8..00000000 --- a/locale/moreblocks.pl.tr +++ /dev/null @@ -1,93 +0,0 @@ -# textdomain: moreblocks - -# Polish translation for More Blocks. -# Copyright © 2011-2020 Hugo Locurcio and contributors -# This file is distributed under the same license as the More Blocks package. -# mat9117, 2019 -# CodeXP , 2018. - -#: circular_saw.lua - -Circular Saw=Piła tarczowa -Input material=wejście@nmateriał -Left-over=Resztki -Max=Maks -Recycle output=Przetwarzanie@nWyjście -Set=Ustaw -owned by @1=Należy do @1 -Circular Saw is empty=Piła tarczowa jest pusta -Circular Saw is working on @1=Piła tarczowa pracuje na @1 - -#: init.lua - -[moreblocks] loaded.=[moreblocks] załadowane. - -#: nodes.lua - -Deprecated=Przestarzałe -All-faces Acacia Tree=Wielostronna tekstura akacji -All-faces Aspen Tree=Wielostronna tekstura osiki -All-faces Jungle Tree=Wielostronna tekstura drzewa dżunglowego -All-faces Pine Tree=Wielostronna tekstura sosny -All-faces Tree=Wielostronna tekstura drzewa -Cactus Brick=Kaktusowa cegła -Cactus Checker=Kaktusowa szachownica -Centered Wooden Tile=Wyśrodkowany drewniany kafelek -Checker Stone Tile=Kamienna szachownica -Circle Stone Bricks=Okrągłe kamienne cegły -Clean Glass=Czyste szkło -Coal Checker=Węglowa szachownica -Coal Glass=Szkło węglowe -Clean Super Glow Glass= -Trap Clean Super Glow Glass= -Trap Clean Glass= -Clean Glow Glass= -Trap Clean Glow Glass= -Coal Stone=Kamień węglowy -Coal Stone Bricks=Węglowe kamienne cegły -Compressed Cobblestone=Skompresowany bruk -Compressed Desert Cobblestone= -Compressed Dirt=Skompresowana ziemia -Copper Patina Block=Blok patynowanej miedzi -Empty Shelf=Pusta półka -Full Wooden Tile=Pełny drewniany kafelek -Glow Glass=Świecące szkło -Iron Checker=Żelazna szachownica -Iron Glass=Żelazne szkło -Iron Stone=Żelazny kamień -Iron Stone Bricks=Żelazne kamienne cegły -Plankstone=Deskokamień -Rope=Lina -Split Stone Tile=Kamienny blok kafelkowy -Stone Bricks=Kamienne cegły -Stone Tile=Kamienny kafelek -Super Glow Glass=Super świecące szkło -Sweeper=Miotła -Tar=Smoła -Trap Desert Stone=Pułapka z pustynnego kamienia -Trap Glass=Szklana pułapka -Trap Glow Glass=Pułapka ze świecącego szkłą -Trap Obsidian=Obsydianowa pułapka -Trap Obsidian Glass=Pułapka z obsydianowego szkła -Trap Sandstone=Pułapka z piaskowca -Trap Stone=Kamienna pułapka -Trap Super Glow Glass=Pułapka z super świecącego szkła -Wooden Tile=Drewniany kafelek -Offset Wooden Tile= -Downwards Wooden Tile=Dolny drewniany kafelek -# @deprecated -Leftwards Wooden Tile=Lewy drewniany kafelek -# @deprecated -Rightwards Wooden Tile=Prawy drewniany kafelek - -#: ownership.lua -Sorry, @1 owns that spot.=Przykro mi, to miejsce należy do @1 -someone=ktoś - -#: stairsplus/common.lua - -@1 Microblock=@1 Mikroblok -@1 Slab=@1 Płyta -@1 Slope=@1 Spad -@1 Panel=@1 Panel -@1 Stairs=@1 Schody diff --git a/locale/moreblocks.template.tr b/locale/moreblocks.template.tr deleted file mode 100644 index c509f18e..00000000 --- a/locale/moreblocks.template.tr +++ /dev/null @@ -1,89 +0,0 @@ -# textdomain: moreblocks - -#: circular_saw.lua - -Circular Saw= -Input material= -Left-over= -Max= -Recycle output= -Set= -owned by @1= -Circular Saw is empty= -Circular Saw is working on @1= - -#: nodes.lua - -Deprecated= -All-faces Acacia Tree= -All-faces Aspen Tree= -All-faces Jungle Tree= -All-faces Pine Tree= -All-faces Tree= -Cactus Brick= -Cactus Checker= -Centered Wooden Tile= -Checker Stone Tile= -Circle Stone Bricks= -Clean Glass= -Coal Checker= -Coal Glass= -Clean Super Glow Glass= -Trap Clean Super Glow Glass= -Trap Clean Glass= -Clean Glow Glass= -Trap Clean Glow Glass= -Coal Stone= -Coal Stone Bricks= -Compressed Cobblestone= -Compressed Desert Cobblestone= -Compressed Dirt= -Copper Patina Block= -Empty Shelf= -Full Wooden Tile= -Glow Glass= -Iron Checker= -Iron Glass= -Iron Stone= -Iron Stone Bricks= -Plankstone= -Rope= -Split Stone Tile= -Stone Bricks= -Stone Tile= -Super Glow Glass= -Sweeper= -Tar= -Trap Desert Stone= -Trap Glass= -Trap Glow Glass= -Trap Obsidian= -Trap Obsidian Glass= -Trap Sandstone= -Trap Stone= -Trap Super Glow Glass= -Wooden Tile= -Offset Wooden Tile= -Downwards Wooden Tile= -Leftwards Wooden Tile= -Rightwards Wooden Tile= - - -#: ownership.lua - -Sorry, @1 owns that spot.= -someone= - -#: stairsplus/common.lua - -@1 Microblock= -@1 Slab= -@1 Slope= -@1 Panel= -@1 Stairs= - -#: stairsplus/registrations.lua - -Concrete= -Cement= -Brass Block= diff --git a/locale/moreblocks.zh_CN.tr b/locale/moreblocks.zh_CN.tr deleted file mode 100644 index ac55722b..00000000 --- a/locale/moreblocks.zh_CN.tr +++ /dev/null @@ -1,94 +0,0 @@ -# textdomain: moreblocks - -# zh_CN translation for More Blocks. -# Copyright © 2011-2020 Hugo Locurcio and contributors -# This file is distributed under the same license as the More Blocks package. -# IFRFSX , 2020. - -#: circular_saw.lua - -Circular Saw=圆锯 -Input material=输入@n材料 -Left-over=剩余材料 -Max=最大值 -Recycle output=回收@n输出物 -Set=设置 -owned by @1=属于@1所有 -Circular Saw is empty=圆锯是空的 -Circular Saw is working on @1=圆锯正在加工@1 - -#: nodes.lua - -Deprecated=弃用 -All-faces Acacia Tree=全切面相思树木方块 -All-faces Aspen Tree=全切面白杨树木方块 -All-faces Jungle Tree=全切面丛林树木方块 -All-faces Pine Tree=全切面松树木方块 -All-faces Tree=全切面树木方块 -Cactus Brick=仙人掌砖 -Cactus Checker=仙人掌棋盘方块 -Centered Wooden Tile=居中的木瓦 -Checker Stone Tile=棋盘石瓦 -Circle Stone Bricks=圆石砖 -Clean Glass=干净的玻璃 -Coal Checker=棋盘煤块 -Coal Glass=煤玻璃 -Clean Super Glow Glass= -Trap Clean Super Glow Glass= -Trap Clean Glass= -Clean Glow Glass= -Trap Clean Glow Glass= -Coal Stone=煤炭石 -Coal Stone Bricks=煤炭石砖 -Compressed Cobblestone=压缩圆石 -Compressed Desert Cobblestone= -Compressed Dirt=压缩土 -Copper Patina Block=铜绿方块 -Empty Shelf=空书架 -Full Wooden Tile=全木瓦 -Glow Glass=发光玻璃 -Iron Checker=棋盘铁方块 -Iron Glass=铁玻璃 -Iron Stone=铁石 -Iron Stone Bricks=铁石砖 -Plankstone=板石 -Rope=绳子 -Split Stone Tile=裂石砖 -Stone Bricks=石砖 -Stone Tile=石瓦 -Super Glow Glass=超级发光玻璃 -Sweeper=清扫器 -Tar=焦油 -Trap Desert Stone=陷阱沙漠石 -Trap Glass=陷阱玻璃 -Trap Glow Glass=陷阱发光玻璃 -Trap Obsidian=陷阱黑耀石 -Trap Obsidian Glass=陷阱黑耀石玻璃 -Trap Sandstone=陷阱沙石 -Trap Stone=陷阱石 -Trap Super Glow Glass=陷阱超级发光玻璃 -Wooden Tile=木瓦 -Offset Wooden Tile=胶合木瓦 -Downwards Wooden Tile=向下的木瓦 -Leftwards Wooden Tile=向左的木瓦 -Rightwards Wooden Tile=向右的木瓦 - - -#: ownership.lua - -Sorry, @1 owns that spot.=抱歉,那个位置是@1的。 -someone=某人 - -#: stairsplus/common.lua - -@1 Microblock=@1小方块 -@1 Slab=@1台阶 -@1 Slope=@1斜坡 -@1 Panel=@1嵌板 -@1 Stairs=@1楼梯 - -#: stairsplus/registrations.lua - -Concrete= -Cement= -Brass Block= diff --git a/locale/moreblocks.zh_TW.tr b/locale/moreblocks.zh_TW.tr deleted file mode 100644 index 49a8cbcb..00000000 --- a/locale/moreblocks.zh_TW.tr +++ /dev/null @@ -1,94 +0,0 @@ -# textdomain: moreblocks - -# zh_TW translation for More Blocks. -# Copyright © 2011-2020 Hugo Locurcio and contributors -# This file is distributed under the same license as the More Blocks package. -# IFRFSX , 2020. - -#: circular_saw.lua - -Circular Saw=圓鋸 -Input material=輸入@n材料 -Left-over=剩餘材料 -Max=最大值 -Recycle output=回收@n輸出物 -Set=設置 -owned by @1=屬於@1所有 -Circular Saw is empty=圓鋸是空的 -Circular Saw is working on @1=圓鋸正在加工@1 - -#: nodes.lua - -Deprecated=棄用 -All-faces Acacia Tree=全切面相思樹木方塊 -All-faces Aspen Tree=全切面白楊樹木方塊 -All-faces Jungle Tree=全切面叢林樹木方塊 -All-faces Pine Tree=全切面松樹木方塊 -All-faces Tree=全切面樹木方塊 -Cactus Brick=仙人掌磚 -Cactus Checker=仙人掌棋盤方塊 -Centered Wooden Tile=居中的木瓦 -Checker Stone Tile=棋盤石瓦 -Circle Stone Bricks=圓石磚 -Clean Glass=乾淨的玻璃 -Coal Checker=棋盤煤塊 -Coal Glass=煤玻璃 -Clean Super Glow Glass= -Trap Clean Super Glow Glass= -Trap Clean Glass= -Clean Glow Glass= -Trap Clean Glow Glass= -Coal Stone=煤炭石 -Coal Stone Bricks=煤炭石磚 -Compressed Cobblestone=壓縮圓石 -Compressed Desert Cobblestone= -Compressed Dirt=壓縮土 -Copper Patina Block=銅綠方塊 -Empty Shelf=空書架 -Full Wooden Tile=全木瓦 -Glow Glass=發光玻璃 -Iron Checker=棋盤鐵方塊 -Iron Glass=鐵玻璃 -Iron Stone=鐵石 -Iron Stone Bricks=鐵石磚 -Plankstone=板石 -Rope=繩子 -Split Stone Tile=裂石磚 -Stone Bricks=石磚 -Stone Tile=石瓦 -Super Glow Glass=超級發光玻璃 -Sweeper=清掃器 -Tar=焦油 -Trap Desert Stone=陷阱沙漠石 -Trap Glass=陷阱玻璃 -Trap Glow Glass=陷阱發光玻璃 -Trap Obsidian=陷阱黑耀石 -Trap Obsidian Glass=陷阱黑耀石玻璃 -Trap Sandstone=陷阱沙石 -Trap Stone=陷阱石 -Trap Super Glow Glass=陷阱超級發光玻璃 -Wooden Tile=木瓦 -Offset Wooden Tile=膠合木瓦 -Downwards Wooden Tile=向下的木瓦 -Leftwards Wooden Tile=向左的木瓦 -Rightwards Wooden Tile=向右的木瓦 - - -#: ownership.lua - -Sorry, @1 owns that spot.=抱歉,那個位置是@1的。 -someone=某人 - -#: stairsplus/common.lua - -@1 Microblock=@1小方塊 -@1 Slab=@1臺階 -@1 Slope=@1斜坡 -@1 Panel=@1嵌板 -@1 Stairs=@1樓梯 - -#: stairsplus/registrations.lua - -Concrete= -Cement= -Brass Block= diff --git a/luacheck.sh b/luacheck.sh new file mode 100644 index 00000000..fefd3b92 --- /dev/null +++ b/luacheck.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +luacheck --config ./invsaw/.luacheckrc -q ./invsaw +luacheck --config ./moreblocks/.luacheckrc -q ./moreblocks +luacheck --config ./stairsplus/.luacheckrc -q ./stairsplus +luacheck --config ./stairsplus_legacy/.luacheckrc -q ./stairsplus_legacy diff --git a/mod.conf b/mod.conf deleted file mode 100644 index b155297b..00000000 --- a/mod.conf +++ /dev/null @@ -1,4 +0,0 @@ -name = moreblocks -description = Adds various miscellaneous blocks to the game. -optional_depends = default,stairs,farming,wool,basic_materials -min_minetest_version = 5.0.0 diff --git a/modpack.conf b/modpack.conf new file mode 100644 index 00000000..3c6a23bd --- /dev/null +++ b/modpack.conf @@ -0,0 +1,7 @@ +name = moreblocks +version = 3.0.0 +title = More Blocks +description = Adds various blocks to the game. +author = Hugo Locurcio + +min_minetest_version = 5.5.0 diff --git a/moreblocks/.luacheckrc b/moreblocks/.luacheckrc new file mode 100644 index 00000000..ea4d0726 --- /dev/null +++ b/moreblocks/.luacheckrc @@ -0,0 +1,657 @@ +std = "lua51+luajit+minetest+moreblocks" +unused_args = false +max_line_length = 120 + +stds.minetest = { + read_globals = { + "DIR_DELIM", + "dump", + "dump2", + + math = { + fields = { + abs = {}, + acos = {}, + asin = {}, + atan = {}, + atan2 = {}, + ceil = {}, + cos = {}, + cosh = {}, + deg = {}, + exp = {}, + factorial = {}, + floor = {}, + fmod = {}, + frexp = {}, + huge = {}, + hypot = {}, + ldexp = {}, + log = {}, + log10 = {}, + max = {}, + min = {}, + modf = {}, + pi = {}, + pow = {}, + rad = {}, + random = {}, + randomseed = {}, + round = {}, + sign = {}, + sin = {}, + sinh = {}, + sqrt = {}, + tan = {}, + tanh = {}, + }, + }, + table = { + fields = { + copy = {}, + concat = {}, + foreach = {}, + foreachi = {}, + getn = {}, + indexof = {}, + insert = {}, + insert_all = {}, + key_value_swap = {}, + maxn = {}, + move = {}, + remove = {}, + shuffle = {}, + sort = {}, + }, + }, + string = { + fields = { + byte = {}, + char = {}, + dump = {}, + find = {}, + format = {}, + gmatch = {}, + len = {}, + lower = {}, + match = {}, + rep = {}, + reverse = {}, + split = {}, + sub = {}, + trim = {}, + upper = {}, + }, + }, + vector = { + fields = { + add = {}, + angle = {}, + apply = {}, + check = {}, + combine = {}, + copy = {}, + cross = {}, + dir_to_rotation = {}, + direction = {}, + distance = {}, + divide = {}, + dot = {}, + equals = {}, + floor = {}, + from_string = {}, + length = {}, + metatable = {}, + multiply = {}, + new = {}, + normalize = {}, + offset = {}, + rotate = {}, + rotate_around_axis = {}, + round = {}, + sort = {}, + subtract = {}, + to_string = {}, + zero = {}, + }, + }, + + ItemStack = { + fields = { + add_item = {}, + add_wear = {}, + add_wear_by_uses = {}, + clear = {}, + get_count = {}, + get_definition = {}, + get_description = {}, + get_free_space = {}, + get_meta = {}, + get_metadata = {}, + get_name = {}, + get_short_description = {}, + get_stack_max = {}, + get_tool_capabilities = {}, + get_wear = {}, + is_empty = {}, + is_known = {}, + item_fits = {}, + peek_item = {}, + replace = {}, + set_count = {}, + set_metadata = {}, + set_name = {}, + set_wear = {}, + take_item = {}, + to_string = {}, + to_table = {}, + }, + }, + PerlinNoise = { + fields = { + get_2d = {}, + get_3d = {}, + }, + }, + PerlinNoiseMap = { + fields = { + calc_2d_map = {}, + calc_3d_map = {}, + get_2d_map = {}, + get_2d_map_flat = {}, + get_3d_map = {}, + get_3d_map_flat = {}, + get_map_slice = {}, + }, + }, + PseudoRandom = { + fields = { + next = {}, + }, + }, + PcgRandom = { + fields = { + next = {}, + rand_normal_dist = {}, + }, + }, + SecureRandom = { + fields = { + next_bytes = {}, + }, + }, + Settings = { + fields = { + get = {}, + get_bool = {}, + get_flags = {}, + get_names = {}, + get_np_group = {}, + remove = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + to_table = {}, + write = {}, + }, + }, + VoxelArea = { + fields = { + MaxEdge = {}, + MinEdge = {}, + contains = {}, + containsi = {}, + containsp = {}, + getExtent = {}, + getVolume = {}, + index = {}, + indexp = {}, + iter = {}, + iterp = {}, + new = {}, + position = {}, + ystride = {}, + zstride = {}, + }, + }, + VoxelManip = { + fields = { + calc_lighting = {}, + get_data = {}, + get_emerged_area = {}, + get_light_data = {}, + get_node_at = {}, + get_param2_data = {}, + read_from_map = {}, + set_data = {}, + set_light_data = {}, + set_lighting = {}, + set_node_at = {}, + set_param2_data = {}, + update_liquids = {}, + update_map = {}, + was_modified = {}, + write_to_map = {}, + }, + }, + + minetest = { + fields = { + CONTENT_AIR = {}, + CONTENT_IGNORE = {}, + CONTENT_UNKNOWN = {}, + EMERGE_CANCELLED = {}, + EMERGE_ERRORED = {}, + EMERGE_FROM_DISK = {}, + EMERGE_FROM_MEMORY = {}, + EMERGE_GENERATED = {}, + LIGHT_MAX = {}, + MAP_BLOCKSIZE = {}, + PLAYER_MAX_BREATH_DEFAULT = {}, + PLAYER_MAX_HP_DEFAULT = {}, + add_entity = {}, + add_item = {}, + add_node = {}, + add_node_level = {}, + add_particle = {}, + add_particlespawner = {}, + after = {}, + async_event_handler = {}, + async_jobs = {}, + auth_reload = {}, + ban_player = {}, + builtin_auth_handler = {}, + bulk_set_node = {}, + calculate_knockback = {}, + callback_origins = {}, + cancel_shutdown_requests = {}, + chat_send_all = {}, + chat_send_player = {}, + chatcommands = {}, + check_for_falling = {}, + check_password_entry = {}, + check_player_privs = {}, + check_single_for_falling = {}, + clear_craft = {}, + clear_objects = {}, + clear_registered_biomes = {}, + clear_registered_decorations = {}, + clear_registered_ores = {}, + clear_registered_schematics = {}, + close_formspec = {}, + colorize = {}, + colorspec_to_bytes = {}, + colorspec_to_colorstring = {}, + compare_block_status = {}, + compress = {}, + cpdir = {}, + craft_predict = {}, + craftitemdef_default = {}, + create_detached_inventory = {}, + create_detached_inventory_raw = {}, + create_schematic = {}, + debug = {}, + decode_base64 = {}, + decompress = {}, + delete_area = {}, + delete_particlespawner = {}, + deserialize = {}, + detached_inventories = {}, + dig_node = {}, + dir_to_facedir = {}, + dir_to_wallmounted = {}, + dir_to_yaw = {}, + disconnect_player = {}, + do_async_callback = {}, + do_item_eat = {}, + dynamic_add_media = {}, + dynamic_media_callbacks = {}, + emerge_area = {}, + encode_base64 = {}, + encode_png = {}, + env = {}, + explode_scrollbar_event = {}, + explode_table_event = {}, + explode_textlist_event = {}, + facedir_to_dir = {}, + features = {}, + find_node_near = {}, + find_nodes_in_area = {}, + find_nodes_in_area_under_air = {}, + find_nodes_with_meta = {}, + find_path = {}, + fix_light = {}, + forceload_block = {}, + forceload_free_block = {}, + format_chat_message = {}, + formspec_escape = {}, + generate_decorations = {}, + generate_ores = {}, + get_all_craft_recipes = {}, + get_artificial_light = {}, + get_auth_handler = {}, + get_background_escape_sequence = {}, + get_ban_description = {}, + get_ban_list = {}, + get_biome_data = {}, + get_biome_id = {}, + get_biome_name = {}, + get_builtin_path = {}, + get_color_escape_sequence = {}, + get_connected_players = {}, + get_content_id = {}, + get_craft_recipe = {}, + get_craft_result = {}, + get_current_modname = {}, + get_day_count = {}, + get_decoration_id = {}, + get_dig_params = {}, + get_dir_list = {}, + get_gametime = {}, + get_gen_notify = {}, + get_heat = {}, + get_hit_params = {}, + get_humidity = {}, + get_inventory = {}, + get_item_group = {}, + get_last_run_mod = {}, + get_mapgen_object = {}, + get_mapgen_params = {}, + get_mapgen_setting = {}, + get_mapgen_setting_noiseparams = {}, + get_meta = {}, + get_mod_storage = {}, + get_modnames = {}, + get_modpath = {}, + get_name_from_content_id = {}, + get_natural_light = {}, + get_node = {}, + get_node_drops = {}, + get_node_group = {}, + get_node_level = {}, + get_node_light = {}, + get_node_max_level = {}, + get_node_or_nil = {}, + get_node_timer = {}, + get_noiseparams = {}, + get_objects_in_area = {}, + get_objects_inside_radius = {}, + get_password_hash = {}, + get_perlin = {}, + get_perlin_map = {}, + get_player_by_name = {}, + get_player_information = {}, + get_player_ip = {}, + get_player_privs = {}, + get_player_radius_area = {}, + get_pointed_thing_position = {}, + get_position_from_hash = {}, + get_server_max_lag = {}, + get_server_status = {}, + get_server_uptime = {}, + get_spawn_level = {}, + get_timeofday = {}, + get_tool_wear_after_use = {}, + get_translated_string = {}, + get_translator = {}, + get_us_time = {}, + get_user_path = {}, + get_version = {}, + get_voxel_manip = {}, + get_worldpath = {}, + global_exists = {}, + handle_async = {}, + handle_node_drops = {}, + has_feature = {}, + hash_node_position = {}, + hud_replace_builtin = {}, + inventorycube = {}, + is_area_protected = {}, + is_colored_paramtype = {}, + is_creative_enabled = {}, + is_nan = {}, + is_player = {}, + is_protected = {}, + is_singleplayer = {}, + is_yes = {}, + item_drop = {}, + item_eat = {}, + item_place = {}, + item_place_node = {}, + item_place_object = {}, + item_secondary_use = {}, + itemstring_with_color = {}, + itemstring_with_palette = {}, + kick_player = {}, + line_of_sight = {}, + load_area = {}, + log = {}, + luaentities = {}, + mkdir = {}, + mod_channel_join = {}, + mvdir = {}, + node_dig = {}, + node_punch = {}, + nodedef_default = {}, + noneitemdef_default = {}, + notify_authentication_modified = {}, + object_refs = {}, + on_craft = {}, + override_chatcommand = {}, + override_item = {}, + parse_coordinates = {}, + parse_json = {}, + parse_relative_number = {}, + place_node = {}, + place_schematic = {}, + place_schematic_on_vmanip = {}, + player_exists = {}, + pointed_thing_to_face_pos = {}, + pos_to_string = {}, + print = {}, + privs_to_string = {}, + punch_node = {}, + raillike_group = {}, + raycast = {}, + read_schematic = {}, + record_protection_violation = {}, + register_abm = {}, + register_alias = {}, + register_alias_force = {}, + register_allow_player_inventory_action = {}, + register_async_dofile = {}, + register_authentication_handler = {}, + register_biome = {}, + register_can_bypass_userlimit = {}, + register_chatcommand = {}, + register_craft = {}, + register_craft_predict = {}, + register_craftitem = {}, + register_decoration = {}, + register_entity = {}, + register_globalstep = {}, + register_item = {}, + register_lbm = {}, + register_node = {}, + register_on_auth_fail = {}, + register_on_authplayer = {}, + register_on_chat_message = {}, + register_on_chatcommand = {}, + register_on_cheat = {}, + register_on_craft = {}, + register_on_dieplayer = {}, + register_on_dignode = {}, + register_on_generated = {}, + register_on_item_eat = {}, + register_on_joinplayer = {}, + register_on_leaveplayer = {}, + register_on_liquid_transformed = {}, + register_on_mapgen_init = {}, + register_on_modchannel_message = {}, + register_on_mods_loaded = {}, + register_on_newplayer = {}, + register_on_placenode = {}, + register_on_player_hpchange = {}, + register_on_player_inventory_action = {}, + register_on_player_receive_fields = {}, + register_on_prejoinplayer = {}, + register_on_priv_grant = {}, + register_on_priv_revoke = {}, + register_on_protection_violation = {}, + register_on_punchnode = {}, + register_on_punchplayer = {}, + register_on_respawnplayer = {}, + register_on_rightclickplayer = {}, + register_on_shutdown = {}, + register_ore = {}, + register_playerevent = {}, + register_privilege = {}, + register_schematic = {}, + register_tool = {}, + registered_abms = {other_fields = true}, + registered_aliases = {other_fields = true}, + registered_allow_player_inventory_actions = {other_fields = true}, + registered_biomes = {other_fields = true}, + registered_can_bypass_userlimit = {other_fields = true}, + registered_chatcommands = {other_fields = true}, + registered_craft_predicts = {other_fields = true}, + registered_craftitems = {other_fields = true}, + registered_decorations = {other_fields = true}, + registered_entities = {other_fields = true}, + registered_globalsteps = {other_fields = true}, + registered_items = {other_fields = true}, + registered_lbms = {other_fields = true}, + registered_nodes = {other_fields = true}, + registered_on_authplayers = {other_fields = true}, + registered_on_chat_messages = {other_fields = true}, + registered_on_chatcommands = {other_fields = true}, + registered_on_cheats = {other_fields = true}, + registered_on_crafts = {other_fields = true}, + registered_on_dieplayers = {other_fields = true}, + registered_on_dignodes = {other_fields = true}, + registered_on_generateds = {other_fields = true}, + registered_on_item_eats = {other_fields = true}, + registered_on_joinplayers = {other_fields = true}, + registered_on_leaveplayers = {other_fields = true}, + registered_on_liquid_transformed = {other_fields = true}, + registered_on_modchannel_message = {other_fields = true}, + registered_on_mods_loaded = {other_fields = true}, + registered_on_newplayers = {other_fields = true}, + registered_on_placenodes = {other_fields = true}, + registered_on_player_hpchange = {other_fields = true}, + registered_on_player_hpchanges = {other_fields = true}, + registered_on_player_inventory_actions = {other_fields = true}, + registered_on_player_receive_fields = {other_fields = true}, + registered_on_prejoinplayers = {other_fields = true}, + registered_on_priv_grant = {other_fields = true}, + registered_on_priv_revoke = {other_fields = true}, + registered_on_protection_violation = {other_fields = true}, + registered_on_punchnodes = {other_fields = true}, + registered_on_punchplayers = {other_fields = true}, + registered_on_respawnplayers = {other_fields = true}, + registered_on_rightclickplayers = {other_fields = true}, + registered_on_shutdown = {other_fields = true}, + registered_ores = {other_fields = true}, + registered_playerevents = {other_fields = true}, + registered_privileges = {other_fields = true}, + registered_tools = {other_fields = true}, + remove_detached_inventory = {}, + remove_detached_inventory_raw = {}, + remove_node = {}, + remove_player = {}, + remove_player_auth = {}, + request_http_api = {}, + request_insecure_environment = {}, + request_shutdown = {}, + rgba = {}, + rmdir = {}, + rollback_get_last_node_actor = {}, + rollback_get_node_actions = {}, + rollback_punch_callbacks = {}, + rollback_revert_actions_by = {}, + rotate_and_place = {}, + rotate_node = {}, + run_callbacks = {}, + run_priv_callbacks = {}, + safe_file_write = {}, + send_join_message = {}, + send_leave_message = {}, + serialize = {}, + serialize_roundtrip = {}, + serialize_schematic = {}, + set_gen_notify = {}, + set_last_run_mod = {}, + set_mapgen_params = {}, + set_mapgen_setting = {}, + set_mapgen_setting_noiseparams = {}, + set_node = {}, + set_node_level = {}, + set_noiseparams = {}, + set_player_password = {}, + set_player_privs = {}, + set_timeofday = {}, + setting_get = {}, + setting_get_pos = {}, + setting_getbool = {}, + setting_save = {}, + setting_set = {}, + setting_setbool = {}, + settings = { + fields = { + get = {}, + get_bool = {}, + get_np_group = {}, + get_flags = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + remove = {}, + get_names = {}, + write = {}, + to_table = {}, + }, + }, + sha1 = {}, + show_formspec = {}, + show_general_help_formspec = {}, + show_privs_help_formspec = {}, + sound_fade = {}, + sound_play = {}, + sound_stop = {}, + spawn_falling_node = {}, + spawn_item = {}, + spawn_tree = {}, + string_to_area = {}, + string_to_pos = {}, + string_to_privs = {}, + strip_background_colors = {}, + strip_colors = {}, + strip_foreground_colors = {}, + strip_param2_color = {}, + swap_node = {}, + tooldef_default = {}, + transforming_liquid_add = {}, + translate = {}, + unban_player_or_ip = {}, + unregister_biome = {}, + unregister_chatcommand = {}, + unregister_item = {}, + wallmounted_to_dir = {}, + wrap_text = {}, + write_json = {}, + yaw_to_dir = {}, + }, + }, + } +} + +stds.moreblocks = { + globals = { + "moreblocks", + }, + read_globals = { + "default", + "stairs", + "stairsplus", + }, +} diff --git a/moreblocks/API.md b/moreblocks/API.md new file mode 100644 index 00000000..a5bd8559 --- /dev/null +++ b/moreblocks/API.md @@ -0,0 +1,9 @@ + +* `moreblocks.api.register_all_faces(itemstring, base, [redef])` + Register an "All Faces" variant of a tree. + +* `moreblocks.api.register_no_faces(itemstring, base, [redef])` + Register a "No Faces" variant of a tree. + +* `moreblocks.api.register_trap(itemstring, base, [redef])` + Register a "Trap" variant of a node. A trap variant is a non-solid node that looks like the original. diff --git a/aliases.lua b/moreblocks/aliases.lua similarity index 51% rename from aliases.lua rename to moreblocks/aliases.lua index fc4492f4..37b6a2e5 100644 --- a/aliases.lua +++ b/moreblocks/aliases.lua @@ -1,32 +1,38 @@ ---[[ -More Blocks: alias definitions - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] +local cm = moreblocks.resources.craft_materials -- More Blocks aliases: minetest.register_alias("sweeper", "moreblocks:sweeper") -minetest.register_alias("circular_saw", "moreblocks:circular_saw") -minetest.register_alias("jungle_stick", "moreblocks:jungle_stick") + +if cm.stick then + minetest.register_alias("jungle_stick", cm.stick) + minetest.register_alias("moreblocks:jungle_stick", cm.stick) +end -- Old block/item replacement: -minetest.register_alias("moreblocks:oerkkiblock", "default:mossycobble") -minetest.register_alias("moreblocks:screwdriver", "screwdriver:screwdriver") +if cm.mossycobble then + minetest.register_alias("moreblocks:oerkkiblock", cm.mossycobble) +end + +if cm.screwdriver then + minetest.register_alias("moreblocks:screwdriver", cm.screwdriver) +end -- Node and item renaming: -minetest.register_alias("moreblocks:stone_bricks", "default:stonebrick") -minetest.register_alias("moreblocks:stonebrick", "default:stonebrick") -minetest.register_alias("moreblocks:junglewood", "default:junglewood") -minetest.register_alias("moreblocks:jungle_wood", "default:junglewood") -minetest.register_alias("moreblocks:fence_junglewood", "default:fence_junglewood") -minetest.register_alias("moreblocks:fence_jungle_wood", "default:fence_junglewood") -minetest.register_alias("moreblocks:jungle_stick", "default:stick") +if cm.stone_brick then + minetest.register_alias("moreblocks:stone_bricks", cm.stone_brick) + minetest.register_alias("moreblocks:stonebrick", cm.stone_brick) +end + +if cm.jungle_wood then + minetest.register_alias("moreblocks:junglewood", cm.jungle_wood) + minetest.register_alias("moreblocks:jungle_wood", cm.jungle_wood) +end -for _, t in pairs(circular_saw.names) do - minetest.register_alias("moreblocks:" .. t[1] .. "_jungle_wood" .. t[2], - "moreblocks:" .. t[1] .. "_junglewood" .. t[2]) +if cm.fence_jungle_wood then + minetest.register_alias("moreblocks:fence_junglewood", cm.fence_jungle_wood) + minetest.register_alias("moreblocks:fence_jungle_wood", cm.fence_jungle_wood) end + minetest.register_alias("moreblocks:horizontaltree", "moreblocks:horizontal_tree") minetest.register_alias("moreblocks:horizontaljungletree", "moreblocks:horizontal_jungle_tree") minetest.register_alias("moreblocks:stonesquare", "moreblocks:stone_tile") @@ -55,31 +61,18 @@ minetest.register_alias("moreblocks:cactusbrick", "moreblocks:cactus_brick") minetest.register_alias("moreblocks:cleanglass", "moreblocks:clean_glass") minetest.register_alias("moreblocks:emptybookshelf", "moreblocks:empty_bookshelf") minetest.register_alias("moreblocks:junglestick", "moreblocks:jungle_stick") -minetest.register_alias("moreblocks:splitstonesquare","moreblocks:split_stone_tile") -minetest.register_alias("moreblocks:allfacestree","moreblocks:all_faces_tree") -minetest.register_alias("moreblocks:empty_bookshelf","moreblocks:empty_shelf") -minetest.register_alias("moreblocks:split_stone_tile_alt","moreblocks:checker_stone_tile") +minetest.register_alias("moreblocks:splitstonesquare", "moreblocks:split_stone_tile") +minetest.register_alias("moreblocks:allfacestree", "moreblocks:all_faces_tree") +minetest.register_alias("moreblocks:empty_bookshelf", "moreblocks:empty_shelf") +minetest.register_alias("moreblocks:split_stone_tile_alt", "moreblocks:checker_stone_tile") --- ABM for horizontal trees (fix facedir): -local horizontal_tree_convert_facedir = {7, 12, 9, 18} +if moreblocks.has.stairsplus and cm.jungle_wood then + stairsplus.api.register_alias_all("moreblocks:jungle_wood", cm.jungle_wood) +end -minetest.register_abm({ - nodenames = {"moreblocks:horizontal_tree","moreblocks:horizontal_jungle_tree"}, - interval = 1, - chance = 1, - action = function(pos, node) - if node.name == "moreblocks:horizontal_tree" then - node.name = "default:tree" - else - node.name = "default:jungletree" - end - node.param2 = node.param2 < 3 and node.param2 or 0 - minetest.set_node(pos, { - name = node.name, - param2 = horizontal_tree_convert_facedir[node.param2 + 1] - }) - end, -}) +if moreblocks.has.stairsplus then + stairsplus.api.register_alias_all("moreblocks:split_stone_tile_alt", "moreblocks:checker_stone_tile") +end minetest.register_lbm({ name = "moreblocks:reduce_wood_tile_redundancy", @@ -90,16 +83,53 @@ minetest.register_lbm({ "moreblocks:wood_tile_flipped", }, action = function(pos, node) - if node.name:find("left") then - minetest.set_node(pos, {name = "moreblocks:wood_tile_offset", param2=1}) - elseif node.name:find("down") then - minetest.set_node(pos, {name = "moreblocks:wood_tile_offset", param2=2}) - elseif node.name:find("right") then - minetest.set_node(pos, {name = "moreblocks:wood_tile_offset", param2=3}) - else -- wood_tile_flipped - minetest.set_node(pos, {name = "moreblocks:wood_tile", param2=1}) + if node.name == "moreblocks:wood_tile_left" then + minetest.set_node(pos, {name = "moreblocks:wood_tile_offset", param2 = 1}) + elseif node.name == "moreblocks:wood_tile_down" then + minetest.set_node(pos, {name = "moreblocks:wood_tile_offset", param2 = 2}) + elseif node.name == "moreblocks:wood_tile_right" then + minetest.set_node(pos, {name = "moreblocks:wood_tile_offset", param2 = 3}) + else + -- wood_tile_flipped + minetest.set_node(pos, {name = "moreblocks:wood_tile", param2 = 1}) end - minetest.log('action', "LBM replaced " .. node.name .. - " at " .. minetest.pos_to_string(pos)) + moreblocks.log("action", "LBM replaced %s at %s", node.name, minetest.pos_to_string(pos)) end, }) + +local horizontal_tree_convert_facedir = {7, 12, 9, 18} +if cm.tree then + minetest.register_lbm({ + name = "moreblocks:reduce_horizontal_tree_redundancy", + nodenames = { + "moreblocks:horizontal_tree", + }, + action = function(pos, node) + node.name = cm.tree + node.param2 = node.param2 < 3 and node.param2 or 0 + minetest.set_node(pos, { + name = node.name, + param2 = horizontal_tree_convert_facedir[node.param2 + 1] + }) + moreblocks.log("action", "LBM replaced %s at %s", node.name, minetest.pos_to_string(pos)) + end, + }) +end + +if cm.jungle_tree then + minetest.register_lbm({ + name = "moreblocks:reduce_horizontal_jungle_tree_redundancy", + nodenames = { + "moreblocks:horizontal_jungle_tree", + }, + action = function(pos, node) + node.name = cm.jungle_tree + node.param2 = node.param2 < 3 and node.param2 or 0 + minetest.set_node(pos, { + name = node.name, + param2 = horizontal_tree_convert_facedir[node.param2 + 1] + }) + moreblocks.log("action", "LBM replaced %s at %s", node.name, minetest.pos_to_string(pos)) + end, + }) +end diff --git a/moreblocks/api/all_faces.lua b/moreblocks/api/all_faces.lua new file mode 100644 index 00000000..3d4966ab --- /dev/null +++ b/moreblocks/api/all_faces.lua @@ -0,0 +1,28 @@ +local S = moreblocks.S + +function moreblocks.api.register_all_faces(itemstring, base, redef) + local def = table.copy(minetest.registered_nodes[base]) + + def.tiles = {def.tiles[1]} + def.description = S("All-faces @1", def.description) + + if def.short_description then + def.short_description = S("All-faces @1", def.short_description) + end + + redef = redef or {} + for k, v in pairs(redef) do + def[k] = v + end + + minetest.register_node(itemstring, def) + + minetest.register_craft({ + output = itemstring .. " 8", + recipe = { + {base, base, base}, + {base, "", base}, + {base, base, base}, + } + }) +end diff --git a/moreblocks/api/init.lua b/moreblocks/api/init.lua new file mode 100644 index 00000000..6e4c3354 --- /dev/null +++ b/moreblocks/api/init.lua @@ -0,0 +1,5 @@ +moreblocks.api = {} + +moreblocks.dofile("api", "all_faces") +moreblocks.dofile("api", "no_faces") +moreblocks.dofile("api", "trap") diff --git a/moreblocks/api/no_faces.lua b/moreblocks/api/no_faces.lua new file mode 100644 index 00000000..611f3ec9 --- /dev/null +++ b/moreblocks/api/no_faces.lua @@ -0,0 +1,28 @@ +local S = moreblocks.S + +function moreblocks.api.register_no_faces(itemstring, base, redef) + local def = table.copy(minetest.registered_nodes[base]) + + def.tiles = {def.tiles[3]} + def.description = S("No-faces @1", def.description) + + if def.short_description then + def.short_description = S("No-faces @1", def.short_description) + end + + redef = redef or {} + for k, v in pairs(redef) do + def[k] = v + end + + minetest.register_node(itemstring, def) + + minetest.register_craft({ + output = itemstring .. " 9", + recipe = { + {base, base, base}, + {base, base, base}, + {base, base, base}, + } + }) +end diff --git a/moreblocks/api/trap.lua b/moreblocks/api/trap.lua new file mode 100644 index 00000000..736ce8e5 --- /dev/null +++ b/moreblocks/api/trap.lua @@ -0,0 +1,43 @@ +local S = moreblocks.S +local cm = moreblocks.resources.craft_materials + +local outline_trap_nodes = moreblocks.settings.outline_trap_nodes + +function moreblocks.api.register_trap(itemstring, base, redef) + local def = table.copy(minetest.registered_nodes[base]) + + def.description = S("Trap @1", def.description) + + if def.short_description then + def.short_description = S("Trap @1", def.short_description) + end + + if outline_trap_nodes then + for i, tile in ipairs(def.tiles) do + def.tiles[i] = tile .. "^moreblocks_trap_box.png" + end + end + + if def.drawtype ~= "glasslike_framed_optional" then + def.drawtype = "glasslike_framed" + end + + def.walkable = false + def.paramtype = "light" + def.is_ground_content = false + + redef = redef or {} + for k, v in pairs(redef) do + def[k] = v + end + + minetest.register_node(itemstring, def) + + if cm.trap_material then + minetest.register_craft({ + output = itemstring, + type = "shapeless", + recipe = {cm.trap_material, base}, + }) + end +end diff --git a/moreblocks/crafting.lua b/moreblocks/crafting.lua new file mode 100644 index 00000000..ceebc43e --- /dev/null +++ b/moreblocks/crafting.lua @@ -0,0 +1,574 @@ +local cm = moreblocks.resources.craft_materials + +if cm.stick and cm.dry_shrub then + minetest.register_craft({ + output = cm.stick, + recipe = {{cm.dry_shrub}, } + }) +end + +if cm.stick then + minetest.register_craft({ + output = cm.stick, + recipe = {{"group:sapling"}, } + }) +end + +if cm.stick and cm.wood then + minetest.register_craft({ + output = cm.wood, + recipe = { + {cm.stick, cm.stick}, + {cm.stick, cm.stick}, + } + }) +end + +if cm.dirt_with_grass and cm.jungle_grass and cm.dirt then + minetest.register_craft({ + output = cm.dirt_with_grass, + type = "shapeless", + recipe = {cm.jungle_grass, cm.dirt}, + }) +end + +if cm.mossy_cobble and cm.jungle_grass and cm.cobble then + minetest.register_craft({ + output = cm.mossy_cobble, + type = "shapeless", + recipe = {cm.jungle_grass, cm.cobble}, + }) +end + +minetest.register_craft({ + output = "moreblocks:wood_tile 9", + recipe = { + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, + } +}) + +-- This must be registered after `moreblocks:wood_tile` to avoid recipe conflicts, +-- since `moreblocks:wood_tile` is part of `group:wood` +minetest.register_craft({ + output = "moreblocks:wood_tile_center 9", + recipe = { + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "moreblocks:wood_tile", "group:wood"}, + {"group:wood", "group:wood", "group:wood"}, + } +}) + +minetest.register_craft({ + type = "shapeless", + output = "moreblocks:wood_tile", + recipe = {"moreblocks:wood_tile_flipped"} +}) + +minetest.register_craft({ + output = "moreblocks:wood_tile_full 4", + recipe = { + {"moreblocks:wood_tile", "moreblocks:wood_tile"}, + {"moreblocks:wood_tile", "moreblocks:wood_tile"}, + } +}) + +if cm.stick then + minetest.register_craft({ + output = "moreblocks:wood_tile_offset", + recipe = { + {cm.stick}, + {"moreblocks:wood_tile_center"}, + } + }) +end + +minetest.register_craft({ + type = "shapeless", + output = "moreblocks:wood_tile_offset", + recipe = {"moreblocks:wood_tile_down"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "moreblocks:wood_tile_offset", + recipe = {"moreblocks:wood_tile_left"} +}) + +minetest.register_craft({ + type = "shapeless", + output = "moreblocks:wood_tile_offset", + recipe = {"moreblocks:wood_tile_right"} +}) + +if cm.stone and cm.coal_lump then + minetest.register_craft({ + output = "moreblocks:circle_stone_bricks 5", + recipe = { + {"", cm.stone, ""}, + {cm.stone, cm.coal_lump, cm.stone}, + {"", cm.stone, ""}, + } + }) +end + +if cm.jungle_grass and cm.stick then + minetest.register_craft({ + output = "moreblocks:sweeper 4", + recipe = { + {cm.jungle_grass}, + {cm.stick}, + } + }) +end + +if cm.cobble and cm.stone then + minetest.register_craft({ + output = "moreblocks:stone_tile 9", + recipe = { + {cm.cobble, cm.cobble, cm.cobble}, + {cm.cobble, cm.stone, cm.cobble}, + {cm.cobble, cm.cobble, cm.cobble}, + } + }) +end + +minetest.register_craft({ + output = "moreblocks:split_stone_tile", + recipe = { + {"moreblocks:stone_tile"}, + } +}) + +minetest.register_craft({ + output = "moreblocks:checker_stone_tile", + recipe = { + {"moreblocks:split_stone_tile"}, + } +}) + +-- When approaching the below craft, loop back to cobblestone, which can then be used to craft stone tiles again +if cm.cobble then + minetest.register_craft({ + output = cm.cobble, + recipe = { + {"moreblocks:checker_stone_tile"}, + } + }) +end + +if cm.stone and cm.brick then + minetest.register_craft({ + output = "moreblocks:grey_bricks 2", + type = "shapeless", + recipe = {cm.stone, cm.brick}, + }) +end + +if cm.stone_brick and cm.brick then + minetest.register_craft({ + output = "moreblocks:grey_bricks 2", + type = "shapeless", + recipe = {cm.stone_brick, cm.brick}, + }) +end + +if cm.bookshelf and cm.book then + minetest.register_craft({ + output = "moreblocks:empty_shelf", + type = "shapeless", + recipe = {"moreblocks:sweeper", cm.bookshelf}, + replacements = {{cm.bookshelf, cm.book .. " 3"}}, + -- When obtaining an empty shelf, return the books used in it as well + }) +end + +if cm.vessels_shelf and cm.glass_bottle then + minetest.register_craft({ + output = "moreblocks:empty_shelf", + type = "shapeless", + recipe = {"moreblocks:sweeper", cm.vessels_shelf}, + replacements = {{cm.vessels_shelf, cm.glass_bottle .. " 3"}}, + }) +end + +if cm.book and cm.bookshelf then + minetest.register_craft({ + type = "shapeless", + output = cm.bookshelf, + recipe = {"moreblocks:empty_shelf", cm.book, cm.book, cm.book}, + }) +end + +minetest.register_craft({ + output = "moreblocks:empty_shelf", + recipe = { + {"group:wood", "group:wood", "group:wood"}, + {"", "", ""}, + {"group:wood", "group:wood", "group:wood"}, + } +}) + +minetest.register_craft({ + output = "moreblocks:coal_stone_bricks 4", + recipe = { + {"moreblocks:coal_stone", "moreblocks:coal_stone"}, + {"moreblocks:coal_stone", "moreblocks:coal_stone"}, + } +}) + +minetest.register_craft({ + output = "moreblocks:iron_stone_bricks 4", + recipe = { + {"moreblocks:iron_stone", "moreblocks:iron_stone"}, + {"moreblocks:iron_stone", "moreblocks:iron_stone"}, + } +}) + +minetest.register_craft({ + output = "moreblocks:plankstone 4", + recipe = { + {"group:stone", "group:wood"}, + {"group:wood", "group:stone"}, + } +}) + +minetest.register_craft({ + output = "moreblocks:plankstone 4", + recipe = { + {"group:wood", "group:stone"}, + {"group:stone", "group:wood"}, + } +}) + +if cm.coal_lump and cm.stone then + minetest.register_craft({ + output = "moreblocks:coal_checker 4", + recipe = { + {cm.stone, cm.coal_lump}, + {cm.coal_lump, cm.stone}, + } + }) + + minetest.register_craft({ + output = "moreblocks:coal_checker 4", + recipe = { + {cm.coal_lump, cm.stone}, + {cm.stone, cm.coal_lump}, + } + }) +end + +if cm.steel_ingot and cm.stone then + minetest.register_craft({ + output = "moreblocks:iron_checker 4", + recipe = { + {cm.steel_ingot, cm.stone}, + {cm.stone, cm.steel_ingot}, + } + }) + + minetest.register_craft({ + output = "moreblocks:iron_checker 4", + recipe = { + {cm.stone, cm.steel_ingot}, + {cm.steel_ingot, cm.stone}, + } + }) +end + +if cm.chest and cm.chest_locked then + if cm.steel_ingot then + minetest.register_craft({ + output = cm.chest_locked, + type = "shapeless", + recipe = {cm.steel_ingot, cm.chest}, + }) + end + + if cm.copper_ingot then + minetest.register_craft({ + output = cm.chest_locked, + type = "shapeless", + recipe = {cm.copper_ingot, cm.chest}, + }) + end + + if cm.bronze_ingot then + minetest.register_craft({ + output = cm.chest_locked, + type = "shapeless", + recipe = {cm.bronze_ingot, cm.chest}, + }) + end + + if cm.gold_ingot then + minetest.register_craft({ + output = cm.chest_locked, + type = "shapeless", + recipe = {cm.gold_ingot, cm.chest}, + }) + end +end + +if cm.glass and cm.steel_ingot then + minetest.register_craft({ + output = "moreblocks:iron_glass", + type = "shapeless", + recipe = {cm.steel_ingot, cm.glass}, + }) + + minetest.register_craft({ + output = cm.glass, + type = "shapeless", + recipe = {cm.steel_ingot, "moreblocks:coal_glass"}, + }) +end + +if cm.glass and cm.coal_lump then + minetest.register_craft({ + output = cm.glass, + type = "shapeless", + recipe = {cm.coal_lump, "moreblocks:iron_glass"}, + }) + + minetest.register_craft({ + output = "moreblocks:coal_glass", + type = "shapeless", + recipe = {cm.coal_lump, cm.glass}, + }) +end + +if cm.glass then + minetest.register_craft({ + output = "moreblocks:clean_glass", + type = "shapeless", + recipe = {"moreblocks:sweeper", cm.glass}, + }) +end + +minetest.register_craft({ + output = "moreblocks:trap_clean_glass", + type = "shapeless", + recipe = {"moreblocks:sweeper", "moreblocks:trap_glass"}, +}) + +if cm.glass and cm.torch then + minetest.register_craft({ + output = "moreblocks:glow_glass", + type = "shapeless", + recipe = {cm.torch, cm.glass}, + }) +end + +if cm.torch then + minetest.register_craft({ + output = "moreblocks:clean_glow_glass", + type = "shapeless", + recipe = {cm.torch, "moreblocks:clean_glass"}, + }) +end + +minetest.register_craft({ + output = "moreblocks:clean_glow_glass", + type = "shapeless", + recipe = {"moreblocks:sweeper", "moreblocks:glow_glass"}, +}) + +minetest.register_craft({ + output = "moreblocks:trap_clean_glow_glass", + type = "shapeless", + recipe = {"moreblocks:sweeper", "moreblocks:trap_glow_glass"}, +}) + +if cm.torch and cm.glass then + minetest.register_craft({ + output = "moreblocks:super_glow_glass", + type = "shapeless", + recipe = {cm.torch, cm.torch, cm.glass}, + }) +end + +if cm.torch then + minetest.register_craft({ + output = "moreblocks:super_glow_glass", + type = "shapeless", + recipe = {cm.torch, "moreblocks:glow_glass"}, + }) + + minetest.register_craft({ + output = "moreblocks:clean_super_glow_glass", + type = "shapeless", + recipe = {cm.torch, cm.torch, "moreblocks:clean_glass"}, + }) + + minetest.register_craft({ + output = "moreblocks:clean_super_glow_glass", + type = "shapeless", + recipe = {cm.torch, "moreblocks:clean_glow_glass"}, + }) +end + +minetest.register_craft({ + output = "moreblocks:clean_super_glow_glass", + type = "shapeless", + recipe = {"moreblocks:sweeper", "moreblocks:super_glow_glass"}, +}) + +minetest.register_craft({ + output = "moreblocks:trap_clean_super_glow_glass", + type = "shapeless", + recipe = {"moreblocks:sweeper", "moreblocks:trap_super_glow_glass"}, +}) + +if cm.coal_lump and cm.stone then + minetest.register_craft({ + output = "moreblocks:coal_stone", + type = "shapeless", + recipe = {cm.coal_lump, cm.stone}, + }) + + minetest.register_craft({ + output = cm.stone, + type = "shapeless", + recipe = {cm.coal_lump, "moreblocks:iron_stone"}, + }) +end + +if cm.stone and cm.steel_ingot then + minetest.register_craft({ + output = cm.stone, + type = "shapeless", + recipe = {cm.steel_ingot, "moreblocks:coal_stone"}, + }) + + minetest.register_craft({ + output = "moreblocks:iron_stone", + type = "shapeless", + recipe = {cm.steel_ingot, cm.stone}, + }) +end + +if cm.cactus and cm.brick then + minetest.register_craft({ + output = "moreblocks:cactus_brick", + type = "shapeless", + recipe = {cm.cactus, cm.brick}, + }) +end + +if cm.cactus and cm.stone then + minetest.register_craft({ + output = "moreblocks:cactus_checker 4", + recipe = { + {cm.cactus, cm.stone}, + {cm.stone, cm.cactus}, + } + }) + + minetest.register_craft({ + output = "moreblocks:cactus_checker 4", + recipe = { + {cm.stone, cm.cactus}, + {cm.cactus, cm.stone}, + } + }) +end + +if cm.jungle_grass then + minetest.register_craft({ + output = "moreblocks:rope 3", + recipe = { + {cm.jungle_grass}, + {cm.jungle_grass}, + {cm.jungle_grass}, + } + }) +end + +if cm.dirt then + minetest.register_craft({ + output = "moreblocks:dirt_compressed", + recipe = { + {cm.dirt, cm.dirt, cm.dirt}, + {cm.dirt, cm.dirt, cm.dirt}, + {cm.dirt, cm.dirt, cm.dirt}, + } + }) + + minetest.register_craft({ + output = cm.dirt .. " 9", + recipe = {{"moreblocks:dirt_compressed"}}, + }) +end + +if cm.cobble then + minetest.register_craft({ + output = "moreblocks:cobble_compressed", + recipe = { + {cm.cobble, cm.cobble, cm.cobble}, + {cm.cobble, cm.cobble, cm.cobble}, + {cm.cobble, cm.cobble, cm.cobble}, + } + }) + + minetest.register_craft({ + output = cm.cobble .. " 9", + recipe = { + {"moreblocks:cobble_compressed"}, + } + }) +end + +if cm.desert_cobble then + minetest.register_craft({ + output = "moreblocks:desert_cobble_compressed", + recipe = { + {cm.desert_cobble, cm.desert_cobble, cm.desert_cobble}, + {cm.desert_cobble, cm.desert_cobble, cm.desert_cobble}, + {cm.desert_cobble, cm.desert_cobble, cm.desert_cobble}, + } + }) + + minetest.register_craft({ + output = cm.desert_cobble .. " 9", + recipe = { + {"moreblocks:desert_cobble_compressed"}, + } + }) +end + +if cm.pine_tree then + minetest.register_craft({ + type = "cooking", output = "moreblocks:tar", recipe = cm.pine_tree, + }) +end + +if cm.copper_block and cm.bucket_empty then + minetest.register_craft({ + type = "shapeless", + output = "moreblocks:copperpatina", + recipe = {"group:water_bucket", cm.copper_block}, + replacements = { + {"group:water_bucket", cm.bucket_empty} + } + }) +end + +if cm.copper_block then + minetest.register_craft({ + type = "shapeless", + output = "moreblocks:copperpatina", + recipe = {"group:water", cm.copper_block}, + }) +end + +if cm.copper_ingot then + minetest.register_craft({ + output = cm.copper_ingot .. " 9", + recipe = { + {"moreblocks:copperpatina"}, + } + }) +end diff --git a/moreblocks/init.lua b/moreblocks/init.lua new file mode 100644 index 00000000..aaab52ce --- /dev/null +++ b/moreblocks/init.lua @@ -0,0 +1,41 @@ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +moreblocks = { + version = {3, 0, 0}, + fork = "minetest_mods", + + modname = modname, + modpath = modpath, + + S = S, + + has = { + bucket = minetest.get_modpath("bucket"), + default = minetest.get_modpath("default"), + rhotator = minetest.get_modpath("rhotator"), + screwdriver = minetest.get_modpath("screwdriver"), + stairs = minetest.get_modpath("stairs"), + stairsplus = minetest.get_modpath("stairsplus"), + vessels = minetest.get_modpath("vessels"), + }, + + log = function(level, messagefmt, ...) + return minetest.log(level, ("[%s] %s"):format(modname, messagefmt:format(...))) + end, + + dofile = function(...) + return dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua") + end, +} + +moreblocks.dofile("settings") +moreblocks.dofile("util") +moreblocks.dofile("resources", "init") +moreblocks.dofile("api", "init") + +moreblocks.dofile("items") +moreblocks.dofile("nodes") +moreblocks.dofile("crafting") +moreblocks.dofile("aliases") diff --git a/moreblocks/items.lua b/moreblocks/items.lua new file mode 100644 index 00000000..b959af98 --- /dev/null +++ b/moreblocks/items.lua @@ -0,0 +1,7 @@ +-- Items +local S = moreblocks.S + +minetest.register_craftitem("moreblocks:sweeper", { + description = S("Sweeper"), + inventory_image = "moreblocks_sweeper.png", +}) diff --git a/locale/moreblocks.de.tr b/moreblocks/locale/moreblocks.de.tr similarity index 50% rename from locale/moreblocks.de.tr rename to moreblocks/locale/moreblocks.de.tr index b2297e75..d433bb3a 100644 --- a/locale/moreblocks.de.tr +++ b/moreblocks/locale/moreblocks.de.tr @@ -6,30 +6,14 @@ # Xanthin, 2014. # CodeXP , 2018. -#: circular_saw.lua - -Circular Saw=Kreissäge -Input material=Ausgangs-@nmaterial -Left-over=Rest -Max=Anzahl -Recycle output=Wiederver-@nwerten -Set=Ok -owned by @1=gehört @1 -Circular Saw is empty=Kreissäge ist leer -Circular Saw is working on @1=Kreissäge arbeitet mit @1 - #: init.lua [moreblocks] loaded.=[moreblocks] geladen. #: nodes.lua -Deprecated=veraltet -All-faces Acacia Tree=allseitiger Akazienbaumstamm -All-faces Aspen Tree=allseitiger Espenbaumstamm -All-faces Jungle Tree=allseitiger Tropenbaumstamm -All-faces Pine Tree=allseitiger Kieferbaumstamm -All-faces Tree=allseitiger Baumstamm +All-faces @1=allseitiger @1 +No-faces @1= Cactus Brick=Kaktusziegel Cactus Checker=Kaktus-Mosaik Centered Wooden Tile=Holzfliese mittig @@ -39,10 +23,8 @@ Clean Glass=Klares Glas Coal Checker=Kohlen-Mosaik Coal Glass=Kohleglas Clean Super Glow Glass= -Trap Clean Super Glow Glass= -Trap Clean Glass= +Trap @1=@1falle Clean Glow Glass= -Trap Clean Glow Glass= Coal Stone=Kohlestein Coal Stone Bricks=Kohlesteinziegel Compressed Cobblestone=Gepresster Kopfsteinpflaster @@ -64,29 +46,5 @@ Stone Tile=Steinfliese Super Glow Glass=Superleuchtglas Sweeper=Besen Tar=Teer -Trap Desert Stone=Wüstensteinfalle -Trap Glass=Glasfalle -Trap Glow Glass=Leuchtglasfalle -Trap Obsidian=Obsidianfalle -Trap Obsidian Glass=Obsidianglasfalle -Trap Sandstone=Sandsteinfalle -Trap Stone=Steinfalle -Trap Super Glow Glass=Superleuchtglasfalle Wooden Tile=Holzfliese Offset Wooden Tile=Holzfliese versetzt -Downwards Wooden Tile=Holzfliese unten -Leftwards Wooden Tile=Holzfliese links -Rightwards Wooden Tile=Holzfliese rechts - -#: ownership.lua - -Sorry, @1 owns that spot.=Tut mir leid, dieser Bereich gehört @1. -someone=jemand - -#: stairsplus/common.lua - -@1 Microblock=@1mikroblock -@1 Slab=@1platte -@1 Slope=@1neigung -@1 Panel=@1paneel -@1 Stairs=@1treppe diff --git a/moreblocks/locale/moreblocks.es.tr b/moreblocks/locale/moreblocks.es.tr new file mode 100644 index 00000000..3b9ec8b6 --- /dev/null +++ b/moreblocks/locale/moreblocks.es.tr @@ -0,0 +1,47 @@ +# textdomain: moreblocks + +# Spanish translation for More Blocks. +# Copyright © 2011-2020 Hugo Locurcio and contributors +# This file is distributed under the same license as the More Blocks package. +# kaeza, 2013. +# CodeXP , 2018. +# Carlos Barraza 2020. + +#: nodes.lua + +All-faces @1=@1, todas las caras +No-faces @1= +Cactus Brick=Ladrillos de Cactus +Cactus Checker=Cuadros de Cactus +Centered Wooden Tile=Parqué​ Centrado +Checker Stone Tile=Cuadros de Baldosa de Piedra +Circle Stone Bricks=Bloques de Piedra Circulares +Clean Glass=Cristal Limpio +Coal Checker=Cuadros de Carbón +Coal Glass=Cristal con Carbón +Clean Super Glow Glass=Cristal Súper Brillante Limpio +Trap @1=@1 Falso +Clean Glow Glass=Cristal Brillante Limpio +Coal Stone=Carbón y Piedra +Coal Stone Bricks=Ladrillos de Piedra de Carbon +Compressed Cobblestone=Adoquín Comprimido +Compressed Desert Cobblestone=Adoquín del Desierto Comprimido +Compressed Dirt=Tierra Comprimida +Copper Patina Block=Bloque de Pátina de Cobre +Empty Shelf=Estante vacio +Full Wooden Tile=Parqué​ Completo +Glow Glass=Cristal Brillante +Iron Checker=Cuadros de Hierro +Iron Glass=Cristal con Hierro +Iron Stone=Hierro y Piedra +Iron Stone Bricks=Ladrillo de Piedra de Hierro +Plankstone=Tablones de piedra +Rope=Soga +Split Stone Tile=Baldosas de Piedra Partida +Stone Bricks=Ladrillos de Piedra +Stone Tile=Baldosa de Piedra +Super Glow Glass=Cristal Súper Brillante +Sweeper=Limpiador +Tar=Alquitrán +Wooden Tile=Parqué​ +Offset Wooden Tile=Parqué​ Ajustado diff --git a/locale/moreblocks.fr.tr b/moreblocks/locale/moreblocks.fr.tr similarity index 50% rename from locale/moreblocks.fr.tr rename to moreblocks/locale/moreblocks.fr.tr index 790b19a3..c6d86c1a 100644 --- a/locale/moreblocks.fr.tr +++ b/moreblocks/locale/moreblocks.fr.tr @@ -7,30 +7,14 @@ # Jat15, 2013. # CodeXP , 2018. -#: circular_saw.lua - -Circular Saw=Scie circulaire -Input material=Matériau@nd'entrée -Left-over=Reste -Max=Max -Recycle output=Sortie à@nrecycler -Set=Définir -owned by @1=propriété de @1 -Circular Saw is empty=Scie circulaire vide -Circular Saw is working on @1=Scie circulaire manipulant @1 - #: init.lua [moreblocks] loaded.=[moreblocks] a été chargé. #: nodes.lua -Deprecated=déprécié -All-faces Acacia Tree=Tronc d'arbre d'acacia (toutes faces) -All-faces Aspen Tree=Tronc d'arbre de peuplier (toutes faces) -All-faces Jungle Tree=Tronc d'arbre de jungle (toutes faces) -All-faces Pine Tree=Tronc d'arbre de pin (toutes faces) -All-faces Tree=Tronc d'arbre (toutes faces) +All-faces @1=@1 (toutes faces) +No-faces @1= Cactus Brick=Briques de cactus Cactus Checker=Damier en cactus Centered Wooden Tile=Dalle en bois centrée @@ -40,10 +24,8 @@ Clean Glass=Verre propre Coal Checker=Damier en charbon Coal Glass=Verre de charbon Clean Super Glow Glass= -Trap Clean Super Glow Glass= -Trap Clean Glass= +Trap @1=@1 traversable Clean Glow Glass= -Trap Clean Glow Glass= Coal Stone=Pierre de charbon Coal Stone Bricks=Briques en pierre de charbon Compressed Cobblestone=Pierre taillée compressée @@ -65,29 +47,5 @@ Stone Tile=Dalle en pierre Super Glow Glass=Verre très brillant Sweeper=Balai Tar=Bitume -Trap Desert Stone=Pierre du désert traversable -Trap Glass=Verre traversable -Trap Glow Glass=Verre brillant traversable -Trap Obsidian=Obsidienne traversable -Trap Obsidian Glass=Verre d'obsidienne traversable -Trap Sandstone=Grès traversable -Trap Stone=Pierre traversable -Trap Super Glow Glass=Verre très brillant traversable Wooden Tile=Dalle en bois Offset Wooden Tile=Dalle en bois décalée -Downwards Wooden Tile=Dalle en bois vers le bas -Leftwards Wooden Tile=Dalle en bois vers la gauche -Rightwards Wooden Tile=Dalle en bois vers la droite - -#: ownership.lua - -Sorry, @1 owns that spot.=Désolé, @1 possède cet endroit. -someone=quelqu'un - -#: stairsplus/common.lua - -@1 Microblock=Microbloc en @1 -@1 Slab=Demi-dalle en @1 -@1 Slope=Pente en @1 -@1 Panel=Barre en @1 -@1 Stairs=Escaliers en @1 diff --git a/locale/moreblocks.it.tr b/moreblocks/locale/moreblocks.it.tr similarity index 55% rename from locale/moreblocks.it.tr rename to moreblocks/locale/moreblocks.it.tr index f3c16392..67d4e22b 100644 --- a/locale/moreblocks.it.tr +++ b/moreblocks/locale/moreblocks.it.tr @@ -6,30 +6,14 @@ # Emon, 2016. # CodeXP , 2018. -#: circular_saw.lua - -Circular Saw=Sega circolare -Input material=Materiale@niniziale -Left-over=Scarto -Max=Max. -Recycle output=Ricicla@nfinale -Set=Imp. -owned by @1= -Circular Saw is empty=Sega circolare, vuota -Circular Saw is working on @1=Sega circolare, in funzione su @1 - #: init.lua [moreblocks] loaded.=[moreblocks] caricato. #: nodes.lua -Deprecated= -All-faces Acacia Tree= -All-faces Aspen Tree= -All-faces Jungle Tree= -All-faces Pine Tree= -All-faces Tree=Albero su ogni lato +All-faces @1=@1 su ogni lato +No-faces @1= Cactus Brick=Mattoni di cactus Cactus Checker=Scacchiera in cactus Centered Wooden Tile=Mattonella in legno centrata @@ -39,10 +23,8 @@ Clean Glass=Vetro pulito Coal Checker=Scacchiera in carbone Coal Glass=Vetro e carbone Clean Super Glow Glass= -Trap Clean Super Glow Glass= -Trap Clean Glass= +Trap @1=@1 trappola Clean Glow Glass= -Trap Clean Glow Glass= Coal Stone=Pietra in carbone Coal Stone Bricks=Mattoni di pietra in carbone Compressed Cobblestone= @@ -64,29 +46,5 @@ Stone Tile=Mattonella in pietra Super Glow Glass=Super vetro luminoso Sweeper=Spazzola Tar= -Trap Desert Stone= -Trap Glass=Vetro trappola -Trap Glow Glass=Vetro luminoso trappola -Trap Obsidian= -Trap Obsidian Glass= -Trap Sandstone= -Trap Stone=Pietra trappola -Trap Super Glow Glass=Super vetro luminoso trappola Wooden Tile=Mattonella in legno Offset Wooden Tile= -Downwards Wooden Tile= -Leftwards Wooden Tile= -Rightwards Wooden Tile= - -#: ownership.lua - -Sorry, @1 owns that spot.=Spiacente, quel punto è di proprietà di @1 -someone=qualcuno - -#: stairsplus/common.lua - -@1 Microblock=Microblocco @1 -@1 Slab=Lastra - @1 -@1 Slope= -@1 Panel=Pannello - @1 -@1 Stairs=Scale - @1 diff --git a/moreblocks/locale/moreblocks.pl.tr b/moreblocks/locale/moreblocks.pl.tr new file mode 100644 index 00000000..35ce9752 --- /dev/null +++ b/moreblocks/locale/moreblocks.pl.tr @@ -0,0 +1,50 @@ +# textdomain: moreblocks + +# Polish translation for More Blocks. +# Copyright © 2011-2020 Hugo Locurcio and contributors +# This file is distributed under the same license as the More Blocks package. +# mat9117, 2019 +# CodeXP , 2018. + +#: init.lua + +[moreblocks] loaded.=[moreblocks] załadowane. + +#: nodes.lua + +All-faces @1=Wielostronna tekstura @1 +No-faces @1= +Cactus Brick=Kaktusowa cegła +Cactus Checker=Kaktusowa szachownica +Centered Wooden Tile=Wyśrodkowany drewniany kafelek +Checker Stone Tile=Kamienna szachownica +Circle Stone Bricks=Okrągłe kamienne cegły +Clean Glass=Czyste szkło +Coal Checker=Węglowa szachownica +Coal Glass=Szkło węglowe +Clean Super Glow Glass= +Trap @1=@1 pułapka +Clean Glow Glass= +Coal Stone=Kamień węglowy +Coal Stone Bricks=Węglowe kamienne cegły +Compressed Cobblestone=Skompresowany bruk +Compressed Desert Cobblestone= +Compressed Dirt=Skompresowana ziemia +Copper Patina Block=Blok patynowanej miedzi +Empty Shelf=Pusta półka +Full Wooden Tile=Pełny drewniany kafelek +Glow Glass=Świecące szkło +Iron Checker=Żelazna szachownica +Iron Glass=Żelazne szkło +Iron Stone=Żelazny kamień +Iron Stone Bricks=Żelazne kamienne cegły +Plankstone=Deskokamień +Rope=Lina +Split Stone Tile=Kamienny blok kafelkowy +Stone Bricks=Kamienne cegły +Stone Tile=Kamienny kafelek +Super Glow Glass=Super świecące szkło +Sweeper=Miotła +Tar=Smoła +Wooden Tile=Drewniany kafelek +Offset Wooden Tile= diff --git a/locale/moreblocks.ru.tr b/moreblocks/locale/moreblocks.ru.tr similarity index 50% rename from locale/moreblocks.ru.tr rename to moreblocks/locale/moreblocks.ru.tr index 8b1da894..72f13a77 100644 --- a/locale/moreblocks.ru.tr +++ b/moreblocks/locale/moreblocks.ru.tr @@ -9,28 +9,14 @@ #: circular_saw.lua -Circular Saw=циркулярная пила -Input material=Входной@nматериал -Left-over=Остатки -Max=Кол. -Recycle output=Пере-@nобработка -Set=ОК -owned by @1=принадлежит @1 -Circular Saw is empty=циркулярная пила пустая -Circular Saw is working on @1=циркулярная пила, @1 в обработке - #: init.lua [MOD] moreblocks loaded.=[MOD] moreblocks загружен. #: nodes.lua -Deprecated=устаревший -All-faces Acacia Tree=всестороннее бревно акации -All-faces Aspen Tree=всестороннее бревно осины -All-faces Jungle Tree=всестороннее бревно дерева джунглей -All-faces Pine Tree=всестороннее бревно сосновое -All-faces Tree=всестороннее бревно дерева +All-faces @1=всестороннее бревно @1 +No-faces @1= Cactus Brick=кирпич из кактуса Cactus Checker=мозаика из кактуса Centered Wooden Tile=деревянная мозаика (центр) @@ -40,10 +26,8 @@ Clean Glass=чистое стекло Coal Checker=угольная мозаика Coal Glass=угольное стекло Clean Super Glow Glass= -Trap Clean Super Glow Glass= -Trap Clean Glass= +Trap @1=мнимое @1 Clean Glow Glass= -Trap Clean Glow Glass= Coal Stone=угольный камень Coal Stone Bricks=угольно-каменный кирпич Compressed Cobblestone=прессованный булыжник @@ -65,31 +49,5 @@ Stone Tile=каменная плитка Super Glow Glass=супер светящееся стекло Sweeper=метёлка Tar=смола -Trap Desert Stone=мнимый пустынный камень -Trap Glass=мнимое стекло -Trap Glow Glass=мнимое светящееся стекло -Trap Obsidian=мнимый обсидиан -Trap Obsidian Glass=мнимое обсидиановое стекло -Trap Sandstone=мнимый песчаник -Trap Stone=мнимый камень -Trap Super Glow Glass=мнимое супер светящееся стекло Wooden Tile=деревянная мозаика Offset Wooden Tile=деревянная мозаика (сверху) -# @deprecated -Downwards Wooden Tile=деревянная мозаика (снизу) -# @deprecated -Leftwards Wooden Tile=деревянная мозаика (слева) -# @deprecated -Rightwards Wooden Tile=деревянная мозаика (справа) - -#: ownership.lua -Sorry, @1 owns that spot.=Извините, это принадлежит @1. -someone=кому-то - -#: stairsplus/common.lua - -@1 Microblock=@1 (микроблок) -@1 Slab=@1 (плита) -@1 Slope=@1 (наклон) -@1 Panel=@1 (панель) -@1 Stairs=@1 (лестница) diff --git a/moreblocks/locale/moreblocks.template.tr b/moreblocks/locale/moreblocks.template.tr new file mode 100644 index 00000000..15a7fefa --- /dev/null +++ b/moreblocks/locale/moreblocks.template.tr @@ -0,0 +1,40 @@ +# textdomain: moreblocks + +#: nodes.lua + +All-faces @1= +Cactus Brick= +Cactus Checker= +Centered Wooden Tile= +Checker Stone Tile= +Circle Stone Bricks= +Clean Glass= +Coal Checker= +Coal Glass= +Clean Super Glow Glass= +Trap @1= +Clean Glow Glass= +Coal Stone= +Coal Stone Bricks= +Compressed Cobblestone= +Compressed Desert Cobblestone= +Compressed Dirt= +Copper Patina Block= +Empty Shelf= +Full Wooden Tile= +Glow Glass= +Iron Checker= +Iron Glass= +Iron Stone= +Iron Stone Bricks= +No-faces @1= +Plankstone= +Rope= +Split Stone Tile= +Stone Bricks= +Stone Tile= +Super Glow Glass= +Sweeper= +Tar= +Wooden Tile= +Offset Wooden Tile= diff --git a/moreblocks/locale/moreblocks.zh_CN.tr b/moreblocks/locale/moreblocks.zh_CN.tr new file mode 100644 index 00000000..4fe862fe --- /dev/null +++ b/moreblocks/locale/moreblocks.zh_CN.tr @@ -0,0 +1,45 @@ +# textdomain: moreblocks + +# zh_CN translation for More Blocks. +# Copyright © 2011-2020 Hugo Locurcio and contributors +# This file is distributed under the same license as the More Blocks package. +# IFRFSX , 2020. + +#: nodes.lua + +All-faces @1=全切面@1树木方块 +No-faces @1= +Cactus Brick=仙人掌砖 +Cactus Checker=仙人掌棋盘方块 +Centered Wooden Tile=居中的木瓦 +Checker Stone Tile=棋盘石瓦 +Circle Stone Bricks=圆石砖 +Clean Glass=干净的玻璃 +Coal Checker=棋盘煤块 +Coal Glass=煤玻璃 +Clean Super Glow Glass= +Trap @1=陷阱@1 +Clean Glow Glass= +Coal Stone=煤炭石 +Coal Stone Bricks=煤炭石砖 +Compressed Cobblestone=压缩圆石 +Compressed Desert Cobblestone= +Compressed Dirt=压缩土 +Copper Patina Block=铜绿方块 +Empty Shelf=空书架 +Full Wooden Tile=全木瓦 +Glow Glass=发光玻璃 +Iron Checker=棋盘铁方块 +Iron Glass=铁玻璃 +Iron Stone=铁石 +Iron Stone Bricks=铁石砖 +Plankstone=板石 +Rope=绳子 +Split Stone Tile=裂石砖 +Stone Bricks=石砖 +Stone Tile=石瓦 +Super Glow Glass=超级发光玻璃 +Sweeper=清扫器 +Tar=焦油 +Wooden Tile=木瓦 +Offset Wooden Tile=胶合木瓦 diff --git a/moreblocks/locale/moreblocks.zh_TW.tr b/moreblocks/locale/moreblocks.zh_TW.tr new file mode 100644 index 00000000..78a8b2e0 --- /dev/null +++ b/moreblocks/locale/moreblocks.zh_TW.tr @@ -0,0 +1,45 @@ +# textdomain: moreblocks + +# zh_TW translation for More Blocks. +# Copyright © 2011-2020 Hugo Locurcio and contributors +# This file is distributed under the same license as the More Blocks package. +# IFRFSX , 2020. + +#: nodes.lua + +All-faces @1=全切面@1樹木方塊 +No-faces @1= +Cactus Brick=仙人掌磚 +Cactus Checker=仙人掌棋盤方塊 +Centered Wooden Tile=居中的木瓦 +Checker Stone Tile=棋盤石瓦 +Circle Stone Bricks=圓石磚 +Clean Glass=乾淨的玻璃 +Coal Checker=棋盤煤塊 +Coal Glass=煤玻璃 +Clean Super Glow Glass= +Trap @1=陷阱@1 +Clean Glow Glass= +Coal Stone=煤炭石 +Coal Stone Bricks=煤炭石磚 +Compressed Cobblestone=壓縮圓石 +Compressed Desert Cobblestone= +Compressed Dirt=壓縮土 +Copper Patina Block=銅綠方塊 +Empty Shelf=空書架 +Full Wooden Tile=全木瓦 +Glow Glass=發光玻璃 +Iron Checker=棋盤鐵方塊 +Iron Glass=鐵玻璃 +Iron Stone=鐵石 +Iron Stone Bricks=鐵石磚 +Plankstone=板石 +Rope=繩子 +Split Stone Tile=裂石磚 +Stone Bricks=石磚 +Stone Tile=石瓦 +Super Glow Glass=超級發光玻璃 +Sweeper=清掃器 +Tar=焦油 +Wooden Tile=木瓦 +Offset Wooden Tile=膠合木瓦 diff --git a/moreblocks/mod.conf b/moreblocks/mod.conf new file mode 100644 index 00000000..a416c11b --- /dev/null +++ b/moreblocks/mod.conf @@ -0,0 +1,6 @@ +name = moreblocks +version = 3.0.0 +title = More Blocks +description = Adds various blocks to the game. +optional_depends = bucket, default, rhotator, screwdriver, stairs, stairsplus, vessels +min_minetest_version = 5.5.0 diff --git a/moreblocks/nodes.lua b/moreblocks/nodes.lua new file mode 100644 index 00000000..1a63bc8d --- /dev/null +++ b/moreblocks/nodes.lua @@ -0,0 +1,487 @@ +local S = moreblocks.S + +local cm = moreblocks.resources.craft_materials +local t = moreblocks.resources.textures + +local modname = moreblocks.modname + +local sound_dirt = moreblocks.resources.sounds.dirt +local sound_wood = moreblocks.resources.sounds.wood +local sound_stone = moreblocks.resources.sounds.stone +local sound_glass = moreblocks.resources.sounds.glass +local sound_leaves = moreblocks.resources.sounds.leaves +local sound_metal = moreblocks.resources.sounds.metal + +local function is_glasslike(def) + return #def.tiles > 1 and ( + def.drawtype == "glasslike_framed" or + def.drawtype == "glasslike_framed_optional" + ) +end + +local function register_stairs(name, def) + local itemstring = ("%s:%s"):format(modname, name) + + -- Use the primary tile for all sides of cut glasslike nodes. + -- This makes them easier to see + if is_glasslike(def) then + def = table.copy(def) + def.tiles = {def.tiles[1]} + end + + if moreblocks.has.stairsplus then + if stairsplus.settings.legacy_mode then + stairsplus.api.register_group(itemstring, "legacy") + else + stairsplus.api.register_group(itemstring, "common") + end + + elseif moreblocks.has.stairs then + stairs.register_stair_and_slab( + ("%s_%s"):format(modname, name), + itemstring, + def.groups, + def.tiles, + S("@1 Stair", def.description), + S("@1 Slab", def.description), + def.sounds, + true + ) + end +end + +local function tile_tiles(tex) + return {tex, tex, tex, tex, tex .. "^[transformR90", tex .. "^[transformR90"} +end + +local function register_with_stairs(name, def) + local itemstring = ("%s:%s"):format(modname, name) + def.tiles = def.tiles or {("%s_%s.png"):format(modname, name)} + minetest.register_node(itemstring, def) + minetest.register_alias(name, itemstring) + register_stairs(name, def) +end + +local function register_no_stairs(name, def) + local itemstring = ("%s:%s"):format(modname, name) + def.tiles = def.tiles or {("%s_%s.png"):format(modname, name)} + minetest.register_node(itemstring, def) + minetest.register_alias(name, itemstring) +end + +local function register_all_faces(name, base) + name = "all_faces_" .. name + local itemstring = ("%s:%s"):format(modname, name) + moreblocks.api.register_all_faces(itemstring, base) + register_stairs(name, minetest.registered_nodes[itemstring]) + minetest.register_alias(name, itemstring) +end + +local function register_no_faces(name, base) + name = "no_faces_" .. name + local itemstring = ("%s:%s"):format(modname, name) + moreblocks.api.register_no_faces(itemstring, base) + register_stairs(name, minetest.registered_nodes[itemstring]) + minetest.register_alias(name, itemstring) +end + +local function register_trap(name, base) + name = "trap_" .. name + local itemstring = ("%s:%s"):format(modname, name) + moreblocks.api.register_trap(itemstring, base) + minetest.register_alias(name, itemstring) +end + +register_with_stairs("wood_tile", { + description = S("Wooden Tile"), + groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, + is_ground_content = false, + paramtype2 = "facedir", + place_param2 = 0, + tiles = tile_tiles(("%s^moreblocks_wood_tile.png"):format(t.wood)), + sounds = sound_wood, +}) + +register_with_stairs("wood_tile_center", { + description = S("Centered Wooden Tile"), + groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, + is_ground_content = false, + tiles = { + ("%s^moreblocks_wood_tile_center.png"):format(t.wood) + }, + sounds = sound_wood, +}) + +register_with_stairs("wood_tile_full", { + description = S("Full Wooden Tile"), + groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, + is_ground_content = false, + tiles = tile_tiles("moreblocks_wood_tile_full.png"), + sounds = sound_wood, +}) + +register_no_stairs("wood_tile_offset", { + description = S("Offset Wooden Tile"), + paramtype2 = "facedir", + place_param2 = 0, + groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, + is_ground_content = false, + tiles = { + ("%s^moreblocks_wood_tile_offset.png"):format(t.wood) + }, + sounds = sound_wood, +}) + +register_with_stairs("circle_stone_bricks", { + description = S("Circle Stone Bricks"), + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("grey_bricks", { + description = S("Stone Bricks"), + paramtype2 = "facedir", + place_param2 = 0, + groups = {cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("coal_stone_bricks", { + description = S("Coal Stone Bricks"), + paramtype2 = "facedir", + place_param2 = 0, + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("iron_stone_bricks", { + description = S("Iron Stone Bricks"), + paramtype2 = "facedir", + place_param2 = 0, + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("stone_tile", { + description = S("Stone Tile"), + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("split_stone_tile", { + description = S("Split Stone Tile"), + paramtype2 = "facedir", + place_param2 = 0, + tiles = { + "moreblocks_split_stone_tile_top.png", + "moreblocks_split_stone_tile.png" + }, + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("checker_stone_tile", { + description = S("Checker Stone Tile"), + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("tar", { + description = S("Tar"), + groups = {cracky = 2, tar_block = 1}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("dirt_compressed", { + description = S("Compressed Dirt"), + groups = {crumbly = 2}, + is_ground_content = false, + sounds = sound_dirt, +}) + +register_with_stairs("cobble_compressed", { + description = S("Compressed Cobblestone"), + groups = {cracky = 1}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("desert_cobble_compressed", { + description = S("Compressed Desert Cobblestone"), + groups = {cracky = 1}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("plankstone", { + description = S("Plankstone"), + paramtype2 = "facedir", + place_param2 = 0, + groups = {cracky = 3}, + is_ground_content = false, + tiles = tile_tiles("moreblocks_plankstone.png"), + sounds = sound_stone, +}) + +register_with_stairs("iron_glass", { + description = S("Iron Glass"), + drawtype = "glasslike_framed_optional", + tiles = { + ("%s^[colorize:#DEDEDE"):format(t.glass), + ("%s^[colorize:#DEDEDE"):format(t.glass_detail) + }, + use_texture_alpha = "clip", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + sounds = sound_glass, +}) + +register_with_stairs("coal_glass", { + description = S("Coal Glass"), + drawtype = "glasslike_framed_optional", + tiles = { + ("%s^[colorize:#828282"):format(t.glass), + ("%s^[colorize:#828282"):format(t.glass_detail) + }, + use_texture_alpha = "clip", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + sounds = sound_glass, +}) + +register_with_stairs("clean_glass", { + description = S("Clean Glass"), + drawtype = "glasslike_framed_optional", + tiles = { + "moreblocks_clean_glass.png", + "moreblocks_clean_glass_detail.png" + }, + use_texture_alpha = "clip", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + sounds = sound_glass, +}) + +register_with_stairs("cactus_brick", { + description = S("Cactus Brick"), + paramtype2 = "facedir", + place_param2 = 0, + groups = {cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("cactus_checker", { + description = S("Cactus Checker"), + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + tiles = tile_tiles(("%s^moreblocks_cactus_checker.png"):format(t.stone)), + sounds = sound_stone, +}) + +register_no_stairs("empty_shelf", { + description = S("Empty Shelf"), + paramtype2 = "facedir", + tiles = { + t.wood, + t.wood, + t.wood, + t.wood, + "moreblocks_empty_shelf.png", + "moreblocks_empty_shelf.png" + }, + groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3}, + is_ground_content = false, + sounds = sound_wood, + furnace_burntime = 15, +}) + +register_with_stairs("coal_stone", { + description = S("Coal Stone"), + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("iron_stone", { + description = S("Iron Stone"), + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("coal_checker", { + description = S("Coal Checker"), + tiles = tile_tiles(("%s^moreblocks_coal_checker.png"):format(t.stone)), + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("iron_checker", { + description = S("Iron Checker"), + tiles = tile_tiles(("%s^moreblocks_iron_checker.png"):format(t.stone)), + groups = {stone = 1, cracky = 3}, + is_ground_content = false, + sounds = sound_stone, +}) + +register_with_stairs("glow_glass", { + description = S("Glow Glass"), + drawtype = "glasslike_framed_optional", + tiles = { + ("%s^[colorize:#E9CD61"):format(t.glass), + ("%s^[colorize:#E9CD61"):format(t.glass_detail) + }, + use_texture_alpha = "clip", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + light_source = 11, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + sounds = sound_glass, +}) + +register_with_stairs("super_glow_glass", { + description = S("Super Glow Glass"), + drawtype = "glasslike_framed_optional", + tiles = { + ("%s^[colorize:#FFFF78"):format(t.glass), + ("%s^[colorize:#FFFF78"):format(t.glass_detail) + }, + use_texture_alpha = "clip", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + light_source = minetest.LIGHT_MAX, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + sounds = sound_glass, +}) + +register_with_stairs("clean_glow_glass", { + description = S("Clean Glow Glass"), + drawtype = "glasslike_framed_optional", + tiles = { + "moreblocks_clean_glass.png^[colorize:#E9CD61", + "moreblocks_clean_glass_detail.png^[colorize:#E9CD61" + }, + use_texture_alpha = "clip", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + light_source = 11, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + sounds = sound_glass, +}) + +register_with_stairs("clean_super_glow_glass", { + description = S("Clean Super Glow Glass"), + drawtype = "glasslike_framed_optional", + tiles = { + "moreblocks_clean_glass.png^[colorize:#FFFF78", + "moreblocks_clean_glass_detail.png^[colorize:#FFFF78" + }, + use_texture_alpha = "clip", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + light_source = minetest.LIGHT_MAX, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + sounds = sound_glass, +}) + +register_with_stairs("copperpatina", { + description = S("Copper Patina Block"), + groups = {cracky = 1, level = 2}, + is_ground_content = false, + sounds = sound_metal, +}) + +register_no_stairs("rope", { + description = S("Rope"), + drawtype = "signlike", + inventory_image = "moreblocks_rope.png", + wield_image = "moreblocks_rope.png", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + paramtype2 = "wallmounted", + walkable = false, + climbable = true, + selection_box = {type = "wallmounted", }, + groups = {snappy = 3, flammable = 2}, + sounds = sound_leaves, +}) + +register_trap("clean_glass", "moreblocks:clean_glass") +register_trap("clean_glow_glass", "moreblocks:clean_glow_glass") +register_trap("clean_super_glow_glass", "moreblocks:clean_super_glow_glass") + +if cm.stone then + register_trap("stone", cm.stone) +end + +if cm.desert_stone then + register_trap("desert_stone", cm.desert_stone) +end + +if cm.glass then + register_trap("glass", cm.glass) + register_trap("glow_glass", "moreblocks:glow_glass") + register_trap("super_glow_glass", "moreblocks:super_glow_glass") +end + +if cm.obsidian_glass then + register_trap("obsidian_glass", cm.obsidian_glass) +end + +if cm.obsidian then + register_trap("obsidian", cm.obsidian) +end + +if cm.obsidian then + register_trap("obsidian", cm.obsidian) +end + +if cm.sandstone then + register_trap("sandstone", cm.sandstone) +end + +if cm.tree then + register_all_faces("tree", cm.tree) + register_no_faces("tree", cm.tree) +end + +if cm.jungle_tree then + register_all_faces("jungle_tree", cm.jungle_tree) + register_no_faces("jungle_tree", cm.jungle_tree) +end + +if cm.pine_tree then + register_all_faces("pine_tree", cm.pine_tree) + register_no_faces("pine_tree", cm.pine_tree) +end + +if cm.acacia_tree then + register_all_faces("acacia_tree", cm.acacia_tree) + register_no_faces("acacia_tree", cm.acacia_tree) +end + +if cm.aspen_tree then + register_all_faces("aspen_tree", cm.aspen_tree) + register_no_faces("aspen_tree", cm.aspen_tree) +end diff --git a/moreblocks/resources/craft_materials.lua b/moreblocks/resources/craft_materials.lua new file mode 100644 index 00000000..77e1d44e --- /dev/null +++ b/moreblocks/resources/craft_materials.lua @@ -0,0 +1,68 @@ +local table_set_all = moreblocks.util.table_set_all + +moreblocks.resources.craft_materials = {} + +if moreblocks.has.bucket then + table_set_all(moreblocks.resources.craft_materials, { + bucket_empty = "bucket:bucket_empty", + }) +end + +if moreblocks.has.default then + table_set_all(moreblocks.resources.craft_materials, { + acacia_tree = "default:acacia_tree", + aspen_tree = "default:aspen_tree", + book = "default:book", + bookshelf = "default:bookshelf", + brick = "default:brick", + bronze_ingot = "default:bronze_ingot", + cactus = "default:cactus", + chest = "default:chest", + chest_locked = "default:chest_locked", + coal_lump = "default:coal_lump", + cobble = "default:cobble", + copper_block = "default:copperblock", + copper_ingot = "default:copper_ingot", + desert_cobble = "default:desert_cobble", + desert_stone = "default:desert_stone", + dirt = "default:dirt", + dirt_with_grass = "default:dirt_with_grass", + dry_shrub = "default:dry_shrub", + fence_jungle_wood = "default:fence_junglewood", + glass = "default:glass", + gold_ingot = "default:gold_ingot", + jungle_grass = "default:junglegrass", + jungle_tree = "default:jungletree", + jungle_wood = "default:junglewood", + mossy_cobble = "default:mossycobble", + obsidian = "default:obsidian", + obsidian_glass = "default:obsidian_glass", + pine_tree = "default:pine_tree", + sandstone = "default:sandstone", + steel_ingot = "default:steel_ingot", + stick = "default:stick", + stone_brick = "default:stonebrick", + stone = "default:stone", + torch = "default:torch", + trap_material = "default:mese_crystal_fragment", + tree = "default:tree", + wood = "default:wood", + }) +end + +if moreblocks.has.screwdriver then + table_set_all(moreblocks.resources.craft_materials, { + screwdriver = "screwdriver:screwdriver", + }) +elseif moreblocks.has.rhotator then + table_set_all(moreblocks.resources.craft_materials, { + screwdriver = "rhotator:screwdriver_multi", + }) +end + +if moreblocks.has.vessels then + table_set_all(moreblocks.resources.craft_materials, { + glass_bottle = "vessels:glass_bottle", + vessels_shelf = "vessels:shelf", + }) +end diff --git a/moreblocks/resources/init.lua b/moreblocks/resources/init.lua new file mode 100644 index 00000000..64ec3c70 --- /dev/null +++ b/moreblocks/resources/init.lua @@ -0,0 +1,5 @@ +moreblocks.resources = {} + +moreblocks.dofile("resources", "craft_materials") +moreblocks.dofile("resources", "sounds") +moreblocks.dofile("resources", "textures") diff --git a/moreblocks/resources/sounds.lua b/moreblocks/resources/sounds.lua new file mode 100644 index 00000000..375c3dcd --- /dev/null +++ b/moreblocks/resources/sounds.lua @@ -0,0 +1,14 @@ +local table_set_all = moreblocks.util.table_set_all + +moreblocks.resources.sounds = {} + +if moreblocks.has.default then + table_set_all(moreblocks.resources.sounds, { + dirt = default.node_sound_dirt_defaults(), + glass = default.node_sound_glass_defaults(), + leaves = default.node_sound_leaves_defaults(), + metal = default.node_sound_metal_defaults(), + stone = default.node_sound_stone_defaults(), + wood = default.node_sound_wood_defaults(), + }) +end diff --git a/moreblocks/resources/textures.lua b/moreblocks/resources/textures.lua new file mode 100644 index 00000000..8dff5ede --- /dev/null +++ b/moreblocks/resources/textures.lua @@ -0,0 +1,51 @@ +local table_set_all = moreblocks.util.table_set_all + +moreblocks.resources.textures = { + desert_stone = "[combine:16x16^[noalpha^[colorize:#85513e", + glass = ([[ + [combine:16x16 + :0,0=\[combine\:1x16\^[noalpha\^[colorize\:#FFF + :0,0=\[combine\:16x1\^[noalpha\^[colorize\:#FFF + :0,15=\[combine\:16x1\^[noalpha\^[colorize\:#FFF + :15,0=\[combine\:1x16\^[noalpha\^[colorize\:#FFF + ]]):gsub("%s", ""), + glass_detail = ([[ + [combine:16x16 + :0,0=\[combine\:1x16\^[noalpha\^[colorize\:#FFF + :0,0=\[combine\:16x1\^[noalpha\^[colorize\:#FFF + :0,15=\[combine\:16x1\^[noalpha\^[colorize\:#FFF + :15,0=\[combine\:1x16\^[noalpha\^[colorize\:#FFF + ]]):gsub("%s", ""), + obsidian = "default_obsidian.png", + obsidian_glass = ([[ + [combine:16x16 + :0,0=\[combine\:1x16\^[noalpha\^[colorize\:#000 + :0,0=\[combine\:16x1\^[noalpha\^[colorize\:#000 + :0,15=\[combine\:16x1\^[noalpha\^[colorize\:#000 + :15,0=\[combine\:1x16\^[noalpha\^[colorize\:#000 + ]]):gsub("%s", ""), + obsidian_glass_detail = ([[ + [combine:16x16 + :0,0=\[combine\:1x16\^[noalpha\^[colorize\:#000 + :0,0=\[combine\:16x1\^[noalpha\^[colorize\:#000 + :0,15=\[combine\:16x1\^[noalpha\^[colorize\:#000 + :15,0=\[combine\:1x16\^[noalpha\^[colorize\:#000 + ]]):gsub("%s", ""), + sandstone = "default_sandstone.png", + stone = "[combine:16x16^[noalpha^[colorize:#686463", + wood = "[combine:16x16^[noalpha^[colorize:#654321", +} + +if moreblocks.has.default then + table_set_all(moreblocks.resources.textures, { + desert_stone = "default_desert_stone.png", + glass = "default_glass.png", + glass_detail = "default_glass_detail.png", + obsidian = "default_obsidian.png", + obsidian_glass = "default_obsidian_glass.png", + obsidian_glass_detail = "default_obsidian_glass_detail.png", + sandstone = "default_sandstone.png", + stone = "default_stone.png", + wood = "default_wood.png", + }) +end diff --git a/moreblocks/settings.lua b/moreblocks/settings.lua new file mode 100644 index 00000000..91a1a50a --- /dev/null +++ b/moreblocks/settings.lua @@ -0,0 +1,5 @@ +local s = minetest.settings + +moreblocks.settings = { + outline_trap_nodes = s:get_bool("moreblocks.outline_trap_nodes", true), +} diff --git a/textures/moreblocks_cactus_brick.png b/moreblocks/textures/moreblocks_cactus_brick.png similarity index 100% rename from textures/moreblocks_cactus_brick.png rename to moreblocks/textures/moreblocks_cactus_brick.png diff --git a/textures/moreblocks_cactus_checker.png b/moreblocks/textures/moreblocks_cactus_checker.png similarity index 100% rename from textures/moreblocks_cactus_checker.png rename to moreblocks/textures/moreblocks_cactus_checker.png diff --git a/textures/moreblocks_checker_stone_tile.png b/moreblocks/textures/moreblocks_checker_stone_tile.png similarity index 100% rename from textures/moreblocks_checker_stone_tile.png rename to moreblocks/textures/moreblocks_checker_stone_tile.png diff --git a/textures/moreblocks_circle_stone_bricks.png b/moreblocks/textures/moreblocks_circle_stone_bricks.png similarity index 100% rename from textures/moreblocks_circle_stone_bricks.png rename to moreblocks/textures/moreblocks_circle_stone_bricks.png diff --git a/textures/moreblocks_clean_glass.png b/moreblocks/textures/moreblocks_clean_glass.png similarity index 100% rename from textures/moreblocks_clean_glass.png rename to moreblocks/textures/moreblocks_clean_glass.png diff --git a/textures/moreblocks_clean_glass_detail.png b/moreblocks/textures/moreblocks_clean_glass_detail.png similarity index 100% rename from textures/moreblocks_clean_glass_detail.png rename to moreblocks/textures/moreblocks_clean_glass_detail.png diff --git a/textures/moreblocks_coal_checker.png b/moreblocks/textures/moreblocks_coal_checker.png similarity index 100% rename from textures/moreblocks_coal_checker.png rename to moreblocks/textures/moreblocks_coal_checker.png diff --git a/textures/moreblocks_coal_glass_stairsplus.png b/moreblocks/textures/moreblocks_coal_glass_stairsplus.png similarity index 100% rename from textures/moreblocks_coal_glass_stairsplus.png rename to moreblocks/textures/moreblocks_coal_glass_stairsplus.png diff --git a/textures/moreblocks_coal_stone.png b/moreblocks/textures/moreblocks_coal_stone.png similarity index 100% rename from textures/moreblocks_coal_stone.png rename to moreblocks/textures/moreblocks_coal_stone.png diff --git a/textures/moreblocks_coal_stone_bricks.png b/moreblocks/textures/moreblocks_coal_stone_bricks.png similarity index 100% rename from textures/moreblocks_coal_stone_bricks.png rename to moreblocks/textures/moreblocks_coal_stone_bricks.png diff --git a/textures/moreblocks_cobble_compressed.png b/moreblocks/textures/moreblocks_cobble_compressed.png similarity index 100% rename from textures/moreblocks_cobble_compressed.png rename to moreblocks/textures/moreblocks_cobble_compressed.png diff --git a/textures/moreblocks_copperpatina.png b/moreblocks/textures/moreblocks_copperpatina.png similarity index 100% rename from textures/moreblocks_copperpatina.png rename to moreblocks/textures/moreblocks_copperpatina.png diff --git a/textures/moreblocks_desert_cobble_compressed.png b/moreblocks/textures/moreblocks_desert_cobble_compressed.png similarity index 100% rename from textures/moreblocks_desert_cobble_compressed.png rename to moreblocks/textures/moreblocks_desert_cobble_compressed.png diff --git a/textures/moreblocks_dirt_compressed.png b/moreblocks/textures/moreblocks_dirt_compressed.png similarity index 100% rename from textures/moreblocks_dirt_compressed.png rename to moreblocks/textures/moreblocks_dirt_compressed.png diff --git a/textures/moreblocks_empty_shelf.png b/moreblocks/textures/moreblocks_empty_shelf.png similarity index 100% rename from textures/moreblocks_empty_shelf.png rename to moreblocks/textures/moreblocks_empty_shelf.png diff --git a/textures/moreblocks_glass_stairsplus.png b/moreblocks/textures/moreblocks_glass_stairsplus.png similarity index 100% rename from textures/moreblocks_glass_stairsplus.png rename to moreblocks/textures/moreblocks_glass_stairsplus.png diff --git a/textures/moreblocks_glow_glass_stairsplus.png b/moreblocks/textures/moreblocks_glow_glass_stairsplus.png similarity index 100% rename from textures/moreblocks_glow_glass_stairsplus.png rename to moreblocks/textures/moreblocks_glow_glass_stairsplus.png diff --git a/textures/moreblocks_grey_bricks.png b/moreblocks/textures/moreblocks_grey_bricks.png similarity index 100% rename from textures/moreblocks_grey_bricks.png rename to moreblocks/textures/moreblocks_grey_bricks.png diff --git a/textures/moreblocks_iron_checker.png b/moreblocks/textures/moreblocks_iron_checker.png similarity index 100% rename from textures/moreblocks_iron_checker.png rename to moreblocks/textures/moreblocks_iron_checker.png diff --git a/textures/moreblocks_iron_glass_stairsplus.png b/moreblocks/textures/moreblocks_iron_glass_stairsplus.png similarity index 100% rename from textures/moreblocks_iron_glass_stairsplus.png rename to moreblocks/textures/moreblocks_iron_glass_stairsplus.png diff --git a/textures/moreblocks_iron_stone.png b/moreblocks/textures/moreblocks_iron_stone.png similarity index 100% rename from textures/moreblocks_iron_stone.png rename to moreblocks/textures/moreblocks_iron_stone.png diff --git a/textures/moreblocks_iron_stone_bricks.png b/moreblocks/textures/moreblocks_iron_stone_bricks.png similarity index 100% rename from textures/moreblocks_iron_stone_bricks.png rename to moreblocks/textures/moreblocks_iron_stone_bricks.png diff --git a/textures/moreblocks_junglestick.png b/moreblocks/textures/moreblocks_junglestick.png similarity index 100% rename from textures/moreblocks_junglestick.png rename to moreblocks/textures/moreblocks_junglestick.png diff --git a/textures/moreblocks_obsidian_glass_stairsplus.png b/moreblocks/textures/moreblocks_obsidian_glass_stairsplus.png similarity index 100% rename from textures/moreblocks_obsidian_glass_stairsplus.png rename to moreblocks/textures/moreblocks_obsidian_glass_stairsplus.png diff --git a/textures/moreblocks_plankstone.png b/moreblocks/textures/moreblocks_plankstone.png similarity index 100% rename from textures/moreblocks_plankstone.png rename to moreblocks/textures/moreblocks_plankstone.png diff --git a/textures/moreblocks_plankstone_2.png b/moreblocks/textures/moreblocks_plankstone_2.png similarity index 100% rename from textures/moreblocks_plankstone_2.png rename to moreblocks/textures/moreblocks_plankstone_2.png diff --git a/textures/moreblocks_rope.png b/moreblocks/textures/moreblocks_rope.png similarity index 100% rename from textures/moreblocks_rope.png rename to moreblocks/textures/moreblocks_rope.png diff --git a/textures/moreblocks_split_stone_tile.png b/moreblocks/textures/moreblocks_split_stone_tile.png similarity index 100% rename from textures/moreblocks_split_stone_tile.png rename to moreblocks/textures/moreblocks_split_stone_tile.png diff --git a/textures/moreblocks_split_stone_tile_top.png b/moreblocks/textures/moreblocks_split_stone_tile_top.png similarity index 100% rename from textures/moreblocks_split_stone_tile_top.png rename to moreblocks/textures/moreblocks_split_stone_tile_top.png diff --git a/textures/moreblocks_stone_tile.png b/moreblocks/textures/moreblocks_stone_tile.png similarity index 100% rename from textures/moreblocks_stone_tile.png rename to moreblocks/textures/moreblocks_stone_tile.png diff --git a/textures/moreblocks_super_glow_glass_stairsplus.png b/moreblocks/textures/moreblocks_super_glow_glass_stairsplus.png similarity index 100% rename from textures/moreblocks_super_glow_glass_stairsplus.png rename to moreblocks/textures/moreblocks_super_glow_glass_stairsplus.png diff --git a/textures/moreblocks_sweeper.png b/moreblocks/textures/moreblocks_sweeper.png similarity index 100% rename from textures/moreblocks_sweeper.png rename to moreblocks/textures/moreblocks_sweeper.png diff --git a/textures/moreblocks_tar.png b/moreblocks/textures/moreblocks_tar.png similarity index 100% rename from textures/moreblocks_tar.png rename to moreblocks/textures/moreblocks_tar.png diff --git a/textures/moreblocks_trap_box.png b/moreblocks/textures/moreblocks_trap_box.png similarity index 100% rename from textures/moreblocks_trap_box.png rename to moreblocks/textures/moreblocks_trap_box.png diff --git a/textures/moreblocks_trap_box_glass.png b/moreblocks/textures/moreblocks_trap_box_glass.png similarity index 100% rename from textures/moreblocks_trap_box_glass.png rename to moreblocks/textures/moreblocks_trap_box_glass.png diff --git a/textures/moreblocks_tree_stairsplus.png b/moreblocks/textures/moreblocks_tree_stairsplus.png similarity index 100% rename from textures/moreblocks_tree_stairsplus.png rename to moreblocks/textures/moreblocks_tree_stairsplus.png diff --git a/textures/moreblocks_wood_tile.png b/moreblocks/textures/moreblocks_wood_tile.png similarity index 100% rename from textures/moreblocks_wood_tile.png rename to moreblocks/textures/moreblocks_wood_tile.png diff --git a/textures/moreblocks_wood_tile_center.png b/moreblocks/textures/moreblocks_wood_tile_center.png similarity index 100% rename from textures/moreblocks_wood_tile_center.png rename to moreblocks/textures/moreblocks_wood_tile_center.png diff --git a/textures/moreblocks_wood_tile_full.png b/moreblocks/textures/moreblocks_wood_tile_full.png similarity index 100% rename from textures/moreblocks_wood_tile_full.png rename to moreblocks/textures/moreblocks_wood_tile_full.png diff --git a/textures/moreblocks_wood_tile_offset.png b/moreblocks/textures/moreblocks_wood_tile_offset.png similarity index 100% rename from textures/moreblocks_wood_tile_offset.png rename to moreblocks/textures/moreblocks_wood_tile_offset.png diff --git a/moreblocks/util.lua b/moreblocks/util.lua new file mode 100644 index 00000000..697901e3 --- /dev/null +++ b/moreblocks/util.lua @@ -0,0 +1,8 @@ +moreblocks.util = { + table_set_all = function(t, other_table) + for key, value in pairs(other_table) do + t[key] = value + end + return t + end +} diff --git a/moreblocks_legacy_recipes/.luacheckrc b/moreblocks_legacy_recipes/.luacheckrc new file mode 100644 index 00000000..9da1f810 --- /dev/null +++ b/moreblocks_legacy_recipes/.luacheckrc @@ -0,0 +1,653 @@ +std = "lua51+luajit+minetest+moreblocks_legacy_recipes" +unused_args = false +max_line_length = 120 + +stds.minetest = { + read_globals = { + "DIR_DELIM", + "dump", + "dump2", + + math = { + fields = { + abs = {}, + acos = {}, + asin = {}, + atan = {}, + atan2 = {}, + ceil = {}, + cos = {}, + cosh = {}, + deg = {}, + exp = {}, + factorial = {}, + floor = {}, + fmod = {}, + frexp = {}, + huge = {}, + hypot = {}, + ldexp = {}, + log = {}, + log10 = {}, + max = {}, + min = {}, + modf = {}, + pi = {}, + pow = {}, + rad = {}, + random = {}, + randomseed = {}, + round = {}, + sign = {}, + sin = {}, + sinh = {}, + sqrt = {}, + tan = {}, + tanh = {}, + }, + }, + table = { + fields = { + copy = {}, + concat = {}, + foreach = {}, + foreachi = {}, + getn = {}, + indexof = {}, + insert = {}, + insert_all = {}, + key_value_swap = {}, + maxn = {}, + move = {}, + remove = {}, + shuffle = {}, + sort = {}, + }, + }, + string = { + fields = { + byte = {}, + char = {}, + dump = {}, + find = {}, + format = {}, + gmatch = {}, + len = {}, + lower = {}, + match = {}, + rep = {}, + reverse = {}, + split = {}, + sub = {}, + trim = {}, + upper = {}, + }, + }, + vector = { + fields = { + add = {}, + angle = {}, + apply = {}, + check = {}, + combine = {}, + copy = {}, + cross = {}, + dir_to_rotation = {}, + direction = {}, + distance = {}, + divide = {}, + dot = {}, + equals = {}, + floor = {}, + from_string = {}, + length = {}, + metatable = {}, + multiply = {}, + new = {}, + normalize = {}, + offset = {}, + rotate = {}, + rotate_around_axis = {}, + round = {}, + sort = {}, + subtract = {}, + to_string = {}, + zero = {}, + }, + }, + + ItemStack = { + fields = { + add_item = {}, + add_wear = {}, + add_wear_by_uses = {}, + clear = {}, + get_count = {}, + get_definition = {}, + get_description = {}, + get_free_space = {}, + get_meta = {}, + get_metadata = {}, + get_name = {}, + get_short_description = {}, + get_stack_max = {}, + get_tool_capabilities = {}, + get_wear = {}, + is_empty = {}, + is_known = {}, + item_fits = {}, + peek_item = {}, + replace = {}, + set_count = {}, + set_metadata = {}, + set_name = {}, + set_wear = {}, + take_item = {}, + to_string = {}, + to_table = {}, + }, + }, + PerlinNoise = { + fields = { + get_2d = {}, + get_3d = {}, + }, + }, + PerlinNoiseMap = { + fields = { + calc_2d_map = {}, + calc_3d_map = {}, + get_2d_map = {}, + get_2d_map_flat = {}, + get_3d_map = {}, + get_3d_map_flat = {}, + get_map_slice = {}, + }, + }, + PseudoRandom = { + fields = { + next = {}, + }, + }, + PcgRandom = { + fields = { + next = {}, + rand_normal_dist = {}, + }, + }, + SecureRandom = { + fields = { + next_bytes = {}, + }, + }, + Settings = { + fields = { + get = {}, + get_bool = {}, + get_flags = {}, + get_names = {}, + get_np_group = {}, + remove = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + to_table = {}, + write = {}, + }, + }, + VoxelArea = { + fields = { + MaxEdge = {}, + MinEdge = {}, + contains = {}, + containsi = {}, + containsp = {}, + getExtent = {}, + getVolume = {}, + index = {}, + indexp = {}, + iter = {}, + iterp = {}, + new = {}, + position = {}, + ystride = {}, + zstride = {}, + }, + }, + VoxelManip = { + fields = { + calc_lighting = {}, + get_data = {}, + get_emerged_area = {}, + get_light_data = {}, + get_node_at = {}, + get_param2_data = {}, + read_from_map = {}, + set_data = {}, + set_light_data = {}, + set_lighting = {}, + set_node_at = {}, + set_param2_data = {}, + update_liquids = {}, + update_map = {}, + was_modified = {}, + write_to_map = {}, + }, + }, + + minetest = { + fields = { + CONTENT_AIR = {}, + CONTENT_IGNORE = {}, + CONTENT_UNKNOWN = {}, + EMERGE_CANCELLED = {}, + EMERGE_ERRORED = {}, + EMERGE_FROM_DISK = {}, + EMERGE_FROM_MEMORY = {}, + EMERGE_GENERATED = {}, + LIGHT_MAX = {}, + MAP_BLOCKSIZE = {}, + PLAYER_MAX_BREATH_DEFAULT = {}, + PLAYER_MAX_HP_DEFAULT = {}, + add_entity = {}, + add_item = {}, + add_node = {}, + add_node_level = {}, + add_particle = {}, + add_particlespawner = {}, + after = {}, + async_event_handler = {}, + async_jobs = {}, + auth_reload = {}, + ban_player = {}, + builtin_auth_handler = {}, + bulk_set_node = {}, + calculate_knockback = {}, + callback_origins = {}, + cancel_shutdown_requests = {}, + chat_send_all = {}, + chat_send_player = {}, + chatcommands = {}, + check_for_falling = {}, + check_password_entry = {}, + check_player_privs = {}, + check_single_for_falling = {}, + clear_craft = {}, + clear_objects = {}, + clear_registered_biomes = {}, + clear_registered_decorations = {}, + clear_registered_ores = {}, + clear_registered_schematics = {}, + close_formspec = {}, + colorize = {}, + colorspec_to_bytes = {}, + colorspec_to_colorstring = {}, + compare_block_status = {}, + compress = {}, + cpdir = {}, + craft_predict = {}, + craftitemdef_default = {}, + create_detached_inventory = {}, + create_detached_inventory_raw = {}, + create_schematic = {}, + debug = {}, + decode_base64 = {}, + decompress = {}, + delete_area = {}, + delete_particlespawner = {}, + deserialize = {}, + detached_inventories = {}, + dig_node = {}, + dir_to_facedir = {}, + dir_to_wallmounted = {}, + dir_to_yaw = {}, + disconnect_player = {}, + do_async_callback = {}, + do_item_eat = {}, + dynamic_add_media = {}, + dynamic_media_callbacks = {}, + emerge_area = {}, + encode_base64 = {}, + encode_png = {}, + env = {}, + explode_scrollbar_event = {}, + explode_table_event = {}, + explode_textlist_event = {}, + facedir_to_dir = {}, + features = {}, + find_node_near = {}, + find_nodes_in_area = {}, + find_nodes_in_area_under_air = {}, + find_nodes_with_meta = {}, + find_path = {}, + fix_light = {}, + forceload_block = {}, + forceload_free_block = {}, + format_chat_message = {}, + formspec_escape = {}, + generate_decorations = {}, + generate_ores = {}, + get_all_craft_recipes = {}, + get_artificial_light = {}, + get_auth_handler = {}, + get_background_escape_sequence = {}, + get_ban_description = {}, + get_ban_list = {}, + get_biome_data = {}, + get_biome_id = {}, + get_biome_name = {}, + get_builtin_path = {}, + get_color_escape_sequence = {}, + get_connected_players = {}, + get_content_id = {}, + get_craft_recipe = {}, + get_craft_result = {}, + get_current_modname = {}, + get_day_count = {}, + get_decoration_id = {}, + get_dig_params = {}, + get_dir_list = {}, + get_gametime = {}, + get_gen_notify = {}, + get_heat = {}, + get_hit_params = {}, + get_humidity = {}, + get_inventory = {}, + get_item_group = {}, + get_last_run_mod = {}, + get_mapgen_object = {}, + get_mapgen_params = {}, + get_mapgen_setting = {}, + get_mapgen_setting_noiseparams = {}, + get_meta = {}, + get_mod_storage = {}, + get_modnames = {}, + get_modpath = {}, + get_name_from_content_id = {}, + get_natural_light = {}, + get_node = {}, + get_node_drops = {}, + get_node_group = {}, + get_node_level = {}, + get_node_light = {}, + get_node_max_level = {}, + get_node_or_nil = {}, + get_node_timer = {}, + get_noiseparams = {}, + get_objects_in_area = {}, + get_objects_inside_radius = {}, + get_password_hash = {}, + get_perlin = {}, + get_perlin_map = {}, + get_player_by_name = {}, + get_player_information = {}, + get_player_ip = {}, + get_player_privs = {}, + get_player_radius_area = {}, + get_pointed_thing_position = {}, + get_position_from_hash = {}, + get_server_max_lag = {}, + get_server_status = {}, + get_server_uptime = {}, + get_spawn_level = {}, + get_timeofday = {}, + get_tool_wear_after_use = {}, + get_translated_string = {}, + get_translator = {}, + get_us_time = {}, + get_user_path = {}, + get_version = {}, + get_voxel_manip = {}, + get_worldpath = {}, + global_exists = {}, + handle_async = {}, + handle_node_drops = {}, + has_feature = {}, + hash_node_position = {}, + hud_replace_builtin = {}, + inventorycube = {}, + is_area_protected = {}, + is_colored_paramtype = {}, + is_creative_enabled = {}, + is_nan = {}, + is_player = {}, + is_protected = {}, + is_singleplayer = {}, + is_yes = {}, + item_drop = {}, + item_eat = {}, + item_place = {}, + item_place_node = {}, + item_place_object = {}, + item_secondary_use = {}, + itemstring_with_color = {}, + itemstring_with_palette = {}, + kick_player = {}, + line_of_sight = {}, + load_area = {}, + log = {}, + luaentities = {}, + mkdir = {}, + mod_channel_join = {}, + mvdir = {}, + node_dig = {}, + node_punch = {}, + nodedef_default = {}, + noneitemdef_default = {}, + notify_authentication_modified = {}, + object_refs = {}, + on_craft = {}, + override_chatcommand = {}, + override_item = {}, + parse_coordinates = {}, + parse_json = {}, + parse_relative_number = {}, + place_node = {}, + place_schematic = {}, + place_schematic_on_vmanip = {}, + player_exists = {}, + pointed_thing_to_face_pos = {}, + pos_to_string = {}, + print = {}, + privs_to_string = {}, + punch_node = {}, + raillike_group = {}, + raycast = {}, + read_schematic = {}, + record_protection_violation = {}, + register_abm = {}, + register_alias = {}, + register_alias_force = {}, + register_allow_player_inventory_action = {}, + register_async_dofile = {}, + register_authentication_handler = {}, + register_biome = {}, + register_can_bypass_userlimit = {}, + register_chatcommand = {}, + register_craft = {}, + register_craft_predict = {}, + register_craftitem = {}, + register_decoration = {}, + register_entity = {}, + register_globalstep = {}, + register_item = {}, + register_lbm = {}, + register_node = {}, + register_on_auth_fail = {}, + register_on_authplayer = {}, + register_on_chat_message = {}, + register_on_chatcommand = {}, + register_on_cheat = {}, + register_on_craft = {}, + register_on_dieplayer = {}, + register_on_dignode = {}, + register_on_generated = {}, + register_on_item_eat = {}, + register_on_joinplayer = {}, + register_on_leaveplayer = {}, + register_on_liquid_transformed = {}, + register_on_mapgen_init = {}, + register_on_modchannel_message = {}, + register_on_mods_loaded = {}, + register_on_newplayer = {}, + register_on_placenode = {}, + register_on_player_hpchange = {}, + register_on_player_inventory_action = {}, + register_on_player_receive_fields = {}, + register_on_prejoinplayer = {}, + register_on_priv_grant = {}, + register_on_priv_revoke = {}, + register_on_protection_violation = {}, + register_on_punchnode = {}, + register_on_punchplayer = {}, + register_on_respawnplayer = {}, + register_on_rightclickplayer = {}, + register_on_shutdown = {}, + register_ore = {}, + register_playerevent = {}, + register_privilege = {}, + register_schematic = {}, + register_tool = {}, + registered_abms = {other_fields = true}, + registered_aliases = {other_fields = true}, + registered_allow_player_inventory_actions = {other_fields = true}, + registered_biomes = {other_fields = true}, + registered_can_bypass_userlimit = {other_fields = true}, + registered_chatcommands = {other_fields = true}, + registered_craft_predicts = {other_fields = true}, + registered_craftitems = {other_fields = true}, + registered_decorations = {other_fields = true}, + registered_entities = {other_fields = true}, + registered_globalsteps = {other_fields = true}, + registered_items = {other_fields = true}, + registered_lbms = {other_fields = true}, + registered_nodes = {other_fields = true}, + registered_on_authplayers = {other_fields = true}, + registered_on_chat_messages = {other_fields = true}, + registered_on_chatcommands = {other_fields = true}, + registered_on_cheats = {other_fields = true}, + registered_on_crafts = {other_fields = true}, + registered_on_dieplayers = {other_fields = true}, + registered_on_dignodes = {other_fields = true}, + registered_on_generateds = {other_fields = true}, + registered_on_item_eats = {other_fields = true}, + registered_on_joinplayers = {other_fields = true}, + registered_on_leaveplayers = {other_fields = true}, + registered_on_liquid_transformed = {other_fields = true}, + registered_on_modchannel_message = {other_fields = true}, + registered_on_mods_loaded = {other_fields = true}, + registered_on_newplayers = {other_fields = true}, + registered_on_placenodes = {other_fields = true}, + registered_on_player_hpchange = {other_fields = true}, + registered_on_player_hpchanges = {other_fields = true}, + registered_on_player_inventory_actions = {other_fields = true}, + registered_on_player_receive_fields = {other_fields = true}, + registered_on_prejoinplayers = {other_fields = true}, + registered_on_priv_grant = {other_fields = true}, + registered_on_priv_revoke = {other_fields = true}, + registered_on_protection_violation = {other_fields = true}, + registered_on_punchnodes = {other_fields = true}, + registered_on_punchplayers = {other_fields = true}, + registered_on_respawnplayers = {other_fields = true}, + registered_on_rightclickplayers = {other_fields = true}, + registered_on_shutdown = {other_fields = true}, + registered_ores = {other_fields = true}, + registered_playerevents = {other_fields = true}, + registered_privileges = {other_fields = true}, + registered_tools = {other_fields = true}, + remove_detached_inventory = {}, + remove_detached_inventory_raw = {}, + remove_node = {}, + remove_player = {}, + remove_player_auth = {}, + request_http_api = {}, + request_insecure_environment = {}, + request_shutdown = {}, + rgba = {}, + rmdir = {}, + rollback_get_last_node_actor = {}, + rollback_get_node_actions = {}, + rollback_punch_callbacks = {}, + rollback_revert_actions_by = {}, + rotate_and_place = {}, + rotate_node = {}, + run_callbacks = {}, + run_priv_callbacks = {}, + safe_file_write = {}, + send_join_message = {}, + send_leave_message = {}, + serialize = {}, + serialize_roundtrip = {}, + serialize_schematic = {}, + set_gen_notify = {}, + set_last_run_mod = {}, + set_mapgen_params = {}, + set_mapgen_setting = {}, + set_mapgen_setting_noiseparams = {}, + set_node = {}, + set_node_level = {}, + set_noiseparams = {}, + set_player_password = {}, + set_player_privs = {}, + set_timeofday = {}, + setting_get = {}, + setting_get_pos = {}, + setting_getbool = {}, + setting_save = {}, + setting_set = {}, + setting_setbool = {}, + settings = { + fields = { + get = {}, + get_bool = {}, + get_np_group = {}, + get_flags = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + remove = {}, + get_names = {}, + write = {}, + to_table = {}, + }, + }, + sha1 = {}, + show_formspec = {}, + show_general_help_formspec = {}, + show_privs_help_formspec = {}, + sound_fade = {}, + sound_play = {}, + sound_stop = {}, + spawn_falling_node = {}, + spawn_item = {}, + spawn_tree = {}, + string_to_area = {}, + string_to_pos = {}, + string_to_privs = {}, + strip_background_colors = {}, + strip_colors = {}, + strip_foreground_colors = {}, + strip_param2_color = {}, + swap_node = {}, + tooldef_default = {}, + transforming_liquid_add = {}, + translate = {}, + unban_player_or_ip = {}, + unregister_biome = {}, + unregister_chatcommand = {}, + unregister_item = {}, + wallmounted_to_dir = {}, + wrap_text = {}, + write_json = {}, + yaw_to_dir = {}, + }, + }, + } +} + +stds.moreblocks_legacy_recipes = { + globals = { + }, + read_globals = { + }, +} diff --git a/moreblocks_legacy_recipes/LICENSE.md b/moreblocks_legacy_recipes/LICENSE.md new file mode 100644 index 00000000..67f5f7f0 --- /dev/null +++ b/moreblocks_legacy_recipes/LICENSE.md @@ -0,0 +1,13 @@ +# zlib license + +Copyright © 2011-2020 Hugo Locurcio and contributors + +**This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.** + +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. diff --git a/moreblocks_legacy_recipes/README.md b/moreblocks_legacy_recipes/README.md new file mode 100644 index 00000000..a8525c9a --- /dev/null +++ b/moreblocks_legacy_recipes/README.md @@ -0,0 +1,18 @@ + +code to increase the productivity of some recipes which was originally part of +[moreblocks](https://github.com/minetest-mods/moreblocks/) but has since been removed. + +copied directly from +https://github.com/minetest-mods/moreblocks/blob/1a03b041dd49cf52e8d5d84e72206718055b1455/redefinitions.lua + +## License + +Copyright © 2011-2020 Hugo Locurcio and contributors + +- More Blocks code is licensed under the zlib license, see + [`LICENSE.md`](LICENSE.md) for details. +- Unless otherwise specified, More Blocks textures are licensed under + [CC BY-SA 3.0 Unported](https://creativecommons.org/licenses/by-sa/3.0/). + +`moreblocks_copperpatina.png` was created by pithydon, and is licensed under +[CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/redefinitions.lua b/moreblocks_legacy_recipes/init.lua similarity index 92% rename from redefinitions.lua rename to moreblocks_legacy_recipes/init.lua index 4d59c3c2..9b50570b 100644 --- a/redefinitions.lua +++ b/moreblocks_legacy_recipes/init.lua @@ -1,3 +1,8 @@ +-- disabled by default +if not minetest.settings:get_bool("moreblocks_legacy_recipes.enabled", false) then + return +end + --[[ More Blocks: redefinitions of default stuff @@ -50,7 +55,9 @@ local change_recipe_amount = function(product, recipe, func) redo.output = ("%s %d"):format(product, newamount) minetest.register_craft(redo) - minetest.log("action", ("[MOD]%s: recipe for %s production: %d => %d"):format(modname, product, oldamount, newamount)) + minetest.log("action", ("[MOD]%s: recipe for %s production: %d => %d"):format( + modname, product, oldamount, newamount + )) end local increase_craft_production = function(product, func) @@ -85,7 +92,8 @@ end increase_craft_production_table({ { function(n) return n:match('^default:sign_wall') end, function(old) return old + 1 end }, { function(n) return n == 'default:paper' end, function(old) return old*4 end }, - { function(n) return n:match('^carts:.*rail$') or n:match('^default:.*rail$') end, function(old) return old + old/2 end }, + { function(n) return n:match('^carts:.*rail$') or n:match('^default:.*rail$') end, + function(old) return old + old/2 end }, }) minetest.register_craft({ diff --git a/moreblocks_legacy_recipes/mod.conf b/moreblocks_legacy_recipes/mod.conf new file mode 100644 index 00000000..37cdbcde --- /dev/null +++ b/moreblocks_legacy_recipes/mod.conf @@ -0,0 +1,3 @@ +name = moreblocks_legacy_recipes +description = adds back recipe changes that used to be part of moreblocks +optional_depends = carts, default diff --git a/nodes.lua b/nodes.lua deleted file mode 100644 index a13d36a5..00000000 --- a/nodes.lua +++ /dev/null @@ -1,577 +0,0 @@ ---[[ -More Blocks: node definitions - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - -local S = moreblocks.S - -local sound_dirt = moreblocks.node_sound_dirt_defaults() -local sound_wood = moreblocks.node_sound_wood_defaults() -local sound_stone = moreblocks.node_sound_stone_defaults() -local sound_glass = moreblocks.node_sound_glass_defaults() -local sound_leaves = moreblocks.node_sound_leaves_defaults() - --- Don't break on 0.4.14 and earlier. -local sound_metal = (moreblocks.node_sound_metal_defaults - and moreblocks.node_sound_metal_defaults() or sound_stone) - -local function tile_tiles(name) - local tex = "moreblocks_" ..name.. ".png" - return {tex, tex, tex, tex, tex.. "^[transformR90", tex.. "^[transformR90"} -end - -local function wood_tile_replace(itemstack, placer, pointed_thing) - local substack - if itemstack:get_name() == "moreblocks:wood_tile_flipped" then - substack = ItemStack("moreblocks:wood_tile") - else -- right, left, and down variants - substack = ItemStack("moreblocks:wood_tile_offset") - end - local _, success = minetest.item_place(substack, placer, pointed_thing) - if success then - itemstack:take_item() - end - return itemstack -end - -local deprecated = (" ("..S('Deprecated')..")") -local nodes = { - ["wood_tile"] = { - description = S("Wooden Tile"), - groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, - is_ground_content = false, - paramtype2 = "facedir", - place_param2 = 0, - tiles = {"default_wood.png^moreblocks_wood_tile.png", - "default_wood.png^moreblocks_wood_tile.png", - "default_wood.png^moreblocks_wood_tile.png", - "default_wood.png^moreblocks_wood_tile.png", - "default_wood.png^moreblocks_wood_tile.png^[transformR90", - "default_wood.png^moreblocks_wood_tile.png^[transformR90"}, - sounds = sound_wood, - }, - ["wood_tile_flipped"] = { - description = S("Wooden Tile") .. deprecated, - tiles = {"default_wood.png^moreblocks_wood_tile.png^[transformR90", - "default_wood.png^moreblocks_wood_tile.png^[transformR90", - "default_wood.png^moreblocks_wood_tile.png^[transformR90", - "default_wood.png^moreblocks_wood_tile.png^[transformR90", - "default_wood.png^moreblocks_wood_tile.png^[transformR180", - "default_wood.png^moreblocks_wood_tile.png^[transformR180"}, - no_stairs = true, - on_place = wood_tile_replace - }, - ["wood_tile_center"] = { - description = S("Centered Wooden Tile"), - groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, - is_ground_content = false, - tiles = {"default_wood.png^moreblocks_wood_tile_center.png"}, - sounds = sound_wood, - }, - ["wood_tile_full"] = { - description = S("Full Wooden Tile"), - groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, - is_ground_content = false, - tiles = tile_tiles("wood_tile_full"), - sounds = sound_wood, - }, - ["wood_tile_offset"] = { - description = S("Offset Wooden Tile"), - paramtype2 = "facedir", - place_param2 = 0, - groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, - is_ground_content = false, - tiles = {"default_wood.png^moreblocks_wood_tile_offset.png"}, - sounds = sound_wood, - no_stairs = true, - }, - ["wood_tile_down"] = { - description = S("Downwards Wooden Tile") .. deprecated, - tiles = {"default_wood.png^[transformR180^moreblocks_wood_tile_offset.png^[transformR180"}, - no_stairs = true, - on_place = wood_tile_replace - }, - ["wood_tile_left"] = { - description = S("Leftwards Wooden Tile") .. deprecated, - tiles = {"default_wood.png^[transformR270^moreblocks_wood_tile_offset.png^[transformR270"}, - no_stairs = true, - on_place = wood_tile_replace - }, - ["wood_tile_right"] = { - description = S("Rightwards Wooden Tile") .. deprecated, - tiles = {"default_wood.png^[transformR90^moreblocks_wood_tile_offset.png^[transformR90"}, - no_stairs = true, - on_place = wood_tile_replace - }, - ["circle_stone_bricks"] = { - description = S("Circle Stone Bricks"), - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["grey_bricks"] = { - description = S("Stone Bricks"), - paramtype2 = "facedir", - place_param2 = 0, - groups = {cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["coal_stone_bricks"] = { - description = S("Coal Stone Bricks"), - paramtype2 = "facedir", - place_param2 = 0, - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["iron_stone_bricks"] = { - description = S("Iron Stone Bricks"), - paramtype2 = "facedir", - place_param2 = 0, - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["stone_tile"] = { - description = S("Stone Tile"), - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["split_stone_tile"] = { - description = S("Split Stone Tile"), - paramtype2 = "facedir", - place_param2 = 0, - tiles = {"moreblocks_split_stone_tile_top.png", - "moreblocks_split_stone_tile.png"}, - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["checker_stone_tile"] = { - description = S("Checker Stone Tile"), - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["tar"] = { - description = S("Tar"), - groups = {cracky=2, tar_block=1}, - is_ground_content = false, - sounds = sound_stone, - }, - ["dirt_compressed"] = { - description = S("Compressed Dirt"), - groups = {crumbly=2}, - is_ground_content = false, - sounds = sound_dirt, - }, - ["cobble_compressed"] = { - description = S("Compressed Cobblestone"), - groups = {cracky = 1}, - is_ground_content = false, - sounds = sound_stone, - }, - ["desert_cobble_compressed"] = { - description = S("Compressed Desert Cobblestone"), - groups = {cracky = 1}, - is_ground_content = false, - sounds = sound_stone, - }, - ["plankstone"] = { - description = S("Plankstone"), - paramtype2 = "facedir", - place_param2 = 0, - groups = {cracky = 3}, - is_ground_content = false, - tiles = tile_tiles("plankstone"), - sounds = sound_stone, - }, - ["iron_glass"] = { - description = S("Iron Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"default_glass.png^[colorize:#DEDEDE", "default_glass_detail.png^[colorize:#DEDEDE"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - }, - ["coal_glass"] = { - description = S("Coal Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"default_glass.png^[colorize:#828282", "default_glass_detail.png^[colorize:#828282"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - }, - ["clean_glass"] = { - description = S("Clean Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"moreblocks_clean_glass.png", "moreblocks_clean_glass_detail.png"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - }, - ["cactus_brick"] = { - description = S("Cactus Brick"), - paramtype2 = "facedir", - place_param2 = 0, - groups = {cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["cactus_checker"] = { - description = S("Cactus Checker"), - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - tiles = {"default_stone.png^moreblocks_cactus_checker.png", - "default_stone.png^moreblocks_cactus_checker.png", - "default_stone.png^moreblocks_cactus_checker.png", - "default_stone.png^moreblocks_cactus_checker.png", - "default_stone.png^moreblocks_cactus_checker.png^[transformR90", - "default_stone.png^moreblocks_cactus_checker.png^[transformR90"}, - sounds = sound_stone, - }, - ["empty_shelf"] = { - description = S("Empty Shelf"), - paramtype2 = "facedir", - tiles = {"default_wood.png", "default_wood.png", "default_wood.png", - "default_wood.png", "moreblocks_empty_shelf.png", "moreblocks_empty_shelf.png"}, - groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3}, - is_ground_content = false, - sounds = sound_wood, - furnace_burntime = 15, - no_stairs = true, - }, - ["coal_stone"] = { - description = S("Coal Stone"), - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["iron_stone"] = { - description = S("Iron Stone"), - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["coal_checker"] = { - description = S("Coal Checker"), - tiles = {"default_stone.png^moreblocks_coal_checker.png", - "default_stone.png^moreblocks_coal_checker.png", - "default_stone.png^moreblocks_coal_checker.png", - "default_stone.png^moreblocks_coal_checker.png", - "default_stone.png^moreblocks_coal_checker.png^[transformR90", - "default_stone.png^moreblocks_coal_checker.png^[transformR90"}, - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["iron_checker"] = { - description = S("Iron Checker"), - tiles = {"default_stone.png^moreblocks_iron_checker.png", - "default_stone.png^moreblocks_iron_checker.png", - "default_stone.png^moreblocks_iron_checker.png", - "default_stone.png^moreblocks_iron_checker.png", - "default_stone.png^moreblocks_iron_checker.png^[transformR90", - "default_stone.png^moreblocks_iron_checker.png^[transformR90"}, - groups = {stone = 1, cracky = 3}, - is_ground_content = false, - sounds = sound_stone, - }, - ["trap_stone"] = { - description = S("Trap Stone"), - drawtype = "glasslike_framed", - tiles = {"default_stone.png^moreblocks_trap_box.png"}, - walkable = false, - groups = {cracky = 3}, - paramtype = "light", - is_ground_content = false, - sounds = sound_stone, - no_stairs = true, - }, - ["trap_desert_stone"] = { - description = S("Trap Desert Stone"), - drawtype = "glasslike_framed", - tiles = {"default_desert_stone.png^moreblocks_trap_box.png"}, - walkable = false, - groups = {cracky = 3}, - paramtype = "light", - is_ground_content = false, - sounds = sound_stone, - no_stairs = true, - }, - ["trap_glass"] = { - description = S("Trap Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"default_glass.png^moreblocks_trap_box_glass.png", "default_glass_detail.png"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - no_stairs = true, - }, - ["trap_obsidian_glass"] = { - description = S("Trap Obsidian Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"default_obsidian_glass.png^moreblocks_trap_box_glass.png", "default_obsidian_glass_detail.png"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - no_stairs = true, - }, - ["trap_obsidian"] = { - description = S("Trap Obsidian"), - drawtype = "glasslike_framed", - tiles = {"default_obsidian.png^moreblocks_trap_box.png"}, - walkable = false, - groups = {cracky = 1, level = 2}, - paramtype = "light", - is_ground_content = false, - sounds = sound_stone, - no_stairs = true, - }, - ["trap_clean_glass"] = { - description = S("Trap Clean Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"moreblocks_clean_glass.png^moreblocks_trap_box_glass.png", "moreblocks_clean_glass_detail.png"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - no_stairs = true, - }, - ["trap_sandstone"] = { - description = S("Trap Sandstone"), - drawtype = "glasslike_framed", - tiles = {"default_sandstone.png^moreblocks_trap_box.png"}, - walkable = false, - groups = {crumbly = 1, cracky = 3}, - paramtype = "light", - is_ground_content = false, - sounds = sound_stone, - no_stairs = true, - }, - ["all_faces_tree"] = { - description = S("All-faces Tree"), - tiles = {"default_tree_top.png"}, - groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, - sounds = sound_wood, - furnace_burntime = 30, - }, - ["all_faces_jungle_tree"] = { - description = S("All-faces Jungle Tree"), - tiles = {"default_jungletree_top.png"}, - groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, - sounds = sound_wood, - furnace_burntime = 38, - }, - ["all_faces_pine_tree"] = { - description = S("All-faces Pine Tree"), - tiles = {"default_pine_tree_top.png"}, - groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, - sounds = sound_wood, - furnace_burntime = 26, - }, - ["all_faces_acacia_tree"] = { - description = S("All-faces Acacia Tree"), - tiles = {"default_acacia_tree_top.png"}, - groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, - sounds = sound_wood, - furnace_burntime = 34, - }, - ["all_faces_aspen_tree"] = { - description = S("All-faces Aspen Tree"), - tiles = {"default_aspen_tree_top.png"}, - groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, - sounds = sound_wood, - furnace_burntime = 22, - }, - ["glow_glass"] = { - description = S("Glow Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"default_glass.png^[colorize:#E9CD61", "default_glass_detail.png^[colorize:#E9CD61"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - light_source = 11, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - }, - ["clean_glow_glass"] = { - description = S("Clean Glow Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"moreblocks_clean_glass.png^[colorize:#E9CD61", "moreblocks_clean_glass_detail.png^[colorize:#E9CD61"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - light_source = 11, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - }, - ["trap_glow_glass"] = { - description = S("Trap Glow Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"default_glass.png^[colorize:#E9CD61^moreblocks_trap_box_glass.png", "default_glass_detail.png^[colorize:#E9CD61"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - light_source = 11, - walkable = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - no_stairs = true, - }, - ["trap_clean_glow_glass"] = { - description = S("Trap Clean Glow Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"moreblocks_clean_glass.png^[colorize:#E9CD61^moreblocks_trap_box_glass.png", "moreblocks_clean_glass_detail.png^[colorize:#E9CD61"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - light_source = 11, - walkable = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - no_stairs = true, - }, - ["super_glow_glass"] = { - description = S("Super Glow Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"default_glass.png^[colorize:#FFFF78", "default_glass_detail.png^[colorize:#FFFF78"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - light_source = default.LIGHT_MAX, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - }, - ["clean_super_glow_glass"] = { - description = S("Clean Super Glow Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"moreblocks_clean_glass.png^[colorize:#FFFF78", "moreblocks_clean_glass_detail.png^[colorize:#FFFF78"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - light_source = default.LIGHT_MAX, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - }, - ["trap_super_glow_glass"] = { - description = S("Trap Super Glow Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"default_glass.png^[colorize:#FFFF78^moreblocks_trap_box_glass.png", "default_glass_detail.png^[colorize:#FFFF78"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - light_source = default.LIGHT_MAX, - walkable = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - no_stairs = true, - }, - ["trap_clean_super_glow_glass"] = { - description = S("Trap Clean Super Glow Glass"), - drawtype = "glasslike_framed_optional", - tiles = {"moreblocks_clean_glass.png^[colorize:#FFFF78^moreblocks_trap_box_glass.png", "moreblocks_clean_glass_detail.png^[colorize:#FFFF78"}, - use_texture_alpha = "clip", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - light_source = default.LIGHT_MAX, - walkable = false, - groups = {cracky = 3, oddly_breakable_by_hand = 3}, - sounds = sound_glass, - no_stairs = true, - }, - ["rope"] = { - description = S("Rope"), - drawtype = "signlike", - inventory_image = "moreblocks_rope.png", - wield_image = "moreblocks_rope.png", - paramtype = "light", - sunlight_propagates = true, - is_ground_content = false, - paramtype2 = "wallmounted", - walkable = false, - climbable = true, - selection_box = {type = "wallmounted",}, - groups = {snappy = 3, flammable = 2}, - sounds = sound_leaves, - no_stairs = true, - }, - ["copperpatina"] = { - description = S("Copper Patina Block"), - groups = {cracky = 1, level = 2}, - is_ground_content = false, - sounds = sound_metal, - }, -} - -for name, def in pairs(nodes) do - def.tiles = def.tiles or {"moreblocks_" ..name.. ".png"} - minetest.register_node("moreblocks:" ..name, def) - minetest.register_alias(name, "moreblocks:" ..name) - - def_copy = table.copy(def) - - -- Use the primary tile for all sides of cut glasslike nodes. - -- This makes them easier to see - if - #def_copy.tiles > 1 and - def_copy.drawtype and - def_copy.drawtype == "glasslike_framed" or - def_copy.drawtype == "glasslike_framed_optional" - then - def.tiles = {def_copy.tiles[1]} - end - - - if not def.no_stairs then - local groups = {} - for k, v in pairs(def.groups) do groups[k] = v end - stairsplus:register_all("moreblocks", name, "moreblocks:" ..name, { - description = def.description, - groups = groups, - tiles = def.tiles, - sunlight_propagates = def.sunlight_propagates, - light_source = def.light_source, - sounds = def.sounds, - }) - end -end - --- Items - -minetest.register_craftitem("moreblocks:sweeper", { - description = S("Sweeper"), - inventory_image = "moreblocks_sweeper.png", -}) diff --git a/ownership.lua b/ownership.lua deleted file mode 100644 index 3bd4b633..00000000 --- a/ownership.lua +++ /dev/null @@ -1,41 +0,0 @@ ---[[ -More Blocks: ownership handling - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - -local S = moreblocks.S - -function moreblocks.node_is_owned(pos, placer) - local ownername = false - if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod - if HasOwner(pos, placer) then -- returns true if the node is owned - if not IsPlayerNodeOwner(pos, placer:get_player_name()) then - if type(getLastOwner) == "function" then -- ...is an old version - ownername = getLastOwner(pos) - elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version - ownername = GetNodeOwnerName(pos) - else - ownername = S("someone") - end - end - end - - elseif type(isprotect)=="function" then -- glomie's protection mod - if not isprotect(5, pos, placer) then - ownername = S("someone") - end - elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod - if not protector.can_dig(5, pos, placer) then - ownername = S("someone") - end - end - - if ownername ~= false then - minetest.chat_send_player( placer:get_player_name(), S("Sorry, @1 owns that spot.", ownername) ) - return true - else - return false - end -end diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 00000000..296b63df Binary files /dev/null and b/screenshot.png differ diff --git a/screenshot2.png b/screenshot2.png new file mode 100644 index 00000000..491e13c0 Binary files /dev/null and b/screenshot2.png differ diff --git a/screenshot3.png b/screenshot3.png new file mode 100644 index 00000000..75b1c921 Binary files /dev/null and b/screenshot3.png differ diff --git a/settingtypes.txt b/settingtypes.txt index c52286eb..74b65e10 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,3 +1,73 @@ +# Will be created if it doesn't already exist +invsaw.priv (Priv to use the inventory saw) string interact + +# Will be created if it doesn't already exist +invsaw.creative_priv (Priv to use the inventory saw w/out a saw item) string creative + +# The item that a normal player has to have to use the saw in inventory +invsaw.saw_item (Saw item) string stairsplus:circular_saw + +# whether to increase the yield of certain crafting recipes as in moreblocks 2.* +moreblocks_legacy_recipes.enabled (Enable legacy recipes) bool false + +# Add a yellow outline around trap nodes, to make them visibly distinct +moreblocks.outline_trap_nodes (Outline trap nodes) bool true + +# If true, registering stairs w/out a registered recipe item will still create the stair nodes. +# This is how the stairs mod in minetest game works currently. +# Unfortunately, they will not be craftable. +# By default, trying to do this will create an error. +stairs.legacy_stairs_without_recipeitem (Allow stairs without a base node) bool false + +# I guess if you want the saw to be creative-only? +stairsplus.circular_saw_crafting (Allow crafting the circular saw) bool true + +# Defaults to true if creative_mode is enabled. +stairsplus.ex_nihilo (Saw gives infinite nodes) bool false + # If enabled, Stairs+ nodes will be displayed in the inventory when playing in creative mode. # Disabling this can speed up loading times for clients as fewer nodes need to be registered in the creative inventory. -moreblocks.stairsplus_in_creative_inventory (Display Stairs+ nodes in creative inventory) bool true +stairsplus.in_creative_inventory (Display Stairs+ nodes in creative inventory) bool true + +# Whether to show crafting recipes involving Stairs+ nodes (in compatible inventory managers) +stairsplus.in_craft_guide (Show crafting recipes) bool true + +# "user" or "world" cause things to look nicer in general, but some nodes look better w/ the "node" style +stairsplus.default_align_style (World align style) enum user node,user,world + +# regular stairs shapes +stairsplus.basic_shapes (basic shapes) flags micro_8,slab_8,stair,stair_inner,stair_outer panel_1,slope,slope_half,slope_half_raised,panel_2,slope_inner_cut,slope_inner_half,panel_4,slope_inner_half_raised,slope_inner_cut_half_raised,slope_outer,slope_outer_cut,slope_cut,slope_outer_half,panel_12,slope_outer_half_raised,slope_outer_cut_half_raised,panel_14,panel_15,micro_1,slab_15,slab_two_sides,stair_half,slab_three_sides,stair_right_half,slab_three_sides_u,micro_12,micro_14,slab_2,micro_15,slab_4,micro_2,stair_alt_4,stair_alt_2,stair_alt_1,stair_alt_8,slab_1,slab_12,stair,slope_outer_cut_half,slope_inner_cut_half,slab_14,micro_4,micro_8,slab_8,stair_inner,stair_outer,slope_inner,panel_8 + +# the most commonly used variants +stairsplus.common_shapes (common shapes) flags micro_8,panel_8,slab_1,slab_8,stair,stair_inner,stair_outer,slope,slope_half,slope_half_raised,slope_inner,slope_inner_cut,slope_inner_half,slope_inner_cut_half,slope_inner_half_raised,slope_inner_cut_half_raised,slope_outer,slope_outer_cut,slope_cut,slope_outer_half,slope_outer_cut_half,slope_outer_half_raised,slope_outer_cut_half_raised panel_1,slope,slope_half,slope_half_raised,panel_2,slope_inner_cut,slope_inner_half,panel_4,slope_inner_half_raised,slope_inner_cut_half_raised,slope_outer,slope_outer_cut,slope_cut,slope_outer_half,panel_12,slope_outer_half_raised,slope_outer_cut_half_raised,panel_14,panel_15,micro_1,slab_15,slab_two_sides,stair_half,slab_three_sides,stair_right_half,slab_three_sides_u,micro_12,micro_14,slab_2,micro_15,slab_4,micro_2,stair_alt_4,stair_alt_2,stair_alt_1,stair_alt_8,slab_1,slab_12,stair,slope_outer_cut_half,slope_inner_cut_half,slab_14,micro_4,micro_8,slab_8,stair_inner,stair_outer,slope_inner,panel_8 + +# default to registering *all* variants, and some other stuff. +# it is only "safe" to disable this on new servers. +stairsplus.legacy_mode (legacy mode) bool true + +# automatically try to rotate nodes when placed. the mechanic is sometimes confusing. +stairsplus.legacy_place_mechanic (use legacy place mecahnic) bool true + +# allows crafting shaped nodes in addition to cutting them +stairsplus.crafting_schemata_enabled (enable crafting schemata) bool true + +# enable registering stairsplus nodes for basic_materials +stairsplus_legacy.basic_materials () bool true + +# enable registering stairsplus nodes for default +stairsplus_legacy.default () bool true + +# enable registering stairsplus nodes for farming +stairsplus_legacy.farming () bool true + +# enable registering stairsplus nodes for gloopblocks +stairsplus_legacy.gloopblocks () bool true + +# enable registering stairsplus nodes for technic +stairsplus_legacy.technic () bool true + +# enable registering stairsplus nodes for prefab +stairsplus_legacy.prefab () bool true + +# enable registering stairsplus nodes for wool +stairsplus_legacy.wool () bool true diff --git a/sounds.lua b/sounds.lua deleted file mode 100644 index 5385d275..00000000 --- a/sounds.lua +++ /dev/null @@ -1,20 +0,0 @@ ---[[ -More Blocks: sound definitions - -Copyright © 2011-2021 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - -local has_default_mod = minetest.get_modpath("default") -for _, sound in ipairs({"dirt", "wood", "stone", "metal", "glass", "leaves"}) do - -- use sound-function from default if available - -- otherwise fall back to a no-op function (no sounds) - local sound_function_name = "node_sound_" .. sound .. "_defaults" - if has_default_mod then - -- use default sounds - moreblocks[sound_function_name] = default[sound_function_name] - else - -- no-op - moreblocks[sound_function_name] = function() end - end -end diff --git a/stairs/.luacheckrc b/stairs/.luacheckrc new file mode 100644 index 00000000..9bd206e1 --- /dev/null +++ b/stairs/.luacheckrc @@ -0,0 +1,655 @@ +std = "lua51+luajit+minetest+stairs" +unused_args = false +max_line_length = 120 + +stds.minetest = { + read_globals = { + "DIR_DELIM", + "dump", + "dump2", + + math = { + fields = { + abs = {}, + acos = {}, + asin = {}, + atan = {}, + atan2 = {}, + ceil = {}, + cos = {}, + cosh = {}, + deg = {}, + exp = {}, + factorial = {}, + floor = {}, + fmod = {}, + frexp = {}, + huge = {}, + hypot = {}, + ldexp = {}, + log = {}, + log10 = {}, + max = {}, + min = {}, + modf = {}, + pi = {}, + pow = {}, + rad = {}, + random = {}, + randomseed = {}, + round = {}, + sign = {}, + sin = {}, + sinh = {}, + sqrt = {}, + tan = {}, + tanh = {}, + }, + }, + table = { + fields = { + copy = {}, + concat = {}, + foreach = {}, + foreachi = {}, + getn = {}, + indexof = {}, + insert = {}, + insert_all = {}, + key_value_swap = {}, + maxn = {}, + move = {}, + remove = {}, + shuffle = {}, + sort = {}, + }, + }, + string = { + fields = { + byte = {}, + char = {}, + dump = {}, + find = {}, + format = {}, + gmatch = {}, + len = {}, + lower = {}, + match = {}, + rep = {}, + reverse = {}, + split = {}, + sub = {}, + trim = {}, + upper = {}, + }, + }, + vector = { + fields = { + add = {}, + angle = {}, + apply = {}, + check = {}, + combine = {}, + copy = {}, + cross = {}, + dir_to_rotation = {}, + direction = {}, + distance = {}, + divide = {}, + dot = {}, + equals = {}, + floor = {}, + from_string = {}, + length = {}, + metatable = {}, + multiply = {}, + new = {}, + normalize = {}, + offset = {}, + rotate = {}, + rotate_around_axis = {}, + round = {}, + sort = {}, + subtract = {}, + to_string = {}, + zero = {}, + }, + }, + + ItemStack = { + fields = { + add_item = {}, + add_wear = {}, + add_wear_by_uses = {}, + clear = {}, + get_count = {}, + get_definition = {}, + get_description = {}, + get_free_space = {}, + get_meta = {}, + get_metadata = {}, + get_name = {}, + get_short_description = {}, + get_stack_max = {}, + get_tool_capabilities = {}, + get_wear = {}, + is_empty = {}, + is_known = {}, + item_fits = {}, + peek_item = {}, + replace = {}, + set_count = {}, + set_metadata = {}, + set_name = {}, + set_wear = {}, + take_item = {}, + to_string = {}, + to_table = {}, + }, + }, + PerlinNoise = { + fields = { + get_2d = {}, + get_3d = {}, + }, + }, + PerlinNoiseMap = { + fields = { + calc_2d_map = {}, + calc_3d_map = {}, + get_2d_map = {}, + get_2d_map_flat = {}, + get_3d_map = {}, + get_3d_map_flat = {}, + get_map_slice = {}, + }, + }, + PseudoRandom = { + fields = { + next = {}, + }, + }, + PcgRandom = { + fields = { + next = {}, + rand_normal_dist = {}, + }, + }, + SecureRandom = { + fields = { + next_bytes = {}, + }, + }, + Settings = { + fields = { + get = {}, + get_bool = {}, + get_flags = {}, + get_names = {}, + get_np_group = {}, + remove = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + to_table = {}, + write = {}, + }, + }, + VoxelArea = { + fields = { + MaxEdge = {}, + MinEdge = {}, + contains = {}, + containsi = {}, + containsp = {}, + getExtent = {}, + getVolume = {}, + index = {}, + indexp = {}, + iter = {}, + iterp = {}, + new = {}, + position = {}, + ystride = {}, + zstride = {}, + }, + }, + VoxelManip = { + fields = { + calc_lighting = {}, + get_data = {}, + get_emerged_area = {}, + get_light_data = {}, + get_node_at = {}, + get_param2_data = {}, + read_from_map = {}, + set_data = {}, + set_light_data = {}, + set_lighting = {}, + set_node_at = {}, + set_param2_data = {}, + update_liquids = {}, + update_map = {}, + was_modified = {}, + write_to_map = {}, + }, + }, + + minetest = { + fields = { + CONTENT_AIR = {}, + CONTENT_IGNORE = {}, + CONTENT_UNKNOWN = {}, + EMERGE_CANCELLED = {}, + EMERGE_ERRORED = {}, + EMERGE_FROM_DISK = {}, + EMERGE_FROM_MEMORY = {}, + EMERGE_GENERATED = {}, + LIGHT_MAX = {}, + MAP_BLOCKSIZE = {}, + PLAYER_MAX_BREATH_DEFAULT = {}, + PLAYER_MAX_HP_DEFAULT = {}, + add_entity = {}, + add_item = {}, + add_node = {}, + add_node_level = {}, + add_particle = {}, + add_particlespawner = {}, + after = {}, + async_event_handler = {}, + async_jobs = {}, + auth_reload = {}, + ban_player = {}, + builtin_auth_handler = {}, + bulk_set_node = {}, + calculate_knockback = {}, + callback_origins = {}, + cancel_shutdown_requests = {}, + chat_send_all = {}, + chat_send_player = {}, + chatcommands = {}, + check_for_falling = {}, + check_password_entry = {}, + check_player_privs = {}, + check_single_for_falling = {}, + clear_craft = {}, + clear_objects = {}, + clear_registered_biomes = {}, + clear_registered_decorations = {}, + clear_registered_ores = {}, + clear_registered_schematics = {}, + close_formspec = {}, + colorize = {}, + colorspec_to_bytes = {}, + colorspec_to_colorstring = {}, + compare_block_status = {}, + compress = {}, + cpdir = {}, + craft_predict = {}, + craftitemdef_default = {}, + create_detached_inventory = {}, + create_detached_inventory_raw = {}, + create_schematic = {}, + debug = {}, + decode_base64 = {}, + decompress = {}, + delete_area = {}, + delete_particlespawner = {}, + deserialize = {}, + detached_inventories = {}, + dig_node = {}, + dir_to_facedir = {}, + dir_to_wallmounted = {}, + dir_to_yaw = {}, + disconnect_player = {}, + do_async_callback = {}, + do_item_eat = {}, + dynamic_add_media = {}, + dynamic_media_callbacks = {}, + emerge_area = {}, + encode_base64 = {}, + encode_png = {}, + env = {}, + explode_scrollbar_event = {}, + explode_table_event = {}, + explode_textlist_event = {}, + facedir_to_dir = {}, + features = {}, + find_node_near = {}, + find_nodes_in_area = {}, + find_nodes_in_area_under_air = {}, + find_nodes_with_meta = {}, + find_path = {}, + fix_light = {}, + forceload_block = {}, + forceload_free_block = {}, + format_chat_message = {}, + formspec_escape = {}, + generate_decorations = {}, + generate_ores = {}, + get_all_craft_recipes = {}, + get_artificial_light = {}, + get_auth_handler = {}, + get_background_escape_sequence = {}, + get_ban_description = {}, + get_ban_list = {}, + get_biome_data = {}, + get_biome_id = {}, + get_biome_name = {}, + get_builtin_path = {}, + get_color_escape_sequence = {}, + get_connected_players = {}, + get_content_id = {}, + get_craft_recipe = {}, + get_craft_result = {}, + get_current_modname = {}, + get_day_count = {}, + get_decoration_id = {}, + get_dig_params = {}, + get_dir_list = {}, + get_gametime = {}, + get_gen_notify = {}, + get_heat = {}, + get_hit_params = {}, + get_humidity = {}, + get_inventory = {}, + get_item_group = {}, + get_last_run_mod = {}, + get_mapgen_object = {}, + get_mapgen_params = {}, + get_mapgen_setting = {}, + get_mapgen_setting_noiseparams = {}, + get_meta = {}, + get_mod_storage = {}, + get_modnames = {}, + get_modpath = {}, + get_name_from_content_id = {}, + get_natural_light = {}, + get_node = {}, + get_node_drops = {}, + get_node_group = {}, + get_node_level = {}, + get_node_light = {}, + get_node_max_level = {}, + get_node_or_nil = {}, + get_node_timer = {}, + get_noiseparams = {}, + get_objects_in_area = {}, + get_objects_inside_radius = {}, + get_password_hash = {}, + get_perlin = {}, + get_perlin_map = {}, + get_player_by_name = {}, + get_player_information = {}, + get_player_ip = {}, + get_player_privs = {}, + get_player_radius_area = {}, + get_pointed_thing_position = {}, + get_position_from_hash = {}, + get_server_max_lag = {}, + get_server_status = {}, + get_server_uptime = {}, + get_spawn_level = {}, + get_timeofday = {}, + get_tool_wear_after_use = {}, + get_translated_string = {}, + get_translator = {}, + get_us_time = {}, + get_user_path = {}, + get_version = {}, + get_voxel_manip = {}, + get_worldpath = {}, + global_exists = {}, + handle_async = {}, + handle_node_drops = {}, + has_feature = {}, + hash_node_position = {}, + hud_replace_builtin = {}, + inventorycube = {}, + is_area_protected = {}, + is_colored_paramtype = {}, + is_creative_enabled = {}, + is_nan = {}, + is_player = {}, + is_protected = {}, + is_singleplayer = {}, + is_yes = {}, + item_drop = {}, + item_eat = {}, + item_place = {}, + item_place_node = {}, + item_place_object = {}, + item_secondary_use = {}, + itemstring_with_color = {}, + itemstring_with_palette = {}, + kick_player = {}, + line_of_sight = {}, + load_area = {}, + log = {}, + luaentities = {}, + mkdir = {}, + mod_channel_join = {}, + mvdir = {}, + node_dig = {}, + node_punch = {}, + nodedef_default = {}, + noneitemdef_default = {}, + notify_authentication_modified = {}, + object_refs = {}, + on_craft = {}, + override_chatcommand = {}, + override_item = {}, + parse_coordinates = {}, + parse_json = {}, + parse_relative_number = {}, + place_node = {}, + place_schematic = {}, + place_schematic_on_vmanip = {}, + player_exists = {}, + pointed_thing_to_face_pos = {}, + pos_to_string = {}, + print = {}, + privs_to_string = {}, + punch_node = {}, + raillike_group = {}, + raycast = {}, + read_schematic = {}, + record_protection_violation = {}, + register_abm = {}, + register_alias = {}, + register_alias_force = {}, + register_allow_player_inventory_action = {}, + register_async_dofile = {}, + register_authentication_handler = {}, + register_biome = {}, + register_can_bypass_userlimit = {}, + register_chatcommand = {}, + register_craft = {}, + register_craft_predict = {}, + register_craftitem = {}, + register_decoration = {}, + register_entity = {}, + register_globalstep = {}, + register_item = {}, + register_lbm = {}, + register_node = {}, + register_on_auth_fail = {}, + register_on_authplayer = {}, + register_on_chat_message = {}, + register_on_chatcommand = {}, + register_on_cheat = {}, + register_on_craft = {}, + register_on_dieplayer = {}, + register_on_dignode = {}, + register_on_generated = {}, + register_on_item_eat = {}, + register_on_joinplayer = {}, + register_on_leaveplayer = {}, + register_on_liquid_transformed = {}, + register_on_mapgen_init = {}, + register_on_modchannel_message = {}, + register_on_mods_loaded = {}, + register_on_newplayer = {}, + register_on_placenode = {}, + register_on_player_hpchange = {}, + register_on_player_inventory_action = {}, + register_on_player_receive_fields = {}, + register_on_prejoinplayer = {}, + register_on_priv_grant = {}, + register_on_priv_revoke = {}, + register_on_protection_violation = {}, + register_on_punchnode = {}, + register_on_punchplayer = {}, + register_on_respawnplayer = {}, + register_on_rightclickplayer = {}, + register_on_shutdown = {}, + register_ore = {}, + register_playerevent = {}, + register_privilege = {}, + register_schematic = {}, + register_tool = {}, + registered_abms = {other_fields = true}, + registered_aliases = {other_fields = true}, + registered_allow_player_inventory_actions = {other_fields = true}, + registered_biomes = {other_fields = true}, + registered_can_bypass_userlimit = {other_fields = true}, + registered_chatcommands = {other_fields = true}, + registered_craft_predicts = {other_fields = true}, + registered_craftitems = {other_fields = true}, + registered_decorations = {other_fields = true}, + registered_entities = {other_fields = true}, + registered_globalsteps = {other_fields = true}, + registered_items = {other_fields = true}, + registered_lbms = {other_fields = true}, + registered_nodes = {other_fields = true}, + registered_on_authplayers = {other_fields = true}, + registered_on_chat_messages = {other_fields = true}, + registered_on_chatcommands = {other_fields = true}, + registered_on_cheats = {other_fields = true}, + registered_on_crafts = {other_fields = true}, + registered_on_dieplayers = {other_fields = true}, + registered_on_dignodes = {other_fields = true}, + registered_on_generateds = {other_fields = true}, + registered_on_item_eats = {other_fields = true}, + registered_on_joinplayers = {other_fields = true}, + registered_on_leaveplayers = {other_fields = true}, + registered_on_liquid_transformed = {other_fields = true}, + registered_on_modchannel_message = {other_fields = true}, + registered_on_mods_loaded = {other_fields = true}, + registered_on_newplayers = {other_fields = true}, + registered_on_placenodes = {other_fields = true}, + registered_on_player_hpchange = {other_fields = true}, + registered_on_player_hpchanges = {other_fields = true}, + registered_on_player_inventory_actions = {other_fields = true}, + registered_on_player_receive_fields = {other_fields = true}, + registered_on_prejoinplayers = {other_fields = true}, + registered_on_priv_grant = {other_fields = true}, + registered_on_priv_revoke = {other_fields = true}, + registered_on_protection_violation = {other_fields = true}, + registered_on_punchnodes = {other_fields = true}, + registered_on_punchplayers = {other_fields = true}, + registered_on_respawnplayers = {other_fields = true}, + registered_on_rightclickplayers = {other_fields = true}, + registered_on_shutdown = {other_fields = true}, + registered_ores = {other_fields = true}, + registered_playerevents = {other_fields = true}, + registered_privileges = {other_fields = true}, + registered_tools = {other_fields = true}, + remove_detached_inventory = {}, + remove_detached_inventory_raw = {}, + remove_node = {}, + remove_player = {}, + remove_player_auth = {}, + request_http_api = {}, + request_insecure_environment = {}, + request_shutdown = {}, + rgba = {}, + rmdir = {}, + rollback_get_last_node_actor = {}, + rollback_get_node_actions = {}, + rollback_punch_callbacks = {}, + rollback_revert_actions_by = {}, + rotate_and_place = {}, + rotate_node = {}, + run_callbacks = {}, + run_priv_callbacks = {}, + safe_file_write = {}, + send_join_message = {}, + send_leave_message = {}, + serialize = {}, + serialize_roundtrip = {}, + serialize_schematic = {}, + set_gen_notify = {}, + set_last_run_mod = {}, + set_mapgen_params = {}, + set_mapgen_setting = {}, + set_mapgen_setting_noiseparams = {}, + set_node = {}, + set_node_level = {}, + set_noiseparams = {}, + set_player_password = {}, + set_player_privs = {}, + set_timeofday = {}, + setting_get = {}, + setting_get_pos = {}, + setting_getbool = {}, + setting_save = {}, + setting_set = {}, + setting_setbool = {}, + settings = { + fields = { + get = {}, + get_bool = {}, + get_np_group = {}, + get_flags = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + remove = {}, + get_names = {}, + write = {}, + to_table = {}, + }, + }, + sha1 = {}, + show_formspec = {}, + show_general_help_formspec = {}, + show_privs_help_formspec = {}, + sound_fade = {}, + sound_play = {}, + sound_stop = {}, + spawn_falling_node = {}, + spawn_item = {}, + spawn_tree = {}, + string_to_area = {}, + string_to_pos = {}, + string_to_privs = {}, + strip_background_colors = {}, + strip_colors = {}, + strip_foreground_colors = {}, + strip_param2_color = {}, + swap_node = {}, + tooldef_default = {}, + transforming_liquid_add = {}, + translate = {}, + unban_player_or_ip = {}, + unregister_biome = {}, + unregister_chatcommand = {}, + unregister_item = {}, + wallmounted_to_dir = {}, + wrap_text = {}, + write_json = {}, + yaw_to_dir = {}, + }, + }, + } +} + +stds.stairs = { + globals = { + "stairs", + }, + read_globals = { + "stairsplus", + }, +} diff --git a/stairs/README.md b/stairs/README.md new file mode 100644 index 00000000..04981cc2 --- /dev/null +++ b/stairs/README.md @@ -0,0 +1 @@ +stairs compat: override what stairs does diff --git a/stairs/api.lua b/stairs/api.lua new file mode 100644 index 00000000..5cbad99c --- /dev/null +++ b/stairs/api.lua @@ -0,0 +1,158 @@ +local f = string.format + +local api = stairsplus.api + +local S = stairsplus.S + +local legacy = stairs.legacy + +local is_legacy_drawtype = stairsplus.compat.is_legacy_drawtype +local is_legacy_paramtype2 = stairsplus.compat.is_legacy_paramtype2 + +local default_align_style = stairsplus.settings.default_align_style +local legacy_stairs_without_recipeitem = stairs.settings.legacy_stairs_without_recipeitem + +function stairs.register_stair(subname, node, groups, tiles, description, sounds, worldaligntex) + if not minetest.registered_nodes[node] then + -- registering a stair for a node that doesn't exist + if legacy_stairs_without_recipeitem then + legacy.register_stair(subname, node, groups, tiles, description, sounds, worldaligntex) + return + + else + error(f("attempt to register stairs for unknown node %q. " .. + "set `stairs.legacy_stairs_without_recipeitem = true` in minetest.conf to enable this behavior.", node)) + end + end + + local meta = { + align_style = worldaligntex and "world" or default_align_style + } + + if is_legacy_drawtype(node) then + meta.ignore_drawtype = true + end + if is_legacy_paramtype2(node) then + meta.ignore_paramtype2 = true + end + + api.register_single(node, "stair", { + groups = groups, + tiles = tiles, + description = description, + sounds = sounds, + }, meta) + + minetest.register_alias(("stairs:stair_%s"):format(subname), api.format_name(node, "stair")) +end + +function stairs.register_slab(subname, node, groups, tiles, description, sounds, worldaligntex) + if not minetest.registered_nodes[node] then + -- registering a stair for a node that doesn't exist + if legacy_stairs_without_recipeitem then + legacy.register_slab(subname, node, groups, tiles, description, sounds, worldaligntex) + return + + else + error(f("attempt to register stairs for unknown node %q. " .. + "set `stairs.legacy_stairs_without_recipeitem = true` in minetest.conf to enable this behavior.", node)) + end + end + + local meta = { + align_style = worldaligntex and "world" or default_align_style + } + if is_legacy_drawtype(node) then + meta.ignore_drawtype = true + end + if is_legacy_paramtype2(node) then + meta.ignore_paramtype2 = true + end + + api.register_single(node, "slab_8", { + groups = groups, + tiles = tiles, + description = description, + sounds = sounds, + }, meta) + + minetest.register_alias(("stairs:slab_%s"):format(subname), api.format_name(node, "slab_8")) +end + +function stairs.register_stair_inner(subname, node, groups, tiles, description, sounds, worldaligntex, full_description) + if not minetest.registered_nodes[node] then + -- registering a stair for a node that doesn't exist + if legacy_stairs_without_recipeitem then + legacy.register_stair_inner(subname, node, groups, tiles, description, sounds, worldaligntex, + full_description) + return + + else + error(f("attempt to register stairs for unknown node %q. " .. + "set `stairs.legacy_stairs_without_recipeitem = true` in minetest.conf to enable this behavior.", node)) + end + end + + local meta = { + align_style = worldaligntex and "world" or default_align_style + } + if is_legacy_drawtype(node) then + meta.ignore_drawtype = true + end + if is_legacy_paramtype2(node) then + meta.ignore_paramtype2 = true + end + + api.register_single(node, "stair_inner", { + groups = groups, + tiles = tiles, + description = full_description or S("Inner @1", description), + sounds = sounds, + }, meta) + + minetest.register_alias(("stairs:stair_inner_%s"):format(subname), api.format_name(node, "stair_inner")) +end + +function stairs.register_stair_outer(subname, node, groups, tiles, description, sounds, worldaligntex, full_description) + if not minetest.registered_nodes[node] then + -- registering a stair for a node that doesn't exist + if legacy_stairs_without_recipeitem then + legacy.register_stair_outer(subname, node, groups, tiles, description, sounds, worldaligntex, + full_description) + return + + else + error(f("attempt to register stairs for unknown node %q. " .. + "set `stairs.legacy_stairs_without_recipeitem = true` in minetest.conf to enable this behavior.", node)) + end + end + + local meta = { + align_style = worldaligntex and "world" or default_align_style + } + if is_legacy_drawtype(node) then + meta.ignore_drawtype = true + end + if is_legacy_paramtype2(node) then + meta.ignore_paramtype2 = true + end + + api.register_single(node, "stair_outer", { + groups = groups, + tiles = tiles, + description = full_description or S("Outer @1", description), + sounds = sounds, + }, meta) + + minetest.register_alias(("stairs:stair_outer_%s"):format(subname), api.format_name(node, "stair_outer")) +end + +function stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds, + worldaligntex, desc_stair_inner, desc_stair_outer) + stairs.register_stair(subname, recipeitem, groups, images, desc_stair, sounds, worldaligntex) + stairs.register_slab(subname, recipeitem, groups, images, desc_slab, sounds, worldaligntex) + stairs.register_stair_inner(subname, recipeitem, groups, images, desc_stair, sounds, worldaligntex, + desc_stair_inner) + stairs.register_stair_outer(subname, recipeitem, groups, images, desc_stair, sounds, worldaligntex, + desc_stair_outer) +end diff --git a/stairs/compat.lua b/stairs/compat.lua new file mode 100644 index 00000000..35d03348 --- /dev/null +++ b/stairs/compat.lua @@ -0,0 +1,4 @@ +-- for very, very old worlds... + +minetest.register_alias("stairs:stair_pinewood", "stairs:stair_pine_wood") +minetest.register_alias("stairs:slab_pinewood", "stairs:slab_pine_wood") diff --git a/stairs/init.lua b/stairs/init.lua new file mode 100644 index 00000000..3269c0b3 --- /dev/null +++ b/stairs/init.lua @@ -0,0 +1,34 @@ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +stairs = { + version = {3, 0, 0}, + fork = "minetest_mods", + + modname = modname, + modpath = modpath, + + S = S, + + has = { + default = minetest.get_modpath("default"), + i3 = minetest.get_modpath("i3"), + stairs = minetest.get_modpath("stairs"), + unified_inventory = minetest.get_modpath("unified_inventory"), + }, + + log = function(level, messagefmt, ...) + return minetest.log(level, ("[%s] %s"):format(modname, messagefmt:format(...))) + end, + + dofile = function(...) + return dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua") + end, +} + +stairs.dofile("settings") +stairs.dofile("util") +stairs.dofile("legacy") +stairs.dofile("api") +stairs.dofile("compat") diff --git a/stairs/legacy.lua b/stairs/legacy.lua new file mode 100644 index 00000000..7eba9bb6 --- /dev/null +++ b/stairs/legacy.lua @@ -0,0 +1,245 @@ +local rotate_and_place = minetest.rotate_and_place + +local get_node_vars = stairs.util.get_node_vars +local get_stair_images = stairs.util.get_stair_images + +local legacy = {} + +local nodeboxes = { + stair = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.0, 0.5}, + {-0.5, 0.0, 0.0, 0.5, 0.5, 0.5}, + }, + }, + slab = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + stair_inner = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.0, 0.5}, + {-0.5, 0.0, 0.0, 0.5, 0.5, 0.5}, + {-0.5, 0.0, -0.5, 0.0, 0.5, 0.0}, + }, + }, + stair_outer = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.0, 0.5}, + {-0.5, 0.0, 0.0, 0.0, 0.5, 0.5}, + }, + }, +} + +local function register_generic(name, recipeitem, groups, images, description, sounds, worldaligntex, nodebox) + if not nodebox then + error() + end + + local light_source, texture_alpha, sunlight = get_node_vars(recipeitem) + + local stair_images = get_stair_images(images, worldaligntex) + + minetest.register_node(name, { + description = description, + drawtype = "nodebox", + tiles = stair_images, + use_texture_alpha = texture_alpha, + sunlight_propagates = sunlight, + light_source = light_source, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + groups = groups, + sounds = sounds, + node_box = nodebox, + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + + return rotate_and_place(itemstack, placer, pointed_thing) + end, + }) +end + +function legacy.register_stair(subname, recipeitem, groups, images, description, sounds, worldaligntex) + local new_groups = table.copy(groups) + new_groups.stair = 1 + + register_generic(":stairs:stair_" .. subname, recipeitem, new_groups, images, description, sounds, + worldaligntex, nodeboxes.stair) + + if recipeitem and minetest.registered_nodes[recipeitem] then + -- Recipe matches appearence in inventory + minetest.register_craft({ + output = "stairs:stair_" .. subname .. " 8", + recipe = { + {"", "", recipeitem}, + {"", recipeitem, recipeitem}, + {recipeitem, recipeitem, recipeitem}, + }, + }) + + -- Use stairs to craft full blocks again (1:1) + minetest.register_craft({ + output = recipeitem .. " 3", + recipe = { + {"stairs:stair_" .. subname, "stairs:stair_" .. subname}, + {"stairs:stair_" .. subname, "stairs:stair_" .. subname}, + }, + }) + + -- Fuel + local baseburntime = minetest.get_craft_result({ + method = "fuel", + width = 1, + items = {recipeitem} + }).time + + if baseburntime > 0 then + minetest.register_craft({ + type = "fuel", + recipe = "stairs:stair_" .. subname, + burntime = math.floor(baseburntime * 0.75), + }) + end + end +end + + +-- Register slab +-- Node will be called stairs:slab_ + +function legacy.register_slab(subname, recipeitem, groups, images, description, sounds, worldaligntex) + local new_groups = table.copy(groups) + new_groups.slab = 1 + + register_generic(":stairs:slab_" .. subname, recipeitem, new_groups, images, description, sounds, + worldaligntex, nodeboxes.slab) + + if recipeitem and minetest.registered_nodes[recipeitem] then + minetest.register_craft({ + output = "stairs:slab_" .. subname .. " 6", + recipe = { + {recipeitem, recipeitem, recipeitem}, + }, + }) + + -- Use 2 slabs to craft a full block again (1:1) + minetest.register_craft({ + output = recipeitem, + recipe = { + {"stairs:slab_" .. subname}, + {"stairs:slab_" .. subname}, + }, + }) + + -- Fuel + local baseburntime = minetest.get_craft_result({ + method = "fuel", + width = 1, + items = {recipeitem} + }).time + if baseburntime > 0 then + minetest.register_craft({ + type = "fuel", + recipe = "stairs:slab_" .. subname, + burntime = math.floor(baseburntime * 0.5), + }) + end + end +end + +-- Register inner stair +-- Node will be called stairs:stair_inner_ + +function legacy.register_stair_inner(subname, recipeitem, groups, images, description, sounds, worldaligntex, + full_description) + + local new_groups = table.copy(groups) + new_groups.stair = 1 + if full_description then + description = full_description + else + description = "Inner " .. description + end + + register_generic(":stairs:stair_inner_" .. subname, recipeitem, new_groups, images, description, sounds, + worldaligntex, nodeboxes.stair_inner) + + if recipeitem and minetest.registered_nodes[recipeitem] then + minetest.register_craft({ + output = "stairs:stair_inner_" .. subname .. " 7", + recipe = { + {"", recipeitem, ""}, + {recipeitem, "", recipeitem}, + {recipeitem, recipeitem, recipeitem}, + }, + }) + + -- Fuel + local baseburntime = minetest.get_craft_result({ + method = "fuel", + width = 1, + items = {recipeitem} + }).time + + if baseburntime > 0 then + minetest.register_craft({ + type = "fuel", + recipe = "stairs:stair_inner_" .. subname, + burntime = math.floor(baseburntime * 0.875), + }) + end + end +end + + +-- Register outer stair +-- Node will be called stairs:stair_outer_ + +function legacy.register_stair_outer(subname, recipeitem, groups, images, description, sounds, worldaligntex, + full_description) + local new_groups = table.copy(groups) + new_groups.stair = 1 + + if full_description then + description = full_description + else + description = "Outer " .. description + end + + register_generic(":stairs:stair_outer_" .. subname, recipeitem, new_groups, images, description, sounds, + worldaligntex, nodeboxes.stair_outer) + + if recipeitem and minetest.registered_nodes[recipeitem] then + minetest.register_craft({ + output = "stairs:stair_outer_" .. subname .. " 6", + recipe = { + {"", recipeitem, ""}, + {recipeitem, recipeitem, recipeitem}, + }, + }) + + -- Fuel + local baseburntime = minetest.get_craft_result({ + method = "fuel", + width = 1, + items = {recipeitem} + }).time + + if baseburntime > 0 then + minetest.register_craft({ + type = "fuel", + recipe = "stairs:stair_outer_" .. subname, + burntime = math.floor(baseburntime * 0.625), + }) + end + end +end + +stairs.legacy = legacy diff --git a/stairs/mod.conf b/stairs/mod.conf new file mode 100644 index 00000000..9550e2d9 --- /dev/null +++ b/stairs/mod.conf @@ -0,0 +1,5 @@ +name = stairs +version = 3.0.0 +title = Stairs+'s Stairs Compat layer +description = stair API +depends = stairsplus diff --git a/stairs/settings.lua b/stairs/settings.lua new file mode 100644 index 00000000..a4434eae --- /dev/null +++ b/stairs/settings.lua @@ -0,0 +1,5 @@ +local s = minetest.settings + +stairs.settings = { + legacy_stairs_without_recipeitem = s:get_bool("stairs.legacy_stairs_without_recipeitem", false), +} diff --git a/stairs/util.lua b/stairs/util.lua new file mode 100644 index 00000000..c76bb528 --- /dev/null +++ b/stairs/util.lua @@ -0,0 +1,47 @@ +local default_align_style = stairsplus.settings.default_align_style + +local util = {} + +-- get node settings to use for stairs +function util.get_node_vars(nodename) + local def = minetest.registered_nodes[nodename] + + if def then + return def.light_source, def.use_texture_alpha, def.sunlight_propagates + end +end + +function util.get_stair_images(images, worldaligntex) + local stair_images = {} + + for i, image in ipairs(images) do + local stair_image + + if type(image) == "string" then + stair_image = { + name = image, + backface_culling = true, + } + + else + stair_image = table.copy(image) + if stair_image.backface_culling == nil then + stair_image.backface_culling = true + end + end + + if stair_image.align_style == nil then + if worldaligntex then + stair_image.align_style = "world" + else + stair_image.align_style = default_align_style + end + end + + stair_images[i] = stair_image + end + + return stair_images +end + +stairs.util = util diff --git a/stairsplus/.luacheckrc b/stairsplus/.luacheckrc new file mode 100644 index 00000000..62b9dd45 --- /dev/null +++ b/stairsplus/.luacheckrc @@ -0,0 +1,655 @@ +std = "lua51+luajit+minetest+stairsplus" +unused_args = false +max_line_length = 120 + +stds.minetest = { + read_globals = { + "DIR_DELIM", + "dump", + "dump2", + + math = { + fields = { + abs = {}, + acos = {}, + asin = {}, + atan = {}, + atan2 = {}, + ceil = {}, + cos = {}, + cosh = {}, + deg = {}, + exp = {}, + factorial = {}, + floor = {}, + fmod = {}, + frexp = {}, + huge = {}, + hypot = {}, + ldexp = {}, + log = {}, + log10 = {}, + max = {}, + min = {}, + modf = {}, + pi = {}, + pow = {}, + rad = {}, + random = {}, + randomseed = {}, + round = {}, + sign = {}, + sin = {}, + sinh = {}, + sqrt = {}, + tan = {}, + tanh = {}, + }, + }, + table = { + fields = { + copy = {}, + concat = {}, + foreach = {}, + foreachi = {}, + getn = {}, + indexof = {}, + insert = {}, + insert_all = {}, + key_value_swap = {}, + maxn = {}, + move = {}, + remove = {}, + shuffle = {}, + sort = {}, + }, + }, + string = { + fields = { + byte = {}, + char = {}, + dump = {}, + find = {}, + format = {}, + gmatch = {}, + len = {}, + lower = {}, + match = {}, + rep = {}, + reverse = {}, + split = {}, + sub = {}, + trim = {}, + upper = {}, + }, + }, + vector = { + fields = { + add = {}, + angle = {}, + apply = {}, + check = {}, + combine = {}, + copy = {}, + cross = {}, + dir_to_rotation = {}, + direction = {}, + distance = {}, + divide = {}, + dot = {}, + equals = {}, + floor = {}, + from_string = {}, + length = {}, + metatable = {}, + multiply = {}, + new = {}, + normalize = {}, + offset = {}, + rotate = {}, + rotate_around_axis = {}, + round = {}, + sort = {}, + subtract = {}, + to_string = {}, + zero = {}, + }, + }, + + ItemStack = { + fields = { + add_item = {}, + add_wear = {}, + add_wear_by_uses = {}, + clear = {}, + get_count = {}, + get_definition = {}, + get_description = {}, + get_free_space = {}, + get_meta = {}, + get_metadata = {}, + get_name = {}, + get_short_description = {}, + get_stack_max = {}, + get_tool_capabilities = {}, + get_wear = {}, + is_empty = {}, + is_known = {}, + item_fits = {}, + peek_item = {}, + replace = {}, + set_count = {}, + set_metadata = {}, + set_name = {}, + set_wear = {}, + take_item = {}, + to_string = {}, + to_table = {}, + }, + }, + PerlinNoise = { + fields = { + get_2d = {}, + get_3d = {}, + }, + }, + PerlinNoiseMap = { + fields = { + calc_2d_map = {}, + calc_3d_map = {}, + get_2d_map = {}, + get_2d_map_flat = {}, + get_3d_map = {}, + get_3d_map_flat = {}, + get_map_slice = {}, + }, + }, + PseudoRandom = { + fields = { + next = {}, + }, + }, + PcgRandom = { + fields = { + next = {}, + rand_normal_dist = {}, + }, + }, + SecureRandom = { + fields = { + next_bytes = {}, + }, + }, + Settings = { + fields = { + get = {}, + get_bool = {}, + get_flags = {}, + get_names = {}, + get_np_group = {}, + remove = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + to_table = {}, + write = {}, + }, + }, + VoxelArea = { + fields = { + MaxEdge = {}, + MinEdge = {}, + contains = {}, + containsi = {}, + containsp = {}, + getExtent = {}, + getVolume = {}, + index = {}, + indexp = {}, + iter = {}, + iterp = {}, + new = {}, + position = {}, + ystride = {}, + zstride = {}, + }, + }, + VoxelManip = { + fields = { + calc_lighting = {}, + get_data = {}, + get_emerged_area = {}, + get_light_data = {}, + get_node_at = {}, + get_param2_data = {}, + read_from_map = {}, + set_data = {}, + set_light_data = {}, + set_lighting = {}, + set_node_at = {}, + set_param2_data = {}, + update_liquids = {}, + update_map = {}, + was_modified = {}, + write_to_map = {}, + }, + }, + + minetest = { + fields = { + CONTENT_AIR = {}, + CONTENT_IGNORE = {}, + CONTENT_UNKNOWN = {}, + EMERGE_CANCELLED = {}, + EMERGE_ERRORED = {}, + EMERGE_FROM_DISK = {}, + EMERGE_FROM_MEMORY = {}, + EMERGE_GENERATED = {}, + LIGHT_MAX = {}, + MAP_BLOCKSIZE = {}, + PLAYER_MAX_BREATH_DEFAULT = {}, + PLAYER_MAX_HP_DEFAULT = {}, + add_entity = {}, + add_item = {}, + add_node = {}, + add_node_level = {}, + add_particle = {}, + add_particlespawner = {}, + after = {}, + async_event_handler = {}, + async_jobs = {}, + auth_reload = {}, + ban_player = {}, + builtin_auth_handler = {}, + bulk_set_node = {}, + calculate_knockback = {}, + callback_origins = {}, + cancel_shutdown_requests = {}, + chat_send_all = {}, + chat_send_player = {}, + chatcommands = {}, + check_for_falling = {}, + check_password_entry = {}, + check_player_privs = {}, + check_single_for_falling = {}, + clear_craft = {}, + clear_objects = {}, + clear_registered_biomes = {}, + clear_registered_decorations = {}, + clear_registered_ores = {}, + clear_registered_schematics = {}, + close_formspec = {}, + colorize = {}, + colorspec_to_bytes = {}, + colorspec_to_colorstring = {}, + compare_block_status = {}, + compress = {}, + cpdir = {}, + craft_predict = {}, + craftitemdef_default = {}, + create_detached_inventory = {}, + create_detached_inventory_raw = {}, + create_schematic = {}, + debug = {}, + decode_base64 = {}, + decompress = {}, + delete_area = {}, + delete_particlespawner = {}, + deserialize = {}, + detached_inventories = {}, + dig_node = {}, + dir_to_facedir = {}, + dir_to_wallmounted = {}, + dir_to_yaw = {}, + disconnect_player = {}, + do_async_callback = {}, + do_item_eat = {}, + dynamic_add_media = {}, + dynamic_media_callbacks = {}, + emerge_area = {}, + encode_base64 = {}, + encode_png = {}, + env = {}, + explode_scrollbar_event = {}, + explode_table_event = {}, + explode_textlist_event = {}, + facedir_to_dir = {}, + features = {}, + find_node_near = {}, + find_nodes_in_area = {}, + find_nodes_in_area_under_air = {}, + find_nodes_with_meta = {}, + find_path = {}, + fix_light = {}, + forceload_block = {}, + forceload_free_block = {}, + format_chat_message = {}, + formspec_escape = {}, + generate_decorations = {}, + generate_ores = {}, + get_all_craft_recipes = {}, + get_artificial_light = {}, + get_auth_handler = {}, + get_background_escape_sequence = {}, + get_ban_description = {}, + get_ban_list = {}, + get_biome_data = {}, + get_biome_id = {}, + get_biome_name = {}, + get_builtin_path = {}, + get_color_escape_sequence = {}, + get_connected_players = {}, + get_content_id = {}, + get_craft_recipe = {}, + get_craft_result = {}, + get_current_modname = {}, + get_day_count = {}, + get_decoration_id = {}, + get_dig_params = {}, + get_dir_list = {}, + get_gametime = {}, + get_gen_notify = {}, + get_heat = {}, + get_hit_params = {}, + get_humidity = {}, + get_inventory = {}, + get_item_group = {}, + get_last_run_mod = {}, + get_mapgen_object = {}, + get_mapgen_params = {}, + get_mapgen_setting = {}, + get_mapgen_setting_noiseparams = {}, + get_meta = {}, + get_mod_storage = {}, + get_modnames = {}, + get_modpath = {}, + get_name_from_content_id = {}, + get_natural_light = {}, + get_node = {}, + get_node_drops = {}, + get_node_group = {}, + get_node_level = {}, + get_node_light = {}, + get_node_max_level = {}, + get_node_or_nil = {}, + get_node_timer = {}, + get_noiseparams = {}, + get_objects_in_area = {}, + get_objects_inside_radius = {}, + get_password_hash = {}, + get_perlin = {}, + get_perlin_map = {}, + get_player_by_name = {}, + get_player_information = {}, + get_player_ip = {}, + get_player_privs = {}, + get_player_radius_area = {}, + get_pointed_thing_position = {}, + get_position_from_hash = {}, + get_server_max_lag = {}, + get_server_status = {}, + get_server_uptime = {}, + get_spawn_level = {}, + get_timeofday = {}, + get_tool_wear_after_use = {}, + get_translated_string = {}, + get_translator = {}, + get_us_time = {}, + get_user_path = {}, + get_version = {}, + get_voxel_manip = {}, + get_worldpath = {}, + global_exists = {}, + handle_async = {}, + handle_node_drops = {}, + has_feature = {}, + hash_node_position = {}, + hud_replace_builtin = {}, + inventorycube = {}, + is_area_protected = {}, + is_colored_paramtype = {}, + is_creative_enabled = {}, + is_nan = {}, + is_player = {}, + is_protected = {}, + is_singleplayer = {}, + is_yes = {}, + item_drop = {}, + item_eat = {}, + item_place = {}, + item_place_node = {}, + item_place_object = {}, + item_secondary_use = {}, + itemstring_with_color = {}, + itemstring_with_palette = {}, + kick_player = {}, + line_of_sight = {}, + load_area = {}, + log = {}, + luaentities = {}, + mkdir = {}, + mod_channel_join = {}, + mvdir = {}, + node_dig = {}, + node_punch = {}, + nodedef_default = {}, + noneitemdef_default = {}, + notify_authentication_modified = {}, + object_refs = {}, + on_craft = {}, + override_chatcommand = {}, + override_item = {}, + parse_coordinates = {}, + parse_json = {}, + parse_relative_number = {}, + place_node = {}, + place_schematic = {}, + place_schematic_on_vmanip = {}, + player_exists = {}, + pointed_thing_to_face_pos = {}, + pos_to_string = {}, + print = {}, + privs_to_string = {}, + punch_node = {}, + raillike_group = {}, + raycast = {}, + read_schematic = {}, + record_protection_violation = {}, + register_abm = {}, + register_alias = {}, + register_alias_force = {}, + register_allow_player_inventory_action = {}, + register_async_dofile = {}, + register_authentication_handler = {}, + register_biome = {}, + register_can_bypass_userlimit = {}, + register_chatcommand = {}, + register_craft = {}, + register_craft_predict = {}, + register_craftitem = {}, + register_decoration = {}, + register_entity = {}, + register_globalstep = {}, + register_item = {}, + register_lbm = {}, + register_node = {}, + register_on_auth_fail = {}, + register_on_authplayer = {}, + register_on_chat_message = {}, + register_on_chatcommand = {}, + register_on_cheat = {}, + register_on_craft = {}, + register_on_dieplayer = {}, + register_on_dignode = {}, + register_on_generated = {}, + register_on_item_eat = {}, + register_on_joinplayer = {}, + register_on_leaveplayer = {}, + register_on_liquid_transformed = {}, + register_on_mapgen_init = {}, + register_on_modchannel_message = {}, + register_on_mods_loaded = {}, + register_on_newplayer = {}, + register_on_placenode = {}, + register_on_player_hpchange = {}, + register_on_player_inventory_action = {}, + register_on_player_receive_fields = {}, + register_on_prejoinplayer = {}, + register_on_priv_grant = {}, + register_on_priv_revoke = {}, + register_on_protection_violation = {}, + register_on_punchnode = {}, + register_on_punchplayer = {}, + register_on_respawnplayer = {}, + register_on_rightclickplayer = {}, + register_on_shutdown = {}, + register_ore = {}, + register_playerevent = {}, + register_privilege = {}, + register_schematic = {}, + register_tool = {}, + registered_abms = {other_fields = true}, + registered_aliases = {other_fields = true}, + registered_allow_player_inventory_actions = {other_fields = true}, + registered_biomes = {other_fields = true}, + registered_can_bypass_userlimit = {other_fields = true}, + registered_chatcommands = {other_fields = true}, + registered_craft_predicts = {other_fields = true}, + registered_craftitems = {other_fields = true}, + registered_decorations = {other_fields = true}, + registered_entities = {other_fields = true}, + registered_globalsteps = {other_fields = true}, + registered_items = {other_fields = true}, + registered_lbms = {other_fields = true}, + registered_nodes = {other_fields = true}, + registered_on_authplayers = {other_fields = true}, + registered_on_chat_messages = {other_fields = true}, + registered_on_chatcommands = {other_fields = true}, + registered_on_cheats = {other_fields = true}, + registered_on_crafts = {other_fields = true}, + registered_on_dieplayers = {other_fields = true}, + registered_on_dignodes = {other_fields = true}, + registered_on_generateds = {other_fields = true}, + registered_on_item_eats = {other_fields = true}, + registered_on_joinplayers = {other_fields = true}, + registered_on_leaveplayers = {other_fields = true}, + registered_on_liquid_transformed = {other_fields = true}, + registered_on_modchannel_message = {other_fields = true}, + registered_on_mods_loaded = {other_fields = true}, + registered_on_newplayers = {other_fields = true}, + registered_on_placenodes = {other_fields = true}, + registered_on_player_hpchange = {other_fields = true}, + registered_on_player_hpchanges = {other_fields = true}, + registered_on_player_inventory_actions = {other_fields = true}, + registered_on_player_receive_fields = {other_fields = true}, + registered_on_prejoinplayers = {other_fields = true}, + registered_on_priv_grant = {other_fields = true}, + registered_on_priv_revoke = {other_fields = true}, + registered_on_protection_violation = {other_fields = true}, + registered_on_punchnodes = {other_fields = true}, + registered_on_punchplayers = {other_fields = true}, + registered_on_respawnplayers = {other_fields = true}, + registered_on_rightclickplayers = {other_fields = true}, + registered_on_shutdown = {other_fields = true}, + registered_ores = {other_fields = true}, + registered_playerevents = {other_fields = true}, + registered_privileges = {other_fields = true}, + registered_tools = {other_fields = true}, + remove_detached_inventory = {}, + remove_detached_inventory_raw = {}, + remove_node = {}, + remove_player = {}, + remove_player_auth = {}, + request_http_api = {}, + request_insecure_environment = {}, + request_shutdown = {}, + rgba = {}, + rmdir = {}, + rollback_get_last_node_actor = {}, + rollback_get_node_actions = {}, + rollback_punch_callbacks = {}, + rollback_revert_actions_by = {}, + rotate_and_place = {}, + rotate_node = {}, + run_callbacks = {}, + run_priv_callbacks = {}, + safe_file_write = {}, + send_join_message = {}, + send_leave_message = {}, + serialize = {}, + serialize_roundtrip = {}, + serialize_schematic = {}, + set_gen_notify = {}, + set_last_run_mod = {}, + set_mapgen_params = {}, + set_mapgen_setting = {}, + set_mapgen_setting_noiseparams = {}, + set_node = {}, + set_node_level = {}, + set_noiseparams = {}, + set_player_password = {}, + set_player_privs = {}, + set_timeofday = {}, + setting_get = {}, + setting_get_pos = {}, + setting_getbool = {}, + setting_save = {}, + setting_set = {}, + setting_setbool = {}, + settings = { + fields = { + get = {}, + get_bool = {}, + get_np_group = {}, + get_flags = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + remove = {}, + get_names = {}, + write = {}, + to_table = {}, + }, + }, + sha1 = {}, + show_formspec = {}, + show_general_help_formspec = {}, + show_privs_help_formspec = {}, + sound_fade = {}, + sound_play = {}, + sound_stop = {}, + spawn_falling_node = {}, + spawn_item = {}, + spawn_tree = {}, + string_to_area = {}, + string_to_pos = {}, + string_to_privs = {}, + strip_background_colors = {}, + strip_colors = {}, + strip_foreground_colors = {}, + strip_param2_color = {}, + swap_node = {}, + tooldef_default = {}, + transforming_liquid_add = {}, + translate = {}, + unban_player_or_ip = {}, + unregister_biome = {}, + unregister_chatcommand = {}, + unregister_item = {}, + wallmounted_to_dir = {}, + wrap_text = {}, + write_json = {}, + yaw_to_dir = {}, + }, + }, + } +} + +stds.stairsplus = { + globals = { + "stairsplus", + }, + read_globals = { + "default", + }, +} diff --git a/stairsplus/API.md b/stairsplus/API.md index 46b838d6..fe48b53f 100644 --- a/stairsplus/API.md +++ b/stairsplus/API.md @@ -1,82 +1,331 @@ # API documentation for Stairs+ -* `stairsplus:register_all(modname, subname, recipeitem, fields)` - Registers a stair, slab, panel, microblock, and any other types of - nodes to be added in the future. - This also registers the node with the circular saw. - Example: - ```lua - stairsplus:register_all("moreblocks", "wood", "default:wood", { - description = "Wooden", - tiles = {"default_wood.png"}, - groups = {oddly_breakabe_by_hand=1}, - sounds = moreblocks.node_sound_wood_defaults(), - }) - ``` -The following register only a particular type of microblock. -You will probably never want to use them directly: +In general, function arguments specified in square brackets ("[ ]") are optional. -* `stairsplus:register_stair(modname, subname, recipeitem, fields)` -* `stairsplus:register_slab(modname, subname, recipeitem, fields)` -* `stairsplus:register_panel(modname, subname, recipeitem, fields)` +## Shape API + +For registering new shapes. + +* `stairsplus.api.register_shape(name, def)` + An example of a node_box shape: + ```lua + stairsplus.api.register_shape("slab_8", { + name_format = "slab_%s_8", + aliases = {"slab_%s"}, + description = "@1 1/2 Slab", + shape_groups = {slab = 1, legacy = 1}, + eighths = 4, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, + }) + ``` + An example of a mesh shape: + ```lua + 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} + } + } + + stairsplus.api.register_shape("slope", { + name_format = "slope_%s", + description = "@1 Slope", + shape_groups = {slope = 1, legacy = 1}, + eighths = 4, + drawtype = "mesh", + mesh = "stairsplus_slope.obj", + collision_box = box_slope, + selection_box = box_slope, + }) + ``` + Hopefully most of the paramaters should be self explanatory. `eighths` is the number of 1/8th node + microblocks that the shape is "worth", i.e. how much material is used in crafting it. +* `stairsplus.api.register_shape_group(shape_group, shapes)` + Register a new shape group. + +The following tables are exposed for convenience, but shouldn't be directly modified: + +* `stairsplus.api.registered_shapes` + A hash of shape definitions by name. + +* `stairsplus.api.shapes_by_group` + A hash of lists of shapes in a group, by the shape group name. + + +## Node API + +These are for registering shapes of a node + +* `stairsplus.api.register_on_register_single(function(node, shaped_name))` + Register a callback for when a shaped node is registered. Mostly useful for integration with + inventory managers. + +* `stairsplus.api.register_single(node, shape, [overrides], [meta])` + Register a single shape of a node. + If no "micro_8" shape is defined, it will be defined before registering another shape. Attempting to + register an already-registered shape will not override anything. + Many of the node's properties will be inherited from the + node and shape definition, but can be manually changed via `overrides`. `meta` is used to specify + whether special logic should be used while defining the shaped node. The following values are supported: + * `ignore_type = true` + Whether to ignore the base node's `type` - usually, it is an error to try to register a shape for a + non-node. + * `ignore_drawtype = true` + Whether to ignore the base node's `drawtye`. Usually, it is an error to try to register a shape for a + non-node-like drawtype. + * `ignore_paramtype2 = true` + Whether to ignore the base node's `paramtype2`. Usually, it is an error to register a shape for node + which is not compatible with a `facedir` drawtype. + * `align_style = "node" | "user" | "world"` + Whether to override the align_style for the textures used to draw the shaped node. The default behavior + is to use the value defined by the `stairsplus.default_align_style` setting, which defaults to `"user"`. + * `allow_override_groups = true` + Whether to allow groups to be specified in the overrides (otherwise, they are ignored). + * `allow_override_drawtype = true` + Whether to allow a drawtype to be specified in the overrides (otherwise, it is ignored). + * `allow_override_paramtype2 = true` + Whether to allow a paramtype2 to be specified in the overrides (otherwise, it is ignored). + +* `stairsplus.api.register_all(node, [overrides], [meta])` + Register all registered shapes for a node. we do not recommend using this, due to the 32767 node limit. + we recommend using + +* `stairsplus.api.register_shapes(node, shapes, [overrides], [meta])` + Register variants for a custom list of shapes. +* `stairsplus.api.register_group(node, shape_group, [overrides], [meta])` + Register variants for a defined shape group. +* `stairsplus.api.register_groups(node, shape_groups, [overrides], [meta])` + Register variants for a list of shape groups. + +* `stairsplus.api.format_name(node, shape)` + Get the itemstring for a shaped variant. It is not guaranteed that the resulting itemstring actually + exists. + +* `stairsplus.api.get_shapes(node)` + Get the defined shapes for a node. Returns `nil` if no shapes are registered for the node. + +* `stairsplus.api.get_shapes_hash(node)` + Get a hash where the keys are the shapes supported by the node. Mutating the return value is not + recommended. Will return `nil` if no shapes are registered for the node. + +* `stairsplus.api.get_schema_recipe_item(node, shape_or_item)` + If `shape_or_item` is an empty string, return an empty string. If it is an itemstring (contains a ":"), + that itemstring is returned. If it is a shape, and the shape is defined for the given node, returns + the name of the shaped node. If it is a shape, but the shape is not defined for the given node, returns + `nil`. If it is the special string `"node"`, then it returns the node argument. `shape_or_item` may + optionally specify a count value, which will modify the returned value accordingly. + ```lua + assert(stairsplus.api.get_schema_recipe_item("default:stone", "node 3") == "default:stone 3") + assert(stairsplus.api.get_schema_recipe_item("default:stone", "slope 3") == "default:slope_stone 3") + ``` + +* `stairsplus.api.get_micronode(node)` + Convenience method for `stairsplus.api.get_schema_recipe_item(node, "micro_8")`. + +* `stairsplus.api.get_node_of_shaped_node(shaped_node)` + Given a shaped node, get the "base" node it was made from. + +* `stairsplus.api.get_shape_of_shaped_node(shaped_node)` + Given a shaped node, get its shape. + + +## Alias API + +* `stairsplus.api.register_alias_single(old_node, new_node, shape)` + Hopefully this is self-explanatory. +* `stairsplus.api.register_alias_all(old_node, new_node)` +* `stairsplus.api.register_alias_shapes(old_node, new_node, shapes)` +* `stairsplus.api.register_alias_group(old_node, new_node, group)` +* `stairsplus.api.register_alias_groups(old_node, new_node, groups)` + +* `stairsplus.api.register_alias_force_single(old_node, new_node, shape)` + `alias_force` implies that the shapes for the "old_node" already exist, so after aliasing them, + we remove them from internal data structures. +* `stairsplus.api.register_alias_force_all(old_node, new_node)` +* `stairsplus.api.register_alias_force_shapes(old_node, new_node, shape)` +* `stairsplus.api.register_alias_force_group(old_node, new_node, group)` +* `stairsplus.api.register_alias_force_groups(old_node, new_node, groups)` + +## Group API + +Specify how to handle a node's groups when creating a shaped variant. By default, a node's +groups have their name transformed in the same way that the node's name is, e.g. `"wood"` will become e.g. +`"micro_wood_8"`, so that the shaped nodes can't be used in crafting recipes that call for `"group:wood"`. + +* `stairsplus.api.register_passthrough_group(group)` + Mark a group as "passthrough", i.e. it will not be transformed when assigned to a shaped node. + This is necessary to e.g. allow nodes to dig-able (e.g. groups like `"cracky"`, `"oddly_breakable_by_hand"`). + +* `stairsplus.api.register_passthrough_groups(groups)` + Marks a list of groups as passthrough. + +* `stairsplus.api.register_scaling_group(group)` + Like "passthrough", but this scales the group's *value* depending on the # of "eighths" that the shape + is worth. This is useful for groups like `"fall_damage_add_percent"` and `"slippery"`. + +* `stairsplus.api.register_scaling_groups(groups)` + Marks a list of groups as scaling. + +* `stairsplus.api.register_ignore_group(group)` + Marks a group as something we should just ignore entirely when creating a shaped node. Useful + for things like `"connect_to_raillike"` or `"attached_node"`, which don't makde sense for a shaped + node. + +* `stairsplus.api.register_ignore_groups(groups)` + Marks a list of groups to ignore. + +* `stairsplus.api.build_groups(node, shape)` + Given a node and a shape, return the groups to assign to a shaped node. + +## Legacy API + +These are methods that support legacy behavior which can optionally be disabled. + +* `stairsplus.api.on_place(itemstack, placer, pointed_thing)` + Handle placing a node. The legacy behavior is to try to rotate the node based on a number of + obscure factors. It can be useful sometimes, but confusing other times. + +* `stairsplus.api.scale_light(light_source, shape_def)` + How much light should a shaped glowing node emit? The legacy behavior was to drop the value by `1`. + The non-legacy behavior scales it down more, based on the number of eighths used in the shape. + +## Crafting API + +A powerful new API for registering crafting recipes involving shaped nodes. + +* `stairsplus.api.register_on_register_craft_schema(func)` + A callback for when a schema is registered. Useful for integrating inventory managers. + +* `stairsplus.api.register_craft_schema(schema)` + Register a crafting schema, which is like a normal crafting recipe, but it may have bare "shapes" in the + recipe/output. For every node w/ the variants in the recipe, a variant involving those shaped nodes + will be created (when all mods are loaded, so you don't have to worry about the order in which things + are defined). + ```lua + stairsplus.api.register_craft_schema({ + output = "panel_8 6", + recipe = {{"node", "node", "node"}}, + }) + + stairsplus.api.register_craft_schema({ + type = "shapeless", + output = "micro_8 7", + recipe = {"stair_inner"}, + }) + ``` + +* `stairsplus.api.register_schema_crafts_for_node(node)` + Creates real recipes for all schemas using available variants of the given node. Called automatically after all + mods are loaded for every node which has shaped nodes. Currently only supports "shaped" and "shapeless" recipe + types (these don't make much sense for cooking/fuel). Given the schemas above, if called for `"default:stone"`, + this would result in the following: + ```lua + minetest.register_craft({ + output = "default:panel_stone_8 6", + recipe = {{"default:stone", "default:stone", "default:stone"}}, + }) + + minetest.register_craft({ + type = "shapeless", + output = "default:micro_stone_8 7", + recipe = {"default:stair_stone_inner"}, + }) + ``` + +* `stairsplus.api.register_crafts_for_shapes(recipe)` + For "cooking" and "fuel" recipe types, register scaled variants for all *currently defined* + shaped variants. It is an error to try to register a cooking recipe for nodes with mis-matched shapes. + ```lua + stairsplus.api.register_crafts_for_shapes({ + type = "cooking", + output = "default:stone", + recipe = "default:cobblestone", + cooktime = 3, + }) + + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:coalblock", + burntime = 370, + }) + ``` + which would result in concrete recipes like + ```lua + minetest.register_craft({ + type = "cooking", + output = "default:panel_stone_8", + recipe = "default:panel_cobblestone_8", + cooktime = 0.75, + }) + + minetest.register_craft({ + type = "fuel", + recipe = "default:panel_coalblock_8", + burntime = 92.5, + }) + ``` + +## Station API + +For the creation of crafting stations which can be used to transform nodes into shaped variants, and back. + +* `stairsplus.api.register_station(name, def)` + * `name`: an itemstring + * `def`: a regular node definition, with the following parameters: + * `shape_groups`: a list of shape groups that can be created with the station (required). + * `build_formspec = function(meta, inv)` + A function which will build the formspec for the node (not required, but you probably want to use it). + * `update_metadata = function(meta, inv)` + A function which updates the node's metadata (optional) + +## Compat API + +For compatability w/ other mods + +* `function stairsplus.compat.override_stairs(name, node, overrides, meta)` + Override stairs registered w/ the `stairs` mod, and replace them w/ stairsplus-compatible nodes. + +# Legacy API + +Methods from the previous "moreblocks" version of stairsplus which are still provided so as not to break +compatability with older mods. + +* `stairsplus:register_all(modname, subname, recipeitem, fields)` + Example: + ```lua + stairsplus:register_all("moreblocks", "wood", "default:wood", { + description = "Wooden", + tiles = {"default_wood.png"}, + groups = {oddly_breakabe_by_hand=1}, + sounds = moreblocks.node_sound_wood_defaults(), + }) + ``` * `stairsplus:register_micro(modname, subname, recipeitem, fields)` +* `stairsplus:register_panel(modname, subname, recipeitem, fields)` +* `stairsplus:register_slab(modname, subname, recipeitem, fields)` * `stairsplus:register_slope(modname, subname, recipeitem, fields)` +* `stairsplus:register_stair(modname, subname, recipeitem, fields)` +* `stairsplus:register_custom_subset(subset, modname, subname, recipeitem, fields)` -If you only want to register a subset of stairsplus nodes, -you can use the `stairsplus:register_custom_subset(subset, modname, subname, recipeitem, fields)` function. -The subset table should have the following format: - -```lua - local subset = { - { "micro", "" }, - { "micro", "_1" }, - { "micro", "_2" }, - { "micro", "_4" }, - { "micro", "_12" }, - { "micro", "_14" }, - { "micro", "_15" }, - { "panel", "" }, - { "panel", "_1" }, - { "panel", "_2" }, - { "panel", "_4" }, - { "panel", "_12" }, - { "panel", "_14" }, - { "panel", "_15" }, - { "slab", "" }, - { "slab", "_quarter" }, - { "slab", "_three_quarter" }, - { "slab", "_1" }, - { "slab", "_2" }, - { "slab", "_14" }, - { "slab", "_15" }, - { "slab", "_two_sides" }, - { "slab", "_three_sides" }, - { "slab", "_three_sides_u" }, - { "slope", "" }, - { "slope", "_half" }, - { "slope", "_half_raised" }, - { "slope", "_inner" }, - { "slope", "_inner_half" }, - { "slope", "_inner_half_raised" }, - { "slope", "_inner_cut" }, - { "slope", "_inner_cut_half" }, - { "slope", "_inner_cut_half_raised" }, - { "slope", "_outer" }, - { "slope", "_outer_half" }, - { "slope", "_outer_half_raised" }, - { "slope", "_outer_cut" }, - { "slope", "_outer_cut_half" }, - { "slope", "_outer_cut_half_raised" }, - { "slope", "_cut" }, - { "stair", "" }, - { "stair", "_half" }, - { "stair", "_right_half" }, - { "stair", "_inner" }, - { "stair", "_outer" }, - { "stair", "_alt" }, - { "stair", "_alt_1" }, - { "stair", "_alt_2" }, - { "stair", "_alt_4" }, - } -``` -You can remove entries as needed. +* `stairsplus:register_alias_all(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_micro(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_panel(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_slab(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_slope(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_stair(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_custom_subset_alias(subset, modname_old, subname_old, modname_new, subname_new)` + +* `stairsplus:register_alias_force_all(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_force_micro(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_force_panel(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_force_slab(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_force_slope(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_alias_force_stair(modname_old, subname_old, modname_new, subname_new)` +* `stairsplus:register_custom_subset_alias(subset, modname_old, subname_old, modname_new, subname_new)` diff --git a/stairsplus/aliases.lua b/stairsplus/aliases.lua new file mode 100644 index 00000000..e31f4da7 --- /dev/null +++ b/stairsplus/aliases.lua @@ -0,0 +1,2 @@ +minetest.register_alias("circular_saw", "stairsplus:circular_saw") +minetest.register_alias("moreblocks:circular_saw", "stairsplus:circular_saw") diff --git a/stairsplus/api/alias.lua b/stairsplus/api/alias.lua new file mode 100644 index 00000000..81ec9f13 --- /dev/null +++ b/stairsplus/api/alias.lua @@ -0,0 +1,104 @@ +local api = stairsplus.api + +local table_is_empty = stairsplus.util.table_is_empty + +function api.register_alias_shape(old_node, new_node, shape) + local old_shaped_node = api.format_name(old_node, shape) + local new_shaped_node = api.format_name(new_node, shape) + + minetest.register_alias(old_shaped_node, new_shaped_node) + + local shape_def = api.registered_shapes[shape] + if shape_def.aliases then + local old_mod, old_name = old_node:match("^([^:]+):(.*)$") + for _, alias in ipairs(shape_def.aliases) do + old_shaped_node = ("%s:%s"):format(old_mod, alias:format(old_name)) + minetest.register_alias(old_shaped_node, new_shaped_node) + end + end +end + +function api.register_alias_all(old_node, new_node) + for shape in pairs(api.registered_shapes) do + api.register_alias_shape(old_node, new_node, shape) + end +end + +function api.register_alias_shapes(old_node, new_node, shapes) + for _, shape in ipairs(shapes) do + api.register_alias_shape(old_node, new_node, shape) + end +end + +function api.register_alias_group(old_node, new_node, group) + for _, shape in ipairs(api.shapes_by_group[group] or {}) do + api.register_alias_shape(old_node, new_node, shape) + end +end + +function api.register_alias_groups(old_node, new_node, groups) + for _, group in ipairs(groups) do + api.register_alias_group(old_node, new_node, group) + end +end + +function api.register_alias_force_shape(old_node, new_node, shape) + local old_shaped_node = api.format_name(old_node, shape) + local new_shaped_node = api.format_name(new_node, shape) + + minetest.register_alias_force(old_shaped_node, new_shaped_node) + + local shape_def = api.registered_shapes[shape] + if shape_def.aliases then + local old_mod, old_name = old_node:match("^([^:]+):(.*)$") + for _, alias in ipairs(shape_def.aliases) do + old_shaped_node = ("%s:%s"):format(old_mod, alias:format(old_name)) + minetest.register_alias_force(old_shaped_node, new_shaped_node) + end + end + + local nodes = api.nodes_by_shape[shape] or {} + if nodes[old_node] then + nodes[old_node] = nil + nodes[new_node] = true + api.nodes_by_shape[shape] = nodes + end + + local old_shapes = api.shapes_by_node[old_node] or {} + if old_shapes[shape] then + old_shapes[shape] = nil + if table_is_empty(old_shapes) then + api.shapes_by_node[old_node] = nil + else + api.shapes_by_node[old_node] = old_shapes + end + + local new_shapes = api.shapes_by_node[new_node] or {} + new_shapes[new_node] = true + api.shapes_by_node[new_node] = new_shapes + end +end + +function api.register_alias_force_all(old_node, new_node) + for shape in pairs(api.registered_shapes) do + api.register_alias_force_shape(old_node, new_node, shape) + end +end + +function api.register_alias_force_shapes(old_node, new_node, shapes) + for _, shape in ipairs(shapes) do + api.register_alias_force_shape(old_node, new_node, shape) + end +end + +function api.register_alias_force_group(old_node, new_node, group) + for _, shape in ipairs(api.shapes_by_group[group] or {}) do + api.register_alias_force_shape(old_node, new_node, shape) + end +end + +function api.register_alias_force_groups(old_node, new_node, groups) + for _, group in ipairs(groups) do + api.register_alias_force_group(old_node, new_node, group) + end +end diff --git a/stairsplus/api/group_filters.lua b/stairsplus/api/group_filters.lua new file mode 100644 index 00000000..a765d599 --- /dev/null +++ b/stairsplus/api/group_filters.lua @@ -0,0 +1,64 @@ +local api = stairsplus.api + +local in_creative_inventory = stairsplus.settings.in_creative_inventory +local in_craft_guide = stairsplus.settings.in_craft_guide + +api.passthrough_groups = {} +api.scaling_groups = {} +api.ignore_groups = {} + +function api.register_passthrough_group(group) + api.passthrough_groups[group] = true +end + +function api.register_passthrough_groups(groups) + for _, group in ipairs(groups) do + api.register_passthrough_group(group) + end +end + +function api.register_scaling_group(group) + api.scaling_groups[group] = true +end + +function api.register_scaling_groups(groups) + for _, group in ipairs(groups) do + api.register_scaling_group(group) + end +end + +function api.register_ignore_group(group) + api.ignore_groups[group] = true +end + +function api.register_ignore_groups(groups) + for _, group in ipairs(groups) do + api.register_ignore_group(group) + end +end + +function api.build_groups(node, shape) + local node_def = minetest.registered_nodes[node] + + local groups = { + [("shape_%s"):format(shape)] = 1, + not_in_creative_inventory = (not in_creative_inventory) and 1 or nil, + not_in_craft_guide = (not in_craft_guide) and 1 or nil, + } + + local shape_def = api.registered_shapes[shape] + + for group, value in pairs(node_def.groups) do + if api.passthrough_groups[group] then + groups[group] = value + + elseif api.scaling_groups[group] then + groups[group] = (shape_def.eighths / 8) * value + + elseif not api.ignore_groups[group] then + groups[shape_def.name_format:format(group)] = value + end + end + + return groups +end diff --git a/stairsplus/api/init.lua b/stairsplus/api/init.lua new file mode 100644 index 00000000..2e0c528d --- /dev/null +++ b/stairsplus/api/init.lua @@ -0,0 +1,9 @@ +stairsplus.api = {} + +stairsplus.dofile("api", "legacy") +stairsplus.dofile("api", "shape") +stairsplus.dofile("api", "group_filters") +stairsplus.dofile("api", "node") +stairsplus.dofile("api", "alias") +stairsplus.dofile("api", "recipe") +stairsplus.dofile("api", "station") diff --git a/stairsplus/api/legacy.lua b/stairsplus/api/legacy.lua new file mode 100644 index 00000000..1e79fce2 --- /dev/null +++ b/stairsplus/api/legacy.lua @@ -0,0 +1,109 @@ +local api = stairsplus.api + +local legacy_mode = stairsplus.settings.legacy_mode +local legacy_place_mechanic = stairsplus.settings.legacy_place_mechanic + +if legacy_place_mechanic then + local wall_right_dirmap = {9, 18, 7, 12} + local wall_left_dirmap = {11, 16, 5, 14} + local ceil_dirmap = {20, 23, 22, 21} + + function api.on_place(itemstack, placer, pointed_thing) + if not minetest.is_player(placer) then + return minetest.item_place(itemstack, placer, pointed_thing) + end + + local controls = placer:get_player_control() + + local sneak = controls.sneak + local aux = controls.aux1 + + local shaped_node_name = itemstack:get_name() + local shape = api.get_shape_of_shaped_node(shaped_node_name) + + local under = pointed_thing.under + local under_node = minetest.get_node(under) + local under_shape = api.get_shape_of_shaped_node(under_node.name) + + local same_cat = shape == under_shape + + -- standard (floor) facedir, also used for sneak placement against the lower half of the wall + local p2 = placer and minetest.dir_to_facedir(placer:get_look_dir()) or 0 + + -- check which face and which quadrant we are interested in + -- this is used both to check if we're handling parallel placement in the same-category case, + -- and in general for sneak placement + local face_pos = minetest.pointed_thing_to_face_pos(placer, pointed_thing) + local face_off = vector.subtract(face_pos, under) + + -- we cannot trust face_off to tell us the correct directionif the + -- under node has a non-standard shape, so use the distance between under and above + local wallmounted = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.above, under)) + + if same_cat and not aux then + p2 = under_node.param2 + -- flip if placing above or below an upright or upside-down node + -- TODO should we also flip when placing next to a side-mounted node? + if wallmounted < 2 then + if p2 < 4 then + p2 = (p2 + 2) % 4 + p2 = ceil_dirmap[p2 + 1] + elseif p2 > 19 then + p2 = ceil_dirmap[p2 - 19] - 20 + p2 = (p2 + 2) % 4 + end + end + else + -- for same-cat placement, aux is used to disable param2 copying + if same_cat then + aux = not aux + end + + local remap + + -- standard placement against the wall + local use_wallmap = (wallmounted > 1 and not sneak) or (wallmounted < 2 and sneak) + + -- standard placement against the ceiling, or sneak placement against the upper half of the wall + local use_ceilmap = wallmounted == 1 and not sneak + use_ceilmap = use_ceilmap or (wallmounted > 1 and sneak and face_off.y > 0) + + if use_wallmap then + local left = (p2 == 0 and face_off.x < 0) or + (p2 == 1 and face_off.z > 0) or + (p2 == 2 and face_off.x > 0) or + (p2 == 3 and face_off.z < 0) + if aux then + left = not left + end + remap = left and wall_left_dirmap or wall_right_dirmap + elseif use_ceilmap then + remap = ceil_dirmap + end + + if aux then + p2 = (p2 + 2) % 4 + end + + if remap then + p2 = remap[p2 + 1] + end + end + + return minetest.item_place(itemstack, placer, pointed_thing, p2) + end + +else + api.on_place = minetest.item_place +end + +function api.scale_light(light_source, shape_def) + if not light_source or light_source == 0 then + return 0 + + elseif legacy_mode then + return light_source - 1 + end + + return math.max(1, math.min(math.round(light_source * shape_def.eighths / 4), light_source)) +end diff --git a/stairsplus/api/node.lua b/stairsplus/api/node.lua new file mode 100644 index 00000000..e942b02a --- /dev/null +++ b/stairsplus/api/node.lua @@ -0,0 +1,330 @@ +-- for registering variants of a specific node +local api = stairsplus.api + +local table_set_all = stairsplus.util.table_set_all +local table_sort_keys = stairsplus.util.table_sort_keys + +local S = stairsplus.S + +local default_align_style = stairsplus.settings.default_align_style + +api.nodes_by_shape = {} +api.shapes_by_node = {} + +api.node_by_shaped_node = {} +api.shape_by_shaped_node = {} + +api.registered_singles = {} +api.registered_on_register_singles = {} + +function api.register_on_register_single(func) + table.insert(api.registered_on_register_singles, func) +end + +local function check_node_validity(node_def, meta) + local type_ = node_def.type + if not meta.ignore_type and type_ ~= "node" then + error(("cannot register non-node %q w/ stairsplus"):format(node_def.name)) + end + + local drawtype = node_def.drawtype + if not meta.ignore_drawtype and ( + drawtype == "airlike" or + drawtype == "liquid" or + drawtype == "flowingliquid" or + drawtype == "torchlike" or + drawtype == "signlike" or + drawtype == "plantlike" or + drawtype == "firelike" or + drawtype == "fencelike" or + drawtype == "raillike" or + drawtype == "nodebox" or + drawtype == "mesh" or + drawtype == "plantlike_rooted" + ) then + error(("cannot register %q w/ drawtype %q w/ stairsplus"):format(node_def.name, drawtype)) + end + + local paramtype2 = node_def.paramtype2 + if not meta.ignore_paramtype2 and ( + paramtype2 == "flowingliquid" or + paramtype2 == "wallmounted" or + paramtype2 == "leveled" or + paramtype2 == "degrotate" or + paramtype2 == "meshoptions" or + paramtype2 == "color" or + paramtype2 == "colorwallmounted" or + paramtype2 == "glasslikeliquidlevel" or + paramtype2 == "colordegrotate" + ) then + error(("cannot register %q w/ paramtype2 %q w/ stairsplus"):format(node_def.name, paramtype2)) + end +end + +function api.format_name(node, shape) + local mod, name = node:match("^([^:]+):(.*)$") + local shape_def = api.registered_shapes[shape] + return ("%s:%s"):format(mod, shape_def.name_format:format(name)) +end + +function api.register_single(node, shape, overrides, meta) + if not minetest.registered_nodes[node] then + error(("node %q is not defined"):format(node)) + end + + if shape ~= "micro_8" and not (api.nodes_by_shape.micro_8 or {})[node] then + -- always make sure a microblock exists + api.register_single(node, "micro_8", overrides, meta) + end + + local shaped_name = api.format_name(node, shape) + + stairsplus.log("info", "registering %s", shaped_name) + + meta = meta or {} + overrides = table.copy(overrides or {}) + + local node_def = table.copy(minetest.registered_nodes[node]) + + check_node_validity(node_def, meta) + + if (api.nodes_by_shape[shape] or {})[node] then + return -- already registered + end + + local shape_def = api.registered_shapes[shape] + + local paramtype2 + if node_def.paramtype2 == "colorfacedir" then + paramtype2 = "colorfacedir" + else + paramtype2 = shape_def.paramtype2 or "facedir" + end + + -- shaped_node definition + local def = { + description = S(shape_def.description, node_def.description or node), + + drawtype = shape_def.drawtype, + mesh = shape_def.mesh, + node_box = shape_def.node_box, + collision_box = shape_def.collision_box, + selection_box = shape_def.selection_box, + paramtype = shape_def.paramtype or "light", + paramtype2 = paramtype2, + + light_source = api.scale_light(node_def.light_source, shape_def), + groups = api.build_groups(node, shape), + + tiles = node_def.tiles, + overlay_tiles = node_def.overlay_tiles, + use_texture_alpha = node_def.use_texture_alpha, + color = node_def.color, + palette = node_def.palette, -- for coloredfacedir + stack_max = node_def.stack_max, + sounds = node_def.sounds, + is_ground_content = node_def.is_ground_content, + walkable = node_def.walkable, + pointable = node_def.pointable, + diggable = node_def.diggable, + climbable = node_def.climbable, + move_resistance = node_def.move_resistance, + + on_place = function(...) return api.on_place(...) end, + } + + -- see-through nodes tend to look better if we just use the first tile + if (node_def.drawtype or ""):match("glass") then + if #def.tiles > 1 then + def.tiles = {def.tiles[1]} + end + + if def.overlay_tiles and #def.overlay_tiles > 1 then + def.overlay_tiles = {def.overlay_tiles[1]} + end + end + + if node_def.short_description then + def.short_description = S(shape_def.description, node_def.short_description) + end + + -- if there's a drop defined, and we can drop a shaped version, do so + if meta.legacy_drop then + if type(meta.legacy_drop) == "string" then + local item = api.get_schema_recipe_item(meta.legacy_drop, shape) + if item then + def.drop = item + end + end + + elseif node_def.drop and type(node_def.drop) == "string" then + local item = api.get_schema_recipe_item(node_def.drop, shape) + if item then + def.drop = item + end + end + + if not meta.allow_override_groups and overrides.groups then + stairsplus.log("warning", "removing group overrides from %s (was %s, will be %s)", + shaped_name, minetest.write_json(overrides.groups), minetest.write_json(def.groups) + ) + overrides.groups = nil + end + + if not meta.allow_override_drawtype and overrides.drawtype then + stairsplus.log("warning", "removing drawtype override %s from %s", overrides.drawtype, shaped_name) + overrides.drawtype = nil + end + + if not meta.allow_override_paramtype2 and overrides.paramtype2 then + stairsplus.log("warning", "removing paramtype2 override %s from %s", overrides.paramtype2, shaped_name) + overrides.paramtype2 = nil + end + + table_set_all(def, overrides) + + -- set backface_culling and align_style + local align_style = meta.align_style or default_align_style + for i, tile in ipairs(def.tiles) do + if type(tile) == "string" then + def.tiles[i] = { + name = tile, + backface_culling = true, + align_style = align_style, + } + elseif not (tile.animation or tile.color) then + tile.backface_culling = true + tile.align_style = align_style + end + end + + if def.overlay_tiles then + for i, tile in ipairs(def.overlay_tiles) do + if type(tile) == "string" then + def.overlay_tiles[i] = { + name = tile, + backface_culling = true, + align_style = align_style, + } + elseif not (tile.animation or tile.color) then + tile.backface_culling = true + tile.align_style = align_style + end + def.overlay_tiles[i] = tile + end + end + + -- register node + minetest.register_node(":" .. shaped_name, def) + + -- alias old name formats + if shape_def.aliases then + local mod, name = node:match("^([^:]+):(.*)$") + for _, alias in ipairs(shape_def.aliases) do + minetest.register_alias( + ("%s:%s"):format(mod, alias:format(name)), + shaped_name + ) + end + end + + local nodes = api.nodes_by_shape[shape] or {} + nodes[node] = true + api.nodes_by_shape[shape] = nodes + + local shapes = api.shapes_by_node[node] or {} + shapes[shape] = true + api.shapes_by_node[node] = shapes + + api.node_by_shaped_node[shaped_name] = node + api.shape_by_shaped_node[shaped_name] = shape + + api.node_by_shaped_node[node] = node + api.shape_by_shaped_node[node] = "node" + + table.insert(api.registered_singles, {node, shaped_name}) + + for _, func in ipairs(api.registered_on_register_singles) do + func(node, shaped_name) + end + + return shaped_name +end + +function api.register_all(node, overrides, meta) + for shape in pairs(api.registered_shapes) do + api.register_single(node, shape, overrides, meta) + end +end + +function api.register_singles(node, shapes, overrides, meta) + for _, shape in ipairs(shapes) do + api.register_single(node, shape, overrides, meta) + end +end + +function api.register_group(node, shape_group, overrides, meta) + for _, shape in ipairs(api.shapes_by_group[shape_group] or {}) do + api.register_single(node, shape, overrides, meta) + end +end + +function api.register_groups(node, shape_groups, overrides, meta) + for _, group in ipairs(shape_groups) do + api.register_group(node, group, overrides, meta) + end +end + +function api.get_shapes(node) + if api.shapes_by_node[node] then + return table_sort_keys(api.shapes_by_node[node]) + end +end + +-- warning: don't mutate the return value +function api.get_shapes_hash(node) + return api.shapes_by_node[node] +end + +-- turn a recipe item into a shape if possible +function api.get_schema_recipe_item(node, shape_or_item) + if shape_or_item == "" then + return "" + end + + local name, count = shape_or_item:match("^([^ ]+) (%d+)") + + if not name then + name = shape_or_item + end + + count = tonumber(count) + + if api.registered_shapes[name] then + name = api.format_name(node, name) + + elseif name == "node" then + name = node + + elseif not name:match(":") then + return + end + + if count then + return ("%s %s"):format(name, count) + else + return name + end +end + +function api.get_micronode(node) + return api.get_schema_recipe_item(node, "micro_8") +end + +function api.get_node_of_shaped_node(shaped_node) + return api.node_by_shaped_node[shaped_node] +end + +function api.get_shape_of_shaped_node(shaped_node) + return api.shape_by_shaped_node[shaped_node] +end diff --git a/stairsplus/api/recipe.lua b/stairsplus/api/recipe.lua new file mode 100644 index 00000000..48003ecd --- /dev/null +++ b/stairsplus/api/recipe.lua @@ -0,0 +1,261 @@ +-- for registering recipe schemas +local api = stairsplus.api + +api.registered_recipe_schemas = {} +api.registered_on_register_craft_schemas = {} + +local registered_schemas_by_node = {} + +local function is_valid_output(item, shapes) + local item_name = item:match("^([^ ]+)") + + return item_name and (shapes[item_name] or item_name == "node" or item_name:match(":")) +end + +local function is_valid_item(item, shapes) + return is_valid_output(item, shapes) or item == "" +end + +local function verify_schema(schema) + local problems = {} + + if not (schema.type == "shaped" or schema.type == "shapeless" or schema.type == nil) then + table.insert(problems, ("unimplemented schema type %q"):format(schema.type)) + end + + if not is_valid_output(schema.output, api.registered_shapes) then + table.insert(problems, ("don't know how to handle output %q"):format(schema.output)) + end + + if schema.replacements then + for _, replacement in ipairs(schema.replacements) do + for _, item in ipairs(replacement) do + if not is_valid_item(item, api.registered_shapes) then + table.insert(problems, ("don't know how to handle replacement item %q"):format(item)) + end + end + end + end + + if schema.type == "shapeless" then + for _, item in ipairs(schema.recipe) do + if not is_valid_item(item, api.registered_shapes) then + table.insert(problems, ("don't know how to handle craft item %q"):format(item)) + end + end + + else + for _, row in ipairs(schema.recipe) do + for _, item in ipairs(row) do + if not is_valid_item(item, api.registered_shapes) then + table.insert(problems, ("don't know how to handle craft item %q"):format(item)) + end + end + end + end + + if #problems > 0 then + return table.concat(problems, ", ") + end +end + +local function has_the_right_shapes(schema, shapes) + if not is_valid_output(schema.output, shapes) then + return false + end + + if schema.replacements then + for _, replacement in ipairs(schema.replacements) do + for _, item in ipairs(replacement) do + if not is_valid_item(item, shapes) then + return false + end + end + end + end + + if schema.type == "shapeless" then + for _, item in ipairs(schema.recipe) do + if not is_valid_item(item, shapes) then + return false + end + end + + elseif schema.type == "shaped" or schema.type == nil then + for _, row in ipairs(schema.recipe) do + for _, item in ipairs(row) do + if not is_valid_item(item, shapes) then + return false + end + end + end + end + + return true +end + +local function register_for_schema(node, schema) + stairsplus.log("verbose", "using schema %s w/ node %s", minetest.write_json(schema), node) + + local recipe = table.copy(schema) + + recipe.output = api.get_schema_recipe_item(node, recipe.output) + + if recipe.replacements then + for _, replacement in ipairs(recipe.replacements) do + for i, item in ipairs(replacement) do + replacement[i] = api.get_schema_recipe_item(node, item) + end + end + end + + if recipe.type == "shapeless" then + for i, item in ipairs(recipe.recipe) do + recipe.recipe[i] = api.get_schema_recipe_item(node, item) + end + + elseif recipe.type == "shaped" or recipe.type == nil then + for _, row in ipairs(recipe.recipe) do + for i, item in ipairs(row) do + row[i] = api.get_schema_recipe_item(node, item) + end + end + end + + stairsplus.log("info", "registering recipe %s", minetest.write_json(recipe)) + + minetest.register_craft(recipe) +end + +function api.register_on_register_craft_schema(func) + table.insert(api.registered_on_register_craft_schemas, func) +end + +function api.register_craft_schema(schema) + local problems = verify_schema(schema) + + if problems then + error(problems) + end + + stairsplus.log("info", "registering craft schema %s", minetest.write_json(schema)) + + table.insert(api.registered_recipe_schemas, schema) + + for node, shapes in pairs(api.shapes_by_node) do + local registered_schemas = registered_schemas_by_node[node] or {} + + if has_the_right_shapes(schema, shapes) and not registered_schemas[schema] then + register_for_schema(node, schema) + registered_schemas[schema] = true + end + + registered_schemas_by_node[node] = registered_schemas + end + + for _, func in ipairs(api.registered_on_register_craft_schemas) do + func(schema) + end +end + +function api.register_schema_crafts_for_node(node) + local registered_schemas = registered_schemas_by_node[node] or {} + + local shapes = api.get_shapes_hash(node) + for _, schema in ipairs(api.registered_recipe_schemas) do + if has_the_right_shapes(schema, shapes) and not registered_schemas[schema] then + register_for_schema(node, schema) + registered_schemas[schema] = true + end + end + + registered_schemas_by_node[node] = registered_schemas +end + +api.register_on_register_single(api.register_schema_crafts_for_node) + +local function shapes_match(a, b) + local a_shapes = api.get_shapes(a) + local b_shapes = api.get_shapes(b) + + if #a_shapes ~= #b_shapes then + return false + end + + for i = 1, #a_shapes do + if a_shapes[i] ~= b_shapes[i] then + return false + end + end + + return true +end + +local function register_cooking_for_shapes(recipe) + local mod, name = recipe.recipe:match("^([^:]+):(.*)$") + + if mod ~= "group" and not shapes_match(recipe.output, recipe.recipe) then + error(("error: shapes of %s and %s do not match"):format(recipe.output, recipe.recipe)) + end + + local shapes = api.get_shapes(recipe.output) + + for _, shape in ipairs(shapes) do + local shape_def = api.registered_shapes[shape] + local input + if mod == "group" then + input = "group:" .. shape_def.name_format:format(name) + else + input = api.get_schema_recipe_item(recipe.recipe, shape) + end + + minetest.register_craft({ + type = "cooking", + output = api.get_schema_recipe_item(recipe.output, shape), + recipe = input, + cooktime = math.max(1.0, (recipe.cooktime or 3) * (shape_def.eighths / 8)), + }) + end +end + +local function register_fuel_for_shapes(recipe) + local mod, name = recipe.recipe:match("^([^:]+):(.*)$") + local shapes + if mod == "group" then + shapes = api.registered_shapes + else + shapes = api.get_shapes_hash(recipe.recipe) + end + + if not shapes then + error(("don't know how to handle fuel %s"):format(recipe.recipe)) + end + + for shape in pairs(shapes) do + local shape_def = api.registered_shapes[shape] + local input + if mod == "group" then + input = "group:" .. shape_def.name_format:format(name) + else + input = api.get_schema_recipe_item(recipe.recipe, shape) + end + + minetest.register_craft({ + type = "fuel", + recipe = input, + burntime = math.max(1.0, (recipe.burntime or 1) * (shape_def.eighths / 8)), + }) + end +end + +function api.register_crafts_for_shapes(recipe) + if recipe.type == "cooking" then + register_cooking_for_shapes(recipe) + + elseif recipe.type == "fuel" then + register_fuel_for_shapes(recipe) + + else + error(("unsupported recipe type %s"):format(recipe.type)) + end +end diff --git a/stairsplus/api/shape.lua b/stairsplus/api/shape.lua new file mode 100644 index 00000000..29393fe0 --- /dev/null +++ b/stairsplus/api/shape.lua @@ -0,0 +1,32 @@ +local api = stairsplus.api + +api.registered_on_register_shapes = {} +api.registered_shapes = {} +api.shapes_by_group = {} + +function api.register_on_register_shape(func) + table.insert(api.registered_on_register_shapes, func) +end + +function api.register_shape(name, def) + stairsplus.log("info", "registering shape %q", name) + def.shape_groups = def.shape_groups or {} + api.registered_shapes[name] = def + + for group in pairs(def.shape_groups) do + local shapes = api.shapes_by_group[group] or {} + table.insert(shapes, name) + api.shapes_by_group[group] = shapes + end + + for _, func in ipairs(api.registered_on_register_shapes) do + func(name, def) + end +end + +function api.register_shape_group(shape_group, shapes) + for _, shape in ipairs(shapes) do + api.registered_shapes[shape].shape_groups[shape_group] = 1 + end + api.shapes_by_group[shape_group] = shapes +end diff --git a/stairsplus/api/station.lua b/stairsplus/api/station.lua new file mode 100644 index 00000000..1ac08816 --- /dev/null +++ b/stairsplus/api/station.lua @@ -0,0 +1,360 @@ +-- for creating the circular saw and similar nodes + +local api = stairsplus.api + +local has_metadata = stairsplus.util.has_metadata +local resolve_aliases = stairsplus.util.resolve_aliases + +local default_stack_max = tonumber(minetest.settings:get("default_stack_max")) or 99 + +local station = {} + +function station.get_cost(shaped_node) + if shaped_node == "" then + return 0 + end + + local shape = api.get_shape_of_shaped_node(shaped_node) + if shape == "node" then + return 8 + end + + local shape_def = api.registered_shapes[shape] + return shape_def and shape_def.eighths +end + +function station.get_current_node(inv) + local input_stack = inv:get_stack("stairsplus:input", 1) + if not input_stack:is_empty() then + return api.get_node_of_shaped_node(input_stack:get_name()) + end + + local micro_stack = inv:get_stack("stairsplus:micro", 1) + if not micro_stack:is_empty() then + return api.get_node_of_shaped_node(micro_stack:get_name()) + end + + local recycle_stack = inv:get_stack("stairsplus:recycle", 1) + if not recycle_stack:is_empty() then + return api.get_node_of_shaped_node(recycle_stack:get_name()) + end +end + +function station.can_dig(meta, inv) + return inv:is_empty("stairsplus:input") and inv:is_empty("stairsplus:micro") +end + +function station.on_receive_fields(meta, inv, formname, fields, sender, build_formspec, update_metadata) + local max = tonumber(fields.max_offered) + if max and max > 0 then + meta:set_int("stairsplus:max_offered", max) + -- Update to show the correct number of items: + station.update_inventory(meta, inv) + if update_metadata then + update_metadata(meta, inv) + end + + if build_formspec then + meta:set_string("formspec", build_formspec(meta, inv)) + end + end + + return not not fields.max_offered +end + +local function fix_aliases(inv) + local input = inv:get_stack("stairsplus:input", 1) + input:set_name(resolve_aliases(input:get_name())) + inv:set_stack("stairsplus:input", 1, input) + + local micro = inv:get_stack("stairsplus:micro", 1) + micro:set_name(resolve_aliases(micro:get_name())) + inv:set_stack("stairsplus:micro", 1, micro) + + local recycle = inv:get_stack("stairsplus:recycle", 1) + recycle:set_name(resolve_aliases(recycle:get_name())) + inv:set_stack("stairsplus:recycle", 1, recycle) + + for i = 1, inv:get_size("stairsplus:output") do + local output = inv:get_stack("stairsplus:output", i) + output:set_name(resolve_aliases(output:get_name())) + inv:set_stack("stairsplus:output", i, output) + end +end + +function station.update_inventory(meta, inv, taken_stack) + fix_aliases(inv) + + local node = station.get_current_node(inv) + local valid_shapes = api.shapes_by_node[node] + + if not (node and valid_shapes) then + inv:set_stack("stairsplus:input", 1, ItemStack()) + inv:set_stack("stairsplus:micro", 1, ItemStack()) + inv:set_stack("stairsplus:recycle", 1, ItemStack()) + for i = 1, inv:get_size("stairsplus:output") do + inv:set_stack("stairsplus:output", i, ItemStack()) + end + return + end + + local input_stack = inv:get_stack("stairsplus:input", 1) + local micro_stack = inv:get_stack("stairsplus:micro", 1) + local recycle_stack = inv:get_stack("stairsplus:recycle", 1) + + local input_cost = station.get_cost(input_stack:get_name()) + local micro_cost = station.get_cost(micro_stack:get_name()) + local recycle_cost = station.get_cost(recycle_stack:get_name()) + + local total_value = ( + (input_stack:get_count() * input_cost) + + (micro_stack:get_count() * micro_cost) + + (recycle_stack:get_count() * recycle_cost) + ) + + if taken_stack then + total_value = total_value - station.get_cost(taken_stack:get_name()) * taken_stack:get_count() + end + + local new_micros = total_value % 8 + local new_blocks = math.floor(total_value / 8) + + local micronode = api.get_micronode(node) + + inv:set_stack("stairsplus:input", 1, ItemStack({name = node, count = new_blocks})) + inv:set_stack("stairsplus:micro", 1, ItemStack({name = micronode, count = new_micros})) + inv:set_stack("stairsplus:recycle", 1, ItemStack()) + + if total_value == 0 then + for i = 1, inv:get_size("stairsplus:output") do + inv:set_stack("stairsplus:output", i, "") + end + return + end + + local max_offered = meta:get_int("stairsplus:max_offered") + local shape_groups = minetest.parse_json(meta:get_string("stairsplus:shape_groups")) + + local i = 1 + for _, group in ipairs(shape_groups) do + for _, shape in ipairs(api.shapes_by_group[group]) do + if valid_shapes[shape] then + local shape_def = api.registered_shapes[shape] + local shaped_node = api.format_name(node, shape) + local stack_max = math.min(max_offered, ItemStack(shaped_node):get_stack_max()) + local count = math.min(stack_max, math.floor(total_value / shape_def.eighths)) + local stack + if count > 0 then + stack = ItemStack({name = shaped_node, count = count}) + else + stack = "" + end + inv:set_stack("stairsplus:output", i, stack) + i = i + 1 + end + end + end + + for j = i, inv:get_size("stairsplus:output") do + inv:set_stack("stairsplus:output", j, "") + end +end + +-- Moving the inventory of the station around is not allowed because it +-- is a fictional inventory. Moving inventory around would be rather +-- impractical and make things more difficult to calculate: +function station.allow_inventory_move(meta, inv, from_list, from_index, to_list, to_index, count, player) + return 0 +end + +function station.allow_inventory_put(meta, inv, listname, index, stack, player) + if listname == "stairsplus:output" then + return 0 + end + + if has_metadata(stack) then + return 0 + end + + local to_put_node = resolve_aliases(stack:get_name()) + local node = api.get_node_of_shaped_node(to_put_node) + local shape = api.get_shape_of_shaped_node(to_put_node) + + if not (node and shape) then + return 0 + end + + local current_node = station.get_current_node(inv) + + local input_stack = inv:get_stack("stairsplus:input", 1) + local micro_stack = inv:get_stack("stairsplus:micro", 1) + + if current_node and node ~= current_node then + if ( + (input_stack:is_empty() and listname == "stairsplus:micro") or + (micro_stack:is_empty() and listname == "stairsplus:input") + ) then + return stack:get_count() + else + return 0 + end + end + + local count = stack:get_count() + local cost = station.get_cost(to_put_node) + + local current_value = 8 * input_stack:get_count() + micro_stack:get_count() + local max_value = 8 * ItemStack(node):get_stack_max() + 7 + + local available_value = max_value - current_value + local available_count = math.floor(available_value / cost) + + return math.min(count, available_count) +end + +function station.on_inventory_put(meta, inv, listname, index, stack, player, update_metadata) + station.update_inventory(meta, inv) + if update_metadata then + update_metadata(meta, inv) + end +end + +function station.on_inventory_take(meta, inv, listname, index, stack, player, update_metadata) + if listname == "stairsplus:output" then + station.update_inventory(meta, inv, stack) + else + station.update_inventory(meta, inv) + end + + if update_metadata then + update_metadata(meta, inv) + end +end + +function station.initialize_metadata(meta, inv, shape_groups, build_formspec, update_metadata) + meta:set_string("stairsplus:shape_groups", minetest.write_json(shape_groups)) + + if meta:get_int("max_offered") ~= 0 then + meta:set_int("stairsplus:max_offered", meta:get_int("max_offered")) + + elseif meta:get_int("stairsplus:max_offered") == 0 then + meta:set_int("stairsplus:max_offered", default_stack_max) + end + + if build_formspec then + meta:set_string("formspec", build_formspec(meta, inv)) + end + + if update_metadata then + update_metadata(meta, inv) + end +end + +function station.initialize_inventory(inv, shape_groups) + local output_size = 0 + for _, group in ipairs(shape_groups) do + output_size = output_size + #api.shapes_by_group[group] + end + + inv:set_size("stairsplus:input", 1) + inv:set_size("stairsplus:micro", 1) + inv:set_size("stairsplus:recycle", 1) + inv:set_size("stairsplus:output", output_size) + + -- get rid of old lists + for _, listname in ipairs({"input", "micro", "recycle", "output"}) do + if inv:get_size(listname) > 0 then + inv:set_list(("stairsplus:%s"):format(listname), inv:get_list(listname)) + inv:set_size(listname, 0) + end + end +end + +function station.on_construct(pos, shape_groups, build_formspec, update_metadata) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + + station.initialize_inventory(inv, shape_groups) + station.initialize_metadata(meta, inv, shape_groups, build_formspec, update_metadata) + station.update_inventory(meta, inv) +end + +function station.after_place_node(pos, placer) + local meta = minetest.get_meta(pos) + if minetest.is_player(placer) then + meta:set_string("owner", placer:get_player_name()) + end +end + +function api.register_station(name, def) + local shape_groups = def.shape_groups + local build_formspec = def.build_formspec + local update_metadata = def.update_metadata + + if not shape_groups then + error("station requires shape_groups defined") + end + + def.shape_groups = nil + def.build_formspec = nil + def.update_metadata = nil + + def.after_place_node = def.after_place_node or station.after_place_node + def.on_construct = def.on_construct or + function(pos) + return station.on_construct(pos, shape_groups, build_formspec, update_metadata) + end + + def.can_dig = def.can_dig or + function(pos, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return station.can_dig(meta, inv, player) + end + + def.on_receive_fields = def.on_receive_fields or + function(pos, formname, fields, sender) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return station.on_receive_fields( + meta, inv, formname, fields, sender, build_formspec, update_metadata + ) + end + + def.allow_metadata_inventory_move = def.allow_metadata_inventory_move or + function(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return station.allow_inventory_move(meta, inv, from_list, from_index, to_list, to_index, count, player) + end + + def.allow_metadata_inventory_put = def.allow_metadata_inventory_put or + function(pos, listname, index, stack, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return station.allow_inventory_put(meta, inv, listname, index, stack, player) + end + + def.on_metadata_inventory_put = def.on_metadata_inventory_put or + function(pos, listname, index, stack, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return station.on_inventory_put(meta, inv, listname, index, stack, player, update_metadata) + end + + def.on_metadata_inventory_take = def.on_metadata_inventory_take or + function(pos, listname, index, stack, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return station.on_inventory_take(meta, inv, listname, index, stack, player, update_metadata) + end + + def._stairsplus_shape_groups = shape_groups + + def.groups = table.copy(def.groups or {}) + def.groups.stairsplus_station = 1 + + minetest.register_node(name, def) +end + +api.station = station diff --git a/stairsplus/circular_saw.lua b/stairsplus/circular_saw.lua new file mode 100644 index 00000000..167e9a39 --- /dev/null +++ b/stairsplus/circular_saw.lua @@ -0,0 +1,133 @@ +stairsplus.api.circular_saw = {} +local circular_saw = stairsplus.api.circular_saw +local api = stairsplus.api +local station = api.station + +local get_location_string = stairsplus.util.get_location_string + +local S = stairsplus.S +local F = minetest.formspec_escape + +local formspec_style = stairsplus.resources.formspec_style + + +function circular_saw.build_formspec(meta, inv) + local inv_location = get_location_string(inv) + return ([[ + size[10,11] + %s + label[0,0;] + label[0,0;%s] + list[%s;stairsplus:input;1.7,0;1,1;] + label[0,1;%s] + list[%s;stairsplus:micro;1.7,1;1,1;] + label[0,2;%s] + list[%s;stairsplus:recycle;1.7,2;1,1;] + field[0.3,3.5;1,1;max_offered;%s:;%i] + button[1,3.2;1.7,1;Set;%s] + + list[%s;stairsplus:output;2.8,0;7,7;] + list[current_player;main;1.5,7.25;8,4;] + + listring[%s;stairsplus:output] + listring[current_player;main] + listring[%s;stairsplus:recycle] + + listring[%s;stairsplus:micro] + listring[current_player;main] + + listring[%s;stairsplus:input] + listring[current_player;main] + ]]):format( + formspec_style, + F(S("Nodes")), + inv_location, + F(S("Microblocks")), + inv_location, + F(S("Input")), + inv_location, + F(S("Max")), + meta:get_int("stairsplus:max_offered"), + F(S("Set")), + inv_location, + inv_location, + inv_location, + inv_location, + inv_location + ) +end + +function circular_saw.update_metadata(meta, inv) + local parts = {S("Circular Saw")} + + local owner = meta:get_string("owner") + if owner ~= "" then + table.insert(parts, S("(owned by @1)", owner)) + end + + local working_on = station.get_current_node(inv) + if working_on then + local stack = ItemStack(working_on) + table.insert(parts, S("Working on @1", stack:get_short_description() or stack:get_description())) + else + table.insert(parts, S("Empty")) + end + + meta:set_string("infotext", table.concat(parts, " ")) +end + +api.register_station("stairsplus:circular_saw", { + description = S("Circular Saw"), + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.4, -0.5, -0.4, -0.25, 0.25, -0.25}, -- Leg + {0.25, -0.5, 0.25, 0.4, 0.25, 0.4}, -- Leg + {-0.4, -0.5, 0.25, -0.25, 0.25, 0.4}, -- Leg + {0.25, -0.5, -0.4, 0.4, 0.25, -0.25}, -- Leg + {-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- Tabletop + {-0.01, 0.4375, -0.125, 0.01, 0.5, 0.125}, -- Saw blade (top) + {-0.01, 0.375, -0.1875, 0.01, 0.4375, 0.1875}, -- Saw blade (bottom) + {-0.25, -0.0625, -0.25, 0.25, 0.25, 0.25}, -- Motor case + }, + }, + tiles = { + "stairsplus_circular_saw_top.png", + "stairsplus_circular_saw_bottom.png", + "stairsplus_circular_saw_side.png" + }, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2}, + sounds = stairsplus.resources.sounds.wood, + + shape_groups = {"legacy"}, + build_formspec = circular_saw.build_formspec, + update_metadata = circular_saw.update_metadata, +}) + +local cm = stairsplus.resources.craft_materials + +if stairsplus.settings.circular_saw_crafting and cm.steel_ingot then + minetest.register_craft({ + output = "stairsplus:circular_saw", + recipe = { + {"", cm.steel_ingot, ""}, + {"group:wood", "group:wood", "group:wood"}, + {"group:wood", "", "group:wood"}, + } + }) +end + +minetest.register_lbm({ + label = "Upgrade legacy saws", + name = "stairsplus:replace_legacy_saws", + nodenames = {"stairsplus:circular_saw"}, + run_at_every_load = false, + action = function(pos, node) + local def = minetest.registered_nodes[node.name] + def.on_construct(pos, {"legacy"}, circular_saw.build_formspec, circular_saw.update_metadata) + end, +}) diff --git a/stairsplus/common.lua b/stairsplus/common.lua deleted file mode 100644 index 6d09ab50..00000000 --- a/stairsplus/common.lua +++ /dev/null @@ -1,181 +0,0 @@ ---[[ -More Blocks: registrations - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - -local S = moreblocks.S - -local descriptions = { - ["micro"] = "Microblock", - ["slab"] = "Slab", - ["slope"] = "Slope", - ["panel"] = "Panel", - ["stair"] = "Stairs", -} - --- Extends the standad rotate_node placement so that it takes into account --- the side (top/bottom or left/right) of the face being pointed at. --- As with the standard rotate_node, sneak can be used to force the perpendicular --- placement (wall placement on floor/ceiling, floor/ceiling placement on walls). --- Additionally, the aux / sprint / special key can be used to place the node --- as if from the opposite side. --- --- When placing a node next to one of the same category (e.g. slab to slab or --- stair to stair), the default placement (regardless of sneak) is to copy the --- under node's param2, flipping if placed above or below it. The aux key disable --- this behavior. -local wall_right_dirmap = {9, 18, 7, 12} -local wall_left_dirmap = {11, 16, 5, 14} -local ceil_dirmap = {20, 23, 22, 21} - --- extract the stairsplus category from a node name --- assumes the name is in the form mod_name:category_original_ndoe_name -local function name_to_category(name) - local colon = name:find(":") or 0 - colon = colon + 1 - local under = name:find("_", colon) - return name:sub(colon, under) -end - -stairsplus.rotate_node_aux = function(itemstack, placer, pointed_thing) - local sneak = placer and placer:get_player_control().sneak - local aux = placer and placer:get_player_control().aux1 - - -- category for what we are placing - local item_prefix = name_to_category(itemstack:get_name()) - -- category for what we are placing against - local under = pointed_thing.under - local under_node = minetest.get_node(under) - local under_prefix = under_node and name_to_category(under_node.name) - - local same_cat = item_prefix == under_prefix - - -- standard (floor) facedir, also used for sneak placement against the lower half of the wall - local p2 = placer and minetest.dir_to_facedir(placer:get_look_dir()) or 0 - - -- check which face and which quadrant we are interested in - -- this is used both to check if we're handling parallel placement in the same-category case, - -- and in general for sneak placement - local face_pos = minetest.pointed_thing_to_face_pos(placer, pointed_thing) - local face_off = vector.subtract(face_pos, under) - - -- we cannot trust face_off to tell us the correct directionif the - -- under node has a non-standard shape, so use the distance between under and above - local wallmounted = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.above, under)) - - if same_cat and not aux then - p2 = under_node.param2 - -- flip if placing above or below an upright or upside-down node - -- TODO should we also flip when placing next to a side-mounted node? - if wallmounted < 2 then - if p2 < 4 then - p2 = (p2 + 2) % 4 - p2 = ceil_dirmap[p2 + 1] - elseif p2 > 19 then - p2 = ceil_dirmap[p2 - 19] - 20 - p2 = (p2 + 2) % 4 - end - end - else - -- for same-cat placement, aux is used to disable param2 copying - if same_cat then - aux = not aux - end - - local remap = nil - - -- standard placement against the wall - local use_wallmap = (wallmounted > 1 and not sneak) or (wallmounted < 2 and sneak) - - -- standard placement against the ceiling, or sneak placement against the upper half of the wall - local use_ceilmap = wallmounted == 1 and not sneak - use_ceilmap = use_ceilmap or (wallmounted > 1 and sneak and face_off.y > 0) - - if use_wallmap then - local left = (p2 == 0 and face_off.x < 0) or - (p2 == 1 and face_off.z > 0) or - (p2 == 2 and face_off.x > 0) or - (p2 == 3 and face_off.z < 0) - if aux then - left = not left - end - remap = left and wall_left_dirmap or wall_right_dirmap - elseif use_ceilmap then - remap = ceil_dirmap - end - - if aux then - p2 = (p2 + 2) % 4 - end - - if remap then - p2 = remap[p2 + 1] - end - end - - return minetest.item_place(itemstack, placer, pointed_thing, p2) -end - -stairsplus.register_single = function(category, alternate, info, modname, subname, recipeitem, fields) - - local src_def = minetest.registered_nodes[recipeitem] or {} - local desc_base = S("@1 "..descriptions[category], fields.description) - local def = {} - - if category ~= "slab" then - def = table.copy(info) - end - - -- copy fields to def - for k, v in pairs(fields) do - def[k] = v - end - - def.drawtype = "nodebox" - def.paramtype = "light" - def.paramtype2 = def.paramtype2 or "facedir" - if def.use_texture_alpha == nil then - def.use_texture_alpha = src_def.use_texture_alpha - end - - -- This makes node rotation work on placement - def.place_param2 = nil - - -- Darken light sources slightly to make up for their smaller visual size - def.light_source = math.max(0, (def.light_source or 0) - 1) - - def.on_place = stairsplus.rotate_node_aux - def.groups = stairsplus:prepare_groups(fields.groups) - - if category == "slab" then - if type(info) ~= "table" then - def.node_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, (info/16)-0.5, 0.5}, - } - def.description = ("%s (%d/16)"):format(desc_base, info) - else - def.node_box = { - type = "fixed", - fixed = info, - } - def.description = desc_base .. alternate:gsub("_", " "):gsub("(%a)(%S*)", function(a, b) return a:upper() .. b end) - end - else - def.description = desc_base - if category == "slope" then - def.drawtype = "mesh" - elseif category == "stair" and alternate == "" then - def.groups.stair = 1 - end - end - - if fields.drop and not (type(fields.drop) == "table") then - def.drop = modname.. ":" .. category .. "_" .. fields.drop .. alternate - end - - minetest.register_node(":" ..modname.. ":" .. category .. "_" .. subname .. alternate, def) - stairsplus.register_recipes(category, alternate, modname, subname, recipeitem) -end diff --git a/stairsplus/compat/i3.lua b/stairsplus/compat/i3.lua new file mode 100644 index 00000000..854d9ec5 --- /dev/null +++ b/stairsplus/compat/i3.lua @@ -0,0 +1,43 @@ +-- luacheck: globals i3 + +if not stairsplus.has.i3 then + return +end + +-- https://github.com/fluxionary/minetest-moreblocks/issues/13 +-- remove i3's assumption that it controls our compression groups +for node in pairs(i3.compress_groups) do + if node:match("^moreblocks:slope_") or node:match("^wool:slope_") then + i3.compress_groups[node] = nil + end +end + +local api = stairsplus.api + +i3.register_craft_type("stairsplus:circular_saw", { + description = "Stairs+ circular saw", + icon = "stairsplus_saw_button.png", +}) + +local function on_register_single(node, shaped_name) + i3.register_craft({ + type = "stairsplus:circular_saw", + result = shaped_name, + items = {node}, + }) + + local micronode = api.get_micronode(node) + if shaped_name ~= micronode then + local compress_groups = i3.compress_groups[micronode] or {} + table.insert(compress_groups, shaped_name) + i3.compress_groups[micronode] = compress_groups + i3.compressed[shaped_name] = true + end +end + +for _, single in ipairs(api.registered_singles) do + local node, shaped_name = unpack(single) + on_register_single(node, shaped_name) +end + +api.register_on_register_single(on_register_single) diff --git a/stairsplus/compat/init.lua b/stairsplus/compat/init.lua new file mode 100644 index 00000000..1ae668ac --- /dev/null +++ b/stairsplus/compat/init.lua @@ -0,0 +1,23 @@ +stairsplus.compat = { + is_legacy_drawtype = function(node) + local def = minetest.registered_nodes[node] + return ( + def.drawtype == "mesh" or + def.drawtype == "plantlike" or + def.drawtype == "nodebox" + ) + end, + is_legacy_paramtype2 = function(node) + local def = minetest.registered_nodes[node] + return ( + def.paramtype2 == "color" or + def.paramtype2 == "colorwallmounted" or + def.paramtype2 == "glasslikeliquidlevel" + ) + end, +} + +stairsplus.dofile("compat", "i3") +stairsplus.dofile("compat", "unified_inventory") + +stairsplus.dofile("compat", "old_moreblocks") diff --git a/stairsplus/compat/old_moreblocks.lua b/stairsplus/compat/old_moreblocks.lua new file mode 100644 index 00000000..10a69aac --- /dev/null +++ b/stairsplus/compat/old_moreblocks.lua @@ -0,0 +1,251 @@ +-- legacy: export old API for mods which depend on it +-- provide a configuration option to *disable* legacy. it must be enabled by default, to prevent breaking +-- existing servers +local api = stairsplus.api + +local is_legacy_drawtype = stairsplus.compat.is_legacy_drawtype +local is_legacy_paramtype2 = stairsplus.compat.is_legacy_paramtype2 + +local legacy_mode = stairsplus.settings.legacy_mode + +local function clean_legacy_fields(fields) + fields = fields or {} + + fields.drawtype = nil + fields.light_source = nil + fields.inventory_image = nil + fields.inventory_overlay = nil + fields.wield_image = nil + fields.wield_overlay = nil + fields.wield_scale = nil + fields.tool_capabilities = nil + fields.node_placement_prediction = nil + fields.node_dig_prediction = nil + fields.on_place = nil + fields.on_secondary_use = nil + fields.on_drop = nil + fields.on_use = nil + fields.after_use = nil + fields.paramtype2 = nil + fields.node_box = nil + fields.mesh = nil + fields.connects_to = nil + fields.connect_sides = nil + fields.selection_box = nil + fields.collision_box = nil + fields.legacy_facedir_simple = nil + fields.legacy_wallmounted = nil + fields.drop = nil + fields.on_construct = nil + fields.on_destruct = nil + fields.after_destruct = nil + fields.after_place_node = nil + fields.after_dig_node = nil + fields.can_dig = nil + fields.on_punch = nil + fields.on_rightclick = nil + fields.on_dig = nil + fields.on_timer = nil + fields.on_receive_fields = nil + + return fields +end + +local function handle_legacy_drop(modname, drop) + if not drop then + return + end + + if type(drop) == "table" then + return drop + else + return ("%s:%s"):format(modname, drop) + end +end + +local function register_group(modname, subname, recipeitem, fields, group) + if not minetest.registered_nodes[recipeitem] then + error(("cannot register stairs for %s before the node is defined"):format(recipeitem)) + end + + local meta = {} + + meta.legacy_drop = handle_legacy_drop(modname, fields.drop) + + if is_legacy_drawtype(recipeitem) then + meta.ignore_drawtype = true + end + + if is_legacy_paramtype2(recipeitem) then + meta.ignore_paramtype2 = true + end + + fields = clean_legacy_fields(fields) + + api.register_group(recipeitem, group, fields, meta) + + local old_name = ("%s:%s"):format(modname, subname) + if old_name ~= recipeitem then + api.register_alias_group(old_name, recipeitem, group) + end +end + +function stairsplus:register_all(modname, subname, recipeitem, fields) + if legacy_mode then + register_group(modname, subname, recipeitem, fields, "legacy") + else + register_group(modname, subname, recipeitem, fields, "common") + end +end + +function stairsplus:register_micro(modname, subname, recipeitem, fields) + register_group(modname, subname, recipeitem, fields, "micro") +end + +function stairsplus:register_panel(modname, subname, recipeitem, fields) + register_group(modname, subname, recipeitem, fields, "panel") +end + +function stairsplus:register_slab(modname, subname, recipeitem, fields) + register_group(modname, subname, recipeitem, fields, "slab") +end + +function stairsplus:register_slope(modname, subname, recipeitem, fields) + register_group(modname, subname, recipeitem, fields, "slope") +end + +function stairsplus:register_stair(modname, subname, recipeitem, fields) + register_group(modname, subname, recipeitem, fields, "stair") +end + +local fix_shape_table = { + micro = "micro_8", + panel = "panel_8", + slab = "slab_8", + slab_quarter = "slab_4", + slab_three_quarter = "slab_12", + stair_alt = "stair_alt_8", +} + +local function interpret_subset(subset) + local shapes = {} + for _, v in ipairs(subset) do + local shape = table.concat(v, "") + shape = fix_shape_table[shape] or shape + table.insert(shapes, shape) + end + return shapes +end + +function stairsplus:register_custom_subset(subset, modname, subname, recipeitem, fields) + local shapes = interpret_subset(subset) + + fields = clean_legacy_fields(fields) + local meta = {} + if is_legacy_drawtype(recipeitem) then + meta.ignore_drawtype = true + end + + api.register_singles(recipeitem, shapes, fields, meta) + + local old_name = ("%s:%s"):format(modname, subname) + if old_name ~= recipeitem then + api.register_alias_shapes(old_name, recipeitem, shapes) + end +end + +function stairsplus:register_alias_all(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + + if legacy_mode then + api.register_alias_group(old_node, new_node, "legacy") + else + api.register_alias_group(old_node, new_node, "common") + end +end + +function stairsplus:register_alias_micro(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_group(old_node, new_node, "micro") +end + +function stairsplus:register_alias_panel(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_group(old_node, new_node, "panel") +end + +function stairsplus:register_alias_slab(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_group(old_node, new_node, "slab") +end + +function stairsplus:register_alias_slope(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_group(old_node, new_node, "slope") +end + +function stairsplus:register_alias_stair(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_group(old_node, new_node, "stair") +end + +function stairsplus:register_custom_subset_alias(subset, modname_old, subname_old, modname_new, subname_new) + local shapes = interpret_subset(subset) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_shapes(old_node, new_node, shapes) +end + +function stairsplus:register_alias_force_all(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + + if legacy_mode then + api.register_alias_force_group(old_node, new_node, "legacy") + else + api.register_alias_force_group(old_node, new_node, "common") + end +end + +function stairsplus:register_alias_force_micro(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_force_group(old_node, new_node, "micro") +end + +function stairsplus:register_alias_force_panel(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_force_group(old_node, new_node, "panel") +end + +function stairsplus:register_alias_force_slab(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_force_group(old_node, new_node, "slab") +end + +function stairsplus:register_alias_force_slope(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_force_group(old_node, new_node, "slope") +end + +function stairsplus:register_alias_force_stair(modname_old, subname_old, modname_new, subname_new) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_force_group(old_node, new_node, "stair") +end + +function stairsplus:register_custom_subset_alias(subset, modname_old, subname_old, modname_new, subname_new) + local shapes = interpret_subset(subset) + local old_node = ("%s:%s"):format(modname_old, subname_old) + local new_node = ("%s:%s"):format(modname_new, subname_new) + api.register_alias_force_shapes(old_node, new_node, shapes) +end diff --git a/stairsplus/compat/unified_inventory.lua b/stairsplus/compat/unified_inventory.lua new file mode 100644 index 00000000..b38d2091 --- /dev/null +++ b/stairsplus/compat/unified_inventory.lua @@ -0,0 +1,48 @@ +-- luacheck: read globals unified_inventory + +if not stairsplus.has.unified_inventory then + return +end + +local api = stairsplus.api + +unified_inventory.register_craft_type("stairsplus:circular_saw", { + description = "Stairs+ circular saw", + icon = "stairsplus_saw_button.png", + width = 1, + height = 1, + uses_crafting_grid = false, +}) + +unified_inventory.register_category("stairsplus:cuttable", { + symbol = "stairsplus:circular_saw", + label = "Cuttable in the circular saw", + index = 0, + items = {} +}) + +unified_inventory.register_category("stairsplus:cut_node", { + symbol = "stairsplus:circular_saw", + label = "Nodes cut in the circular saw", + index = 0, + items = {} +}) + +local function on_register_single(node, shaped_name) + unified_inventory.register_craft({ + output = shaped_name, + type = "stairsplus:circular_saw", + items = {node}, + width = 1, + }) + + unified_inventory.add_category_item("stairsplus:cuttable", node) + unified_inventory.add_category_item("stairsplus:cut_node", shaped_name) +end + +for _, single in ipairs(api.registered_singles) do + local node, shaped_name = unpack(single) + on_register_single(node, shaped_name) +end + +api.register_on_register_single(on_register_single) diff --git a/stairsplus/craft_schemas/init.lua b/stairsplus/craft_schemas/init.lua new file mode 100644 index 00000000..f5a83d92 --- /dev/null +++ b/stairsplus/craft_schemas/init.lua @@ -0,0 +1,6 @@ + +stairsplus.dofile("craft_schemas", "micro_8_all") +stairsplus.dofile("craft_schemas", "other") +stairsplus.dofile("craft_schemas", "slopes") +stairsplus.dofile("craft_schemas", "stairs") +stairsplus.dofile("craft_schemas", "standard_composition") diff --git a/stairsplus/craft_schemas/micro_8_all.lua b/stairsplus/craft_schemas/micro_8_all.lua new file mode 100644 index 00000000..22e9f3a4 --- /dev/null +++ b/stairsplus/craft_schemas/micro_8_all.lua @@ -0,0 +1,12 @@ +local api = stairsplus.api +local register_craft_schema = api.register_craft_schema + +for shape, shape_def in pairs(api.registered_shapes) do + if shape ~= "micro_8" and math.floor(shape_def.eighths) > 0 then + register_craft_schema({ + type = "shapeless", + output = ("micro_8 %i"):format(shape_def.eighths), + recipe = {shape}, + }) + end +end diff --git a/stairsplus/craft_schemas/other.lua b/stairsplus/craft_schemas/other.lua new file mode 100644 index 00000000..662d1f0a --- /dev/null +++ b/stairsplus/craft_schemas/other.lua @@ -0,0 +1,84 @@ +local api = stairsplus.api +local register_craft_schema = api.register_craft_schema + +---- panel_8 + +register_craft_schema({ + output = "panel_8 12", + recipe = { + {"node", ""}, + {"node", "node"}, + }, +}) + +register_craft_schema({ + output = "panel_8 12", + recipe = { + {"", "node"}, + {"node", "node"}, + }, +}) + +-- slabs + +register_craft_schema({ + type = "shapeless", + output = "slab_8", + recipe = {"micro_8", "micro_8", "micro_8", "micro_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slab_8", + recipe = {"slab_2", "slab_2", "slab_2", "slab_2"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slab_8 2", + recipe = {"slab_1", "slab_1", "slab_1", "slab_1", "slab_1", "slab_1", "slab_1", "slab_1"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slab_4 2", + recipe = {"slab_1", "slab_1", "slab_1", "slab_1"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slab_12", + recipe = {"slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slab_14", + recipe = {"slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2"}, +}) + +-- node + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"panel_8", "panel_8", "panel_8", "panel_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slab_4", "slab_4", "slab_4", "slab_4"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2", "slab_2"}, +}) diff --git a/stairsplus/craft_schemas/slopes.lua b/stairsplus/craft_schemas/slopes.lua new file mode 100644 index 00000000..3593ac2a --- /dev/null +++ b/stairsplus/craft_schemas/slopes.lua @@ -0,0 +1,106 @@ +local api = stairsplus.api +local register_craft_schema = api.register_craft_schema + +-- slopes + +register_craft_schema({ + type = "shapeless", + output = "slab_8", + recipe = {"slope_half", "slope_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slab_8", + recipe = {"slope_outer_half", "slope_inner_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slab_8", + recipe = {"slope_outer_cut_half", "slope_inner_cut_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slope_half_raised", + recipe = {"slope_half", "slope_half", "slope_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slope_half_raised", + recipe = {"slab_8", "slope_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slope_inner_half_raised", + recipe = {"slab_8", "slope_inner_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slope_outer_half_raised", + recipe = {"slab_8", "slope_outer_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "slope_inner_cut_half_raised", + recipe = {"slab_8", "slope_inner_cut_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope", "slope"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope_half", "slope_half_raised"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope_half", "slope_half", "slope_half", "slope_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope_outer", "slope_inner"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope_outer_half", "slope_inner_half_raised"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope_outer_half_raised", "slope_inner_half"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope_outer_cut", "slope_inner_cut"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope_outer_cut_half", "slope_inner_cut_half_raised"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node", + recipe = {"slope_cut", "slope_cut"}, +}) diff --git a/stairsplus/craft_schemas/stairs.lua b/stairsplus/craft_schemas/stairs.lua new file mode 100644 index 00000000..5aca905f --- /dev/null +++ b/stairsplus/craft_schemas/stairs.lua @@ -0,0 +1,150 @@ +local api = stairsplus.api +local register_craft_schema = api.register_craft_schema + +register_craft_schema({ + type = "shapeless", + output = "slab_8 3", + recipe = {"stair", "stair"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "node 3", + recipe = {"stair", "stair", "stair", "stair"}, +}) + +register_craft_schema({ + output = "stair 8", + recipe = { + {"node", "", ""}, + {"node", "node", ""}, + {"node", "node", "node"}, + }, +}) + +register_craft_schema({ + output = "stair 8", + recipe = { + {"", "", "node"}, + {"", "node", "node"}, + {"node", "node", "node"}, + }, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair", + recipe = {"panel_8", "slab_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair", + recipe = {"panel_8", "panel_8", "panel_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair", + recipe = {"micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair", + recipe = {"panel_8", "panel_8", "panel_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair_inner", + recipe = {"micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8", "micro_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair_outer", + recipe = {"micro_8", "slab_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair_outer", + recipe = {"micro_8", "micro_8", "micro_8", "micro_8", "micro_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair_half", + recipe = {"micro_8", "micro_8", "micro_8"}, +}) + +register_craft_schema({ + type = "shapeless", + output = "stair_half", + recipe = {"panel_8", "micro_8"}, +}) + +register_craft_schema({ + output = "stair_alt_1", + recipe = { + {"panel_1", ""}, + {"", "panel_1"}, + }, +}) + +register_craft_schema({ + output = "stair_alt_1", + recipe = { + {"", "panel_1"}, + {"panel_1", ""}, + }, +}) + +register_craft_schema({ + output = "stair_alt_2", + recipe = { + {"panel_2", ""}, + {"", "panel_2"}, + }, +}) + +register_craft_schema({ + output = "stair_alt_2", + recipe = { + {"", "panel_2"}, + {"panel_2", ""}, + }, +}) + +register_craft_schema({ + output = "stair_alt_4", + recipe = { + {"panel_4", ""}, + {"", "panel_4"}, + }, +}) + +register_craft_schema({ + output = "stair_alt_4", + recipe = { + {"", "panel_4"}, + {"panel_4", ""}, + }, +}) + +register_craft_schema({ + output = "stair_alt_8", + recipe = { + {"panel_8", ""}, + {"", "panel_8"}, + }, +}) + +register_craft_schema({ + output = "stair_alt_8", + recipe = { + {"", "panel_8"}, + {"panel_8", ""}, + }, +}) diff --git a/stairsplus/craft_schemas/standard_composition.lua b/stairsplus/craft_schemas/standard_composition.lua new file mode 100644 index 00000000..e6bb8932 --- /dev/null +++ b/stairsplus/craft_schemas/standard_composition.lua @@ -0,0 +1,133 @@ +local api = stairsplus.api +local register_craft_schema = api.register_craft_schema + +local slices = {1, 2, 4, 8, 12, 14, 15} + +local valid_slice = { + [1] = true, + [2] = true, + [4] = true, + [8] = true, + [12] = true, + [14] = true, + [15] = true, +} + +local full_promotion = { + micro = "panel_8", + panel = "slab_8", + slab = "node", +} + +local half_promotion = { + micro = "panel", + panel = "slab", +} + +local demotion = { + node = "slab", + slab = "panel", + panel = "micro", +} + +-- stack things on top of each other +for _, shape in ipairs({"micro", "panel", "slab"}) do + for _, slice1 in ipairs(slices) do + local shape1 = ("%s_%s"):format(shape, slice1) + local def1 = api.registered_shapes[shape1] + + for _, slice2 in ipairs(slices) do + local shape2 = ("%s_%s"):format(shape, slice2) + local def2 = api.registered_shapes[shape2] + + local slice3 = slice1 + slice2 + + if valid_slice[slice3] then + local shape3 = ("%s_%s"):format(shape, slice3) + local def3 = api.registered_shapes[shape3] + local n = math.floor((def1.eighths + def2.eighths) / def3.eighths) + + register_craft_schema({ + output = ("%s %s"):format(shape3, n), + recipe = { + {shape1}, + {shape2}, + }, + }) + + elseif slice3 == 16 then + register_craft_schema({ + output = ("%s"):format(full_promotion[shape]), + recipe = { + {shape1}, + {shape2}, + }, + }) + end + end + end +end + +-- stack things next to each other +for _, shape in ipairs({"micro", "panel"}) do + for _, slice in ipairs(slices) do + local shape1 = ("%s_%s"):format(shape, slice) + local def1 = api.registered_shapes[shape1] + local shape2 = ("%s_%s"):format(half_promotion[shape], slice) + local def2 = api.registered_shapes[shape2] + local n = math.floor(2 * def1.eighths / def2.eighths) + + register_craft_schema({ + output = ("%s %s"):format(shape2, n), + recipe = { + {shape1, shape1}, + }, + }) + end +end + +-- split in half horizontally + +register_craft_schema({ + output = "slab_8 6", + recipe = {{"node", "node", "node"}}, +}) + +for _, shape in ipairs({"micro", "panel", "slab"}) do + for _, slice1 in ipairs({2, 4, 8}) do + local slice2 = slice1 / 2 + local shape1 = ("%s_%s"):format(shape, slice1) + local shape2 = ("%s_%s"):format(shape, slice2) + local def1 = api.registered_shapes[shape1] + local def2 = api.registered_shapes[shape2] + local n = math.floor(3 * def1.eighths / def2.eighths) + + register_craft_schema({ + output = ("%s %s"):format(shape2, n), + recipe = { + {shape1, shape1, shape1}, + }, + }) + end +end + +-- split in half vertically + +for _, shape in ipairs({"panel", "slab"}) do + for _, slice in ipairs(slices) do + local shape1 = ("%s_%s"):format(shape, slice) + local shape2 = ("%s_%s"):format(demotion[shape], slice) + local def1 = api.registered_shapes[shape1] + local def2 = api.registered_shapes[shape2] + local n = math.floor(3 * def1.eighths / def2.eighths) + + register_craft_schema({ + output = ("%s %s"):format(shape2, n), + recipe = { + {shape1}, + {shape1}, + {shape1}, + }, + }) + end +end diff --git a/stairsplus/custom.lua b/stairsplus/custom.lua deleted file mode 100644 index 961d1ea8..00000000 --- a/stairsplus/custom.lua +++ /dev/null @@ -1,97 +0,0 @@ ---[[ -More Blocks: microblock definitions - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - ---[[ -Subset table should have the following format: (You can remove entries as needed.) - -local subset = { - { "micro", "" }, - { "micro", "_1" }, - { "micro", "_2" }, - { "micro", "_4" }, - { "micro", "_12" }, - { "micro", "_14" }, - { "micro", "_15" }, - { "panel", "" }, - { "panel", "_1" }, - { "panel", "_2" }, - { "panel", "_4" }, - { "panel", "_12" }, - { "panel", "_14" }, - { "panel", "_15" }, - { "slab", "" }, - { "slab", "_quarter" }, - { "slab", "_three_quarter" }, - { "slab", "_1" }, - { "slab", "_2" }, - { "slab", "_14" }, - { "slab", "_15" }, - { "slab", "_two_sides" }, - { "slab", "_three_sides" }, - { "slab", "_three_sides_u" }, - { "slope", "" }, - { "slope", "_half" }, - { "slope", "_half_raised" }, - { "slope", "_inner" }, - { "slope", "_inner_half" }, - { "slope", "_inner_half_raised" }, - { "slope", "_inner_cut" }, - { "slope", "_inner_cut_half" }, - { "slope", "_inner_cut_half_raised" }, - { "slope", "_outer" }, - { "slope", "_outer_half" }, - { "slope", "_outer_half_raised" }, - { "slope", "_outer_cut" }, - { "slope", "_outer_cut_half" }, - { "slope", "_outer_cut_half_raised" }, - { "slope", "_cut" }, - { "stair", "" }, - { "stair", "_half" }, - { "stair", "_right_half" }, - { "stair", "_inner" }, - { "stair", "_outer" }, - { "stair", "_alt" }, - { "stair", "_alt_1" }, - { "stair", "_alt_2" }, - { "stair", "_alt_4" }, -} ---]] - --- luacheck: no unused -local function register_custom_subset(subset, modname, subname, recipeitem, groups, images, description, drop, light) - stairsplus:register_custom_subset(subset, modname, subname, recipeitem, { - groups = groups, - tiles = images, - description = description, - drop = drop, - light_source = light, - sounds = moreblocks.node_sound_stone_defaults(), - }) -end - -function stairsplus:register_custom_subset_alias(subset, modname_old, subname_old, modname_new, subname_new) - local subset_copy = table.copy(subset) - for k, v in pairs(subset_copy) do - minetest.register_alias(modname_old .. ":" .. v[1] .. "_" .. subname_old .. v[2], modname_new .. ":" .. v[1] .. "_" .. subname_new .. v[2]) - end -end - -function stairsplus:register_custom_subset_alias_force(subset, modname_old, subname_old, modname_new, subname_new) - local subset_copy = table.copy(subset) - for k, v in pairs(subset_copy) do - minetest.register_alias_force(modname_old .. ":" .. v[1] .. "_" .. subname_old .. v[2], modname_new .. ":" .. v[1] .. "_" .. subname_new .. v[2]) - end -end - -function stairsplus:register_custom_subset(subset, modname, subname, recipeitem, fields) - local subset_copy = table.copy(subset) - for k, v in pairs(subset_copy) do - stairsplus.register_single(v[1], v[2], stairsplus.defs[v[1]][v[2]], modname, subname, recipeitem, fields) - end - - circular_saw.known_nodes[recipeitem] = {modname, subname} -end diff --git a/stairsplus/defs.lua b/stairsplus/defs.lua deleted file mode 100644 index 893ec68a..00000000 --- a/stairsplus/defs.lua +++ /dev/null @@ -1,409 +0,0 @@ ---[[ -More Blocks: registrations - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - - -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_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} - } -} - -stairsplus.defs = { - ["micro"] = { - [""] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, 0, 0.5}, - }, - }, - ["_1"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5}, - }, - }, - ["_2"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, -0.375, 0.5}, - }, - }, - ["_4"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, -0.25, 0.5}, - }, - }, - ["_12"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5}, - }, - }, - ["_14"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, 0.375, 0.5}, - }, - }, - ["_15"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0, 0.4375, 0.5}, - }, - } - }, - ["panel"] = { - [""] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, 0, 0.5}, - }, - }, - ["_1"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5}, - }, - }, - ["_2"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5}, - }, - }, - ["_4"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, -0.25, 0.5}, - }, - }, - ["_12"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5}, - }, - }, - ["_14"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5}, - }, - }, - ["_15"] = { - node_box = { - type = "fixed", - fixed = {-0.5, -0.5, 0, 0.5, 0.4375, 0.5}, - }, - } - }, - ["slab"] = { - [""] = 8, - ["_quarter"] = 4, - ["_three_quarter"] = 12, - ["_1"] = 1, - ["_2"] = 2, - ["_14"] = 14, - ["_15"] = 15, - ["_two_sides"] = { - { -0.5, -0.5, -0.5, 0.5, -7/16, 7/16 }, - { -0.5, -0.5, 7/16, 0.5, 0.5, 0.5 } - }, - ["_three_sides"] = { - { -7/16, -0.5, -0.5, 0.5, -7/16, 7/16 }, - { -7/16, -0.5, 7/16, 0.5, 0.5, 0.5 }, - { -0.5, -0.5, -0.5, -7/16, 0.5, 0.5 } - }, - ["_three_sides_u"] = { - { -0.5, -0.5, -0.5, 0.5, 0.5, -7/16 }, - { -0.5, -0.5, -7/16, 0.5, -7/16, 7/16 }, - { -0.5, -0.5, 7/16, 0.5, 0.5, 0.5 } - } - }, - ["slope"] = { - [""] = { - mesh = "moreblocks_slope.obj", - collision_box = box_slope, - selection_box = box_slope, - - }, - ["_half"] = { - mesh = "moreblocks_slope_half.obj", - collision_box = box_slope_half, - selection_box = box_slope_half, - }, - ["_half_raised"] = { - mesh = "moreblocks_slope_half_raised.obj", - collision_box = box_slope_half_raised, - selection_box = box_slope_half_raised, - }, - - --============================================================== - - ["_inner"] = { - mesh = "moreblocks_slope_inner.obj", - collision_box = box_slope_inner, - selection_box = box_slope_inner, - }, - ["_inner_half"] = { - mesh = "moreblocks_slope_inner_half.obj", - collision_box = box_slope_inner_half, - selection_box = box_slope_inner_half, - }, - ["_inner_half_raised"] = { - mesh = "moreblocks_slope_inner_half_raised.obj", - collision_box = box_slope_inner_half_raised, - selection_box = box_slope_inner_half_raised, - }, - - --============================================================== - - ["_inner_cut"] = { - mesh = "moreblocks_slope_inner_cut.obj", - collision_box = box_slope_inner, - selection_box = box_slope_inner, - }, - ["_inner_cut_half"] = { - mesh = "moreblocks_slope_inner_cut_half.obj", - collision_box = box_slope_inner_half, - selection_box = box_slope_inner_half, - }, - ["_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, - }, - - --============================================================== - - ["_outer"] = { - mesh = "moreblocks_slope_outer.obj", - collision_box = box_slope_outer, - selection_box = box_slope_outer, - }, - ["_outer_half"] = { - mesh = "moreblocks_slope_outer_half.obj", - collision_box = box_slope_outer_half, - selection_box = box_slope_outer_half, - }, - ["_outer_half_raised"] = { - mesh = "moreblocks_slope_outer_half_raised.obj", - collision_box = box_slope_outer_half_raised, - selection_box = box_slope_outer_half_raised, - }, - - --============================================================== - - ["_outer_cut"] = { - mesh = "moreblocks_slope_outer_cut.obj", - collision_box = box_slope_outer, - selection_box = box_slope_outer, - }, - ["_outer_cut_half"] = { - mesh = "moreblocks_slope_outer_cut_half.obj", - collision_box = box_slope_outer_half, - selection_box = box_slope_outer_half, - }, - ["_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, - }, - ["_cut"] = { - mesh = "moreblocks_slope_cut.obj", - collision_box = box_slope_outer, - selection_box = box_slope_outer, - }, - }, - ["stair"] = { - [""] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, - {-0.5, 0, 0, 0.5, 0.5, 0.5}, - }, - }, - }, - ["_half"] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.5, -0.5, 0, 0, 0.5}, - {-0.5, 0, 0, 0, 0.5, 0.5}, - }, - }, - }, - ["_right_half"] = { - node_box = { - type = "fixed", - fixed = { - {0, -0.5, -0.5, 0.5, 0, 0.5}, - {0, 0, 0, 0.5, 0.5, 0.5}, - }, - }, - }, - ["_inner"] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, - {-0.5, 0, 0, 0.5, 0.5, 0.5}, - {-0.5, 0, -0.5, 0, 0.5, 0}, - }, - }, - }, - ["_outer"] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, - {-0.5, 0, 0, 0, 0.5, 0.5}, - }, - }, - }, - ["_alt"] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.5, -0.5, 0.5, 0, 0}, - {-0.5, 0, 0, 0.5, 0.5, 0.5}, - }, - }, - }, - ["_alt_1"] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.0625, -0.5, 0.5, 0, 0}, - {-0.5, 0.4375, 0, 0.5, 0.5, 0.5}, - }, - }, - }, - ["_alt_2"] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.125, -0.5, 0.5, 0, 0}, - {-0.5, 0.375, 0, 0.5, 0.5, 0.5}, - }, - }, - }, - ["_alt_4"] = { - node_box = { - type = "fixed", - fixed = { - {-0.5, -0.25, -0.5, 0.5, 0, 0}, - {-0.5, 0.25, 0, 0.5, 0.5, 0.5}, - }, - }, - }, - }, -} - -for type,a in pairs(stairsplus.defs) do - for name,b in pairs(stairsplus.defs[type]) do - table.insert(stairsplus.shapes_list, { type .. "_", name }) - end -end diff --git a/stairsplus/groups/builtin.lua b/stairsplus/groups/builtin.lua new file mode 100644 index 00000000..41721f5e --- /dev/null +++ b/stairsplus/groups/builtin.lua @@ -0,0 +1,22 @@ + +stairsplus.api.register_passthrough_groups({ + "not_in_creative_inventory", + "dig_immediate", + "float", + "level", + "slippery", + "falling_node", + "disable_jump", +}) + +stairsplus.api.register_scaling_groups({ + "bouncy", + "fall_damage_add_percent", + "slippery", +}) + +stairsplus.api.register_ignore_groups({ + "attached_node", + "connect_to_raillike", + "tool", +}) diff --git a/stairsplus/groups/default.lua b/stairsplus/groups/default.lua new file mode 100644 index 00000000..77ac750e --- /dev/null +++ b/stairsplus/groups/default.lua @@ -0,0 +1,14 @@ +if not stairsplus.has.default then + return +end + +stairsplus.api.register_passthrough_groups({ + "crumbly", + "cracky", + "snappy", + "choppy", + "fleshy", + "flammable", + "explody", + "oddly_breakable_by_hand", +}) diff --git a/stairsplus/groups/init.lua b/stairsplus/groups/init.lua new file mode 100644 index 00000000..d9d2a83f --- /dev/null +++ b/stairsplus/groups/init.lua @@ -0,0 +1,3 @@ +stairsplus.dofile("groups", "builtin") +stairsplus.dofile("groups", "default") +stairsplus.dofile("groups", "other") diff --git a/stairsplus/groups/other.lua b/stairsplus/groups/other.lua new file mode 100644 index 00000000..566321dd --- /dev/null +++ b/stairsplus/groups/other.lua @@ -0,0 +1,61 @@ +-- group overrides for various other mods + +-- various things found in the wild +stairsplus.api.register_passthrough_groups({ + "bendy", + "dig_generic", + "dig_sand", + "dig_stone", + "dig_tree", + "fast_travel", + "melty", + "unbreakable", +}) + +stairsplus.api.register_ignore_groups({ + "type_node", + "ud_param2_colorable", +}) + +-- mineclone +stairsplus.api.register_passthrough_groups({ + "pickaxey", + "axey", + "shovely", + "swordy", + "swordy_cobweb", + "shearsy", + "shearsy_wool", + "handy", + "creative_breakable", + "dig_by_water", + "destroy_by_lava_flow", + "dig_by_piston", + "non_mycelium_plant", + "enderman_takable", + "disable_suffocation", + "no_rename", +}) + +stairsplus.api.register_scaling_groups({ + "falling_node_damage", + "fire_encouragement", + "fire_flammability", + "comparator_signal", + "set_on_fire", + "compostability", +}) + +stairsplus.api.register_ignore_groups({ + "crush_after_fall", + "cultivatable", + "path_creation_possible", + "spreading_dirt_type", + "dirtifies_below_solid", + "dirtifier", + "destroys_items", + "no_eat_delay", + "can_eat_when_full", + "attached_node_facedir", + "supported_node", +}) diff --git a/stairsplus/init.lua b/stairsplus/init.lua index 4e071deb..7a73b67b 100644 --- a/stairsplus/init.lua +++ b/stairsplus/init.lua @@ -1,82 +1,48 @@ ---[[ -More Blocks: Stairs+ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] +stairsplus = { + version = {3, 0, 0}, + fork = "minetest_mods", --- Nodes will be called :{stair,slab,panel,micro,slope}_ + modname = modname, + modpath = modpath, -local modpath = minetest.get_modpath("moreblocks").. "/stairsplus" + S = S, -stairsplus = {} -stairsplus.expect_infinite_stacks = false + has = { + default = minetest.get_modpath("default"), + i3 = minetest.get_modpath("i3"), + stairs = minetest.get_modpath("stairs"), + unified_inventory = minetest.get_modpath("unified_inventory"), + }, -stairsplus.shapes_list = {} + log = function(level, messagefmt, ...) + return minetest.log(level, ("[%s] %s"):format(modname, messagefmt:format(...))) + end, -if - not minetest.get_modpath("unified_inventory") - and minetest.settings:get_bool("creative_mode") -then - stairsplus.expect_infinite_stacks = true -end + dofile = function(...) + return dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua") + end, +} -function stairsplus:prepare_groups(groups) - local result = {} - if groups then - for k, v in pairs(groups) do - if k ~= "wood" and k ~= "stone" and k ~= "wool" and k ~= "tree" then - result[k] = v - end - end - end - if not moreblocks.config.stairsplus_in_creative_inventory then - result.not_in_creative_inventory = 1 - end - return result -end +-- please don't change the order in which things are loaded, without understanding why they're ordered like this +stairsplus.dofile("settings") +stairsplus.dofile("util") -function stairsplus:register_all(modname, subname, recipeitem, fields) - self:register_stair(modname, subname, recipeitem, fields) - self:register_slab(modname, subname, recipeitem, fields) - self:register_slope(modname, subname, recipeitem, fields) - self:register_panel(modname, subname, recipeitem, fields) - self:register_micro(modname, subname, recipeitem, fields) -end +stairsplus.dofile("api", "init") -function stairsplus:register_alias_all(modname_old, subname_old, modname_new, subname_new) - self:register_stair_alias(modname_old, subname_old, modname_new, subname_new) - self:register_slab_alias(modname_old, subname_old, modname_new, subname_new) - self:register_slope_alias(modname_old, subname_old, modname_new, subname_new) - self:register_panel_alias(modname_old, subname_old, modname_new, subname_new) - self:register_micro_alias(modname_old, subname_old, modname_new, subname_new) -end -function stairsplus:register_alias_force_all(modname_old, subname_old, modname_new, subname_new) - self:register_stair_alias_force(modname_old, subname_old, modname_new, subname_new) - self:register_slab_alias_force(modname_old, subname_old, modname_new, subname_new) - self:register_slope_alias_force(modname_old, subname_old, modname_new, subname_new) - self:register_panel_alias_force(modname_old, subname_old, modname_new, subname_new) - self:register_micro_alias_force(modname_old, subname_old, modname_new, subname_new) -end +stairsplus.dofile("shapes", "init") +stairsplus.dofile("groups", "init") --- luacheck: no unused -local function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light) - stairsplus:register_all(modname, subname, recipeitem, { - groups = groups, - tiles = images, - description = description, - drop = drop, - light_source = light - }) +if stairsplus.settings.crafting_schemata_enabled then + stairsplus.dofile("craft_schemas", "init") end -dofile(modpath .. "/defs.lua") -dofile(modpath .. "/recipes.lua") -dofile(modpath .. "/common.lua") -dofile(modpath .. "/stairs.lua") -dofile(modpath .. "/slabs.lua") -dofile(modpath .. "/slopes.lua") -dofile(modpath .. "/panels.lua") -dofile(modpath .. "/microblocks.lua") -dofile(modpath .. "/custom.lua") -dofile(modpath .. "/registrations.lua") +stairsplus.dofile("resources", "init") +stairsplus.dofile("circular_saw") + +stairsplus.dofile("compat", "init") + +stairsplus.dofile("aliases") diff --git a/stairsplus/locale/cleanup_tr.py b/stairsplus/locale/cleanup_tr.py new file mode 100644 index 00000000..d6d6015b --- /dev/null +++ b/stairsplus/locale/cleanup_tr.py @@ -0,0 +1,38 @@ +import pathlib +import re + +ourdir = pathlib.Path('./') + +template = (ourdir / 'stairsplus.template.tr').open().readlines() + +for tr in ourdir.glob('*.tr'): + if str(tr) == 'stairsplus.template.tr': + continue + + trs = {} + for line in tr.open(): + m = re.fullmatch('([^=]+)=(.*)', line.rstrip('\n')) + if m: + trs[m.group(1)] = m.group(2) + + with tr.open('w') as fh: + for line in template: + m = re.fullmatch('([^=]+)=(.*)', line.rstrip()) + if m: + key = m.group(1) + value = trs.get(m.group(1), "") + if value == "": + if 'Microblock' in key: + value = trs.get('@1 Microblock', "") + elif 'Panel' in key: + value = trs.get('@1 Panel', "") + elif 'Slab' in key: + value = trs.get('@1 Slab', "") + elif 'Slope' in key: + value = trs.get('@1 Slope', "") + elif 'Stair' in key: + value = trs.get('@1 Stairs', "") + + print(f'{key}={value}', file=fh) + else: + print(line, end='', file=fh) diff --git a/stairsplus/locale/stairsplus.de.tr b/stairsplus/locale/stairsplus.de.tr new file mode 100644 index 00000000..29d27570 --- /dev/null +++ b/stairsplus/locale/stairsplus.de.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw=Kreissäge +Empty=leer +Input=Eingang +Max=Anzahl +Microblocks=mikroblock +Nodes= +(owned by @1)=gehört @1 +Set=Ok +Working on @1=arbeitet mit @1 + +#: shapes/micros.lua +@1 1/16 Microblock=@1mikroblock +@1 1/8 Microblock=@1mikroblock +@1 1/4 Microblock=@1mikroblock +@1 Microblock=@1mikroblock +@1 3/4 Microblock=@1mikroblock +@1 7/8 Microblock=@1mikroblock +@1 15/16 Microblock=@1mikroblock + +#: shapes/panels.lua +@1 1/16 Panel=@1paneel +@1 1/8 Panel=@1paneel +@1 1/4 Panel=@1paneel +@1 1/2 Panel=@1paneel +@1 3/4 Panel=@1paneel +@1 7/8 Panel=@1paneel +@1 15/16 Panel=@1paneel + +#: shapes/slabs.lua +@1 1/16 Slab=@1platte +@1 1/8 Slab=@1platte +@1 1/4 Slab=@1platte +@1 1/2 Slab=@1platte +@1 3/4 Slab=@1platte +@1 7/8 Slab=@1platte +@1 15/16 Slab=@1platte +@1 1/16 Slab Three Sides=@1platte +@1 1/16 Slab Three Sides U=@1platte +@1 1/16 Slab Two Sides=@1platte + +#: shapes/slopes.lua +@1 1/2 Slope=@1neigung +@1 1/2 Slope Raised=@1neigung +@1 Slope=@1neigung +@1 Slope Cut=@1neigung +@1 Slope Inner=@1neigung +@1 Slope Inner Cut=@1neigung +@1 Slope Inner Cut Half=@1neigung +@1 Slope Inner Cut Half Raised=@1neigung +@1 Slope Inner Half=@1neigung +@1 Slope Inner Half Raised=@1neigung +@1 Slope Outer=@1neigung +@1 Slope Outer Cut=@1neigung +@1 Slope Outer Cut Half=@1neigung +@1 Slope Outer Cut Half Raised=@1neigung +@1 Slope Outer Half=@1neigung +@1 Slope Outer Half Raised=@1neigung + +#: shapes/stairs.lua +@1 Stair=@1treppe +@1 1/16 Alt Stair=@1treppe +@1 1/8 Alt Stair=@1treppe +@1 1/4 Alt Stair=@1treppe +@1 1/2 Alt Stair=@1treppe +@1 Inner Stair=@1treppe +@1 Outer Stair=@1treppe +@1 Half Stair=@1treppe +@1 Right Half Stair=@1treppe + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/locale/stairsplus.es.tr b/stairsplus/locale/stairsplus.es.tr new file mode 100644 index 00000000..4a200296 --- /dev/null +++ b/stairsplus/locale/stairsplus.es.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw=Sierra circular +Empty=vacia +Input=aporte +Max=Maximo +Microblocks=Microbloque +Nodes= +(owned by @1)=protegido por @1 +Set=Establecer +Working on @1=trabajando en @1 + +#: shapes/micros.lua +@1 1/16 Microblock=Microbloque de @1 +@1 1/8 Microblock=Microbloque de @1 +@1 1/4 Microblock=Microbloque de @1 +@1 Microblock=Microbloque de @1 +@1 3/4 Microblock=Microbloque de @1 +@1 7/8 Microblock=Microbloque de @1 +@1 15/16 Microblock=Microbloque de @1 + +#: shapes/panels.lua +@1 1/16 Panel=Panel de @1 +@1 1/8 Panel=Panel de @1 +@1 1/4 Panel=Panel de @1 +@1 1/2 Panel=Panel de @1 +@1 3/4 Panel=Panel de @1 +@1 7/8 Panel=Panel de @1 +@1 15/16 Panel=Panel de @1 + +#: shapes/slabs.lua +@1 1/16 Slab=Losa de @1 +@1 1/8 Slab=Losa de @1 +@1 1/4 Slab=Losa de @1 +@1 1/2 Slab=Losa de @1 +@1 3/4 Slab=Losa de @1 +@1 7/8 Slab=Losa de @1 +@1 15/16 Slab=Losa de @1 +@1 1/16 Slab Three Sides=Losa de @1 +@1 1/16 Slab Three Sides U=Losa de @1 +@1 1/16 Slab Two Sides=Losa de @1 + +#: shapes/slopes.lua +@1 1/2 Slope=Pendiente de @1 +@1 1/2 Slope Raised=Pendiente de @1 +@1 Slope=Pendiente de @1 +@1 Slope Cut=Pendiente de @1 +@1 Slope Inner=Pendiente de @1 +@1 Slope Inner Cut=Pendiente de @1 +@1 Slope Inner Cut Half=Pendiente de @1 +@1 Slope Inner Cut Half Raised=Pendiente de @1 +@1 Slope Inner Half=Pendiente de @1 +@1 Slope Inner Half Raised=Pendiente de @1 +@1 Slope Outer=Pendiente de @1 +@1 Slope Outer Cut=Pendiente de @1 +@1 Slope Outer Cut Half=Pendiente de @1 +@1 Slope Outer Cut Half Raised=Pendiente de @1 +@1 Slope Outer Half=Pendiente de @1 +@1 Slope Outer Half Raised=Pendiente de @1 + +#: shapes/stairs.lua +@1 Stair=Escalera de @1 +@1 1/16 Alt Stair=Escalera de @1 +@1 1/8 Alt Stair=Escalera de @1 +@1 1/4 Alt Stair=Escalera de @1 +@1 1/2 Alt Stair=Escalera de @1 +@1 Inner Stair=Escalera de @1 +@1 Outer Stair=Escalera de @1 +@1 Half Stair=Escalera de @1 +@1 Right Half Stair=Escalera de @1 + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/locale/stairsplus.fr.tr b/stairsplus/locale/stairsplus.fr.tr new file mode 100644 index 00000000..7e62e2a4 --- /dev/null +++ b/stairsplus/locale/stairsplus.fr.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw=Scie circulaire +Empty=vide +Input=saisir +Max=Max +Microblocks=Microbloc +Nodes= +(owned by @1)=propriété de @1 +Set=Définir +Working on @1=manipulant @1 + +#: shapes/micros.lua +@1 1/16 Microblock=Microbloc en @1 +@1 1/8 Microblock=Microbloc en @1 +@1 1/4 Microblock=Microbloc en @1 +@1 Microblock=Microbloc en @1 +@1 3/4 Microblock=Microbloc en @1 +@1 7/8 Microblock=Microbloc en @1 +@1 15/16 Microblock=Microbloc en @1 + +#: shapes/panels.lua +@1 1/16 Panel=Barre en @1 +@1 1/8 Panel=Barre en @1 +@1 1/4 Panel=Barre en @1 +@1 1/2 Panel=Barre en @1 +@1 3/4 Panel=Barre en @1 +@1 7/8 Panel=Barre en @1 +@1 15/16 Panel=Barre en @1 + +#: shapes/slabs.lua +@1 1/16 Slab=Demi-dalle en @1 +@1 1/8 Slab=Demi-dalle en @1 +@1 1/4 Slab=Demi-dalle en @1 +@1 1/2 Slab=Demi-dalle en @1 +@1 3/4 Slab=Demi-dalle en @1 +@1 7/8 Slab=Demi-dalle en @1 +@1 15/16 Slab=Demi-dalle en @1 +@1 1/16 Slab Three Sides=Demi-dalle en @1 +@1 1/16 Slab Three Sides U=Demi-dalle en @1 +@1 1/16 Slab Two Sides=Demi-dalle en @1 + +#: shapes/slopes.lua +@1 1/2 Slope=Pente en @1 +@1 1/2 Slope Raised=Pente en @1 +@1 Slope=Pente en @1 +@1 Slope Cut=Pente en @1 +@1 Slope Inner=Pente en @1 +@1 Slope Inner Cut=Pente en @1 +@1 Slope Inner Cut Half=Pente en @1 +@1 Slope Inner Cut Half Raised=Pente en @1 +@1 Slope Inner Half=Pente en @1 +@1 Slope Inner Half Raised=Pente en @1 +@1 Slope Outer=Pente en @1 +@1 Slope Outer Cut=Pente en @1 +@1 Slope Outer Cut Half=Pente en @1 +@1 Slope Outer Cut Half Raised=Pente en @1 +@1 Slope Outer Half=Pente en @1 +@1 Slope Outer Half Raised=Pente en @1 + +#: shapes/stairs.lua +@1 Stair=Escaliers en @1 +@1 1/16 Alt Stair=Escaliers en @1 +@1 1/8 Alt Stair=Escaliers en @1 +@1 1/4 Alt Stair=Escaliers en @1 +@1 1/2 Alt Stair=Escaliers en @1 +@1 Inner Stair=Escaliers en @1 +@1 Outer Stair=Escaliers en @1 +@1 Half Stair=Escaliers en @1 +@1 Right Half Stair=Escaliers en @1 + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/locale/stairsplus.it.tr b/stairsplus/locale/stairsplus.it.tr new file mode 100644 index 00000000..f4f5ad56 --- /dev/null +++ b/stairsplus/locale/stairsplus.it.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw=Sega circolare +Empty=vuota +Input=ingresso +Max=Max. +Microblocks=Microblocco +Nodes= +(owned by @1)= +Set=Imp. +Working on @1=in funzione su @1 + +#: shapes/micros.lua +@1 1/16 Microblock=Microblocco @1 +@1 1/8 Microblock=Microblocco @1 +@1 1/4 Microblock=Microblocco @1 +@1 Microblock=Microblocco @1 +@1 3/4 Microblock=Microblocco @1 +@1 7/8 Microblock=Microblocco @1 +@1 15/16 Microblock=Microblocco @1 + +#: shapes/panels.lua +@1 1/16 Panel=Pannello - @1 +@1 1/8 Panel=Pannello - @1 +@1 1/4 Panel=Pannello - @1 +@1 1/2 Panel=Pannello - @1 +@1 3/4 Panel=Pannello - @1 +@1 7/8 Panel=Pannello - @1 +@1 15/16 Panel=Pannello - @1 + +#: shapes/slabs.lua +@1 1/16 Slab=Lastra - @1 +@1 1/8 Slab=Lastra - @1 +@1 1/4 Slab=Lastra - @1 +@1 1/2 Slab=Lastra - @1 +@1 3/4 Slab=Lastra - @1 +@1 7/8 Slab=Lastra - @1 +@1 15/16 Slab=Lastra - @1 +@1 1/16 Slab Three Sides=Lastra - @1 +@1 1/16 Slab Three Sides U=Lastra - @1 +@1 1/16 Slab Two Sides=Lastra - @1 + +#: shapes/slopes.lua +@1 1/2 Slope= +@1 1/2 Slope Raised= +@1 Slope= +@1 Slope Cut= +@1 Slope Inner= +@1 Slope Inner Cut= +@1 Slope Inner Cut Half= +@1 Slope Inner Cut Half Raised= +@1 Slope Inner Half= +@1 Slope Inner Half Raised= +@1 Slope Outer= +@1 Slope Outer Cut= +@1 Slope Outer Cut Half= +@1 Slope Outer Cut Half Raised= +@1 Slope Outer Half= +@1 Slope Outer Half Raised= + +#: shapes/stairs.lua +@1 Stair=Scale - @1 +@1 1/16 Alt Stair=Scale - @1 +@1 1/8 Alt Stair=Scale - @1 +@1 1/4 Alt Stair=Scale - @1 +@1 1/2 Alt Stair=Scale - @1 +@1 Inner Stair=Scale - @1 +@1 Outer Stair=Scale - @1 +@1 Half Stair=Scale - @1 +@1 Right Half Stair=Scale - @1 + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/locale/stairsplus.pl.tr b/stairsplus/locale/stairsplus.pl.tr new file mode 100644 index 00000000..e74d8995 --- /dev/null +++ b/stairsplus/locale/stairsplus.pl.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw=Piła tarczowa +Empty=jest pusta +Input=Wejście +Max=Maks +Microblocks=Mikroblok +Nodes= +(owned by @1)=Należy do @1 +Set=Ustaw +Working on @1=pracuje na @1 + +#: shapes/micros.lua +@1 1/16 Microblock=@1 Mikroblok +@1 1/8 Microblock=@1 Mikroblok +@1 1/4 Microblock=@1 Mikroblok +@1 Microblock=@1 Mikroblok +@1 3/4 Microblock=@1 Mikroblok +@1 7/8 Microblock=@1 Mikroblok +@1 15/16 Microblock=@1 Mikroblok + +#: shapes/panels.lua +@1 1/16 Panel=@1 Panel +@1 1/8 Panel=@1 Panel +@1 1/4 Panel=@1 Panel +@1 1/2 Panel=@1 Panel +@1 3/4 Panel=@1 Panel +@1 7/8 Panel=@1 Panel +@1 15/16 Panel=@1 Panel + +#: shapes/slabs.lua +@1 1/16 Slab=@1 Płyta +@1 1/8 Slab=@1 Płyta +@1 1/4 Slab=@1 Płyta +@1 1/2 Slab=@1 Płyta +@1 3/4 Slab=@1 Płyta +@1 7/8 Slab=@1 Płyta +@1 15/16 Slab=@1 Płyta +@1 1/16 Slab Three Sides=@1 Płyta +@1 1/16 Slab Three Sides U=@1 Płyta +@1 1/16 Slab Two Sides=@1 Płyta + +#: shapes/slopes.lua +@1 1/2 Slope=@1 Spad +@1 1/2 Slope Raised=@1 Spad +@1 Slope=@1 Spad +@1 Slope Cut=@1 Spad +@1 Slope Inner=@1 Spad +@1 Slope Inner Cut=@1 Spad +@1 Slope Inner Cut Half=@1 Spad +@1 Slope Inner Cut Half Raised=@1 Spad +@1 Slope Inner Half=@1 Spad +@1 Slope Inner Half Raised=@1 Spad +@1 Slope Outer=@1 Spad +@1 Slope Outer Cut=@1 Spad +@1 Slope Outer Cut Half=@1 Spad +@1 Slope Outer Cut Half Raised=@1 Spad +@1 Slope Outer Half=@1 Spad +@1 Slope Outer Half Raised=@1 Spad + +#: shapes/stairs.lua +@1 Stair=@1 Schody +@1 1/16 Alt Stair=@1 Schody +@1 1/8 Alt Stair=@1 Schody +@1 1/4 Alt Stair=@1 Schody +@1 1/2 Alt Stair=@1 Schody +@1 Inner Stair=@1 Schody +@1 Outer Stair=@1 Schody +@1 Half Stair=@1 Schody +@1 Right Half Stair=@1 Schody + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/locale/stairsplus.ru.tr b/stairsplus/locale/stairsplus.ru.tr new file mode 100644 index 00000000..4da6d0fe --- /dev/null +++ b/stairsplus/locale/stairsplus.ru.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw=циркулярная пила +Empty=пустая +Input=вход +Max=Кол. +Microblocks=микроблок +Nodes= +(owned by @1)=принадлежит @1 +Set=ОК +Working on @1=@1 в обработке + +#: shapes/micros.lua +@1 1/16 Microblock=@1 (микроблок) +@1 1/8 Microblock=@1 (микроблок) +@1 1/4 Microblock=@1 (микроблок) +@1 Microblock=@1 (микроблок) +@1 3/4 Microblock=@1 (микроблок) +@1 7/8 Microblock=@1 (микроблок) +@1 15/16 Microblock=@1 (микроблок) + +#: shapes/panels.lua +@1 1/16 Panel=@1 (панель) +@1 1/8 Panel=@1 (панель) +@1 1/4 Panel=@1 (панель) +@1 1/2 Panel=@1 (панель) +@1 3/4 Panel=@1 (панель) +@1 7/8 Panel=@1 (панель) +@1 15/16 Panel=@1 (панель) + +#: shapes/slabs.lua +@1 1/16 Slab=@1 (плита) +@1 1/8 Slab=@1 (плита) +@1 1/4 Slab=@1 (плита) +@1 1/2 Slab=@1 (плита) +@1 3/4 Slab=@1 (плита) +@1 7/8 Slab=@1 (плита) +@1 15/16 Slab=@1 (плита) +@1 1/16 Slab Three Sides=@1 (плита) +@1 1/16 Slab Three Sides U=@1 (плита) +@1 1/16 Slab Two Sides=@1 (плита) + +#: shapes/slopes.lua +@1 1/2 Slope=@1 (наклон) +@1 1/2 Slope Raised=@1 (наклон) +@1 Slope=@1 (наклон) +@1 Slope Cut=@1 (наклон) +@1 Slope Inner=@1 (наклон) +@1 Slope Inner Cut=@1 (наклон) +@1 Slope Inner Cut Half=@1 (наклон) +@1 Slope Inner Cut Half Raised=@1 (наклон) +@1 Slope Inner Half=@1 (наклон) +@1 Slope Inner Half Raised=@1 (наклон) +@1 Slope Outer=@1 (наклон) +@1 Slope Outer Cut=@1 (наклон) +@1 Slope Outer Cut Half=@1 (наклон) +@1 Slope Outer Cut Half Raised=@1 (наклон) +@1 Slope Outer Half=@1 (наклон) +@1 Slope Outer Half Raised=@1 (наклон) + +#: shapes/stairs.lua +@1 Stair=@1 (лестница) +@1 1/16 Alt Stair=@1 (лестница) +@1 1/8 Alt Stair=@1 (лестница) +@1 1/4 Alt Stair=@1 (лестница) +@1 1/2 Alt Stair=@1 (лестница) +@1 Inner Stair=@1 (лестница) +@1 Outer Stair=@1 (лестница) +@1 Half Stair=@1 (лестница) +@1 Right Half Stair=@1 (лестница) + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/locale/stairsplus.template.tr b/stairsplus/locale/stairsplus.template.tr new file mode 100644 index 00000000..c6690b8c --- /dev/null +++ b/stairsplus/locale/stairsplus.template.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw= +Empty= +Input= +Max= +Microblocks= +Nodes= +(owned by @1)= +Set= +Working on @1= + +#: shapes/micros.lua +@1 1/16 Microblock= +@1 1/8 Microblock= +@1 1/4 Microblock= +@1 Microblock= +@1 3/4 Microblock= +@1 7/8 Microblock= +@1 15/16 Microblock= + +#: shapes/panels.lua +@1 1/16 Panel= +@1 1/8 Panel= +@1 1/4 Panel= +@1 1/2 Panel= +@1 3/4 Panel= +@1 7/8 Panel= +@1 15/16 Panel= + +#: shapes/slabs.lua +@1 1/16 Slab= +@1 1/8 Slab= +@1 1/4 Slab= +@1 1/2 Slab= +@1 3/4 Slab= +@1 7/8 Slab= +@1 15/16 Slab= +@1 1/16 Slab Three Sides= +@1 1/16 Slab Three Sides U= +@1 1/16 Slab Two Sides= + +#: shapes/slopes.lua +@1 1/2 Slope= +@1 1/2 Slope Raised= +@1 Slope= +@1 Slope Cut= +@1 Slope Inner= +@1 Slope Inner Cut= +@1 Slope Inner Cut Half= +@1 Slope Inner Cut Half Raised= +@1 Slope Inner Half= +@1 Slope Inner Half Raised= +@1 Slope Outer= +@1 Slope Outer Cut= +@1 Slope Outer Cut Half= +@1 Slope Outer Cut Half Raised= +@1 Slope Outer Half= +@1 Slope Outer Half Raised= + +#: shapes/stairs.lua +@1 Stair= +@1 1/16 Alt Stair= +@1 1/8 Alt Stair= +@1 1/4 Alt Stair= +@1 1/2 Alt Stair= +@1 Inner Stair= +@1 Outer Stair= +@1 Half Stair= +@1 Right Half Stair= + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/locale/stairsplus.zh_CN.tr b/stairsplus/locale/stairsplus.zh_CN.tr new file mode 100644 index 00000000..f12cae38 --- /dev/null +++ b/stairsplus/locale/stairsplus.zh_CN.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw=圆锯 +Empty=是空的 +Input=输入 +Max=最大值 +Microblocks=小方块 +Nodes= +(owned by @1)=属于@1所有 +Set=设置 +Working on @1=正在加工@1 + +#: shapes/micros.lua +@1 1/16 Microblock=@1小方块 +@1 1/8 Microblock=@1小方块 +@1 1/4 Microblock=@1小方块 +@1 Microblock=@1小方块 +@1 3/4 Microblock=@1小方块 +@1 7/8 Microblock=@1小方块 +@1 15/16 Microblock=@1小方块 + +#: shapes/panels.lua +@1 1/16 Panel=@1嵌板 +@1 1/8 Panel=@1嵌板 +@1 1/4 Panel=@1嵌板 +@1 1/2 Panel=@1嵌板 +@1 3/4 Panel=@1嵌板 +@1 7/8 Panel=@1嵌板 +@1 15/16 Panel=@1嵌板 + +#: shapes/slabs.lua +@1 1/16 Slab=@1台阶 +@1 1/8 Slab=@1台阶 +@1 1/4 Slab=@1台阶 +@1 1/2 Slab=@1台阶 +@1 3/4 Slab=@1台阶 +@1 7/8 Slab=@1台阶 +@1 15/16 Slab=@1台阶 +@1 1/16 Slab Three Sides=@1台阶 +@1 1/16 Slab Three Sides U=@1台阶 +@1 1/16 Slab Two Sides=@1台阶 + +#: shapes/slopes.lua +@1 1/2 Slope=@1斜坡 +@1 1/2 Slope Raised=@1斜坡 +@1 Slope=@1斜坡 +@1 Slope Cut=@1斜坡 +@1 Slope Inner=@1斜坡 +@1 Slope Inner Cut=@1斜坡 +@1 Slope Inner Cut Half=@1斜坡 +@1 Slope Inner Cut Half Raised=@1斜坡 +@1 Slope Inner Half=@1斜坡 +@1 Slope Inner Half Raised=@1斜坡 +@1 Slope Outer=@1斜坡 +@1 Slope Outer Cut=@1斜坡 +@1 Slope Outer Cut Half=@1斜坡 +@1 Slope Outer Cut Half Raised=@1斜坡 +@1 Slope Outer Half=@1斜坡 +@1 Slope Outer Half Raised=@1斜坡 + +#: shapes/stairs.lua +@1 Stair=@1楼梯 +@1 1/16 Alt Stair=@1楼梯 +@1 1/8 Alt Stair=@1楼梯 +@1 1/4 Alt Stair=@1楼梯 +@1 1/2 Alt Stair=@1楼梯 +@1 Inner Stair=@1楼梯 +@1 Outer Stair=@1楼梯 +@1 Half Stair=@1楼梯 +@1 Right Half Stair=@1楼梯 + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/locale/stairsplus.zh_TW.tr b/stairsplus/locale/stairsplus.zh_TW.tr new file mode 100644 index 00000000..1dc879f4 --- /dev/null +++ b/stairsplus/locale/stairsplus.zh_TW.tr @@ -0,0 +1,77 @@ +# textdomain: stairsplus + +#: circular_saw.lua + +Circular Saw=圓鋸 +Empty=是空的 +Input=輸入 +Max=最大值 +Microblocks=小方塊 +Nodes= +(owned by @1)=屬於@1所有 +Set=設置 +Working on @1=正在加工@1 + +#: shapes/micros.lua +@1 1/16 Microblock=@1小方塊 +@1 1/8 Microblock=@1小方塊 +@1 1/4 Microblock=@1小方塊 +@1 Microblock=@1小方塊 +@1 3/4 Microblock=@1小方塊 +@1 7/8 Microblock=@1小方塊 +@1 15/16 Microblock=@1小方塊 + +#: shapes/panels.lua +@1 1/16 Panel=@1嵌板 +@1 1/8 Panel=@1嵌板 +@1 1/4 Panel=@1嵌板 +@1 1/2 Panel=@1嵌板 +@1 3/4 Panel=@1嵌板 +@1 7/8 Panel=@1嵌板 +@1 15/16 Panel=@1嵌板 + +#: shapes/slabs.lua +@1 1/16 Slab=@1臺階 +@1 1/8 Slab=@1臺階 +@1 1/4 Slab=@1臺階 +@1 1/2 Slab=@1臺階 +@1 3/4 Slab=@1臺階 +@1 7/8 Slab=@1臺階 +@1 15/16 Slab=@1臺階 +@1 1/16 Slab Three Sides=@1臺階 +@1 1/16 Slab Three Sides U=@1臺階 +@1 1/16 Slab Two Sides=@1臺階 + +#: shapes/slopes.lua +@1 1/2 Slope=@1斜坡 +@1 1/2 Slope Raised=@1斜坡 +@1 Slope=@1斜坡 +@1 Slope Cut=@1斜坡 +@1 Slope Inner=@1斜坡 +@1 Slope Inner Cut=@1斜坡 +@1 Slope Inner Cut Half=@1斜坡 +@1 Slope Inner Cut Half Raised=@1斜坡 +@1 Slope Inner Half=@1斜坡 +@1 Slope Inner Half Raised=@1斜坡 +@1 Slope Outer=@1斜坡 +@1 Slope Outer Cut=@1斜坡 +@1 Slope Outer Cut Half=@1斜坡 +@1 Slope Outer Cut Half Raised=@1斜坡 +@1 Slope Outer Half=@1斜坡 +@1 Slope Outer Half Raised=@1斜坡 + +#: shapes/stairs.lua +@1 Stair=@1樓梯 +@1 1/16 Alt Stair=@1樓梯 +@1 1/8 Alt Stair=@1樓梯 +@1 1/4 Alt Stair=@1樓梯 +@1 1/2 Alt Stair=@1樓梯 +@1 Inner Stair=@1樓梯 +@1 Outer Stair=@1樓梯 +@1 Half Stair=@1樓梯 +@1 Right Half Stair=@1樓梯 + +# compat2/stairs.lua + +Inner @1= +Outer @1= diff --git a/stairsplus/microblocks.lua b/stairsplus/microblocks.lua deleted file mode 100644 index 88f94fc2..00000000 --- a/stairsplus/microblocks.lua +++ /dev/null @@ -1,43 +0,0 @@ ---[[ -More Blocks: microblock definitions - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - --- Node will be called :micro_ - --- luacheck: no unused -local function register_micro(modname, subname, recipeitem, groups, images, description, drop, light) - stairsplus:register_micro(modname, subname, recipeitem, { - groups = groups, - tiles = images, - description = description, - drop = drop, - light_source = light, - sounds = moreblocks.node_sound_stone_defaults(), - }) -end - -function stairsplus:register_micro_alias(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["micro"]) - for alternate, def in pairs(defs) do - minetest.register_alias(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate) - end -end - -function stairsplus:register_micro_alias_force(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["micro"]) - for alternate, def in pairs(defs) do - minetest.register_alias_force(modname_old .. ":micro_" .. subname_old .. alternate, modname_new .. ":micro_" .. subname_new .. alternate) - end -end - -function stairsplus:register_micro(modname, subname, recipeitem, fields) - local defs = table.copy(stairsplus.defs["micro"]) - for alternate, def in pairs(defs) do - stairsplus.register_single("micro", alternate, def, modname, subname, recipeitem, fields) - end - - circular_saw.known_nodes[recipeitem] = {modname, subname} -end diff --git a/stairsplus/mod.conf b/stairsplus/mod.conf new file mode 100644 index 00000000..c265ab5c --- /dev/null +++ b/stairsplus/mod.conf @@ -0,0 +1,5 @@ +name = stairsplus +version = 3.0.0 +title = Stairs+ +description = Microblock API +optional_depends = default, i3, unified_inventory diff --git a/models/moreblocks_slope.obj b/stairsplus/models/stairsplus_slope.obj similarity index 100% rename from models/moreblocks_slope.obj rename to stairsplus/models/stairsplus_slope.obj diff --git a/models/moreblocks_slope_cut.obj b/stairsplus/models/stairsplus_slope_cut.obj similarity index 100% rename from models/moreblocks_slope_cut.obj rename to stairsplus/models/stairsplus_slope_cut.obj diff --git a/models/moreblocks_slope_half.obj b/stairsplus/models/stairsplus_slope_half.obj similarity index 100% rename from models/moreblocks_slope_half.obj rename to stairsplus/models/stairsplus_slope_half.obj diff --git a/models/moreblocks_slope_half_raised.obj b/stairsplus/models/stairsplus_slope_half_raised.obj similarity index 100% rename from models/moreblocks_slope_half_raised.obj rename to stairsplus/models/stairsplus_slope_half_raised.obj diff --git a/models/moreblocks_slope_inner.obj b/stairsplus/models/stairsplus_slope_inner.obj similarity index 100% rename from models/moreblocks_slope_inner.obj rename to stairsplus/models/stairsplus_slope_inner.obj diff --git a/models/moreblocks_slope_inner_cut.obj b/stairsplus/models/stairsplus_slope_inner_cut.obj similarity index 100% rename from models/moreblocks_slope_inner_cut.obj rename to stairsplus/models/stairsplus_slope_inner_cut.obj diff --git a/models/moreblocks_slope_inner_cut_half.obj b/stairsplus/models/stairsplus_slope_inner_cut_half.obj similarity index 100% rename from models/moreblocks_slope_inner_cut_half.obj rename to stairsplus/models/stairsplus_slope_inner_cut_half.obj diff --git a/models/moreblocks_slope_inner_cut_half_raised.obj b/stairsplus/models/stairsplus_slope_inner_cut_half_raised.obj similarity index 100% rename from models/moreblocks_slope_inner_cut_half_raised.obj rename to stairsplus/models/stairsplus_slope_inner_cut_half_raised.obj diff --git a/models/moreblocks_slope_inner_half.obj b/stairsplus/models/stairsplus_slope_inner_half.obj similarity index 100% rename from models/moreblocks_slope_inner_half.obj rename to stairsplus/models/stairsplus_slope_inner_half.obj diff --git a/models/moreblocks_slope_inner_half_raised.obj b/stairsplus/models/stairsplus_slope_inner_half_raised.obj similarity index 100% rename from models/moreblocks_slope_inner_half_raised.obj rename to stairsplus/models/stairsplus_slope_inner_half_raised.obj diff --git a/models/moreblocks_slope_outer.obj b/stairsplus/models/stairsplus_slope_outer.obj similarity index 100% rename from models/moreblocks_slope_outer.obj rename to stairsplus/models/stairsplus_slope_outer.obj diff --git a/models/moreblocks_slope_outer_cut.obj b/stairsplus/models/stairsplus_slope_outer_cut.obj similarity index 100% rename from models/moreblocks_slope_outer_cut.obj rename to stairsplus/models/stairsplus_slope_outer_cut.obj diff --git a/models/moreblocks_slope_outer_cut_half.obj b/stairsplus/models/stairsplus_slope_outer_cut_half.obj similarity index 100% rename from models/moreblocks_slope_outer_cut_half.obj rename to stairsplus/models/stairsplus_slope_outer_cut_half.obj diff --git a/models/moreblocks_slope_outer_cut_half_raised.obj b/stairsplus/models/stairsplus_slope_outer_cut_half_raised.obj similarity index 100% rename from models/moreblocks_slope_outer_cut_half_raised.obj rename to stairsplus/models/stairsplus_slope_outer_cut_half_raised.obj diff --git a/models/moreblocks_slope_outer_half.obj b/stairsplus/models/stairsplus_slope_outer_half.obj similarity index 100% rename from models/moreblocks_slope_outer_half.obj rename to stairsplus/models/stairsplus_slope_outer_half.obj diff --git a/models/moreblocks_slope_outer_half_raised.obj b/stairsplus/models/stairsplus_slope_outer_half_raised.obj similarity index 100% rename from models/moreblocks_slope_outer_half_raised.obj rename to stairsplus/models/stairsplus_slope_outer_half_raised.obj diff --git a/stairsplus/panels.lua b/stairsplus/panels.lua deleted file mode 100644 index 40f33204..00000000 --- a/stairsplus/panels.lua +++ /dev/null @@ -1,43 +0,0 @@ ---[[ -More Blocks: panel definitions - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - --- Node will be called :panel_ - --- luacheck: no unused -local function register_panel(modname, subname, recipeitem, groups, images, description, drop, light) - stairsplus:register_panel(modname, subname, recipeitem, { - groups = groups, - tiles = images, - description = description, - drop = drop, - light_source = light, - sounds = moreblocks.node_sound_stone_defaults(), - }) -end - -function stairsplus:register_panel_alias(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["panel"]) - for alternate, def in pairs(defs) do - minetest.register_alias(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate) - end -end - -function stairsplus:register_panel_alias_force(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["panel"]) - for alternate, def in pairs(defs) do - minetest.register_alias_force(modname_old .. ":panel_" .. subname_old .. alternate, modname_new .. ":panel_" .. subname_new .. alternate) - end -end - -function stairsplus:register_panel(modname, subname, recipeitem, fields) - local defs = table.copy(stairsplus.defs["panel"]) - for alternate, def in pairs(defs) do - stairsplus.register_single("panel", alternate, def, modname, subname, recipeitem, fields) - end - - circular_saw.known_nodes[recipeitem] = {modname, subname} -end diff --git a/stairsplus/recipes.lua b/stairsplus/recipes.lua deleted file mode 100644 index c9aaa29a..00000000 --- a/stairsplus/recipes.lua +++ /dev/null @@ -1,443 +0,0 @@ ---[[ -More Blocks: Stairs+ - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - - -stairsplus.register_recipes = function(category, alternate, modname, subname, recipeitem) - if category == "micro" and alternate == "" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":micro_" .. subname .. " 7", - recipe = {modname .. ":stair_" .. subname .. "_inner"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":micro_" .. subname .. " 6", - recipe = {modname .. ":stair_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":micro_" .. subname .. " 5", - recipe = {modname .. ":stair_" .. subname .. "_outer"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":micro_" .. subname .. " 4", - recipe = {modname .. ":slab_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":micro_" .. subname .. " 4", - recipe = {modname .. ":stair_" .. subname .. "_alt"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":micro_" .. subname .. " 3", - recipe = {modname .. ":stair_" .. subname .. "_right_half"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":micro_" .. subname .. " 2", - recipe = {modname .. ":panel_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, - }) - - minetest.register_alias(modname .. ":micro_" .. subname .. "_bottom", modname .. ":micro_" .. subname) - elseif category == "panel" and alternate == "" then - minetest.register_craft({ - output = modname .. ":panel_" .. subname .. " 12", - recipe = { - {recipeitem, ""}, - {recipeitem, recipeitem}, - }, - }) - - minetest.register_craft({ - output = modname .. ":panel_" .. subname .. " 12", - recipe = { - {"", recipeitem}, - {recipeitem, recipeitem}, - }, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":panel_" .. subname, - recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":panel_" .. subname, modname .. ":panel_" .. subname, modname .. ":panel_" .. subname, modname .. ":panel_" .. subname}, - }) - - minetest.register_alias(modname.. ":panel_" ..subname.. "_bottom", modname.. ":panel_" ..subname) - elseif category == "slab" then - if alternate == "" then - minetest.register_craft({ - output = modname .. ":slab_" .. subname .. " 6", - recipe = {{recipeitem, recipeitem, recipeitem}}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname, - recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, - }) - - -- uncomment this rule when conflict is no longer likely to happen - -- https://github.com/minetest/minetest/issues/2881 - -- minetest.register_craft({ - -- type = "shapeless", - -- output = modname .. ":slab_" .. subname, - -- recipe = {modname .. ":panel_" .. subname, modname .. ":panel_" .. subname}, - -- }) - - -- then remove these two - minetest.register_craft({ - output = modname .. ":slab_" .. subname, - recipe = {{modname .. ":panel_" .. subname, modname .. ":panel_" .. subname}}, - }) - - minetest.register_craft({ - output = modname .. ":slab_" .. subname, - recipe = { - {modname .. ":panel_" .. subname}, - {modname .. ":panel_" .. subname}, - }, - }) - ------------------------------ - - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slab_" .. subname, modname .. ":slab_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. " 3", - recipe = {modname .. ":stair_" .. subname, modname .. ":stair_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname, - recipe = {modname .. ":slab_" .. subname .. "_quarter", modname .. ":slab_" .. subname .. "_quarter"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname, - recipe = {modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname, - recipe = {modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname, - recipe = {modname .. ":slope_" .. subname .. "_half", modname .. ":slope_" .. subname .. "_half"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname, - recipe = {modname .. ":slope_" .. subname .. "_outer_half", modname .. ":slope_" .. subname .. "_inner_half"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname, - recipe = {modname .. ":slope_" .. subname .. "_outer_cut_half", modname .. ":slope_" .. subname .. "_inner_cut_half"}, - }) - elseif alternate == "_quarter" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slab_" .. subname .. "_quarter", modname .. ":slab_" .. subname .. "_quarter", modname .. ":slab_" .. subname .. "_quarter", modname .. ":slab_" .. subname .. "_quarter"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slab_" .. subname .. "_three_quarter", modname .. ":slab_" .. subname .. "_quarter"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_quarter", - recipe = {modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_quarter", - recipe = {modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1"}, - }) - elseif alternate == "_three_quarter" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_three_quarter", - recipe = {modname .. ":slab_" .. subname, modname .. ":slab_" .. subname .. "_quarter"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_three_quarter", - recipe = {modname .. ":slab_" .. subname .. "_quarter", modname .. ":slab_" .. subname .. "_quarter", modname .. ":slab_" .. subname .. "_quarter"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_three_quarter", - recipe = {modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2"}, - }) - elseif alternate == "_2" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slab_" .. subname .. "_14", modname .. ":slab_" .. subname .. "_2"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_2", - recipe = {modname .. ":slab_" .. subname .. "_1", modname .. ":slab_" .. subname .. "_1"}, - }) - elseif alternate == "_14" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_14", - recipe = {modname .. ":slab_" .. subname .. "_three_quarter", modname .. ":slab_" .. subname .. "_2"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_14", - recipe = {modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2", modname .. ":slab_" .. subname .. "_2"}, - }) - elseif alternate == "_15" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slab_" .. subname .. "_15", modname .. ":slab_" .. subname .. "_1"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slab_" .. subname .. "_15", - recipe = {modname .. ":slab_" .. subname .. "_14", modname .. ":slab_" .. subname .. "_1"}, - }) - end - elseif category == "slope" then - if alternate == "" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname, modname .. ":slope_" .. subname}, - }) - elseif alternate == "_half" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname .. "_half", modname .. ":slope_" .. subname .. "_half_raised"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname .. "_half", modname .. ":slope_" .. subname .. "_half", - modname .. ":slope_" .. subname .. "_half", modname .. ":slope_" .. subname .. "_half"}, - }) - elseif alternate == "_outer" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname .. "_outer", modname .. ":slope_" .. subname .. "_inner"}, - }) - elseif alternate == "_outer_half" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname .. "_outer_half", modname .. ":slope_" .. subname .. "_inner_half_raised"}, - }) - elseif alternate == "_inner_half" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname .. "_outer_half_raised", modname .. ":slope_" .. subname .. "_inner_half"}, - }) - elseif alternate == "_outer_cut" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname .. "_outer_cut", modname .. ":slope_" .. subname .. "_inner_cut"}, - }) - elseif alternate == "_outer_cut_half" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname .. "_outer_cut_half", modname .. ":slope_" .. subname .. "_inner_cut_half_raised"}, - }) - elseif alternate == "_cut" then - minetest.register_craft({ - type = "shapeless", - output = recipeitem, - recipe = {modname .. ":slope_" .. subname .. "_cut", modname .. ":slope_" .. subname .. "_cut"}, - }) - elseif alternate == "_half_raised" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slope_" .. subname .. "_half_raised", - recipe = {modname .. ":slope_" .. subname .. "_half", modname .. ":slope_" .. subname .. "_half", - modname .. ":slope_" .. subname .. "_half"}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slope_" .. subname .. "_half_raised", - recipe = {modname .. ":slab_" .. subname, modname .. ":slope_" .. subname .. "_half"}, - }) - elseif alternate == "_inner_half_raised" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slope_" .. subname .. "_inner_half_raised", - recipe = {modname .. ":slab_" .. subname, modname .. ":slope_" .. subname .. "_inner_half"}, - }) - elseif alternate == "_outer_half_raised" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slope_" .. subname .. "_outer_half_raised", - recipe = {modname .. ":slab_" .. subname, modname .. ":slope_" .. subname .. "_outer_half"}, - }) - elseif alternate == "_inner_cut_half_raised" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":slope_" .. subname .. "_inner_cut_half_raised", - recipe = {modname .. ":slab_" .. subname, modname .. ":slope_" .. subname .. "_inner_cut_half"}, - }) - end - elseif category == "stair" then - if alternate == "" then - minetest.register_craft({ - output = modname .. ":stair_" .. subname .. " 8", - recipe = { - {recipeitem, "", ""}, - {recipeitem, recipeitem, ""}, - {recipeitem, recipeitem, recipeitem}, - }, - }) - - minetest.register_craft({ - output = modname .. ":stair_" .. subname .. " 8", - recipe = { - {"", "", recipeitem}, - {"", recipeitem, recipeitem}, - {recipeitem, recipeitem, recipeitem}, - }, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname, - recipe = {modname .. ":panel_" .. subname, modname .. ":slab_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname, - recipe = {modname .. ":panel_" .. subname, modname .. ":panel_" .. subname, modname .. ":panel_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname, - recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname, - recipe = {modname .. ":panel_" .. subname, modname .. ":panel_" .. subname, modname .. ":panel_" .. subname}, - }) - elseif alternate == "_inner" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname .. "_inner", - recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, - }) - elseif alternate == "_outer" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname .. "_outer", - recipe = {modname .. ":micro_" .. subname, modname .. ":slab_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname .. "_outer", - recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, - }) - elseif alternate == "_half" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname .. "_half", - recipe = {modname .. ":micro_" .. subname, modname .. ":micro_" .. subname, modname .. ":micro_" .. subname}, - }) - - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname .. "_half", - recipe = {modname .. ":panel_" .. subname, modname .. ":micro_" .. subname}, - }) - elseif alternate == "_right_half" then - minetest.register_craft({ - type = "shapeless", - output = modname .. ":stair_" .. subname .. "_right_half", - recipe = {modname .. ":stair_" .. subname .. "_half"}, - }) - elseif alternate == "_alt" then - minetest.register_craft({ -- See mirrored variation of the recipe below. - output = modname .. ":stair_" .. subname .. "_alt", - recipe = { - {modname .. ":panel_" .. subname, ""}, - {"" , modname .. ":panel_" .. subname}, - }, - }) - - minetest.register_craft({ -- Mirrored variation of the recipe above. - output = modname .. ":stair_" .. subname .. "_alt", - recipe = { - {"" , modname .. ":panel_" .. subname}, - {modname .. ":panel_" .. subname, ""}, - }, - }) - end - end -end diff --git a/stairsplus/registrations.lua b/stairsplus/registrations.lua deleted file mode 100644 index 023dbf92..00000000 --- a/stairsplus/registrations.lua +++ /dev/null @@ -1,163 +0,0 @@ ---[[ -More Blocks: registrations - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] -local S = moreblocks.S --- default registrations -if minetest.get_modpath("default") then - local default_nodes = { -- Default stairs/slabs/panels/microblocks: - "stone", - "stone_block", - "cobble", - "mossycobble", - "brick", - "sandstone", - "steelblock", - "goldblock", - "copperblock", - "bronzeblock", - "diamondblock", - "tinblock", - "desert_stone", - "desert_stone_block", - "desert_cobble", - "meselamp", - "glass", - "tree", - "wood", - "jungletree", - "junglewood", - "pine_tree", - "pine_wood", - "acacia_tree", - "acacia_wood", - "aspen_tree", - "aspen_wood", - "obsidian", - "obsidian_block", - "obsidianbrick", - "obsidian_glass", - "stonebrick", - "desert_stonebrick", - "sandstonebrick", - "silver_sandstone", - "silver_sandstone_brick", - "silver_sandstone_block", - "desert_sandstone", - "desert_sandstone_brick", - "desert_sandstone_block", - "sandstone_block", - "coral_skeleton", - "ice", - } - - for _, name in pairs(default_nodes) do - local mod = "default" - local nodename = mod .. ":" .. name - local ndef = table.copy(minetest.registered_nodes[nodename]) - ndef.sunlight_propagates = true - - -- Stone and desert_stone drop cobble and desert_cobble respectively. - if type(ndef.drop) == "string" then - ndef.drop = ndef.drop:gsub(".+:", "") - end - - -- Use the primary tile for all sides of cut glasslike nodes and disregard paramtype2. - if #ndef.tiles > 1 and ndef.drawtype and ndef.drawtype:find("glass") then - ndef.tiles = {ndef.tiles[1]} - ndef.paramtype2 = nil - end - - mod = "moreblocks" - stairsplus:register_all(mod, name, nodename, ndef) - minetest.register_alias_force("stairs:stair_" .. name, mod .. ":stair_" .. name) - minetest.register_alias_force("stairs:stair_outer_" .. name, mod .. ":stair_" .. name .. "_outer") - minetest.register_alias_force("stairs:stair_inner_" .. name, mod .. ":stair_" .. name .. "_inner") - minetest.register_alias_force("stairs:slab_" .. name, mod .. ":slab_" .. name) - end -end - --- farming registrations -if minetest.get_modpath("farming") then - local farming_nodes = {"straw"} - for _, name in pairs(farming_nodes) do - local mod = "farming" - local nodename = mod .. ":" .. name - local ndef = table.copy(minetest.registered_nodes[nodename]) - ndef.sunlight_propagates = true - - mod = "moreblocks" - stairsplus:register_all(mod, name, nodename, ndef) - minetest.register_alias_force("stairs:stair_" .. name, mod .. ":stair_" .. name) - minetest.register_alias_force("stairs:stair_outer_" .. name, mod .. ":stair_" .. name .. "_outer") - minetest.register_alias_force("stairs:stair_inner_" .. name, mod .. ":stair_" .. name .. "_inner") - minetest.register_alias_force("stairs:slab_" .. name, mod .. ":slab_" .. name) - end -end - --- wool registrations -if minetest.get_modpath("wool") then - local dyes = {"white", "grey", "black", "red", "yellow", "green", "cyan", - "blue", "magenta", "orange", "violet", "brown", "pink", - "dark_grey", "dark_green"} - for _, name in pairs(dyes) do - local mod = "wool" - local nodename = mod .. ":" .. name - local ndef = table.copy(minetest.registered_nodes[nodename]) - ndef.sunlight_propagates = true - - stairsplus:register_all(mod, name, nodename, ndef) - end -end - --- basic_materials, keeping the original other-mod-oriented names --- for backwards compatibility - -if minetest.get_modpath("basic_materials") then - stairsplus:register_all("technic","concrete","basic_materials:concrete_block",{ - description = S("Concrete"), - tiles = {"basic_materials_concrete_block.png",}, - groups = {cracky=1, level=2, concrete=1}, - sounds = moreblocks.node_sound_stone_defaults(), - }) - - minetest.register_alias("prefab:concrete_stair","technic:stair_concrete") - minetest.register_alias("prefab:concrete_slab","technic:slab_concrete") - - stairsplus:register_all("gloopblocks", "cement", "basic_materials:cement_block", { - description = S("Cement"), - tiles = {"basic_materials_cement_block.png"}, - groups = {cracky=2, not_in_creative_inventory=1}, - sounds = moreblocks.node_sound_stone_defaults(), - sunlight_propagates = true, - }) - - stairsplus:register_all("technic", "brass_block", "basic_materials:brass_block", { - description= S("Brass Block"), - groups={cracky=1, not_in_creative_inventory=1}, - tiles={"basic_materials_brass_block.png"}, - }) - -end - --- Alias cuts of split_stone_tile_alt which was renamed checker_stone_tile. -stairsplus:register_alias_all("moreblocks", "split_stone_tile_alt", "moreblocks", "checker_stone_tile") - --- The following LBM is necessary because the name stair_split_stone_tile_alt --- conflicts with another node and so the alias for that specific node gets --- ignored. -minetest.register_lbm({ - name = "moreblocks:fix_split_stone_tile_alt_name_collision", - nodenames = {"moreblocks:stair_split_stone_tile_alt"}, - action = function(pos, node) - minetest.set_node(pos, { - name = "moreblocks:stair_checker_stone_tile", - param2 = minetest.get_node(pos).param2 - - }) - minetest.log('action', "LBM replaced " .. node.name .. - " at " .. minetest.pos_to_string(pos)) - end, -}) diff --git a/stairsplus/resources/craft_materials.lua b/stairsplus/resources/craft_materials.lua new file mode 100644 index 00000000..5c3475ad --- /dev/null +++ b/stairsplus/resources/craft_materials.lua @@ -0,0 +1,9 @@ +local table_set_all = stairsplus.util.table_set_all + +stairsplus.resources.craft_materials = {} + +if stairsplus.has.default then + table_set_all(stairsplus.resources.craft_materials, { + steel_ingot = "default:steel_ingot", + }) +end diff --git a/stairsplus/resources/formspec_styling.lua b/stairsplus/resources/formspec_styling.lua new file mode 100644 index 00000000..1db52635 --- /dev/null +++ b/stairsplus/resources/formspec_styling.lua @@ -0,0 +1,7 @@ + +stairsplus.resources.formspec_style = "" + +if stairsplus.has.default then + -- prepend background and slot styles from default if available + stairsplus.resources.formspec_style = default.gui_bg .. default.gui_bg_img .. default.gui_slots +end diff --git a/stairsplus/resources/init.lua b/stairsplus/resources/init.lua new file mode 100644 index 00000000..8b13d259 --- /dev/null +++ b/stairsplus/resources/init.lua @@ -0,0 +1,4 @@ +stairsplus.resources = {} + +stairsplus.dofile("resources", "craft_materials") +stairsplus.dofile("resources", "sounds") diff --git a/stairsplus/resources/sounds.lua b/stairsplus/resources/sounds.lua new file mode 100644 index 00000000..c76317f5 --- /dev/null +++ b/stairsplus/resources/sounds.lua @@ -0,0 +1,9 @@ +local table_set_all = stairsplus.util.table_set_all + +stairsplus.resources.sounds = {} + +if stairsplus.has.default then + table_set_all(stairsplus.resources.sounds, { + wood = default.node_sound_wood_defaults(), + }) +end diff --git a/stairsplus/settings.lua b/stairsplus/settings.lua new file mode 100644 index 00000000..fad48f7b --- /dev/null +++ b/stairsplus/settings.lua @@ -0,0 +1,31 @@ +local s = minetest.settings + +stairsplus.settings = { + circular_saw_crafting = s:get_bool("stairsplus.circular_saw_crafting", true), + ex_nihilo = s:get_bool("stairsplus.ex_nihilo", + s:get_bool("creative_mode", false) + ), + + in_creative_inventory = s:get_bool("stairsplus.in_creative_inventory", + s:get_bool("moreblocks.stairsplus_in_creative_inventory", true) + ), + in_craft_guide = s:get_bool("stairsplus.in_craft_guide", true), + + default_align_style = s:get("stairsplus.default_align_style") or "user", + + basic_shapes = string.split(s:get("stairsplus.common_shapes") or table.concat({ + "micro_8", "slab_8", "stair", "stair_inner", "stair_outer", + }, ","), ","), + common_shapes = string.split(s:get("stairsplus.common_shapes") or table.concat({ + "micro_8", "panel_8", "slab_1", "slab_8", "stair", "stair_inner", "stair_outer", + "slope", "slope_half", "slope_half_raised", "slope_inner", "slope_inner_cut", "slope_inner_half", + "slope_inner_cut_half", "slope_inner_half_raised", "slope_inner_cut_half_raised", "slope_outer", + "slope_outer_cut", "slope_cut", "slope_outer_half", "slope_outer_cut_half", "slope_outer_half_raised", + "slope_outer_cut_half_raised", + }, ","), ","), + + legacy_mode = s:get_bool("stairsplus.legacy_mode", true), + legacy_place_mechanic = s:get_bool("stairsplus.legacy_place_mechanic", true), + + crafting_schemata_enabled = s:get_bool("stairsplus.crafting_schemata_enabled", true), +} diff --git a/stairsplus/shapes/init.lua b/stairsplus/shapes/init.lua new file mode 100644 index 00000000..7a04245d --- /dev/null +++ b/stairsplus/shapes/init.lua @@ -0,0 +1,8 @@ +stairsplus.dofile("shapes", "micros") +stairsplus.dofile("shapes", "panels") +stairsplus.dofile("shapes", "slabs") +stairsplus.dofile("shapes", "slopes") +stairsplus.dofile("shapes", "stairs") + +stairsplus.api.register_shape_group("basic", stairsplus.settings.basic_shapes) +stairsplus.api.register_shape_group("common", stairsplus.settings.common_shapes) diff --git a/stairsplus/shapes/micros.lua b/stairsplus/shapes/micros.lua new file mode 100644 index 00000000..29c1b58e --- /dev/null +++ b/stairsplus/shapes/micros.lua @@ -0,0 +1,85 @@ +stairsplus.api.register_shape("micro_1", { + name_format = "micro_%s_1", + description = "@1 1/16 Microblock", + shape_groups = {micro = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5}, + }, +}) + +stairsplus.api.register_shape("micro_2", { + name_format = "micro_%s_2", + description = "@1 1/8 Microblock", + shape_groups = {micro = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0, -0.375, 0.5}, + }, +}) + +stairsplus.api.register_shape("micro_4", { + name_format = "micro_%s_4", + description = "@1 1/4 Microblock", + shape_groups = {micro = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0, -0.25, 0.5}, + }, +}) + +stairsplus.api.register_shape("micro_8", { + name_format = "micro_%s_8", + aliases = {"micro_%s", "micro_%s_bottom"}, + description = "@1 Microblock", -- leave out the 1/2 to not confuse people too much... + shape_groups = {micro = 1, obligatory = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0, 0, 0.5}, + }, +}) + +stairsplus.api.register_shape("micro_12", { + name_format = "micro_%s_12", + description = "@1 3/4 Microblock", + shape_groups = {micro = 1, legacy = 1}, + eighths = 2, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5}, + }, +}) + +stairsplus.api.register_shape("micro_14", { + name_format = "micro_%s_14", + description = "@1 7/8 Microblock", + shape_groups = {micro = 1, legacy = 1}, + eighths = 2, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0, 0.375, 0.5}, + }, +}) + +stairsplus.api.register_shape("micro_15", { + name_format = "micro_%s_15", + aliases = {"micro_%s_5"}, + description = "@1 15/16 Microblock", + shape_groups = {micro = 1, legacy = 1}, + eighths = 2, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0, 0.4375, 0.5}, + }, +}) diff --git a/stairsplus/shapes/panels.lua b/stairsplus/shapes/panels.lua new file mode 100644 index 00000000..1cf01e18 --- /dev/null +++ b/stairsplus/shapes/panels.lua @@ -0,0 +1,84 @@ +stairsplus.api.register_shape("panel_1", { + name_format = "panel_%s_1", + description = "@1 1/16 Panel", + shape_groups = {panel = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5}, + }, +}) + +stairsplus.api.register_shape("panel_2", { + name_format = "panel_%s_2", + description = "@1 1/8 Panel", + shape_groups = {panel = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5}, + }, +}) + +stairsplus.api.register_shape("panel_4", { + name_format = "panel_%s_4", + description = "@1 1/4 Panel", + shape_groups = {panel = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0.5, -0.25, 0.5}, + }, +}) + +stairsplus.api.register_shape("panel_8", { + name_format = "panel_%s_8", + aliases = {"panel_%s", "panel_bottom_%s"}, + description = "@1 1/2 Panel", + shape_groups = {panel = 1, legacy = 1}, + eighths = 2, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0.5, 0, 0.5}, + }, +}) + +stairsplus.api.register_shape("panel_12", { + name_format = "panel_%s_12", + description = "@1 3/4 Panel", + shape_groups = {panel = 1, legacy = 1}, + eighths = 3, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5}, + }, +}) + +stairsplus.api.register_shape("panel_14", { + name_format = "panel_%s_14", + description = "@1 7/8 Panel", + shape_groups = {panel = 1, legacy = 1}, + eighths = 4, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5}, + }, +}) + +stairsplus.api.register_shape("panel_15", { + name_format = "panel_%s_15", + description = "@1 15/16 Panel", + shape_groups = {panel = 1, legacy = 1}, + eighths = 4, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, 0, 0.5, 0.4375, 0.5}, + }, +}) diff --git a/stairsplus/shapes/slabs.lua b/stairsplus/shapes/slabs.lua new file mode 100644 index 00000000..e13d6fb5 --- /dev/null +++ b/stairsplus/shapes/slabs.lua @@ -0,0 +1,135 @@ +stairsplus.api.register_shape("slab_1", { + name_format = "slab_%s_1", + description = "@1 1/16 Slab", + shape_groups = {slab = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}, + }, +}) + +stairsplus.api.register_shape("slab_2", { + name_format = "slab_%s_2", + description = "@1 1/8 Slab", + shape_groups = {slab = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5}, + }, +}) + +stairsplus.api.register_shape("slab_4", { + name_format = "slab_%s_4", + aliases = {"slab_%s_quarter"}, + description = "@1 1/4 Slab", + shape_groups = {slab = 1, legacy = 1}, + eighths = 2, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5}, + }, +}) + +stairsplus.api.register_shape("slab_8", { + name_format = "slab_%s_8", + aliases = {"slab_%s"}, + description = "@1 1/2 Slab", + shape_groups = {slab = 1, legacy = 1}, + eighths = 4, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + }, +}) + +stairsplus.api.register_shape("slab_12", { + name_format = "slab_%s_12", + aliases = {"slab_%s_three_quarter"}, + description = "@1 3/4 Slab", + shape_groups = {slab = 1, legacy = 1}, + eighths = 6, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0.25, 0.5}, + }, +}) + +stairsplus.api.register_shape("slab_14", { + name_format = "slab_%s_14", + description = "@1 7/8 Slab", + shape_groups = {slab = 1, legacy = 1}, + eighths = 7, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0.375, 0.5}, + }, +}) + +stairsplus.api.register_shape("slab_15", { + name_format = "slab_%s_15", + description = "@1 15/16 Slab", + shape_groups = {slab = 1, legacy = 1}, + eighths = 7, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5}, + }, +}) + +--- these terrible things + +stairsplus.api.register_shape("slab_two_sides", { + name_format = "slab_%s_two_sides", + description = "@1 1/16 Slab Two Sides", + shape_groups = {slab = 1, legacy = 1}, + eighths = 2, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -7 / 16, 7 / 16}, + {-0.5, -0.5, 7 / 16, 0.5, 0.5, 0.5} + }, + }, +}) + +stairsplus.api.register_shape("slab_three_sides", { + name_format = "slab_%s_three_sides", + description = "@1 1/16 Slab Three Sides", + shape_groups = {slab = 1, legacy = 1}, + eighths = 3, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-7 / 16, -0.5, -0.5, 0.5, -7 / 16, 7 / 16}, + {-7 / 16, -0.5, 7 / 16, 0.5, 0.5, 0.5}, + {-0.5, -0.5, -0.5, -7 / 16, 0.5, 0.5} + }, + }, +}) + +stairsplus.api.register_shape("slab_three_sides_u", { + name_format = "slab_%s_three_sides_u", + description = "@1 1/16 Slab Three Sides U", + shape_groups = {slab = 1, legacy = 1}, + eighths = 3, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, -7 / 16}, + {-0.5, -0.5, -7 / 16, 0.5, -7 / 16, 7 / 16}, + {-0.5, -0.5, 7 / 16, 0.5, 0.5, 0.5} + }, + }, +}) diff --git a/stairsplus/shapes/slopes.lua b/stairsplus/shapes/slopes.lua new file mode 100644 index 00000000..d87c8c2a --- /dev/null +++ b/stairsplus/shapes/slopes.lua @@ -0,0 +1,276 @@ +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} + } +} + +stairsplus.api.register_shape("slope", { + name_format = "slope_%s", + description = "@1 Slope", + shape_groups = {slope = 1, legacy = 1}, + eighths = 4, + drawtype = "mesh", + mesh = "stairsplus_slope.obj", + collision_box = box_slope, + selection_box = box_slope, +}) + +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}, + } +} + +stairsplus.api.register_shape("slope_half", { + name_format = "slope_%s_half", + description = "@1 1/2 Slope", + shape_groups = {slope = 1, legacy = 1}, + eighths = 2, + drawtype = "mesh", + mesh = "stairsplus_slope_half.obj", + collision_box = box_slope_half, + selection_box = box_slope_half, +}) + +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}, + } +} + +stairsplus.api.register_shape("slope_half_raised", { + name_format = "slope_%s_half_raised", + description = "@1 1/2 Slope Raised", + shape_groups = {slope = 1, legacy = 1}, + eighths = 6, + drawtype = "mesh", + mesh = "stairsplus_slope_half_raised.obj", + collision_box = box_slope_half_raised, + selection_box = box_slope_half_raised, +}) + +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}, + } +} + +stairsplus.api.register_shape("slope_inner", { + name_format = "slope_%s_inner", + description = "@1 Slope Inner", + shape_groups = {slope = 1, legacy = 1}, + eighths = 6, + drawtype = "mesh", + mesh = "stairsplus_slope_inner.obj", + collision_box = box_slope_inner, + selection_box = box_slope_inner, +}) + +stairsplus.api.register_shape("slope_inner_cut", { + name_format = "slope_%s_inner_cut", + description = "@1 Slope Inner Cut", + shape_groups = {slope = 1, legacy = 1}, + eighths = 6, + drawtype = "mesh", + mesh = "stairsplus_slope_inner_cut.obj", + collision_box = box_slope_inner, + selection_box = box_slope_inner, +}) + +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}, + } +} + +stairsplus.api.register_shape("slope_inner_half", { + name_format = "slope_%s_inner_half", + description = "@1 Slope Inner Half", + shape_groups = {slope = 1, legacy = 1}, + eighths = 3, + drawtype = "mesh", + mesh = "stairsplus_slope_inner_half.obj", + collision_box = box_slope_inner_half, + selection_box = box_slope_inner_half, +}) + +stairsplus.api.register_shape("slope_inner_cut_half", { + name_format = "slope_%s_inner_cut_half", + description = "@1 Slope Inner Cut Half", + shape_groups = {slope = 1, legacy = 1}, + eighths = 4, + drawtype = "mesh", + mesh = "stairsplus_slope_inner_cut_half.obj", + collision_box = box_slope_inner_half, + selection_box = box_slope_inner_half, +}) + +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}, + } +} + +stairsplus.api.register_shape("slope_inner_half_raised", { + name_format = "slope_%s_inner_half_raised", + description = "@1 Slope Inner Half Raised", + shape_groups = {slope = 1, legacy = 1}, + eighths = 6, + drawtype = "mesh", + mesh = "stairsplus_slope_inner_half_raised.obj", + collision_box = box_slope_inner_half_raised, + selection_box = box_slope_inner_half_raised, +}) + +stairsplus.api.register_shape("slope_inner_cut_half_raised", { + name_format = "slope_%s_inner_cut_half_raised", + description = "@1 Slope Inner Cut Half Raised", + shape_groups = {slope = 1, legacy = 1}, + eighths = 7, + drawtype = "mesh", + mesh = "stairsplus_slope_inner_cut_half_raised.obj", + collision_box = box_slope_inner_half_raised, + selection_box = box_slope_inner_half_raised, +}) + +--============================================================== + +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} + } +} + +stairsplus.api.register_shape("slope_outer", { + name_format = "slope_%s_outer", + description = "@1 Slope Outer", + shape_groups = {slope = 1, legacy = 1}, + eighths = 3, + drawtype = "mesh", + mesh = "stairsplus_slope_outer.obj", + collision_box = box_slope_outer, + selection_box = box_slope_outer, +}) + +stairsplus.api.register_shape("slope_outer_cut", { + name_format = "slope_%s_outer_cut", + description = "@1 Slope Outer Cut", + shape_groups = {slope = 1, legacy = 1}, + eighths = 2, + drawtype = "mesh", + mesh = "stairsplus_slope_outer_cut.obj", + collision_box = box_slope_outer, + selection_box = box_slope_outer, +}) + +stairsplus.api.register_shape("slope_cut", { + name_format = "slope_%s_cut", + description = "@1 Slope Cut", + shape_groups = {slope = 1, legacy = 1}, + eighths = 4, + drawtype = "mesh", + mesh = "stairsplus_slope_cut.obj", + collision_box = box_slope_outer, + selection_box = box_slope_outer, +}) + +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} + } +} + +stairsplus.api.register_shape("slope_outer_half", { + name_format = "slope_%s_outer_half", + description = "@1 Slope Outer Half", + shape_groups = {slope = 1, legacy = 1}, + eighths = 2, + drawtype = "mesh", + mesh = "stairsplus_slope_outer_half.obj", + collision_box = box_slope_outer_half, + selection_box = box_slope_outer_half, +}) + +stairsplus.api.register_shape("slope_outer_cut_half", { + name_format = "slope_%s_outer_cut_half", + description = "@1 Slope Outer Cut Half", + shape_groups = {slope = 1, legacy = 1}, + eighths = 1, + drawtype = "mesh", + mesh = "stairsplus_slope_outer_cut_half.obj", + collision_box = box_slope_outer_half, + selection_box = box_slope_outer_half, +}) + +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} + } +} + +stairsplus.api.register_shape("slope_outer_half_raised", { + name_format = "slope_%s_outer_half_raised", + description = "@1 Slope Outer Half Raised", + shape_groups = {slope = 1, legacy = 1}, + eighths = 6, + drawtype = "mesh", + mesh = "stairsplus_slope_outer_half_raised.obj", + collision_box = box_slope_outer_half_raised, + selection_box = box_slope_outer_half_raised, +}) + +stairsplus.api.register_shape("slope_outer_cut_half_raised", { + name_format = "slope_%s_outer_cut_half_raised", + description = "@1 Slope Outer Cut Half Raised", + shape_groups = {slope = 1, legacy = 1}, + eighths = 3, + drawtype = "mesh", + mesh = "stairsplus_slope_outer_cut_half_raised.obj", + collision_box = box_slope_outer_half_raised, + selection_box = box_slope_outer_half_raised, +}) diff --git a/stairsplus/shapes/stairs.lua b/stairsplus/shapes/stairs.lua new file mode 100644 index 00000000..14d3ef1b --- /dev/null +++ b/stairsplus/shapes/stairs.lua @@ -0,0 +1,136 @@ +stairsplus.api.register_shape("stair_half", { + name_format = "stair_%s_half", + description = "@1 Half Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 3, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0, 0, 0.5}, + {-0.5, 0, 0, 0, 0.5, 0.5}, + }, + }, +}) + +stairsplus.api.register_shape("stair_right_half", { + name_format = "stair_%s_right_half", + description = "@1 Right Half Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 3, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {0, -0.5, -0.5, 0.5, 0, 0.5}, + {0, 0, 0, 0.5, 0.5, 0.5}, + }, + }, +}) + +stairsplus.api.register_shape("stair", { + name_format = "stair_%s", + description = "@1 Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 6, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + {-0.5, 0, 0, 0.5, 0.5, 0.5}, + }, + }, +}) + +stairsplus.api.register_shape("stair_inner", { + name_format = "stair_%s_inner", + description = "@1 Inner Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 7, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + {-0.5, 0, 0, 0.5, 0.5, 0.5}, + {-0.5, 0, -0.5, 0, 0.5, 0}, + }, + }, +}) + +stairsplus.api.register_shape("stair_outer", { + name_format = "stair_%s_outer", + description = "@1 Outer Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 5, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, + {-0.5, 0, 0, 0, 0.5, 0.5}, + }, + }, +}) + +stairsplus.api.register_shape("stair_alt_1", { + name_format = "stair_%s_alt_1", + description = "@1 1/16 Alt Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.0625, -0.5, 0.5, 0, 0}, + {-0.5, 0.4375, 0, 0.5, 0.5, 0.5}, + }, + }, +}) + +stairsplus.api.register_shape("stair_alt_2", { + name_format = "stair_%s_alt_2", + description = "@1 1/8 Alt Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 1, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.125, -0.5, 0.5, 0, 0}, + {-0.5, 0.375, 0, 0.5, 0.5, 0.5}, + }, + }, +}) + +stairsplus.api.register_shape("stair_alt_4", { + name_format = "stair_%s_alt_4", + description = "@1 1/4 Alt Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 2, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.25, -0.5, 0.5, 0, 0}, + {-0.5, 0.25, 0, 0.5, 0.5, 0.5}, + }, + }, +}) + +stairsplus.api.register_shape("stair_alt_8", { + name_format = "stair_%s_alt_8", + aliases = {"stair_%s_alt"}, + description = "@1 1/2 Alt Stair", + shape_groups = {stair = 1, legacy = 1}, + eighths = 4, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0, 0}, + {-0.5, 0, 0, 0.5, 0.5, 0.5}, + }, + }, +}) diff --git a/stairsplus/slabs.lua b/stairsplus/slabs.lua deleted file mode 100644 index 520b17db..00000000 --- a/stairsplus/slabs.lua +++ /dev/null @@ -1,43 +0,0 @@ ---[[ -More Blocks: slab definitions - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - --- Node will be called :slab_ - --- luacheck: no unused -local function register_slab(modname, subname, recipeitem, groups, images, description, drop, light) - stairsplus:register_slab(modname, subname, recipeitem, { - groups = groups, - tiles = images, - description = description, - drop = drop, - light_source = light, - sounds = moreblocks.node_sound_stone_defaults(), - }) -end - -function stairsplus:register_slab_alias(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["slab"]) - for alternate, def in pairs(defs) do - minetest.register_alias(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate) - end -end - -function stairsplus:register_slab_alias_force(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["slab"]) - for alternate, def in pairs(defs) do - minetest.register_alias_force(modname_old .. ":slab_" .. subname_old .. alternate, modname_new .. ":slab_" .. subname_new .. alternate) - end -end - -function stairsplus:register_slab(modname, subname, recipeitem, fields) - local defs = table.copy(stairsplus.defs["slab"]) - for alternate, shape in pairs(defs) do - stairsplus.register_single("slab", alternate, shape, modname, subname, recipeitem, fields) - end - - circular_saw.known_nodes[recipeitem] = {modname, subname} -end diff --git a/stairsplus/slopes.lua b/stairsplus/slopes.lua deleted file mode 100644 index df3469b8..00000000 --- a/stairsplus/slopes.lua +++ /dev/null @@ -1,43 +0,0 @@ ---[[ -More Blocks: slope definitions - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - --- Node will be called :slope_ - --- luacheck: no unused -local function register_slope(modname, subname, recipeitem, groups, images, description, drop, light) - stairsplus:register_slope(modname, subname, recipeitem, { - groups = groups, - tiles = images, - description = description, - drop = drop, - light_source = light, - sounds = moreblocks.node_sound_stone_defaults(), - }) -end - -function stairsplus:register_slope_alias(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["slope"]) - for alternate, def in pairs(defs) do - minetest.register_alias(modname_old .. ":slope_" .. subname_old .. alternate, modname_new .. ":slope_" .. subname_new .. alternate) - end -end - -function stairsplus:register_slope_alias_force(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["slope"]) - for alternate, def in pairs(defs) do - minetest.register_alias_force(modname_old .. ":slope_" .. subname_old .. alternate, modname_new .. ":slope_" .. subname_new .. alternate) - end -end - -function stairsplus:register_slope(modname, subname, recipeitem, fields) - local defs = table.copy(stairsplus.defs["slope"]) - for alternate, def in pairs(defs) do - stairsplus.register_single("slope", alternate, def, modname, subname, recipeitem, fields) - end - - circular_saw.known_nodes[recipeitem] = {modname, subname} -end diff --git a/stairsplus/stairs.lua b/stairsplus/stairs.lua deleted file mode 100644 index a90a0264..00000000 --- a/stairsplus/stairs.lua +++ /dev/null @@ -1,43 +0,0 @@ ---[[ -More Blocks: stair definitions - -Copyright © 2011-2020 Hugo Locurcio and contributors. -Licensed under the zlib license. See LICENSE.md for more information. ---]] - --- Node will be called :stair_ - --- luacheck: no unused -local function register_stair(modname, subname, recipeitem, groups, images, description, drop, light) - stairsplus:register_stair(modname, subname, recipeitem, { - groups = groups, - tiles = images, - description = description, - drop = drop, - light_source = light, - sounds = moreblocks.node_sound_stone_defaults(), - }) -end - -function stairsplus:register_stair_alias(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["stair"]) - for alternate, def in pairs(defs) do - minetest.register_alias(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate) - end -end - -function stairsplus:register_stair_alias_force(modname_old, subname_old, modname_new, subname_new) - local defs = table.copy(stairsplus.defs["stair"]) - for alternate, def in pairs(defs) do - minetest.register_alias_force(modname_old .. ":stair_" .. subname_old .. alternate, modname_new .. ":stair_" .. subname_new .. alternate) - end -end - -function stairsplus:register_stair(modname, subname, recipeitem, fields) - local defs = table.copy(stairsplus.defs["stair"]) - for alternate, def in pairs(defs) do - stairsplus.register_single("stair", alternate, def, modname, subname, recipeitem, fields) - end - - circular_saw.known_nodes[recipeitem] = {modname, subname} -end diff --git a/textures/moreblocks_circular_saw_bottom.png b/stairsplus/textures/stairsplus_circular_saw_bottom.png similarity index 100% rename from textures/moreblocks_circular_saw_bottom.png rename to stairsplus/textures/stairsplus_circular_saw_bottom.png diff --git a/textures/moreblocks_circular_saw_side.png b/stairsplus/textures/stairsplus_circular_saw_side.png similarity index 100% rename from textures/moreblocks_circular_saw_side.png rename to stairsplus/textures/stairsplus_circular_saw_side.png diff --git a/textures/moreblocks_circular_saw_top.png b/stairsplus/textures/stairsplus_circular_saw_top.png similarity index 100% rename from textures/moreblocks_circular_saw_top.png rename to stairsplus/textures/stairsplus_circular_saw_top.png diff --git a/stairsplus/textures/stairsplus_saw_button.png b/stairsplus/textures/stairsplus_saw_button.png new file mode 100644 index 00000000..8ac80935 Binary files /dev/null and b/stairsplus/textures/stairsplus_saw_button.png differ diff --git a/stairsplus/util.lua b/stairsplus/util.lua new file mode 100644 index 00000000..62697e0d --- /dev/null +++ b/stairsplus/util.lua @@ -0,0 +1,91 @@ +local util = {} + +function util.table_set_all(t, other_table) + for key, value in pairs(other_table) do + t[key] = value + end + return t +end + +function util.table_is_empty(t) + return next(t) == nil +end + +function util.table_sort_keys(t, sort_function) + local sorted = {} + for key in pairs(t) do + table.insert(sorted, key) + end + if sort_function then + table.sort(sorted, sort_function) + else + table.sort(sorted) + end + return sorted +end + +function util.table_equals(t1, t2) + if t1 == t2 then + return true + end + + local tt1 = type(t1) + local tt2 = type(t2) + + if tt1 ~= tt2 then + return false + end + + if tt1 ~= "table" or tt2 ~= "table" then + return t1 == t2 + end + + for k1, v1 in pairs(t1) do + if v1 ~= t2[k1] then + return false + end + end + + for k2, v2 in pairs(t2) do + if t1[k2] ~= v2 then + return false + end + end + + return true +end + +function util.get_location_string(inv) + local location = inv:get_location() + if location.type == "node" then + return ("nodemeta:%i,%i,%i"):format(location.pos.x, location.pos.y, location.pos.z) + elseif location.type == "player" then + return ("player:%s"):format(location.name) + elseif location.type == "detached" then + return ("detached:%s"):format(location.name) + else + error(("unexpected location? %s"):format(dump(location))) + end +end + +function util.resolve_aliases(node, seen) + seen = seen or {} + if seen[node] then + error(("alias loop on %s"):format(node)) + end + local aliased_to = minetest.registered_aliases[node] + if aliased_to then + seen[node] = true + return util.resolve_aliases(aliased_to, seen) + end + return node +end + +function util.has_metadata(item) + item = type(item) == "userdata" and item or ItemStack(item) + local meta = item:get_meta() + + return not util.table_is_empty(meta:to_table().fields) +end + +stairsplus.util = util diff --git a/stairsplus_legacy/.luacheckrc b/stairsplus_legacy/.luacheckrc new file mode 100644 index 00000000..08309c1c --- /dev/null +++ b/stairsplus_legacy/.luacheckrc @@ -0,0 +1,657 @@ +std = "lua51+luajit+minetest+stairsplus_legacy" +unused_args = false +max_line_length = 120 + +stds.minetest = { + read_globals = { + "DIR_DELIM", + "dump", + "dump2", + + math = { + fields = { + abs = {}, + acos = {}, + asin = {}, + atan = {}, + atan2 = {}, + ceil = {}, + cos = {}, + cosh = {}, + deg = {}, + exp = {}, + factorial = {}, + floor = {}, + fmod = {}, + frexp = {}, + huge = {}, + hypot = {}, + ldexp = {}, + log = {}, + log10 = {}, + max = {}, + min = {}, + modf = {}, + pi = {}, + pow = {}, + rad = {}, + random = {}, + randomseed = {}, + round = {}, + sign = {}, + sin = {}, + sinh = {}, + sqrt = {}, + tan = {}, + tanh = {}, + }, + }, + table = { + fields = { + copy = {}, + concat = {}, + foreach = {}, + foreachi = {}, + getn = {}, + indexof = {}, + insert = {}, + insert_all = {}, + key_value_swap = {}, + maxn = {}, + move = {}, + remove = {}, + shuffle = {}, + sort = {}, + }, + }, + string = { + fields = { + byte = {}, + char = {}, + dump = {}, + find = {}, + format = {}, + gmatch = {}, + len = {}, + lower = {}, + match = {}, + rep = {}, + reverse = {}, + split = {}, + sub = {}, + trim = {}, + upper = {}, + }, + }, + vector = { + fields = { + add = {}, + angle = {}, + apply = {}, + check = {}, + combine = {}, + copy = {}, + cross = {}, + dir_to_rotation = {}, + direction = {}, + distance = {}, + divide = {}, + dot = {}, + equals = {}, + floor = {}, + from_string = {}, + length = {}, + metatable = {}, + multiply = {}, + new = {}, + normalize = {}, + offset = {}, + rotate = {}, + rotate_around_axis = {}, + round = {}, + sort = {}, + subtract = {}, + to_string = {}, + zero = {}, + }, + }, + + ItemStack = { + fields = { + add_item = {}, + add_wear = {}, + add_wear_by_uses = {}, + clear = {}, + get_count = {}, + get_definition = {}, + get_description = {}, + get_free_space = {}, + get_meta = {}, + get_metadata = {}, + get_name = {}, + get_short_description = {}, + get_stack_max = {}, + get_tool_capabilities = {}, + get_wear = {}, + is_empty = {}, + is_known = {}, + item_fits = {}, + peek_item = {}, + replace = {}, + set_count = {}, + set_metadata = {}, + set_name = {}, + set_wear = {}, + take_item = {}, + to_string = {}, + to_table = {}, + }, + }, + PerlinNoise = { + fields = { + get_2d = {}, + get_3d = {}, + }, + }, + PerlinNoiseMap = { + fields = { + calc_2d_map = {}, + calc_3d_map = {}, + get_2d_map = {}, + get_2d_map_flat = {}, + get_3d_map = {}, + get_3d_map_flat = {}, + get_map_slice = {}, + }, + }, + PseudoRandom = { + fields = { + next = {}, + }, + }, + PcgRandom = { + fields = { + next = {}, + rand_normal_dist = {}, + }, + }, + SecureRandom = { + fields = { + next_bytes = {}, + }, + }, + Settings = { + fields = { + get = {}, + get_bool = {}, + get_flags = {}, + get_names = {}, + get_np_group = {}, + remove = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + to_table = {}, + write = {}, + }, + }, + VoxelArea = { + fields = { + MaxEdge = {}, + MinEdge = {}, + contains = {}, + containsi = {}, + containsp = {}, + getExtent = {}, + getVolume = {}, + index = {}, + indexp = {}, + iter = {}, + iterp = {}, + new = {}, + position = {}, + ystride = {}, + zstride = {}, + }, + }, + VoxelManip = { + fields = { + calc_lighting = {}, + get_data = {}, + get_emerged_area = {}, + get_light_data = {}, + get_node_at = {}, + get_param2_data = {}, + read_from_map = {}, + set_data = {}, + set_light_data = {}, + set_lighting = {}, + set_node_at = {}, + set_param2_data = {}, + update_liquids = {}, + update_map = {}, + was_modified = {}, + write_to_map = {}, + }, + }, + + minetest = { + fields = { + CONTENT_AIR = {}, + CONTENT_IGNORE = {}, + CONTENT_UNKNOWN = {}, + EMERGE_CANCELLED = {}, + EMERGE_ERRORED = {}, + EMERGE_FROM_DISK = {}, + EMERGE_FROM_MEMORY = {}, + EMERGE_GENERATED = {}, + LIGHT_MAX = {}, + MAP_BLOCKSIZE = {}, + PLAYER_MAX_BREATH_DEFAULT = {}, + PLAYER_MAX_HP_DEFAULT = {}, + add_entity = {}, + add_item = {}, + add_node = {}, + add_node_level = {}, + add_particle = {}, + add_particlespawner = {}, + after = {}, + async_event_handler = {}, + async_jobs = {}, + auth_reload = {}, + ban_player = {}, + builtin_auth_handler = {}, + bulk_set_node = {}, + calculate_knockback = {}, + callback_origins = {}, + cancel_shutdown_requests = {}, + chat_send_all = {}, + chat_send_player = {}, + chatcommands = {}, + check_for_falling = {}, + check_password_entry = {}, + check_player_privs = {}, + check_single_for_falling = {}, + clear_craft = {}, + clear_objects = {}, + clear_registered_biomes = {}, + clear_registered_decorations = {}, + clear_registered_ores = {}, + clear_registered_schematics = {}, + close_formspec = {}, + colorize = {}, + colorspec_to_bytes = {}, + colorspec_to_colorstring = {}, + compare_block_status = {}, + compress = {}, + cpdir = {}, + craft_predict = {}, + craftitemdef_default = {}, + create_detached_inventory = {}, + create_detached_inventory_raw = {}, + create_schematic = {}, + debug = {}, + decode_base64 = {}, + decompress = {}, + delete_area = {}, + delete_particlespawner = {}, + deserialize = {}, + detached_inventories = {}, + dig_node = {}, + dir_to_facedir = {}, + dir_to_wallmounted = {}, + dir_to_yaw = {}, + disconnect_player = {}, + do_async_callback = {}, + do_item_eat = {}, + dynamic_add_media = {}, + dynamic_media_callbacks = {}, + emerge_area = {}, + encode_base64 = {}, + encode_png = {}, + env = {}, + explode_scrollbar_event = {}, + explode_table_event = {}, + explode_textlist_event = {}, + facedir_to_dir = {}, + features = {}, + find_node_near = {}, + find_nodes_in_area = {}, + find_nodes_in_area_under_air = {}, + find_nodes_with_meta = {}, + find_path = {}, + fix_light = {}, + forceload_block = {}, + forceload_free_block = {}, + format_chat_message = {}, + formspec_escape = {}, + generate_decorations = {}, + generate_ores = {}, + get_all_craft_recipes = {}, + get_artificial_light = {}, + get_auth_handler = {}, + get_background_escape_sequence = {}, + get_ban_description = {}, + get_ban_list = {}, + get_biome_data = {}, + get_biome_id = {}, + get_biome_name = {}, + get_builtin_path = {}, + get_color_escape_sequence = {}, + get_connected_players = {}, + get_content_id = {}, + get_craft_recipe = {}, + get_craft_result = {}, + get_current_modname = {}, + get_day_count = {}, + get_decoration_id = {}, + get_dig_params = {}, + get_dir_list = {}, + get_gametime = {}, + get_gen_notify = {}, + get_heat = {}, + get_hit_params = {}, + get_humidity = {}, + get_inventory = {}, + get_item_group = {}, + get_last_run_mod = {}, + get_mapgen_object = {}, + get_mapgen_params = {}, + get_mapgen_setting = {}, + get_mapgen_setting_noiseparams = {}, + get_meta = {}, + get_mod_storage = {}, + get_modnames = {}, + get_modpath = {}, + get_name_from_content_id = {}, + get_natural_light = {}, + get_node = {}, + get_node_drops = {}, + get_node_group = {}, + get_node_level = {}, + get_node_light = {}, + get_node_max_level = {}, + get_node_or_nil = {}, + get_node_timer = {}, + get_noiseparams = {}, + get_objects_in_area = {}, + get_objects_inside_radius = {}, + get_password_hash = {}, + get_perlin = {}, + get_perlin_map = {}, + get_player_by_name = {}, + get_player_information = {}, + get_player_ip = {}, + get_player_privs = {}, + get_player_radius_area = {}, + get_pointed_thing_position = {}, + get_position_from_hash = {}, + get_server_max_lag = {}, + get_server_status = {}, + get_server_uptime = {}, + get_spawn_level = {}, + get_timeofday = {}, + get_tool_wear_after_use = {}, + get_translated_string = {}, + get_translator = {}, + get_us_time = {}, + get_user_path = {}, + get_version = {}, + get_voxel_manip = {}, + get_worldpath = {}, + global_exists = {}, + handle_async = {}, + handle_node_drops = {}, + has_feature = {}, + hash_node_position = {}, + hud_replace_builtin = {}, + inventorycube = {}, + is_area_protected = {}, + is_colored_paramtype = {}, + is_creative_enabled = {}, + is_nan = {}, + is_player = {}, + is_protected = {}, + is_singleplayer = {}, + is_yes = {}, + item_drop = {}, + item_eat = {}, + item_place = {}, + item_place_node = {}, + item_place_object = {}, + item_secondary_use = {}, + itemstring_with_color = {}, + itemstring_with_palette = {}, + kick_player = {}, + line_of_sight = {}, + load_area = {}, + log = {}, + luaentities = {}, + mkdir = {}, + mod_channel_join = {}, + mvdir = {}, + node_dig = {}, + node_punch = {}, + nodedef_default = {}, + noneitemdef_default = {}, + notify_authentication_modified = {}, + object_refs = {}, + on_craft = {}, + override_chatcommand = {}, + override_item = {}, + parse_coordinates = {}, + parse_json = {}, + parse_relative_number = {}, + place_node = {}, + place_schematic = {}, + place_schematic_on_vmanip = {}, + player_exists = {}, + pointed_thing_to_face_pos = {}, + pos_to_string = {}, + print = {}, + privs_to_string = {}, + punch_node = {}, + raillike_group = {}, + raycast = {}, + read_schematic = {}, + record_protection_violation = {}, + register_abm = {}, + register_alias = {}, + register_alias_force = {}, + register_allow_player_inventory_action = {}, + register_async_dofile = {}, + register_authentication_handler = {}, + register_biome = {}, + register_can_bypass_userlimit = {}, + register_chatcommand = {}, + register_craft = {}, + register_craft_predict = {}, + register_craftitem = {}, + register_decoration = {}, + register_entity = {}, + register_globalstep = {}, + register_item = {}, + register_lbm = {}, + register_node = {}, + register_on_auth_fail = {}, + register_on_authplayer = {}, + register_on_chat_message = {}, + register_on_chatcommand = {}, + register_on_cheat = {}, + register_on_craft = {}, + register_on_dieplayer = {}, + register_on_dignode = {}, + register_on_generated = {}, + register_on_item_eat = {}, + register_on_joinplayer = {}, + register_on_leaveplayer = {}, + register_on_liquid_transformed = {}, + register_on_mapgen_init = {}, + register_on_modchannel_message = {}, + register_on_mods_loaded = {}, + register_on_newplayer = {}, + register_on_placenode = {}, + register_on_player_hpchange = {}, + register_on_player_inventory_action = {}, + register_on_player_receive_fields = {}, + register_on_prejoinplayer = {}, + register_on_priv_grant = {}, + register_on_priv_revoke = {}, + register_on_protection_violation = {}, + register_on_punchnode = {}, + register_on_punchplayer = {}, + register_on_respawnplayer = {}, + register_on_rightclickplayer = {}, + register_on_shutdown = {}, + register_ore = {}, + register_playerevent = {}, + register_privilege = {}, + register_schematic = {}, + register_tool = {}, + registered_abms = {other_fields = true}, + registered_aliases = {other_fields = true}, + registered_allow_player_inventory_actions = {other_fields = true}, + registered_biomes = {other_fields = true}, + registered_can_bypass_userlimit = {other_fields = true}, + registered_chatcommands = {other_fields = true}, + registered_craft_predicts = {other_fields = true}, + registered_craftitems = {other_fields = true}, + registered_decorations = {other_fields = true}, + registered_entities = {other_fields = true}, + registered_globalsteps = {other_fields = true}, + registered_items = {other_fields = true}, + registered_lbms = {other_fields = true}, + registered_nodes = {other_fields = true}, + registered_on_authplayers = {other_fields = true}, + registered_on_chat_messages = {other_fields = true}, + registered_on_chatcommands = {other_fields = true}, + registered_on_cheats = {other_fields = true}, + registered_on_crafts = {other_fields = true}, + registered_on_dieplayers = {other_fields = true}, + registered_on_dignodes = {other_fields = true}, + registered_on_generateds = {other_fields = true}, + registered_on_item_eats = {other_fields = true}, + registered_on_joinplayers = {other_fields = true}, + registered_on_leaveplayers = {other_fields = true}, + registered_on_liquid_transformed = {other_fields = true}, + registered_on_modchannel_message = {other_fields = true}, + registered_on_mods_loaded = {other_fields = true}, + registered_on_newplayers = {other_fields = true}, + registered_on_placenodes = {other_fields = true}, + registered_on_player_hpchange = {other_fields = true}, + registered_on_player_hpchanges = {other_fields = true}, + registered_on_player_inventory_actions = {other_fields = true}, + registered_on_player_receive_fields = {other_fields = true}, + registered_on_prejoinplayers = {other_fields = true}, + registered_on_priv_grant = {other_fields = true}, + registered_on_priv_revoke = {other_fields = true}, + registered_on_protection_violation = {other_fields = true}, + registered_on_punchnodes = {other_fields = true}, + registered_on_punchplayers = {other_fields = true}, + registered_on_respawnplayers = {other_fields = true}, + registered_on_rightclickplayers = {other_fields = true}, + registered_on_shutdown = {other_fields = true}, + registered_ores = {other_fields = true}, + registered_playerevents = {other_fields = true}, + registered_privileges = {other_fields = true}, + registered_tools = {other_fields = true}, + remove_detached_inventory = {}, + remove_detached_inventory_raw = {}, + remove_node = {}, + remove_player = {}, + remove_player_auth = {}, + request_http_api = {}, + request_insecure_environment = {}, + request_shutdown = {}, + rgba = {}, + rmdir = {}, + rollback_get_last_node_actor = {}, + rollback_get_node_actions = {}, + rollback_punch_callbacks = {}, + rollback_revert_actions_by = {}, + rotate_and_place = {}, + rotate_node = {}, + run_callbacks = {}, + run_priv_callbacks = {}, + safe_file_write = {}, + send_join_message = {}, + send_leave_message = {}, + serialize = {}, + serialize_roundtrip = {}, + serialize_schematic = {}, + set_gen_notify = {}, + set_last_run_mod = {}, + set_mapgen_params = {}, + set_mapgen_setting = {}, + set_mapgen_setting_noiseparams = {}, + set_node = {}, + set_node_level = {}, + set_noiseparams = {}, + set_player_password = {}, + set_player_privs = {}, + set_timeofday = {}, + setting_get = {}, + setting_get_pos = {}, + setting_getbool = {}, + setting_save = {}, + setting_set = {}, + setting_setbool = {}, + settings = { + fields = { + get = {}, + get_bool = {}, + get_np_group = {}, + get_flags = {}, + set = {}, + set_bool = {}, + set_np_group = {}, + remove = {}, + get_names = {}, + write = {}, + to_table = {}, + }, + }, + sha1 = {}, + show_formspec = {}, + show_general_help_formspec = {}, + show_privs_help_formspec = {}, + sound_fade = {}, + sound_play = {}, + sound_stop = {}, + spawn_falling_node = {}, + spawn_item = {}, + spawn_tree = {}, + string_to_area = {}, + string_to_pos = {}, + string_to_privs = {}, + strip_background_colors = {}, + strip_colors = {}, + strip_foreground_colors = {}, + strip_param2_color = {}, + swap_node = {}, + tooldef_default = {}, + transforming_liquid_add = {}, + translate = {}, + unban_player_or_ip = {}, + unregister_biome = {}, + unregister_chatcommand = {}, + unregister_item = {}, + wallmounted_to_dir = {}, + wrap_text = {}, + write_json = {}, + yaw_to_dir = {}, + }, + }, + } +} + +stds.stairsplus_legacy = { + globals = { + "stairsplus_legacy", + }, + read_globals = { + "default", + "stairs", + "stairsplus", + }, +} diff --git a/stairsplus_legacy/basic_materials.lua b/stairsplus_legacy/basic_materials.lua new file mode 100644 index 00000000..1b2ccc5a --- /dev/null +++ b/stairsplus_legacy/basic_materials.lua @@ -0,0 +1,19 @@ +local materials = stairsplus_legacy.materials + +if materials.concrete_block and materials.concrete_block ~= "basic_materials:concrete_block" then + stairsplus.api.register_alias_all("basic_materials:concrete_block", materials.concrete_block) +elseif minetest.registered_nodes["basic_materials:concrete_block"] then + stairsplus_legacy.register_legacy("basic_materials:concrete_block") +end + +if materials.cement_block and materials.cement_block ~= "basic_materials:cement_block" then + stairsplus.api.register_alias_all("basic_materials:cement_block", materials.cement_block) +elseif minetest.registered_nodes["basic_materials:cement_block"] then + stairsplus_legacy.register_legacy("basic_materials:cement_block") +end + +if materials.brass_block and materials.brass_block ~= "basic_materials:brass_block" then + stairsplus.api.register_alias_all("basic_materials:brass_block", materials.brass_block) +elseif minetest.registered_nodes["basic_materials:brass_block"] then + stairsplus_legacy.register_legacy("basic_materials:brass_block") +end diff --git a/stairsplus_legacy/default.lua b/stairsplus_legacy/default.lua new file mode 100644 index 00000000..3c09225c --- /dev/null +++ b/stairsplus_legacy/default.lua @@ -0,0 +1,193 @@ +local default_nodes = { -- Default stairs/slabs/panels/microblocks: + "acacia_tree", + "acacia_wood", + "aspen_tree", + "aspen_wood", + "brick", + "bronzeblock", + "cobble", + "copperblock", + "coral_skeleton", + "default:ice", + "desert_cobble", + "desert_sandstone", + "desert_sandstone_block", + "desert_sandstone_brick", + "desert_stone", + "desert_stone_block", + "desert_stonebrick", + "diamondblock", + "goldblock", + "ice", + "jungletree", + "junglewood", + "meselamp", + "mossycobble", + "obsidian", + "obsidian_block", + "obsidianbrick", + "pine_tree", + "pine_wood", + "sandstone", + "sandstone_block", + "sandstonebrick", + "silver_sandstone", + "silver_sandstone_block", + "silver_sandstone_brick", + "snowblock", + "steelblock", + "stone", + "stone_block", + "stonebrick", + "tinblock", + "tree", + "wood", +} + +for _, name in ipairs(default_nodes) do + local node = ("default:%s"):format(name) + if minetest.registered_nodes[node] then + stairsplus_legacy.register_legacy(node) + stairsplus.api.register_alias_all(("moreblocks:%s"):format(name), node) + stairsplus.api.register_alias_all(("stairs:%s"):format(name), node) + end +end + +-- glass problems +local glass = { + "glass", + "obsidian_glass", +} + +for _, name in ipairs(glass) do + local node = ("default:%s"):format(name) + if minetest.registered_nodes[node] then + stairsplus_legacy.register_legacy(node, nil, {ignore_paramtype2 = true}) + stairsplus.api.register_alias_all(("moreblocks:%s"):format(name), node) + stairsplus.api.register_alias_all(("stairs:%s"):format(name), node) + end +end + +if minetest.registered_nodes["default:glass"] then + stairsplus.api.register_crafts_for_shapes({ + type = "cooking", + output = "default:glass", + recipe = "group:sand", + }) +end + +if minetest.registered_nodes["default:stone"] and minetest.registered_nodes["default:cobble"] then + stairsplus.api.register_crafts_for_shapes({ + type = "cooking", + output = "default:stone", + recipe = "default:cobble", + }) +end + +if minetest.registered_nodes["default:stone"] and minetest.registered_nodes["default:mossycobble"] then + stairsplus.api.register_crafts_for_shapes({ + type = "cooking", + output = "default:stone", + recipe = "default:mossycobble", + }) +end + +if minetest.registered_nodes["default:desert_stone"] and minetest.registered_nodes["default:desert_cobble"] then + stairsplus.api.register_crafts_for_shapes({ + type = "cooking", + output = "default:desert_stone", + recipe = "default:desert_cobble", + }) +end + +stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "group:tree", + burntime = 30, +}) + +if minetest.registered_nodes["default:tree"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:tree", + burntime = 30, + }) +end + +if minetest.registered_nodes["default:aspen_tree"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:aspen_tree", + burntime = 22, + }) +end + +if minetest.registered_nodes["default:pine_tree"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:pine_tree", + burntime = 26, + }) +end + +if minetest.registered_nodes["default:acacia_tree"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:acacia_tree", + burntime = 34, + }) +end + +if minetest.registered_nodes["default:jungletree"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:jungletree", + burntime = 38, + }) +end + +stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "group:wood", + burntime = 7, +}) + +if minetest.registered_nodes["default:wood"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:wood", + burntime = 7, + }) +end + +if minetest.registered_nodes["default:aspen_wood"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:aspen_wood", + burntime = 5, + }) +end + +if minetest.registered_nodes["default:pine_wood"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:pine_wood", + burntime = 6, + }) +end + +if minetest.registered_nodes["default:acacia_wood"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:acacia_wood", + burntime = 8, + }) +end + +if minetest.registered_nodes["default:junglewood"] then + stairsplus.api.register_crafts_for_shapes({ + type = "fuel", + recipe = "default:junglewood", + burntime = 9, + }) +end diff --git a/stairsplus_legacy/farming.lua b/stairsplus_legacy/farming.lua new file mode 100644 index 00000000..f40329c9 --- /dev/null +++ b/stairsplus_legacy/farming.lua @@ -0,0 +1,9 @@ +local farming_nodes = {"straw"} +for _, name in pairs(farming_nodes) do + local node = ("farming:%s"):format(name) + if minetest.registered_nodes[node] then + stairsplus_legacy.register_legacy(node) + stairsplus.api.register_alias_all(("moreblocks:%s"):format(name), node) + stairsplus.api.register_alias_all(("stairs:%s"):format(name), node) + end +end diff --git a/stairsplus_legacy/gloopblocks.lua b/stairsplus_legacy/gloopblocks.lua new file mode 100644 index 00000000..da6b07af --- /dev/null +++ b/stairsplus_legacy/gloopblocks.lua @@ -0,0 +1,7 @@ +local materials = stairsplus_legacy.materials + +if materials.cement_block and materials.cement_block ~= "gloopblocks:cement" then + stairsplus.api.register_alias_all("gloopblocks:cement", materials.cement_block) +elseif minetest.registered_nodes["gloopblocks:cement"] then + stairsplus_legacy.register_legacy("gloopblocks:cement") +end diff --git a/stairsplus_legacy/init.lua b/stairsplus_legacy/init.lua new file mode 100644 index 00000000..2fd41ef8 --- /dev/null +++ b/stairsplus_legacy/init.lua @@ -0,0 +1,49 @@ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + +stairsplus_legacy = { + version = {3, 0, 0}, + fork = "minetest_mods", + + modname = modname, + modpath = modpath, + + S = S, + + has = { + basic_materials = minetest.get_modpath("basic_materials"), + default = minetest.get_modpath("default"), + farming = minetest.get_modpath("farming"), + gloopblocks = minetest.get_modpath("gloopblocks"), + prefab = minetest.get_modpath("prefab"), + stairs = minetest.get_modpath("stairs"), + technic = minetest.get_modpath("technic"), + wool = minetest.get_modpath("wool"), + }, + + log = function(level, messagefmt, ...) + return minetest.log(level, ("[%s] %s"):format(modname, messagefmt:format(...))) + end, + + dofile = function(...) + return dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua") + end, +} + +stairsplus_legacy.dofile("settings") +stairsplus_legacy.dofile("resources") + +function stairsplus_legacy.register_legacy(node, overrides, meta) + if stairsplus.settings.legacy_mode then + stairsplus.api.register_group(node, "legacy", overrides, meta) + else + stairsplus.api.register_group(node, "common", overrides, meta) + end +end + +for mod, enabled in pairs(stairsplus_legacy.settings) do + if enabled then + stairsplus_legacy.dofile(mod) + end +end diff --git a/stairsplus_legacy/mod.conf b/stairsplus_legacy/mod.conf new file mode 100644 index 00000000..0495ca3d --- /dev/null +++ b/stairsplus_legacy/mod.conf @@ -0,0 +1,6 @@ +name = stairsplus_legacy +version = 3.0.0 +title = Stairs+ legacy support +description = Support for old registrations which were part of moreblocks/stairsplus +depends = stairsplus +optional_depends = basic_materials, default, farming, gloopblocks, stairs, prefab, technic, wool diff --git a/stairsplus_legacy/prefab.lua b/stairsplus_legacy/prefab.lua new file mode 100644 index 00000000..ef4dbba4 --- /dev/null +++ b/stairsplus_legacy/prefab.lua @@ -0,0 +1,9 @@ +local materials = stairsplus_legacy.materials + +if materials.concrete_block and materials.concrete_block ~= "prefab:concrete" then + local slab_name = stairsplus.api.format_name(materials.concrete_block, "slab_8") + local stair_name = stairsplus.api.format_name(materials.concrete_block, "stair") + + minetest.register_alias_force("prefab:concrete_slab", slab_name) + minetest.register_alias_force("prefab:concrete_stair", stair_name) +end diff --git a/stairsplus_legacy/resources.lua b/stairsplus_legacy/resources.lua new file mode 100644 index 00000000..6b5ef1f1 --- /dev/null +++ b/stairsplus_legacy/resources.lua @@ -0,0 +1,34 @@ +stairsplus_legacy.materials = {} + +if stairsplus_legacy.has.prefab then + if minetest.registered_nodes["prefab:concrete"] then + stairsplus_legacy.materials.concrete_block = "prefab:concrete" + end +end + +if stairsplus_legacy.has.gloopblocks then + if minetest.registered_nodes["gloopblocks:cement"] then + stairsplus_legacy.materials.cement_block = "gloopblocks:cement" + end +end + +if stairsplus_legacy.has.technic then + if minetest.registered_nodes["technic:brass_block"] then + stairsplus_legacy.materials.brass_block = "technic:brass_block" + end + if minetest.registered_nodes["technic:concrete"] then + stairsplus_legacy.materials.concrete_block = "technic:concrete" + end +end + +if stairsplus_legacy.has.basic_materials then + if minetest.registered_nodes["basic_materials:brass_block"] then + stairsplus_legacy.materials.brass_block = "basic_materials:brass_block" + end + if minetest.registered_nodes["basic_materials:cement_block"] then + stairsplus_legacy.materials.cement_block = "basic_materials:cement_block" + end + if minetest.registered_nodes["basic_materials:concrete_block"] then + stairsplus_legacy.materials.concrete_block = "basic_materials:concrete_block" + end +end diff --git a/stairsplus_legacy/settings.lua b/stairsplus_legacy/settings.lua new file mode 100644 index 00000000..3e1ace11 --- /dev/null +++ b/stairsplus_legacy/settings.lua @@ -0,0 +1,11 @@ +local s = minetest.settings + +stairsplus_legacy.settings = { + basic_materials = s:get_bool("stairsplus_legacy.basic_materials", true), + default = s:get_bool("stairsplus_legacy.default", true), + farming = s:get_bool("stairsplus_legacy.farming", true), + gloopblocks = s:get_bool("stairsplus_legacy.gloopblocks", true), + technic = s:get_bool("stairsplus_legacy.technic", true), + prefab = s:get_bool("stairsplus_legacy.prefab", true), + wool = s:get_bool("stairsplus_legacy.wool", true), +} diff --git a/stairsplus_legacy/technic.lua b/stairsplus_legacy/technic.lua new file mode 100644 index 00000000..c77b26ef --- /dev/null +++ b/stairsplus_legacy/technic.lua @@ -0,0 +1,13 @@ +local materials = stairsplus_legacy.materials + +if materials.concrete_block and materials.concrete_block ~= "technic:concrete" then + stairsplus.api.register_alias_all("technic:concrete", materials.concrete_block) +elseif minetest.registered_nodes["technic:concrete"] then + stairsplus_legacy.register_legacy("technic:concrete") +end + +if materials.brass_block and materials.brass_block ~= "technic:brass_block" then + stairsplus.api.register_alias_all("technic:brass_block", materials.brass_block) +elseif minetest.registered_nodes["technic:brass_block"] then + stairsplus_legacy.register_legacy("technic:brass_block") +end diff --git a/stairsplus_legacy/wool.lua b/stairsplus_legacy/wool.lua new file mode 100644 index 00000000..502b7d0b --- /dev/null +++ b/stairsplus_legacy/wool.lua @@ -0,0 +1,11 @@ +local dyes = {"white", "grey", "black", "red", "yellow", "green", "cyan", + "blue", "magenta", "orange", "violet", "brown", "pink", + "dark_grey", "dark_green"} + +for _, name in ipairs(dyes) do + local node = ("wool:%s"):format(name) + if minetest.registered_nodes[node] then + stairsplus_legacy.register_legacy(node) + stairsplus.api.register_alias_all(("moreblocks:%s"):format(name), node) + end +end