Passing arguments into tasks

caleidon

Member
Hey!

I'm wondering if it's possible / what the best way is to achieve some sort of argument passing from one task/action to another.

Here's an example:

Let's imagine we have an agent which needs to find food and then eat it. To do this, we'd need four tasks, and all of them would need to communicate.

1. FindItem (I want this to be as generic as possible so it can find an item of any type - but in this case, how would we pass information that we want it to find food?)
2. MoveTo (when FindItem finds an item and returns success, it should also somehow pass the location of that food to MoveTo so the agent can walk there)
3. PickUp (this task needs to know which item to pick up from the 1. FindItem task)
4. Eat (finally, eat the food, but the one we just picked up, so again an argument needs to be passed)

My idea with this that I can make very generic functions which can do different stuff based on what argument gets passed into them, such as FindItem finding either food, armor or weapons.

I know SharedVariables exist, but is that the way "argument" passing was intended as or is there some other way to achieve this? Any example or additional information would be super helpful.

Thanks! :)
 
Yes, SharedVariables are the way to pass arguments. This video has an example of passing a variable between tasks:
 
Top