Getting periodically stats about the enviroment

Messages
10
Likes
3
#1
After a successfull login I get a summary of the changes in the world (new plants/animals) which I want to use to post this into our discord channel.
For this I guess I can use Eco.Stats.OrganismStats.GetPopulationStats() is this correct?

Aftet that I want to iterate over this with a list and create a string for that to push it to discord, but currently the string is always empty. Am I missing something?

C#:
public static string GetEnviromentStatsString()
{
    List<Stats.PopulationStatManager> stats = GetEnviromentStats();

    string s = "";
    stats.ForEach(stat =>
    {
        string line = "Type: " + stat.DisplayName + " | Units: " + stat.Unit + '\n';
        s += line;
        Logger.Info("GetEnviromentStatsString: " + line);

    });
    return s;
}
 
Last edited:

mampf

Administrator
Admin
Mod Dev
Messages
70
Likes
56
#3
Hello ;)

These are too less information for me to look for the error.
Are you using the Debugger in Visual Studio?
Because it should be simple to find the issue with it.

Regards mampf
 
OP
OP
Disane87
Messages
10
Likes
3
#4
I use VS and VSC but I cannot debug because I have to copy the DLLs to the server manually (or in my case via ps script).

How can I proper debug a mod within the server with breakpoints etc?
 
OP
OP
Disane87
Messages
10
Likes
3
#6
I just set my vs up like yours but the mod dlls isn't loaded. Am I missing something?

ok, I should set the debug output to the eco server path, now it works! Hopefully I can debug my own code :D
Actually it was pretty horrible and trial and error withotu proper debugging it
 
Last edited:

ClayC

Copper
Mod Dev
Messages
79
Likes
44
#7
@mampf That's a good way to debug the mod, I was using another method which is more time consuming then that.

What I did is use dev tier to load server in debug mode etc, but I prefer what you posted here and will be using this to debug my mods from now on, Thanks!!
 
OP
OP
Disane87
Messages
10
Likes
3
#8
@mampf That's a good way to debug the mod, I was using another method which is more time consuming then that.

What I did is use dev tier to load server in debug mode etc, but I prefer what you posted here and will be using this to debug my mods from now on, Thanks!!
This is pretty good imho and works like a charm.
Post automatically merged:

Just got it working with vscode flawlessly :) A bit tricky but vscode is prefered by me:
1539162388747.png
 
Last edited:
OP
OP
Disane87
Messages
10
Likes
3
#9
I got it :) Not the best approach but it's okay for the first try:

C#:
[DiscordCommand("Gibt einen Report über die Jobs aller Benutzer zurück.")]
public void EnviromentReport(DiscordMessage message)
{

    try
    {
        var ret = "";
        DateTime statsGenerated = new DateTime();

        var builder = new DiscordEmbedBuilder()
        .WithColor(DiscordColor.Gold)
        .WithTitle($"** Umwelt-Report **")
        .WithDescription($"Hier siehst du einen Bericht übr die aktuelle Umwelt für {DateTime.Now} im Vergleich zu {DateTime.Now.AddDays(-1)}");

        OrganismStats.GetPopulationStats().OrderBy(x => x.DisplayName).ForEach(s =>
        {

            // if(s.DisplayName.Contains("Birch")){
            TimeSpan timeSpan = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0);
            double unixVersion = timeSpan.TotalSeconds;
            List<FloatStatEntry> i = s.GetGraphableData(unixVersion).ToList();
            List<FloatStatEntry> iYesterday = s.GetGraphableData(DateTime.Now.AddDays(-1).Second).ToList();

            var today = i.Last();
            var yesterday = iYesterday.First();
            statsGenerated = DateTime.Now.AddSeconds(today.TimeSeconds * -1);

            var extinctionImminent = (yesterday.Value > today.Value ? true : false);
            var difference = today.Value - yesterday.Value;
            var trendIcon = (extinctionImminent ? "↘️" : "↗️");
            
            if(difference > 0){
                trendIcon = "↗️";
            }else if(difference < 0){
                trendIcon = "↘️";
            }else{
                trendIcon = "↔";
            }

            ret += $"{s.DisplayName.Replace("Population", "")}: {today.Value} ({(difference > 0 ? "+" : "")}{difference}) \n";
            // }
        });
        builder.AddField("Population", ret);
        builder.Timestamp = statsGenerated;
        // Logger.Debug(ret);
        var completed = message.RespondAsync("", false, builder).IsCompleted;
        if (completed)
        {
            Logger.Debug("Message send!");
        }
    }
    catch (Exception ex)
    {
        Logger.Debug($"Fehler: {ex.Message} \n {ex.InnerException}");
    }
}
 
Top Bottom