Closed alexcoder04 closed 2 years ago
Here is my code:
public void PluginMain(){
_data = new ConsoleData();
_Commands = new List<ICommand>();
_Commands.Add(new Script());
_Commands.Add(new ListScripts());
_Commands.Add(new Exec());
Console.WriteLine("savepath: " + _data.SavePath + ".");
Console.WriteLine("savepath: " + data.SavePath + ".");
}
And here is the output:
Startet...
Keine Updates Gefunden!
Lädt: Users.lcs
Users.lcs erfolgreich geladen
Lädt: Plugins
savepath: . # <- nothing here
savepath: . # <- nothing here
Erfolgreich 5 Plugins geladen!
Registriere: Datas
Erfolgreich 6 Datas registriert!
Registriere: Commands
Erfolgreich 30 Commands registriert!
--- LeoConsole v1.5.0 ---
Here is my code:
public void PluginMain(){ _data = new ConsoleData(); _Commands = new List<ICommand>(); _Commands.Add(new Script()); _Commands.Add(new ListScripts()); _Commands.Add(new Exec()); Console.WriteLine("savepath: " + _data.SavePath + "."); Console.WriteLine("savepath: " + data.SavePath + "."); }
And here is the output:
Startet... Keine Updates Gefunden! Lädt: Users.lcs Users.lcs erfolgreich geladen Lädt: Plugins savepath: . # <- nothing here savepath: . # <- nothing here Erfolgreich 5 Plugins geladen! Registriere: Datas Erfolgreich 6 Datas registriert! Registriere: Commands Erfolgreich 30 Commands registriert! --- LeoConsole v1.5.0 ---
I found the mistake.
You can not use _data.SavePath
in PluginMain()
, because data
will be registered after PluginMain()
is called.
I tried to fix it, but due to the register mechanic, it is impossible to fix it.
Why do you want to use it in PluginMain()
?
@alexcoder04
I tried to fix it, but due to the register mechanic, it is impossible to fix it. Why do you want to use it in
PluginMain()
? @alexcoder04
I want to check the SavePath location and create the scripts folder inside.
What about renaming PluginMain()
to something like PluginInit()
and adding another PluginMain()
function, which is called after data
is registered?
I tried to fix it, but due to the register mechanic, it is impossible to fix it. Why do you want to use it in
PluginMain()
? @alexcoder04I want to check the SavePath location and create the scripts folder inside.
What about renaming
PluginMain()
to something likePluginInit()
and adding anotherPluginMain()
function, which is called afterdata
is registered?
yeah, this might could be a solution, I think I will do it like this
Maybe I am doing something wrong, but it seems to me that the data values are not set yet, when
PluginMain()
runs. Is there a way to fix it?my code: