[Solved] Settingtypes.txt odd behviour?

[Solved] Settingtypes.txt odd behviour?

Postby sirrobzeroone » Thu Oct 11, 2018 11:30 pm

I did some scouring of the forum but came up empty and I'm not sure if the behavior I'm seeing in regards to the settingtypes.txt file is expected/known or if its some form of minor issue.

Issue:
Create a new settingtypes.txt file and place 1 bool config setting in there
Code: Select all
#    If enabled do the enabled thing
thing_boolen (Do that thing) bool true


my expectation at this point is that once that setting is placed into the settingtypes file that if the mod is enabled for my game that if I retrieved the setting it should be true.
Code: Select all
enabled_thing = tostring(minetest.settings:get_bool("thing_boolen"))


If I check enabled_thing on load for example at this point the result is that enabled_thing == "nil". If I then close my game then go to settings>>advanced settings and just cycle my "Do that thing" setting to disabled then enabled and then reload my game enabled_thing == "true"

Is this expected/known behaviour with the settingtypes.txt file? is it just occurring as I'm implementing my settingtypes file after I've already got the mod running inside a game? Just curious really as it was a fairly frustrating hour while I couldn't work out why my setting wasn't being set or am I way off the mark :)

Thanks for the help or thoughts.
sirrobzeroone
Member
 
Posts: 37
Joined: Mon Jul 16, 2018 7:56 am

Re: Settingtypes.txt odd behviour?

Postby v-rob » Thu Oct 11, 2018 11:41 pm

I came upon this too. I don't think this is intended, and I can't find a way to fix it. It's very annoying.
v-rob
Member
 
Posts: 619
Joined: Thu Mar 24, 2016 3:19 am
GitHub: v-rob

Re: Settingtypes.txt odd behviour?

Postby TumeniNodes » Fri Oct 12, 2018 12:58 am

edited to remove, as I misunderstood what you were asking
TumeniNodes
Member
 
Posts: 2633
Joined: Fri Feb 26, 2016 7:49 pm
GitHub: TumeniNodes
In-game: TumeniNodes

Re: Settingtypes.txt odd behviour?

Postby rubenwardy » Fri Oct 12, 2018 1:24 am

This is expected behaviour, the file is only used in the advanced settings window and not for default settings. There's an open feature request for this
rubenwardy
Moderator
 
Posts: 5725
Joined: Tue Jun 12, 2012 6:11 pm
GitHub: rubenwardy
In-game: rubenwardy

Re: [Solved] Settingtypes.txt odd behviour?

Postby sirrobzeroone » Fri Oct 12, 2018 9:15 am

Thanks all appreciate the info :)
sirrobzeroone
Member
 
Posts: 37
Joined: Mon Jul 16, 2018 7:56 am

Re: [Solved] Settingtypes.txt odd behviour?

Postby Downad » Mon Mar 18, 2019 12:41 pm

can i uste seetingtypes.txt in my mod or not?

>this is expected behaviour, the file is only used in the advanced settings window and not for default settings. There's an open feature request for this

if it is only used in advanced settings, how van i use it?
must i realy write my mod-settings in minetest.conf?
Downad
Member
 
Posts: 15
Joined: Tue Oct 03, 2017 8:54 am
GitHub: downad
In-game: downad

Re: [Solved] Settingtypes.txt odd behviour?

Postby Linuxdirk » Mon Mar 18, 2019 1:15 pm

Downad wrote:if it is only used in advanced settings, how van i use it?
must i realy write my mod-settings in minetest.conf?

It's weird first, because minetest.settings:* functions do not know anything about settingtypes.txt.

Code: Select all
local my_setting = minetest.settings:get('mymod_my_setting') or 'my default'

This sets my_setting to whatever mymod_my_setting is set to, or if it is not set the string my default is used.

Code: Select all
mymod_my_setting (Set my setting) string my default

This in settingtypes.txt offers the setting via the advanced settings dialog to the user showing the description and the default value my default. When set there the setting is written to the minetest.conf file and the first code then loads the setting value from there instead of using the given default.

minetest.settings:get_bool takes a second parameter being returned as default if the setting was not set in minetest.conf (local mybool = minetest.settings:get_bool('mymod_mybool', true)). Unfortunately the other functions do not have default values.

https://github.com/minetest/minetest/bl ... 5530-L5558
Linuxdirk
Member
 
Posts: 1911
Joined: Wed Sep 17, 2014 11:21 am
In-game: Linuxdirk

Re: [Solved] Settingtypes.txt odd behviour?

Postby Downad » Tue Mar 19, 2019 10:27 am

i think i am stupid - my settingtyps.txt dont work.
my settingtypes.txt
Code: Select all
 Some settings
# Do the mobs damage the player the Areas?
# default: true - in areas the mobs damage the player
mobsdamage_areas (Mobs in the area damage the Player) bool false

# Do the mobs damage the player the PvP-Areas?
# default: true - in PvP-Areas the mobs damage the player
mobdamage_pvpareas (Mobs in the PvP-Areas damage the Player) bool false

my init.lua
Code: Select all
-- mobs in the areas damage the player
-- default: true
local mobs_in_areas_do_damage = minetest.settings:get("mobsdamage_areas")
-- mobs in PvP-areas damage the player
-- default: true
local mobs_in_pvp_areas_do_damage = minetest.settings:get("mobsdamage_pvpareas")

my output in minetest
Code: Select all
2019-03-19 11:20:51: ACTION[Main]: [settingtypes_test] mobs_in_areas_do_damage: nil
2019-03-19 11:20:51: ACTION[Main]: [settingtypes_test] mobs_in_pvp_areas_do_damage: nil

where do i make an Error?
i also testet minetest.settings:ge_bool("mobsdamage_pvpareas") with the same result. nil
Downad
Member
 
Posts: 15
Joined: Tue Oct 03, 2017 8:54 am
GitHub: downad
In-game: downad

Re: [Solved] Settingtypes.txt odd behviour?

Postby ShadMOrdre » Tue Mar 19, 2019 5:37 pm

Downad,

You have the correct setup.

What you now need to do is to go into the Minetest settings menu for your mod, and save the setting there. This will then transfer the setting from settings.txt to minetest.conf.

Rubenwardy,

Would it not make sense to use game.conf, and mod.conf, to enable settings that are preserved, and can be independently configured per game, per mod, or globally? This could probably be folded into the engine logic that also handles minetest.conf. I suggest this, because using the global minetest.conf file to store this info makes it more difficult to independently configure games and mods, without having to go to the settings tab for each instance of game play.

Shad
ShadMOrdre
Member
 
Posts: 285
Joined: Mon Dec 29, 2014 8:07 am
GitHub: ShadMOrdre
In-game: shadmordre

Re: [Solved] Settingtypes.txt odd behviour?

Postby rubenwardy » Tue Mar 19, 2019 5:58 pm

mod.conf and game.conf are for meta data about a mod or game, for example its name or description. Settings shouldn't be placed there
rubenwardy
Moderator
 
Posts: 5725
Joined: Tue Jun 12, 2012 6:11 pm
GitHub: rubenwardy
In-game: rubenwardy

Re: [Solved] Settingtypes.txt odd behviour?

Postby Linuxdirk » Wed Mar 20, 2019 7:26 am

Downad wrote:i think i am stupid - my settingtyps.txt dont work.

settingtypes' sole purpose is offering advanced settings to the users. It does not and likely will never be a place to define default settings in.

Downad wrote:my settingtypes.txt

... is fine. (except your offered default value is false but it's stated in the description that the default value is true).

Downad wrote:my init.lua

... misses setting default values in case the offered advanced setting was not set by the user.

Try this:

Code: Select all
-- mobs in the areas damage the player
-- default: true
local mobs_in_areas_do_damage = minetest.settings:get_bool("mobsdamage_areas", true)
-- mobs in PvP-areas damage the player
-- default: true
local mobs_in_pvp_areas_do_damage = minetest.settings:get_bool("mobsdamage_pvpareas", true)

Downad wrote:i also testet minetest.settings:ge_bool("mobsdamage_pvpareas") with the same result. nil

As long as you do not provide a default value when getting settings it will always be nil. (Please note, only get_bool supports setting a default value for some reason, with other functions you need to provide a default using or for example.)
Linuxdirk
Member
 
Posts: 1911
Joined: Wed Sep 17, 2014 11:21 am
In-game: Linuxdirk



Return to Modding Discussion



Who is online

Users browsing this forum: Yandex Bot [Bot] and 0 guests