Getting a Unit's Command

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
klugemonkey
Inserter
Inserter
Posts: 23
Joined: Tue Jun 12, 2018 5:07 am
Contact:

Getting a Unit's Command

Post by klugemonkey »

It would be very useful to be able to read a Unit's command, similar to a Unit Group's state.

Right now both Units and Unit Groups can take commands, but only Unit Group will allow to read the state details such as attacking, moving, etc. There is method to find out if the Unit has a command, but it only returns a boolean.

I propose adding a method in LuaEntity for a Unit that returns a the Unit's current command. It should support all the possible unit command states (defines.command.attack, etc.). This would expand the existing API and provide consistent functionality in terms of Unit/Unit Group command reading and writing.

Ideally, it could just expose a 'command :: Command [RW}', but since there exists the set_command() and has_command() methods, it probably makes sense to just add a get_command() method:

get_command() -> command
Get the entity's current command.
Return value
command :: defines.command
Can only be used if this is Unit

If really want to implement it fully, could also add in an event when the commands change for a Unit or Unit Group. ;)

Post Reply

Return to “Modding interface requests”