initial commit

This commit is contained in:
𝘋𝘪𝘳𝘬 2023-08-04 15:25:03 +02:00
commit 8c3efc9447
Signed by: dirk
GPG Key ID: F44E7467B12D6707
9 changed files with 184 additions and 0 deletions

21
LICENSE.txt Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) “Linuxdirk”
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

17
README.md Normal file
View File

@ -0,0 +1,17 @@
_**WIP**_
## Configuration options
Listed below are the configuration options that can be set either in the global `minetest.conf` file or in the file `_ladders_3d.conf` in the world directory. Configuration options are set in the following order.
1. Built-in defaults
2. Global configuration options
3. World-specific configuration options
It is suggested to use world-specific configuration options only.
```conf
# For each supported mod as `modname`
ladders_3d_load_modname = true
```
The listing above shows the default values.

63
init.lua Normal file
View File

@ -0,0 +1,63 @@
-- Localize Minetest functions
local get_dir_list = minetest.get_dir_list
local get_modpath = minetest.get_modpath
local get_worldpath = minetest.get_worldpath
local is_yes = minetest.is_yes
-- Create custom log function
local log = function (lvl, str) minetest.log(lvl, '[Ladders 3D] '..str) end
-- Set mod-related things
local modname = minetest.get_current_modname()
local modpath = get_modpath(modname)
local syspath = modpath..DIR_DELIM..'system'..DIR_DELIM
local regpath = modpath..DIR_DELIM..'registry'..DIR_DELIM
-- Initiante global table
ladders_3d = {
worldconfig = Settings(get_worldpath()..DIR_DELIM..'_ladders_3d.conf'),
translator = minetest.get_translator(modname)
}
-- Load functions
dofile(syspath..'register.lua')
dofile(syspath..'helpers.lua')
log('info', 'Mod functionality fully loaded')
-- Run registration files for built-in mod support
--
-- Loading of built-in mod support can be configured either in the global
-- `mintest.conf` file or in a world-specific `_ladders_3d.conf` file. Settings
-- in the local file take precedence over global configuration.
--
-- # Disable loading built-in support for the mod named `modname`
-- ladders_3d_load_modname = false
--
-- If neither option is set, a sane built-in default value is used.
--
-- The registration files are named `modname.something.lua`. The `something`
-- part is optional and allows for separation of complex functionality for that
-- mod. The `modname` up to the first dot is used to determine the mod the
-- support file is for.
--
-- @see ladders_3d.option
for _,regfile in pairs(get_dir_list(regpath, false)) do
local mod = regfile:gsub('%..*', '')
local load = is_yes(ladders_3d.option('load_'..mod, true))
local lua = regfile:gsub('.*%.', '') == 'lua'
if (load == true) and (lua == true) and get_modpath(mod) then
dofile(regpath..regfile)
log('verbose', 'Loaded built-in mod support file `'..regfile..'`')
end
log('info', 'Built-in mod support processed')
end
-- APIfy mod
local register = ladders_3d.register
ladders_3d = { register = register }

1
locale/ladders_3d.de.tr Normal file
View File

@ -0,0 +1 @@
# textdomain: ladders_3d

4
mod.conf Normal file
View File

@ -0,0 +1,4 @@
name = ladders_3d
title = Ladders 3D
description = 3D ladders for a wide variety of base materials.
optional_depends = default

0
registry/README.md Normal file
View File

15
registry/default.lua Normal file
View File

@ -0,0 +1,15 @@
local S = ladders_3d.translator
ladders_3d.register('default_aspen_wood', {
description = S('Aspen Wood Ladder'),
-- recipe = {},
-- yield = 16,
-- uncraft = '',
tiles = { 'default_aspen_wood.png' },
-- sounds = {},
-- light = 0,
-- groups = {},
-- nodebox = {},
-- selectionbox = {},
-- walkable = false
})

16
system/helpers.lua Normal file
View File

@ -0,0 +1,16 @@
-- Get a configuration value or return a default
--
-- This function takes an unprefixed value, automatically prefixes it and
-- tries to get the value from the global configuration or the world-specific
-- configuration. If the option is not found in any of those the given default
-- value is returned.
--
-- @param value The unprefixed option to get
-- @param default The default value in case the option is not found
-- @return mixed The value
ladders_3d.option = function (short_name, default)
local option_name = 'ladders_3d_'..short_name
local global_value = minetest.settings:get(option_name) or default
local world_value = ladders_3d.worldconfig:get(option_name)
return world_value or global_value
end

47
system/register.lua Normal file
View File

@ -0,0 +1,47 @@
-- Default nodebox resembles the default “Minetest Game” ladder shape but
-- in 3D.
local default_nodebox = {
type = 'fixed',
fixed = {
{ -0.4375, -0.5, 0.375, -0.3125, 0.5, 0.5 },
{ 0.3125, -0.5, 0.375, 0.4375, 0.5, 0.5 },
{ -0.5, 0.3125, 0.375, 0.5, 0.4375, 0.5 },
{ -0.5, 0.0625, 0.375, 0.5, 0.1875, 0.5 },
{ -0.5, -0.1875, 0.375, 0.5, -0.0625, 0.5 },
{ -0.5, -0.4375, 0.375, 0.5, -0.3125, 0.5 }
}
}
-- Default selection box resembles the default “Minetest Game” ladder shape
-- but in 3D.
default_selectionbox = {
type = 'fixed',
fixed = { { -0.5, -0.5, 0.375, 0.5, 0.5, 0.5 } }
}
-- Register a ladder
ladders_3d.register = function (short_id, definition)
-- Set groups table
local groups = { oddly_breakable_by_hand = 2 }
for g,v in pairs(definition.groups or {}) do groups[g] = v end
-- Register the node
minetest.register_node(':ladders_3d:'..short_id, {
description = definition.description or short_id,
tiles = definition.tiles,
drawtype = 'nodebox',
paramtype = 'light',
node_box = definition.nodebox or default_nodebox,
selection_box = definition.selectionbox or default_selectionbox,
climbable = true,
walkable = definition.walkable or false,
groups = groups,
paramtype2 = 'facedir',
light_source = definition.light or 0,
})
end