Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Call settings save/load in C#?

Featured Replies

Hey all!
The save and load functiosn are called 3 times.

First load is when you open settings, save is called when you close settings, load is called again when you start the bot  (press play)

Is there any way that i can call the save or load during the rotaiton?

  • Author
1 hour ago, Droidz said:

Hello, for the product or general settings?

Sorry for the general settings ofc. :)
It's because I've made it so it updates some in-game lua variables every time it saves/loads. (It's so i don't have to make an addon with savedVariables to save my lua variables between sessions.)
For my fightclass

Edited by Ordush

  • 4 weeks later...
  • Author

@Droidz is there any way to save fightclass settings with C# as well?
That's actually what i was trying to do.

wManager.wManagerSetting.CurrentSetting.Save();

did not work, i'd like to save the fightclass settings with C#. Is that at all possible?

  • Author
3 hours ago, Droidz said:

Hello, what is your fightclass code?

[Serializable]
public class HunterBeastmasterSettings : Settings
{

        private bool _huntersmark = false;
        [Setting]
        [DefaultValue(false)]
        [Category("Settings")]
        [DisplayName("Hunter's Mark")]
        [Description("Use Hunter's Mark")]
        public bool HuntersMark { get { return _huntersmark; } set { _huntersmark = value; } }



    private HunterBeastmasterSettings()
    {
        ConfigWinForm(new System.Drawing.Point(400, 400), "HunterBeastmaster " + Translate.Get("Settings"));
    }

    public static HunterBeastmasterSettings CurrentSetting { get; set; }

    public bool Save()
    {
        try
        {
            CurrentSetting.FetchFromLua(); // LOAD SETTINGS FROM LUA
            return Save(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName));
        }
        catch (Exception e)
        {
            Logging.WriteError("HunterBeastmasterSettings > Save(): " + e);
            return false;
        }
    }

    public static bool Load()
    {
        try
        {
            if (File.Exists(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
            {
                CurrentSetting = Load<HunterBeastmasterSettings>(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName));
                CurrentSetting.PushToLua(); // SETTINGS LOADED, MUST BE TRANSLATED TO LUA
                return true;
            }
            CurrentSetting = new HunterBeastmasterSettings();
        }
        catch (Exception e)
        {
            Logging.WriteError("HunterBeastmasterSettings > Load(): " + e);
        }
        return false;
    }

    void FetchFromLua()
    {
        HuntersMark = Lua.LuaDoString<bool>("return HuntersMarkDisabled");
        Lua.LuaDoString("print('Fetched Lua')");
    }

    void PushToLua()
    {
        Lua.LuaDoString("HuntersMarkDisabled = " + HuntersMark.ToString().ToLower());
        Lua.LuaDoString("print('Pushed Lua')");
    }
}

 

  • Author

If i am running

wManager.wManagerSetting.CurrentSetting.Save();

Nothing happens, but if i open and close the fightclass options, the save function is called.
But i'd like to add

wManager.wManagerSetting.CurrentSetting.Save();

to the fight class rotation, so it saves every so often instead of only when you open/close the options. :)

 

  • Author
2 hours ago, Droidz said:

HunterBeastmasterSettings.CurrentSetting.Save()

 

@Droidz Am i doing something wrong?
If you look at the code i have above, then the line you just wrote here should save and thereby do

CurrentSetting.FetchFromLua();

But neither if i have it in my rotation and set to do C#, or if i use the DevolpmentTools and write the code below will work?

HunterBeastmasterSettings.CurrentSetting.Save()

This is how it looks:

new SpellState("HunterBeastmasterSettings.CurrentSetting.Save();", 1, context => true, false, false, false, false, false, false, false, false, 0, false, false, false, false, false, false, wManager.Wow.Helpers.FightClassCreator.YesNoAuto.Yes, "", "none", false, false, true),

 

/*
 * SETTINGS
*/

[Serializable]
public class HunterBeastmasterSettings : Settings
{

        private bool _huntersmark = false;
        [Setting]
        [DefaultValue(false)]
        [Category("Settings")]
        [DisplayName("Hunter's Mark")]
        [Description("Use Hunter's Mark")]
        public bool HuntersMark { get { return _huntersmark; } set { _huntersmark = value; } }



    private HunterBeastmasterSettings()
    {
        ConfigWinForm(new System.Drawing.Point(400, 400), "HunterBeastmaster " + Translate.Get("Settings"));
    }

    public static HunterBeastmasterSettings CurrentSetting { get; set; }

    public bool Save()
    {
        try
        {
            CurrentSetting.FetchFromLua(); // LOAD SETTINGS FROM LUA
            return Save(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName));
        }
        catch (Exception e)
        {
            Logging.WriteError("HunterBeastmasterSettings > Save(): " + e);
            return false;
        }
    }

    public static bool Load()
    {
        try
        {
            if (File.Exists(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
            {
                CurrentSetting = Load<HunterBeastmasterSettings>(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName));
                CurrentSetting.PushToLua(); // SETTINGS LOADED, MUST BE TRANSLATED TO LUA
                return true;
            }
            CurrentSetting = new HunterBeastmasterSettings();
        }
        catch (Exception e)
        {
            Logging.WriteError("HunterBeastmasterSettings > Load(): " + e);
        }
        return false;
    }

    void FetchFromLua()
    {
        HuntersMark = Lua.LuaDoString<bool>("return HuntersMarkDisabled");
        Lua.LuaDoString("print('Fetched Lua')");
    }

    void PushToLua()
    {
        Lua.LuaDoString("HuntersMarkDisabled = " + HuntersMark.ToString().ToLower());
        Lua.LuaDoString("print('Pushed Lua')");
    }
}

Yet it is not printing anything nor is it saving. :/
If i open the options by clicking the cogwheel, it will print Pushed Lua, if i close the cogwheel it will print Fetched Lua
This is what i'm trying to do with

HunterBeastmasterSettings.CurrentSetting.Save()
  • Author
57 minutes ago, Droidz said:

When do you want to save (what triggers the save)?

I just want to save every end of the "rotation" or on a timer..
I also tried calling the save with the Development tool.

Edit: I am using the fight class editor to make my fightclasses. (And notepad)
Edit2: To be more precise, what i wanted to do was to put the HunterBeastmasterSettings.CurrentSetting.Save() as the last "spell" in my rotation and then set it to run as C#.

Edited by Ordush

  • Author
4 minutes ago, Droidz said:

try:


new SpellState("Save...", 1, context => HunterBeastmasterSettings.CurrentSetting.Save() && false, false, false, false, false, false, false, false, false, 0, false, false, false, false, false, false, wManager.Wow.Helpers.FightClassCreator.YesNoAuto.Yes, "", "none", false, false, true),

 

You are a god damn god! <3
Thank you!!!!

Edit: Is there any way that i can add this with the fight class editor, so i don't have to change to CS every update? :)

Edited by Ordush

  • Author

@Droidz

Is there any way to Load from the fightclass?

HunterBeastmasterSettings.CurrentSetting.Load()

Won't work since the Load function is static.
The reason i want to load manually is because if people do /reloadui without stopping the bot, it will not load (since it only loads when you press "play")

Edited by Ordush

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.