When I use the SaveConfig on Python it turns all the values to NULL.
happens after updating the config file and calling self.SaveConfig()
Any idea what I am doing wrong?Code:{ "GroupItems": { "admin": [ null, null, null, null, null ], "moderator": [ null ], "player": [ null ] } }
SaveConfig set all values to NULL
Discussion in 'Rust Development' started by RedNinja1337, Mar 5, 2016.
-
Wulf Community Admin
It'd probably help to show the code you are using.
-
[DOUBLEPOST=1457222474][/DOUBLEPOST]If you just call self.SaveConfig() even if you don't change anything on the config file still set all the values to null.Code:
def Init(self): command.AddChatCommand('syncgroups', self.Plugin, '_SyncGroups_') def LoadDefaultConfig(self): self.Config['GroupItems'] = ({ 'admin':({'item_shortname':'attire.hide.boots', 'Amount':1, 'Container':'Wear'}, {'item_shortname':'attire.hide.pants', 'Amount':1, 'Container':'Wear'}, {'item_shortname':'rock', 'Amount':1, 'Container':'Belt'}, {'item_shortname':'bow.hunting', 'Amount':1, 'Container':'Belt'}, {'item_shortname':'arrow.hv', 'Amount':25, 'Container':'Main'},), 'moderator':({},), 'player':({},) }) def _SyncGroups_(self, player, command, args): ConfigGroups = [] for g in self.Config['GroupItems']: ConfigGroups.append(g.ToString()) g = None del g for g in permission.GetGroups(): if g in ConfigGroups: pass else: self.Config['GroupItems'][g.ToString()] = ({},) self.SaveConfig() rust.SendChatMessage(player, 'Config file has been updated!')
[DOUBLEPOST=1457228899][/DOUBLEPOST]
[DOUBLEPOST=1457230110,1457222326][/DOUBLEPOST]Wulf, it only happens when there are tuples on the config file. This does not happens when the config file is first created by calling the function "LoadDefaultConfig" but only when calling the SaveConfig.Attached Files:
-
-
Wulf Community Admin
Weird. @Nogrod would probably know more about it, I'm not really a Python guy.
-
The problem does not seem to be Python but the SaveConfig method. Try to do a test on any other programming language, the issue is when you create a list inside the json file. This does not happens when the json file is created but when the SaveConfig is called. I am pretty sure is a bug on the SaveConfig. The SaveConfig method is turning Lists into null values.
-
Wulf Community Admin
Not sure, but I've not had any problems with lists in the default config. I think we would have noticed it if it was an issue with other languages. -
It must be Python then. I will keep trying to see if I can find a work around this if not Ill leave this function alone and try something different. Thanks Wulf.
-
Wulf Community Admin
Let me know if you find anything. I'll poke Nogrod about it too. -
Sounds good, thanks.
