I'm failing to update my old code to the new task_groups ai


#1

I had this code before:

self._approach_task = crab:get_component('stonehearth:ai')
	:get_task_group('stonehearth:unit_control')
	:create_task('stonehearth:goto_entity', {
		entity = self._entity
		})

It basically moved a crab into its trap (the self._entity)

With the new changes, this does not work anymore.
I tried updating the “stonehearth:unit_control” to the new “stonehearth:task_groups:solo:unit_control”, as I saw in other files, but it throws this error:

stonehearth/services/server/tasks/task_group.lua:143: task stonehearth:goto_entity not declared in solo unit control task group

Which is understandable. But I do not know any taskgroup that can run the stonehearth:goto_entity task.
Did I miss something? Or the only way is creating a new task group?


#2

Yeah, you should create your own task group type and declare stonehearth:goto_entity as a task under it, and if these are tasks you want to give out to individuals, add it to an AI pack that this character has.

We have some internal docs for the refactored AI system. I’ll try to get them converted to something public before A23 is out to stable.


#3

One last thing if it is not a problem
What is the difference between declare_multiple_tasks(), declare_task() and declare_permanent_task()


#4
  • declare_task(): Allows you to call create_task() on this group, but only one instance of the task can be active at a given time. Trying to start another before the first one is finished or canceled will produce an error.
  • declare_multiple_tasks(): Allows you to call create_task() on this group, any any number of task instances can be active at the same time. This is useful if you are creating multiple tasks of the same activity (does) but with different arguments that can be active together.
  • declare_permanent_task(): Same as declare_task(), but also automatically calls create_task() with the arguments specified in the declaration immediately when the character’s AI is initialized.

#5

I’ve posted the docs for the new AI system here: