Jump to content

Change variable in plugin from quest profile


Asoter

Recommended Posts

@Asoter Hello, in order to make a variable changeable by quester, you can transform your current variable into an property.

Let's say you have an quest counter in your plugin defined as int:

public int QuestCounter = 0;

So you need to change this into this:

    public int QuestCounter
    {
        get
        {
            return robotManager.Helpful.Var.GetVar<int>(this.GetType().GetProperties().FirstOrDefault()?.Name);
        }
        set
        {
            robotManager.Helpful.Var.SetVar(this.GetType().GetProperties().FirstOrDefault()?.Name, value);
        }
    }

You can still treat as an normal variable.

 

And in Quester it looks like this:

counter.JPG.524a94f1c044d6b265803c6e02f8bd58.JPG

robotManager.Helpful.Var.SetVar("QuestCounter", 12);

 

Edited by reapler
mistaken CVar <-> Var
Link to comment
Share on other sites

robotManager.Helpful.Var.SetVar("Test", true);

if (robotManager.Helpful.Var.Exist("Test"))
	Logging.Write("GETVAR " + robotManager.Helpful.Var.GetVar<bool>("Test"));

 

Link to comment
Share on other sites

got error when definie this :(

    public int QuestCounter
    {
        get
        {
            return robotManager.Helpful.Var.GetVar<int>(this.GetType().GetProperties().FirstOrDefault()?.Name);
        }
        set
        {
            robotManager.Helpful.Var.SetVar(this.GetType().GetProperties().FirstOrDefault()?.Name, value);
        }
    }
Link to comment
Share on other sites

Hey Again, anyway, got another problem, got no errors but variable finaly didnt change, Im trying to debuging this...:

 

20:34:55 - readyIntoDungeon False
20:34:57 - [PartyChatCommand] Run [CSharp] go to dungeon > robotManager.Helpful.Var.SetVar("readyIntoDungeon", true);
20:34:59 - readyIntoDungeon False
20:35:03 - readyIntoDungeon False
20:35:07 - readyIntoDungeon False

and secondly i define this without question mark after First or Default(beacause with mark I got error from WRobot):
 

    public bool readyIntoDungeon
    {
        get
        {
            return Var.GetVar<bool>(this.GetType().GetProperties().FirstOrDefault().Name);
        }
        set
        {
            Var.SetVar(this.GetType().GetProperties().FirstOrDefault().Name, value);
        }
    }

btw trying with profile but didnt work

Link to comment
Share on other sites

@Asoter Everything looks fine, checked names and values. For me it works: doesn't matter in "RunCode" or in plugin.

You may try this snippet:

using System;
using System.Linq;
using robotManager.Helpful;
using wManager.Plugin;


public class Main : IPlugin
{
        public bool readyIntoDungeon
        {
            get
            {
                Logging.Write(this.GetType().GetProperties().FirstOrDefault().Name);
                return Var.GetVar<bool>(this.GetType().GetProperties().FirstOrDefault().Name);
            }
            set
            {
                Logging.Write(this.GetType().GetProperties().FirstOrDefault().Name);
                Var.SetVar(this.GetType().GetProperties().FirstOrDefault().Name, value);
            }
        }
    
    public void Initialize()
    {
        Logging.Write(""+readyIntoDungeon);
    }

    public void Dispose()
    {

    }
    
    public void Settings()
    {
        readyIntoDungeon = true;
    }
}

Click on settings button then start bot. If it's not printing "true", then something else could be wrong with your plugin. But without an insight into your code, i can't really define the problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...