Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Best way to share variables among tasks (TaskBot)?

Joined
Dec 24, 2018
Messages
29
What would be the best way to share variables among tasks using TaskBot?

For example when interacting with an npc or object, I'd like to turn "moving the camera" and "walking" into separate tasks, so the target entity has to be shared among these tasks.

Is there a proper way to do this or should these activities not be in different task classes?
 
Joined
Oct 23, 2015
Messages
117
What would be the best way to share variables among tasks using TaskBot?

For example when interacting with an npc or object, I'd like to turn "moving the camera" and "walking" into separate tasks, so the target entity has to be shared among these tasks.

Is there a proper way to do this or should these activities not be in different task classes?
I don't use TaskBot but can't you use getter/setters?
 
Joined
Dec 24, 2018
Messages
29
I don't use TaskBot but can't you use getter/setters?

I mean I can hack it with static variables obviously but I was kinda looking for the proper way to do it, or if I shouldn't be splitting it up if I need shared variables.
 
cuppa.drink(java);
Joined
Mar 13, 2018
Messages
7,097
I mean I can hack it with static variables obviously but I was kinda looking for the proper way to do it, or if I shouldn't be splitting it up if I need shared variables.
By my understanding you shouldn't use static variables since they're shared by the entire bot, every tab. That could be wrong though.

I've never used TaskBot, and I'm not 100% understanding what you're trying to accomplish, but if you want to make variables available to your whole bot you should create variables in your root bot object that can be called like

(In your RotateCamera task)
Npc target = ((MyFightingBot) Environment.getBot()).target;

And set in a similar way.

Or use getters and setters, obviously.
 
Joined
Dec 24, 2018
Messages
29
By my understanding you shouldn't use static variables since they're shared by the entire bot, every tab. That could be wrong though.

I've never used TaskBot, and I'm not 100% understanding what you're trying to accomplish, but if you want to make variables available to your whole bot you should create variables in your root bot object that can be called like

(In your RotateCamera task)
Npc target = ((MyFightingBot) Environment.getBot()).target;

And set in a similar way.

Or use getters and setters, obviously.

Yeah thanks, I accomplished it using the root bot object. :)

Just wondering, if you're not using TaskBot, what are you using then? LoopingBot?
 
cuppa.drink(java);
Joined
Mar 13, 2018
Messages
7,097
That's cool, I honestly didn't even know about TreeBot lol, it looks really convenient.

Is TreeBot the way to go then?
I'm a fan of it, I find it really helps with structuring the logic of a bot, once you get the hang of it. There's also a tool somewhere on the site that will help generate the skeleton of a TreeBot if you want that. Also you'll want to write out on paper what your bot tree will look like first so you can run through it and make sure your logic will do what you expect.

But yeah, I recommend at least trying it.
 
Joined
Dec 24, 2018
Messages
29
I'm a fan of it, I find it really helps with structuring the logic of a bot, once you get the hang of it. There's also a tool somewhere on the site that will help generate the skeleton of a TreeBot if you want that. Also you'll want to write out on paper what your bot tree will look like first so you can run through it and make sure your logic will do what you expect.

But yeah, I recommend at least trying it.

Definitely gonna try it next time! I've seen some examples and I can definitely see the appeal.
 
Top