Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 27 additions & 0 deletions settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,30 @@
#
# Disabling this feature will sacrifice safety for convenience.
technic_safe_chainsaw (Chainsaw safety feature) bool true

# Enables the mining drills.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enable Mining Drill is already shown in the settings. Players expect more information if a help icon is shown. If there is no additional information to show, then please remove these description lines.

-->

enable_mining_drill (Enable Mining Drill) bool true

enable_wind_mill (Enable Wind Mill) bool false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. I just wasn't sure what i should put there. The descriptions should be written by someone who understands technic more. I suppose I could remove them.

enable_mining_drill (Enable Mining Drill) bool true

# Enables Wind Mills.
enable_wind_mill (Enable Wind Mill) bool false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the technic_ prefix on all settings such that that their origin is clear. The minetest.conf file is already somewhat chaotic, thus let's not make it much worse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Will do.


# Enables the Flashlight.
enable_flashlight (Enable Flashlight) bool false

# Enables Frames.
enable_frames (Enable Frames) bool false

# Enables Corium Griefing.
enable_corium_griefing (Enable corium_griefing) bool true

# Enables Radiation Protection.
enable_radiation_protection (Enable Radiation Protection) bool true

# Enables Entity Radiation Damage.
enable_entity_radiation_damage (Enable Entity Radiation Damage) bool true

# Enables Long Term Radiation Damage.
enable_longterm_radiation_damage (Enable Long Term Radiation Damage) bool true

# Enables Nuclear Reactor Digiline Selfdestruct.
enable_nuclear_reactor_digiline_selfdestruct (Enable Nuclear Reactor Digiline Selfdestruct) bool false
15 changes: 14 additions & 1 deletion technic/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ technic.config = technic.config or Settings(minetest.get_worldpath().."/technic.

local conf_table = technic.config:to_table()

local function bool_to_string(bool)
if bool then
return "true"
end
return "false"
end

local defaults = {
enable_mining_drill = "true",
enable_mining_laser = "true",
Expand All @@ -13,10 +20,16 @@ local defaults = {
enable_entity_radiation_damage = "true",
enable_longterm_radiation_damage = "true",
enable_nuclear_reactor_digiline_selfdestruct = "false",
technic_safe_chainsaw = "true",
}

for k, v in pairs(defaults) do
if conf_table[k] == nil then
technic.config:set(k, v)
local minetest_val = minetest.settings:get(k)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use technic.config:set(k, core.settings:get_bool(k, v)) where v is the fallback. Requires Minetest 5.0.0 or newer. This is already a requirement, thus usable without further adjustments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't put the nil check for compatibility. If we call one of the core.settings functions and the setting is at it's default value then the function will return nil anyway.

Copy link
Member

@SmallJoker SmallJoker Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part would return nil?

Correction of my previous example:

technic.config:set(k_but_without_technic_prefix, tostring(core.settings:get_bool(k, v)))
-- can be either "true" or "false"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to recall that core.settings:get and core.settings:get_bool return nil when the setting hasn't been changed at least once?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, without the 2nd argument it would indeed return nil. However, providing the fallback argument will act as a default value.

if minetest_val == nil then
technic.config:set(k, v)
else
technic.config:set(k, bool_to_string(minetest_val))
end
end
end