Code:class WipeCycle: def __init__(self): self.Title = "WypeCycle" self.Description = "This example illustrates how to use a basic configuration file" self.Author = "NoSharp" self.Version = V(1, 0, 0) def Init(self): command.AddChatCommand("NextWipe", self.Plugin, "NW") command.AddChatCommand("LastWipe", self.Plugin, "LW") def LoadDefaultConfig(self): default_cfg = { 'Date of the next wipe': ("DATE"), 'Date of the last Wipe': ("DATE") } self.Config = default_cfg self.SaveConfig() def NW(self, player, cmd, args): rust.SendChatMessage(player, self.Config["Date of the next wipe"]) def LW(self, player, cmd, args): rust.SendChatMessage(player, self.Config["Date of the last wipe"])
Solved Config file isn't being updated in Python
Discussion in 'Rust Development' started by Serenity 3, Jul 28, 2016.
-
Wulf Community Admin
The LoadDefaultConfig method is only called once to create the config, so any updating would have to be done by you by either calling it again or doing some checking outside of it in Init or Loaded.
-
so if i put UpdateDefaultConfig(self) would it work?
-
Wulf Community Admin
You can either call LoadDefaultConfig() again in your Init or Loaded, or make something that updates it as needed. Keep in mind that just calling LoadDefaultConfig() again will likely reset all settings in it, so checking if they are customized would be good. -
[DOUBLEPOST=1469709195][/DOUBLEPOST]when i know run /lastwipe it returns nothingCode:
class WipeCycle: def __init__(self): self.Title = "WypeCycle" self.Description = "This example illustrates how to use a basic configuration file" self.Author = "NoSharp" self.Version = V(1, 0, 0) def Init(self): command.AddChatCommand("NextWipe", self.Plugin, "NW") command.AddChatCommand("LastWipe", self.Plugin, "LW") def LoadDefaultConfig(self): default_cfg = { 'Date of the next wipe': ("DATE"), 'Date of the last Wipe': ("DATE") } self.Config = default_cfg self.SaveConfig() def LoadDefaultConfig(): default_cfg = { 'Date of the next wipe': ("DATE"), 'Date of the last wipe': ("DATE"), } self.Config = default_cfg self.SaveConfig() def NW(self, player, cmd, args): rust.SendChatMessage(player, self.Config["Date of the next wipe"]) def LW(self, player, cmd, args): rust.SendChatMessage(player, self.Config["Date of the last wipe"])
-
Wulf Community Admin
You can't have multiple LoadDefaultConfig() hooks; the first one is right. I didn't literally mean add two, I meant call it from another method manually, else do conditional checking of the config and call it if needed. -
im confused...
[DOUBLEPOST=1469709727][/DOUBLEPOST]i had used other rust plugins as an example.
and they normally use self.Defualt = {} at the end of decleration of the plugin
[DOUBLEPOST=1469709851][/DOUBLEPOST]EXAMPLE FROM INFOBOARDSCode:class infoboards: def __init__(self): self.Title = 'Info Boards' self.Version = V(2, 0, 0) self.Author = 'SkinN' self.Description = 'Custom informational boards system' self.ResourceId = 1024 self.Default = { 'CONFIG_VERSION': LATEST_CFG, 'SETTINGS': { 'PREFIX': '<white>[ <lightblue>INFO BOARDS<end> ]<end>', 'BROADCAST TO CONSOLE': True, 'SHOW BOARD IN CHAT': True, 'SHOW BOARD IN CONSOLE': False, 'ENABLE BOARDS': True }, 'MESSAGES': { 'AVAILABLE BOARDS': 'AVAILABLE BOARDS', 'NO BOARDS AVAILABLE': '<#E85858>There are\'t any boards available<end>', 'NO BOARDS FOUND': '<#E85858>No boards found with the name \'{args}\'<end>', 'MULTIPLE BOARDS FOUND': '<#E85858>Multiple boards found with close to \'{args}\'<end>', 'BOARDS DESC': '<orange>/info [board name]<end> <grey>-<end> Displays the list of available boards, if given a name then it will display the desired board' }, 'COLORS': { 'PREFIX': '#00EEEE', 'SYSTEM': 'white' }, 'COMMANDS': { 'BOARDS': ('info', 'boards') }, 'BOARDS': { 'Board Example Title': { 'DESC': 'Board Example Description', 'LINES': ( 'Line # 1', 'Line # 2', 'Line # 3' ) }, 'Server Info': { 'DESC': 'Displays server detailed information', 'LINES': ( '<green>HOSTNAME: <end><silver>{server.hostname}<end>', '<green>DESCRIPTION: <end><silver>{server.description}<end>', '<green>IP: <end><silver>{server.ip}:{server.port}<end>', '<green>MAP: <end><silver>{server.level}<end>', '<green>LOCAL TIME & DATE: <end><silver>{localtime} {localdate}<end>', '<green>GAME TIME & DATE: <end><silver>{gametime} {gamedate}<end>', '<green>PLAYERS: <silver>{players} / {server.maxplayers} ({sleepers} sleepers)<end> SEED: <silver>{server.seed}<end> WORLD SIZE: <silver>{server.worldsize}<end><end>' ) } } } -
Try using Screenshot Request for Rust Legacy | Oxide as an example. A lot less complex.
-
THANK YOU

[DOUBLEPOST=1469710372][/DOUBLEPOST]You are a life saver
-
No problem.
