Jump to content

Ordush

Elite user
  • Posts

    1167
  • Joined

  • Last visited

Posts posted by Ordush

  1. 1 minute ago, camelot10 said:

    so you see difference and didnt understand what happened?

    there is no such definition in wow lua as False only false thats why is set that var to nil

     

    
    	void PushToLua()
    	{
    		var result = Lua.LuaDoString<bool>("HuntersMarkDisabled = " + HuntersMark.ToString().ToLower() + "; print('PUSHED LUA VALUE HunterMarkDisabled=', HuntersMarkDisabled); return HunterMarkDisabled;");
    		Logging.Write("Wrobot push to LUA HunterMark=" + HuntersMark + " return result=" + result + " isCorret=" + (HuntersMark == result) + " ");
    	}
    	void FetchFromLua()
    	{
    		var result = Lua.LuaDoString<bool>("print('FETCH FROM LUA VALUE HunterMarkDisabled=', HuntersMarkDisabled); return HuntersMarkDisabled");
    		HuntersMark = result;
    		Logging.Write("Wrobot fetch from LUA HunterMark=" + result + " ");
    	}

    just make sure for bool in C# before pushing to lua to convert to string and make lowercase

    ToString().ToLower()

    I see. No hoenestly, i did not notice the Uppercase False. I will try doing lower case. :)

  2. 10 minutes ago, camelot10 said:

    you miss something. review code and check if all code where its should be. report what wrobot logging and wow chat info messages

    My lua code is not missing anything, it works just fine without this code.
    I allready know what the problem is:
    It's this line: HuntersMarkDisabled = " + HuntersMark + ";
    It doens't work like that, it will just make HuntersMarkDisabled nil, instead of HuntersMark value.

    if (HuntersMark)
            {
                Lua.LuaDoString("HuntersMarkDisabled = true");
            }
            else
            {
                Lua.LuaDoString("HuntersMarkDisabled = false");
            }

    This however, does work.

  3. 10 hours ago, camelot10 said:
    
    
     
    
    	void PushToLua()
    	{
    		var result = Lua.LuaDoString<bool>("HuntersMarkDisabled = " + HuntersMark + "; print('PUSHED LUA VALUE HunterMarkDisabled=', HuntersMarkDisabled); return HunterMarkDisabled;");
    		Logging.Write("Wrobot push to LUA HunterMark=" + HuntersMark + " return result=" + result+ " isCorret=" + (HuntersMark == result) + " ");
    	}
    	void FetchFromLua()
    	{
    		var result = Lua.LuaDoString<bool>("print('FETCH FROM LUA VALUE HunterMarkDisabled=', HuntersMarkDisabled); return HuntersMarkDisabled");
    		HuntersMark = result;
    		Logging.Write("Wrobot fetch from LUA HunterMark=" + result+ " ");
    	}
    
    as i see, lua also not your strong side. also programming in general same.
    

    step by step tracing from point where no bug to point where bug appear called bug hunting. any programming related entity know how to do that

    do you ever before develop anything related to programming/coding?

    I really do appreciate your help mate.
    But do you HAVE to be so condescending?
    I am not a programmer no, everything i know i have taught myself over the last 6 months.
    I can promise you that i am not bad with lua at all! And yes i do know what "bug hunting" is, or as it is really called debugging... I already have debugged my lua code. Nothing is wrong with my lua code at all. Everything works perfect from the lua perspective.
    The only place where i am having issues is using the c#.
    If i was pro programmer, i would not go to these forums to ask for help.
    Anyway when i load the bot it gives me:
    PUSHED TO LUA VALUE HuntersMarkDisabled=
    When i open fight class settings i get:
    PUSHED TO LUA VALUE HuntersMarkDisabled=
    When i close fight class settings i get:
    FETCH FROM LUA VALUE HuntersMarkDisabled=
    So it seems as if it does not read the value from neither settings nor in-game. Although i know that earlier it has been reading the settings. Since it did change the value in settings, but it just didn't save them.

    I allrdy earlier figured that you can't do HuntersMarkDisabled = " + HuntersMark + ";
    Since it makes HuntersMarkDisabled nil.
    That is why i did:

    if (HuntersMark)
            {
                Lua.LuaDoString("HuntersMarkDisabled = true");
            }
            else
            {
                Lua.LuaDoString("HuntersMarkDisabled = false");
            }
  4. @camelot10

    I have tried this: Just as you told me to, but if i do it like this. It does not work.
    HuntersMark just defaults to false here for some reason. It is as if it doesn't save.
    My example i set HuntersMarkDisabled = true in-game. then i close the bot, and do /reloadui so that my lua is cleared, then i load the bot and run it. now HuntersMarkDisabled = false
    Even SteadyShot which should not in any way be influenced by the game keeps going to "false". :O

    [Serializable]
    public class HunterBeastmasterSettings : Settings
    {
        const string FILE_PREFIX = "CustomClass-HunterBeastmaster";
    
        [Setting]
        [DefaultValue(true)]
        [Category("Combat Spells - Hunter Abilities")]
        [DisplayName("Hunter's Mark Disabled")]
        [Description("Is Hunter's Mark Disabled?")]
        public bool HuntersMark { get; set; }
    
        [Setting]
        [DefaultValue(true)]
        [Category("Combat Spells - Hunter Abilities")]
        [DisplayName("Steady Shot")]
        [Description("Use Steady Shot")]
        public bool SteadyShot { get; set; }
    
        HunterBeastmasterSettings()
        {
            ConfigWinForm(new System.Drawing.Point(400, 400), "HunterBeastmaster " + Translate.Get("Settings"));
        }
    
        public static HunterBeastmasterSettings CurrentSetting { get; set; }
    
        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting = Load<HunterBeastmasterSettings>(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    CurrentSetting.PushToLua(); // SETTINGS LOADED, MUST BE TRANSLATED TO LUA
                    return true;
                }
                CurrentSetting = new HunterBeastmasterSettings();
    
            }
            catch (Exception e)
            {
                Logging.WriteError(FILE_PREFIX + " load error: " + e);
            }
            return false;
        }
    
        public bool Save()
        {
            try
            {
                CurrentSetting.FetchFromLua(); // LOAD SETTINGS FROM LUA
                return Save(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError(FILE_PREFIX + " save error: " + e);
                return false;
            }
        }
    
        
        void FetchFromLua()
        {
        	HuntersMark = Lua.LuaDoString<bool>("return HuntersMarkDisabled");
        }
    
        void PushToLua()
        {
            if (HuntersMark)
            {
                Lua.LuaDoString("HuntersMarkDisabled = true");
            }
            else
            {
                Lua.LuaDoString("HuntersMarkDisabled = false");
            }
        }
    }

     

  5. 2 minutes ago, camelot10 said:

    maybe me, but you dont understand how its works.

    you load config from file to wrobot, and after that you should push settings to lua.

    when you save settings, you you to fetch values from lua and save to file.

    your error, as example: 

    HunterMark default value is true, user set in wow HunterMark as false, before saving settings to file, you push settings to lua > override lua HunterMark to true and save HunterMark=true into xml

    when you load settings from file, HunterMark become true, but after loading you fetch HunterMark from lua and no matter what saved into xml file, its gonna be overriden by lua fetch.

    how to fix: fetch before save, push after load

    Yeah, i thought that was the problem, but i tried swapping them around as you just said, but then nothing happens at all, it neither loads nor saves anything, it just stays "false" no matter what. :/
    And you are right, i don't fully understand it, since C# is not my strongest. Happy that you are willing to help, i will try swap them around and see if i was mistaken. :)

  6. Hey all
    This is a followup post from a previous one, i decided to make a new one to clear up all the clutter.
    I have some code below that is ALMOST working. The problem is: My variables set in the settings of my FC defaults to false when not loaded from in-game lua.
    Therefor when i reload the game, instead of setting my settings to what they were before, they just default to false.
    Anyone with more C# experience than me, who can see what is wrong?
    These variables are set in my lua: HuntersMarkDisabled = true/false
    When the profile is loaded: LoadedInLua = true <-- This is so it doesn't overwrite it's own settings before the profile is loaded.

    [Serializable]
    public class HunterBeastmasterSettings : Settings
    {
        const string FILE_PREFIX = "CustomClass-HunterBeastmaster";
    
        [Setting]
        [DefaultValue(true)]
        [Category("Combat Spells - Hunter Abilities")]
        [DisplayName("Hunter's Mark Disabled")]
        [Description("Is Hunter's Mark Disabled?")]
        public bool HuntersMark { get; set; }
    
        [Setting]
        [DefaultValue(true)]
        [Category("Combat Spells - Hunter Abilities")]
        [DisplayName("Steady Shot")]
        [Description("Use Steady Shot")]
        public bool SteadyShot { get; set; }
    
        HunterBeastmasterSettings()
        {
            ConfigWinForm(new System.Drawing.Point(400, 400), "HunterBeastmaster " + Translate.Get("Settings"));
        }
    
        public static HunterBeastmasterSettings CurrentSetting { get; set; }
    
        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting = Load<HunterBeastmasterSettings>(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    CurrentSetting.FetchFromLua(); // LOAD SETTINGS FROM LUA
                    return true;
                }
                CurrentSetting = new HunterBeastmasterSettings();
    
            }
            catch (Exception e)
            {
                Logging.WriteError(FILE_PREFIX + " load error: " + e);
            }
            return false;
        }
    
        public bool Save()
        {
            try
            {
                CurrentSetting.PushToLua(); // SETTINGS LOADED, MUST BE TRANSLATED TO LUA
                return Save(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError(FILE_PREFIX + " save error: " + e);
                return false;
            }
        }
    
        
        void FetchFromLua()
        {
            var LoadedInLua = Lua.LuaDoString<bool>("return LoadedInLua");
            if (LoadedInLua)
            {
                HuntersMark = Lua.LuaDoString<bool>("return HuntersMarkDisabled");
            }
        }
    
        void PushToLua()
        {
            if (HuntersMark)
            {
                Lua.LuaDoString("HuntersMarkDisabled = true");
            }
            else
            {
                Lua.LuaDoString("HuntersMarkDisabled = false");
            }
        }
    }

     

  7. That did not work, it just gives the error: Couldn't find CVar named 'HuntersMarkDisabled'.
    However i did fix it by doing this:
     

    [Serializable]
    public class HunterBeastmasterSettings : Settings
    {
        const string FILE_PREFIX = "CustomClass-HunterBeastmaster";
    
        [Setting]
        [DefaultValue(true)]
        [Category("Combat Spells - Hunter Abilities")]
        [DisplayName("Hunter's Mark Disabled")]
        [Description("Is Hunter's Mark Disabled?")]
        public bool HuntersMark { get; set; }
    
        [Setting]
        [DefaultValue(true)]
        [Category("Combat Spells - Hunter Abilities")]
        [DisplayName("Steady Shot")]
        [Description("Use Steady Shot")]
        public bool SteadyShot { get; set; }
    
        HunterBeastmasterSettings()
        {
            ConfigWinForm(new System.Drawing.Point(400, 400), "HunterBeastmaster " + Translate.Get("Settings"));
        }
    
        public static HunterBeastmasterSettings CurrentSetting { get; set; }
    
        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting = Load<HunterBeastmasterSettings>(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    CurrentSetting.FetchFromLua(); // SETTINGS LOADED, MUST BE TRANSLATED TO LUA
                    return true;
                }
                CurrentSetting = new HunterBeastmasterSettings();
    
            }
            catch (Exception e)
            {
                Logging.WriteError(FILE_PREFIX + " load error: " + e);
            }
            return false;
        }
    
        public bool Save()
        {
            try
            {
                CurrentSetting.PushToLua(); // LOAD SETTINGS FROM LUA
                return Save(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError(FILE_PREFIX + " save error: " + e);
                return false;
            }
        }
        void FetchFromLua()
        {
            HuntersMark = Lua.LuaDoString<bool>("return HuntersMarkDisabled");
        }
    
        void PushToLua()
        {
            if (HuntersMark)
            {
                Lua.LuaDoString("HuntersMarkDisabled = true");
            }
            else
            {
                Lua.LuaDoString("HuntersMarkDisabled = false");
            }
        }
    }

    With that code, i don't combine C# and Lua in same string. But it does what it is supposed to.
    It also does change in the settings and changes in-game if i change it in the settings. So all is good.
    However, when i reload the game, it seems as if the FetchFromLua Happens before the PushFromLua so it resets to false because of that. This does make sense since it's supposed to fetch from lua on load, but if i swap the two so it fetches on save and pushes on load, then nothing works.

  8. 6 hours ago, iMod said:

    Never worked with ingame variables but give this a try:

    
    CVar.SetCVar("HuntersMarkDisabled", HuntersMark);

    instead of the Lua.DoString();

    If you want to read out your variable try:

    
    bool test = CVar.GetCVar<bool>("HuntersMarkDisabled");

    Hope that helps.

    Thanks for the tips, i will give it a try. :)

  9. I will just make an example of how i'd love for this to work. :)
    SLASH_TOGGLEHUNTERSMARK1 = '/togglehuntersmark'
    SlashCmdList.TOGGLEHUNTERSMARK1=function()
        if HuntersMarkDisabled then
            HuntersMarkDisabled = false
        else
            HuntersMarkDisabled = true
        end
    end

    Then the condition is set to HuntersMarkDisabled false to use hunters mark.

    Works very well without any problems. Now the problem is i relog the game HuntersMarkDisabled is reset (due to the variable no longer being true/false).
    So camelot10 came up with the code above, so that my HuntersMarkDisabled would be stored with the Fight Class settings. Here the problem is that when it does

    Lua.LuaDoString("HuntersMarkDisabled = " + HuntersMark);

    it doesn't turn HuntersMarkDisabled into what HuntersMark is, but it just sets it to nil.

    Hope someone can help with this problem. :)

  10. 4 hours ago, camelot10 said:
    
    [Serializable]
    public class HunterBeastmasterSettings : Settings
    {
    	const string FILE_PREFIX = "CustomClass-HunterBeastmaster";
    
    	[Setting]
    	[DefaultValue(true)]
    	[Category("Combat Spells - Hunter Abilities")]
    	[DisplayName("Hunter's Mark Disabled")]
    	[Description("Is Hunter's Mark Disabled?")]
    	public bool HuntersMark { get; set; }
    
    	[Setting]
    	[DefaultValue(true)]
    	[Category("Combat Spells - Hunter Abilities")]
    	[DisplayName("Steady Shot")]
    	[Description("Use Steady Shot")]
    	public bool SteadyShot { get; set; }
    
    	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(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName));
    		}
    		catch (Exception e)
    		{
    			Logging.WriteError(FILE_PREFIX + " save error: " + e);
    			return false;
    		}
    	}
    
    	public static bool Load()
    	{
    		try
    		{
    			if (File.Exists(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName)))
    			{
    				CurrentSetting = Load<HunterBeastmasterSettings>(AdviserFilePathAndName(FILE_PREFIX, ObjectManager.Me.Name + "." + Usefuls.RealmName));
    				CurrentSetting.PushToLua(); // SETTINGS LOADED, MUST BE TRANSLATED TO LUA
    				return true;
    			}
    			CurrentSetting = new HunterBeastmasterSettings();
    
    		}
    		catch (Exception e)
    		{
    			Logging.WriteError(FILE_PREFIX + " load error: " + e);
    		}
    		return false;
    	}
    	void FetchFromLua()
    	{
    		HuntersMark = Lua.LuaDoString<bool>("return HuntersMarkDisabled");
    	}
    
    	void PushToLua()
    	{
    		Lua.LuaDoString("HuntersMarkDisabled = " + HuntersMark);
    	}
    }

     

    Once again
    Thanks a ton Camelot!

  11. Hey all, i've been tinkering with importing settings into in-game lua variables.
    With the help of camelot10
    I'm almost there getting everything to work.

    void FetchFromLua()
        {
            HuntersMark = Lua.LuaDoString&lt;bool&gt;("return HuntersMarkDisabled");
        }

    This works great, as it changes my setting based on the in-game variable HuntersMarkDisabled.

    The problem is, when i want to send that data back to the game after a new session. I use.
     

    void PushToLua()
    	{
    		Lua.LuaDoString("HuntersMarkDisabled = " + HuntersMark);
    	}

    Which should set the variable HuntersMarkDisabled to whatever HuntersMark was in C# before.
    Now, what happens is: This turns HuntersMarkDisabled into nil instead of true/false
    My guess is that, what it is doing is: It's looking for the lua Variable HuntersMark instead of C#. Any help would be appreciated! :)

    Edit:
    Here is all my code:

    [Serializable]
    public class HunterBeastmasterSettings : Settings
    {
    
    	private bool _huntersmark = true;
    	[Setting]
    	[DefaultValue(true)]
    	[Category("Combat Spells - Hunter Abilities")]
    	[DisplayName("Hunter's Mark Disabled")]
    	[Description("Is Hunter's Mark Disabled?")]
    	public bool HuntersMark { get { return _huntersmark; } set { _huntersmark = value; } }
    
    	private bool _steadyshot = true;
    	[Setting]
    	[DefaultValue(true)]
    	[Category("Combat Spells - Hunter Abilities")]
    	[DisplayName("Steady Shot")]
    	[Description("Use Steady Shot")]
    	public bool SteadyShot { get { return _steadyshot; } set { _steadyshot = value; } }
    
    
    
    	private HunterBeastmasterSettings()
    	{
    		ConfigWinForm(new System.Drawing.Point(400, 400), "HunterBeastmaster " + Translate.Get("Settings"));
    	}
    
    	public static HunterBeastmasterSettings CurrentSetting { get; set; }
    
    	public bool Save()
    	{
    		try
    		{
    			return Save(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName));
    		}
    		catch (Exception e)
    		{
    			Logging.WriteError("HunterBeastmasterSettings &gt; Save(): " + e);
    			return false;
    		}
    	}
    
    	public static bool Load()
    	{
    		try
    		{
    			if (File.Exists(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
    			{
    				CurrentSetting = Load&lt;HunterBeastmasterSettings&gt;(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName));   
    				CurrentSetting.PushToLua();
    				CurrentSetting.FetchFromLua();
    				return true;
    			}
    			CurrentSetting = new HunterBeastmasterSettings();
    			
    		}
    		catch (Exception e)
    		{
    		Logging.WriteError("HunterBeastmasterSettings &gt; Load(): " + e);
    		}
    		return false;
    	}
    	void FetchFromLua()
    	{
    		HuntersMark = Lua.LuaDoString&lt;bool&gt;("return HuntersMarkDisabled");
    	}
    
    	void PushToLua()
    	{
    		Lua.LuaDoString("HuntersMarkDisabled = " + HuntersMark);
    	}
    }

     

  12. So yeah, another problem.
    The

    CurrentSetting.PushToLua();

    Overwrites the settings and sets everything to what default is, because it loads the settings before it does FetchFromLua. I tried doing

    try
            {
                if (File.Exists(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting = Load&lt;HunterBeastmasterSettings&gt;(AdviserFilePathAndName("CustomClass-HunterBeastmaster", ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    if (Updateloaded)
                    {
                    CurrentSetting.PushToLua();
                    }
                    return true;
                }
                CurrentSetting = new HunterBeastmasterSettings();
                
            }
            catch (Exception e)
            {
                Logging.WriteError("HunterBeastmasterSettings &gt; Load(): " + e);
            }
            return false;

    So it would first push the lua after it had loaded the settings, but that did not work. apparently i can't make an if there.
    Any help would be appreciated.

  13. I just went into the shower, while there i think i figured it out.
    If i write the code you see above, and then start my fight class with a c# code (using the editor)
    And i in that code write the following:
    if (Updateloaded != true)
    {
    Updateloaded = true
    FetchFromLua();
    }
    Then it should update my variables before displaying/using them for the rest of the fight class right?
    Meaning that would be how i load them form last session? :)

  14. 2 minutes ago, camelot10 said:

    oh god. whats your C# knowledge level ?

    My C# Knowledge level is almost non existent, which is why i've written my fightclass in lua. This is also why i was asking if anyone knew of a way to do this with lua. :)
    Edit: When it comes to C# I can read examples and modify them for my needs.

  15. 3 hours ago, camelot10 said:
    
    #if VISUAL_STUDIO
    using robotManager.Helpful;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using wManager.Wow.Bot.Tasks;
    using wManager.Wow.Class;
    using wManager.Wow.Helpers;
    using wManager.Wow.ObjectManager;
    using wManager.Wow.Enums;
    using System.Configuration;
    using System.ComponentModel;
    using System.IO;
    #endif
    
    [Serializable]
    public class TestSettings : Settings
    {
    	[Setting]
    	[DefaultValue(true)]
    	[Category("GHOST WOLF SETTINGS")]
    	[DisplayName("Ghost Wolf")]
    	[Description("Use Ghost Wolf")]
    	public bool UGW { get; set; }
    
    	[Setting]
    	[DefaultValue(4)]
    	[Category("GHOST WOLF SETTINGS")]
    	[DisplayName("Use after X secondes")]
    	[Description("Use Ghost Wolf after X secondes out of combat")]
    	public int TGW { get; set; }
    
    	public static TestSettings CurrentSetting { get; set; }
    
    	public TestSettings()
    	{
    	}
    
    	public bool Save()
    	{
    		try
    		{
    			
    			return Save(AdviserFilePathAndName("CustomClass_Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName));
    		}
    		catch (Exception e)
    		{
    			Logging.WriteError("CustomClass_ShamanSettings > Save(): " + e);
    			return false;
    		}
    	}
    	public static bool Load()
    	{
    		try
    		{
    			if (File.Exists(AdviserFilePathAndName("CustomClass_Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
    			{
    				CurrentSetting = Load<TestSettings>(AdviserFilePathAndName("CustomClass_Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName));
    			}
    			else
    			{
    				CurrentSetting = new TestSettings
    				{
    					UGW = true,
    					TGW = 4,
    				};
    			}
    			CurrentSetting.PushToLua();
    			return true;
    		}
    		catch (Exception e)
    		{
    			Logging.WriteError("CustomClass_ShamanSettings > Load(): " + e);
    		}
    		return false;
    	}
    	void PushToLua()
    	{
    		UGW = Lua.LuaDoString<bool>("return luaVar");
    	}
    
    	void FetchFromLua()
    	{
    		Lua.LuaDoString("UGW = " + UGW);
    	}
    }

    quick and dirty example

    I hit a roadblock here

    It does change the setting if i click settings based on what i set HuntersMarkDisabled to in-game, but in-game doesn't change based on what it's set to in the settings (So it saves to settings, but doesn't load from settings)

    [Serializable]
    public class HunterBeastmasterSettings : Settings
    {
    
            [Setting]
            [DefaultValue(true)]
            [Category("Combat Spells - Hunter Abilities")]
            [DisplayName("Hunter's Mark Disabled")]
            [Description("Is Hunter's Mark Disabled?")]
            public bool HuntersMark { get; set; }
    
            [Setting]
            [DefaultValue(true)]
            [Category("Combat Spells - Hunter Abilities")]
            [DisplayName("Steady Shot")]
            [Description("Is Hunter's Mark Disabled?")]
            public bool SteadyShot { get; set; }
    
        public static HunterBeastmasterSettings CurrentSetting { get; set; }
    
            private HunterBeastmasterSettings()
        {   
        }
    
        public bool Save()
        {
            try
            {
                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));
                }
                else
                {
                    CurrentSetting = new HunterBeastmasterSettings
                    {
                        HuntersMark = false,
                        SteadyShot = false,
                    };
                }
                CurrentSetting.PushToLua();
                return true;      
            }
            catch (Exception e)
            {
                Logging.WriteError("HunterBeastmasterSettings > Load(): " + e);
            }
            return false;
        }
        void PushToLua()
        {
            HuntersMark = Lua.LuaDoString<bool>("return HuntersMarkDisabled");
        }
    
        void FetchFromLua()
        {
            Lua.LuaDoString("HuntersMarkDisabled = " + HuntersMark);
        }
    }

    I tried adding CurrentSetting.FetchFromLua(); to the "try" under load.

    Do i need to rewrite the load, like the save has been rewritten for it to work? :)

  16. 2 minutes ago, camelot10 said:
    
    #if VISUAL_STUDIO
    using robotManager.Helpful;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using wManager.Wow.Bot.Tasks;
    using wManager.Wow.Class;
    using wManager.Wow.Helpers;
    using wManager.Wow.ObjectManager;
    using wManager.Wow.Enums;
    using System.Configuration;
    using System.ComponentModel;
    using System.IO;
    #endif
    
    [Serializable]
    public class TestSettings : Settings
    {
    	[Setting]
    	[DefaultValue(true)]
    	[Category("GHOST WOLF SETTINGS")]
    	[DisplayName("Ghost Wolf")]
    	[Description("Use Ghost Wolf")]
    	public bool UGW { get; set; }
    
    	[Setting]
    	[DefaultValue(4)]
    	[Category("GHOST WOLF SETTINGS")]
    	[DisplayName("Use after X secondes")]
    	[Description("Use Ghost Wolf after X secondes out of combat")]
    	public int TGW { get; set; }
    
    	public static TestSettings CurrentSetting { get; set; }
    
    	public TestSettings()
    	{
    	}
    
    	public bool Save()
    	{
    		try
    		{
    			
    			return Save(AdviserFilePathAndName("CustomClass_Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName));
    		}
    		catch (Exception e)
    		{
    			Logging.WriteError("CustomClass_ShamanSettings > Save(): " + e);
    			return false;
    		}
    	}
    	public static bool Load()
    	{
    		try
    		{
    			if (File.Exists(AdviserFilePathAndName("CustomClass_Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
    			{
    				CurrentSetting = Load<TestSettings>(AdviserFilePathAndName("CustomClass_Shaman", ObjectManager.Me.Name + "." + Usefuls.RealmName));
    			}
    			else
    			{
    				CurrentSetting = new TestSettings
    				{
    					UGW = true,
    					TGW = 4,
    				};
    			}
    			CurrentSetting.PushToLua();
    			return true;
    		}
    		catch (Exception e)
    		{
    			Logging.WriteError("CustomClass_ShamanSettings > Load(): " + e);
    		}
    		return false;
    	}
    	void PushToLua()
    	{
    		UGW = Lua.LuaDoString<bool>("return luaVar");
    	}
    
    	void FetchFromLua()
    	{
    		Lua.LuaDoString("UGW = " + UGW);
    	}
    }

    quick and dirty example

    Cheers! Makes sense!

  17. 20 minutes ago, camelot10 said:

    its a very bad practice to save variables between sessions like "c# -> wrobot -> lua -> wow -> addon -> disk" for wrobot and vice versa to load it.

    you can load wrobot settings and set lua vars after load for your lua-fightclass. this allow you to skip dependancy from wow addon and store everything you need for fightclass

    Thank you for giving me a straight answer! It's very appreciated.

    If i understand you right, i should be able to set lua vars using C#. I am obviously not very good at C#.
    I will give it a try looking through the code that people used to make settings (the links you lastly provided). And see if i can figure out how to use that to set lua vars.

    That was all i asked for mate. Thanks

  18. 2 minutes ago, camelot10 said:

    god, why so agressive? there is a small bits of information on this forum, i just whant to explain you how you can solve 99% of wrobot problems by your own.

    but lazy and agressive peoples like you, prefer to ask questions whats required a 5 minutes of time and brain working.

    my second link, first google link lead to 

     

    there is everything you need for saving and loading data/params between wrobot sessions.

    second google link gives complete info too. whats wrong with you? if you can't search internet and im trying to help, why you aggroed? since 24 aug, im only one who helping with answers in this topic. sorry if i hurt your feelings in any way. i hope you understand how to search strict string on current site and follow the trail to get answers in 5-10 mins and dont wait 3 weeks for "kind stranger"

     

    And i appreciate any help i can get, but i don't understand why you have to be rude about it? Yes it took you 5 minutes to get how to use C# for saving/loading data/params.
    What i asked was if/how i can use lua to do it. The reason i ask for lua is because i write my fightclasses in lua not C#.
    Without any reason at all you keep telling me how much i suck at using google etc. I am not being aggressive, quite the opposite, i am being defensive because you keep being rude to me instead of just telling me: "I don't know if you can do it in lua".

  19. 6 minutes ago, camelot10 said:

    now i can be rude, but i must say that:

     seems like you can't search correctly in the internet, first link in my search have partial code of robotManager.Helpful.Settings and lead to http://lmgtfy.com/?q=site%3Awrobot.eu+"AdviserFilePathAndName"

     

     

     

    What is wrong with you? There is NO reason at all to be rude at all... Being arrogant and rude has no place in a public debate area. Clearly i can't seem to get where you want me to go, you could just point me directly to where you want me to go instead of making rude gestures and posting links to a "how to use google" site.

    I am not being rude to you in any way. Your behavior is so weird...

    If anyone asks a question on this forum and i know the answer, i will answer the question, and i will point to where people can find the help they need if i know where.

    Edit: In short: Can you just tell me weather robotManager.Helpful.Settings Can work with lua or not?
    If you don't know, that is fair enough.

  20. Just now, camelot10 said:

    im not rude. i prefer to learn fly other peoples, not to carry then by myself at all time. maybe my english no so good. sorry

    ps. i put correct link above.

     

    And i allrdy did google it before you linked the "how to google" guide..
    If you click your own link you will see there are 6 links, and none of them has any info on how to use robotManager.Helpful.Settings

  21. 3 minutes ago, camelot10 said:

    Var.SetVar

    Var.GetVar

    its a internal wrobot dictionary, no relation to toc or blizzard. its used as wrobot cache, you can save, modify and delete this variables while wrobot run. if wrobot closed -> all var data lost/cleared. OR when wrobot starts, its create this cache/dictionary from scratch.

    dunno what variable you talking about

    Yeah the problem here is exactly that it's cleared.
    The reason i was using an addon instead was because i want it to save my variables between game sessions. When you close the game and wrobot, from what i understand Var.SetVar and Var.GetVar clears and then we're back to default, thereby losing the saved data?

×
×
  • Create New...