Solved Loops, GetSetting()

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Basically I'd like to get the value from a setting an ini file.
E.G
[Items]
Metal Ore=250

I'd like to get "250".
This is what I have at the moment:
Python:
        keys = Plugin.GetIni("Settings").EnumSection("Items")
        setting = Plugin.GetIni("Settings").GetSetting
        Util.Log("----------------------------")
        for key in keys:
            for amount in setting("Items", key):
                Util.Log(key + "=" + amount)
        Util.Log("----------------------------")
At the moment it works, But it will print out:
Metal Ore=2
Metal Ore=5
Metal Ore=0
I want it to print: Metal Ore=250
Anyone got any ideas?
I've never really worked with looping in a file before
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
Mmmm
Python:
ini = Plugin.GetIni("Settings")

keys = ini.EnumSection("Items")

for key in keys:
     Util.Log(key + "=" + ini.GetSetting("Items", key))
Is that what you mean ?
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Mmmm
Python:
ini = Plugin.GetIni("Settings")

keys = ini.EnumSection("Items")

for key in keys:
     Util.Log(key + "=" + ini.GetSetting("Items", key))
Is that what you mean ?
That worked! Thanks!
 
  • Like
Reactions: Snake