2020-06-13 15:23:14 +02:00
|
|
|
--- If the settings object for the given player name doesn't exist, it is created.
|
|
|
|
-- @param name The name of the player to ensure has a settings object.
|
|
|
|
local function settings_init(name)
|
2024-10-10 05:35:45 +02:00
|
|
|
if worldeditadditions_tools.player_data[name] == nil then
|
2020-06-15 14:04:42 +02:00
|
|
|
minetest.log("INFO", "Initialising settings for "..name)
|
2024-10-10 05:35:45 +02:00
|
|
|
worldeditadditions_tools.player_data[name] = {
|
2020-06-13 15:23:14 +02:00
|
|
|
maxdist = 1000,
|
|
|
|
skip_liquid = true
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Gets a given farwand setting for the given player name.
|
|
|
|
-- @param string name The name of the player to get the setting for.
|
|
|
|
-- @param string setting_name The name of the setting to fetch.
|
|
|
|
-- @return any The value of the setting.
|
2024-10-10 05:35:45 +02:00
|
|
|
function worldeditadditions_tools.setting_get(name, setting_name)
|
2020-06-13 15:23:14 +02:00
|
|
|
if setting_name == nil then return nil end
|
|
|
|
settings_init(name)
|
2024-10-10 05:35:45 +02:00
|
|
|
return worldeditadditions_tools.player_data[name][setting_name]
|
2020-06-13 15:23:14 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Sets a given farwand setting for the given player name to the given value.
|
|
|
|
-- @param string name The name of the player to set the setting for.
|
|
|
|
-- @param string setting_name The name of the setting to set.
|
|
|
|
-- @param any setting_value The value to set the setting to.
|
|
|
|
-- @return bool Whether setting the setting was successful or not.
|
2024-10-10 05:35:45 +02:00
|
|
|
function worldeditadditions_tools.setting_set(name, setting_name, setting_value)
|
2020-06-13 15:23:14 +02:00
|
|
|
if setting_name == nil then return false end
|
|
|
|
settings_init(name)
|
2024-10-10 05:35:45 +02:00
|
|
|
worldeditadditions_tools.player_data[name][setting_name] = setting_value
|
2020-06-13 15:23:14 +02:00
|
|
|
return true
|
|
|
|
end
|