Question: Compound Commands to units

Place to get help with not working mods / modding interface.
Post Reply
Humpfry
Burner Inserter
Burner Inserter
Posts: 12
Joined: Wed Jul 20, 2016 12:34 pm
Contact:

Question: Compound Commands to units

Post by Humpfry »

Can someone give an example on how to utilize defines.command.compound


defines.command.compound
structure_type :: defines.compound_command: How the commands should be chained together.
commands :: array of Command: The sub-commands.


Not too sure what is the structure_type is:

{ defines.command.compound, defines.compound_command.logical_and, ... , ...}
or
{defines.command.compound, defines.compound_command.logical_and, { {...} , {...} } }

ie move to multiple rally points then build a base without being distracted as an example

set_multi_command{command=…, unit_count=…, force=…, unit_search_distance=…} → uint

Code: Select all

surface.set_multi_command{ {defines.command.compound, 
                defines.compound_command.return_last ,
                {defines.command.go_to_location, {x = 50, y = 20}, defines.distraction.none} ,
                {defines.command.go_to_location, {x = 60, y = 20}, defines.distraction.none} ,
                {defines.command.go_to_location, {x = 70, y = 20}, defines.distraction.none} ,
                {defines.command.go_to_location, {x = 80, y = 20}, defines.distraction.none} ,
                {defines.command.build_base, {x = 80, y = 20}, defines.distraction.none} },
                          10,
                           "enemy",
                           32}
or

Code: Select all

surface.set_multi_command{ defines.command.compound, 
                defines.compound_command.return_last , 
                { {defines.command.go_to_location, {x = 50, y = 20}, defines.distraction.none} ,
                  {defines.command.go_to_location, {x = 60, y = 20}, defines.distraction.none} ,
                  {defines.command.go_to_location, {x = 70, y = 20}, defines.distraction.none} ,
                  {defines.command.go_to_location, {x = 80, y = 20}, defines.distraction.none} ,
                  {defines.command.build_base, {x = 80, y = 20}, defines.distraction.none} },
                          10,
                           "enemy",
                           32}
I might have made it worse off to use the surface.set_multi_command as an example. Maybe use entity.set_command(cmd) instead. I am more interested in the cmd than the method.

Or something else, just not too sure on structure. Notice the extra brackets on the 2nd example.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5151
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Question: Compound Commands to units

Post by Klonan »

Something like this:

Code: Select all

unit.set_command
{
  type = compound,
  structure_type = structure, 
  commands = 
  {
    {type = go_to, destination = destination},
    {type = attack, target = target, distraction = distraction}
  }
}

Post Reply

Return to “Modding help”