Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minetest.settings to CSM API and allow CSMs to provide settingtypes.txt #12131

Merged
merged 8 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
expose minetest.setting_get_pos to CSM API
  • Loading branch information
AFCMS committed May 5, 2022
commit e11fd787e349b3aba10f9c189e23e7cfdc119113
9 changes: 9 additions & 0 deletions builtin/common/misc_helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@ function core.wrap_text(text, max_length, as_table)
return as_table and result or table.concat(result, '\n')
end


function core.setting_get_pos(name)
local value = core.settings:get(name)
sfan5 marked this conversation as resolved.
Show resolved Hide resolved
if not value then
return nil
end
return core.string_to_pos(value)
end

--------------------------------------------------------------------------------

if INIT == "game" then
Expand Down
38 changes: 38 additions & 0 deletions builtin/game/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,44 @@ function core.get_player_radius_area(player_name, radius)
end


function core.hash_node_position(pos)
return (pos.z + 32768) * 65536 * 65536
+ (pos.y + 32768) * 65536
+ pos.x + 32768
end


function core.get_position_from_hash(hash)
local x = (hash % 65536) - 32768
sfan5 marked this conversation as resolved.
Show resolved Hide resolved
hash = math.floor(hash / 65536)
local y = (hash % 65536) - 32768
hash = math.floor(hash / 65536)
local z = (hash % 65536) - 32768
return vector.new(x, y, z)
end


function core.get_item_group(name, group)
if not core.registered_items[name] or not
core.registered_items[name].groups[group] then
return 0
end
return core.registered_items[name].groups[group]
end


function core.get_node_group(name, group)
core.log("deprecated", "Deprecated usage of get_node_group, use get_item_group instead")
return core.get_item_group(name, group)
end


-- See l_env.cpp for the other functions
function core.get_artificial_light(param1)
return math.floor(param1 / 16)
end


-- To be overriden by protection mods

function core.is_protected(pos, name)
Expand Down