LuaUnitGroup's set_command not being done by group entitie
LuaUnitGroup's set_command not being done by group entitie
Hi,
Just need to know if there is a way to know when a command set to an entity using set_command() is accomplished
has_command does not seem to be able to handle that (it always return true for me ...)
Update : thanks to prg I know that I can track the progress of an entity by adding it to a Unit group, now, the problem is :
When I assign an entity to a group and have the groupe attack a wall, the entity just stays there, and the group state quickly change to finished whithout having anything happen
Just need to know if there is a way to know when a command set to an entity using set_command() is accomplished
has_command does not seem to be able to handle that (it always return true for me ...)
Update : thanks to prg I know that I can track the progress of an entity by adding it to a Unit group, now, the problem is :
When I assign an entity to a group and have the groupe attack a wall, the entity just stays there, and the group state quickly change to finished whithout having anything happen
Last edited by StanFear on Tue Mar 22, 2016 6:50 pm, edited 1 time in total.
Re: Any way to know when a (unit) command is over ?
Make the entity part of a unit group, order the group around, check for group.state == defines.groupstate.finished.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Any way to know when a (unit) command is over ?
this seems promissing, and it might make checking if the command is over not necessary, I'll just be able to use groupstate.attacking_target, which is what I originnaly wanted, so ...prg wrote:Make the entity part of a unit group, order the group around, check for group.state == defines.groupstate.finished.
Thank you !
Re: Any way to know when a (unit) command is over ?
ok, I come with updates,
I think giving commandes to units doesn't work
I have this piece of code :
and what it does is .... absolutely nothing ... the entity stays blocked for some time, then start wandering about ...
I printed on each tick the state of the group : it directly goes to finished (gathering -> finished)
any idea ?
I think giving commandes to units doesn't work
I have this piece of code :
Code: Select all
data.deployed_unit_group = data.deployment_center.surface.create_unit_group{position = deployment_position, force = data.deployment_center.force}
local entity = data.deployment_center.surface.create_entity{name=entity_name, position=deployment_position, force=data.deployment_center.force}
data.deployed_unit_group.add_member(entity)
data.deployed_unit_group.set_command({type=defines.command.attack, target=target_wall, distraction=defines.distraction.none})
data.deployed_unit_group.start_moving()
entity.set_command({type=defines.command.group, group = data.deployed_unit_group, distraction=defines.distraction.none})
I printed on each tick the state of the group : it directly goes to finished (gathering -> finished)
any idea ?
Re: Any way to know when a (unit) command is over ?
Hm, something similar is working for me. The position the group is created in needs to be reachable by the members, but I guess it is since you're able to create an entity in the same position that wanders around. I don't even need the last set_command call for the entity, just adding it is enough to make it follow the group. So... can't tell by just looking at that piece of code.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Any way to know when a (unit) command is over ?
ok, well, the code is right there : https://github.com/stanfear/FactorioMod ... ol.lua#L93prg wrote:So... can't tell by just looking at that piece of code.
the function is at line 93 (you should arrive there with the link)
the code from before is extracted from lines 100 and next
I really hope you'll see something I did not !
(and if you need help understanding my code, just ask !)
Re: Any way to know when a (unit) command is over ?
Is the wall you're trying to attack a valid entity? Does the unit move if you tell it to go_to_location with a hardcoded, reachable destination?
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Any way to know when a (unit) command is over ?
well, when I give the same command to the entity directly, it works (the unit start atacking the wall)prg wrote:Is the wall you're trying to attack a valid entity? Does the unit move if you tell it to go_to_location with a hardcoded, reachable destination?
it's only when using a unit group that it doesn't work
Re: LuaUnitGroup's set_command not being done by group entitie
So that people can test and understand the issue :
the mod in its current state : to reproduce the issue :
the mod in its current state : to reproduce the issue :
- Create a new game
- craft a surface driller
- place the surface driller and power it
- wait for the drill to finish its job
- go to the underground (by standing near the center of the newly placed entity
- once underground, make room for a "digging-robots-deployment-center" (3x3) and place it
- create an assembled digging robot and place it in the deployment center
- mark an area with the "selection-marker" from the toolbelt (deconstruction planner icon) -> click at one place, then clock at another with the item still in hand
- a medium bitter should apear and ... not move (sadly)
Re: LuaUnitGroup's set_command not being done by group entitie
I might have figured out why this wasn' t working!
from the documentation in LuaForce :
I am not 100% certain that this is the reason, but putting it out there won't hurt anyone !
Maybe the waring should be written in the lua doc in the function description !
from the documentation in LuaForce :
and I'm pretty sure the force I was working with was not ia_controllable.ai_controllable :: boolean [Read-Write]
Enables some higher-level AI behaviour for this force. When set to true, biters belonging to this force will automatically expand into new territories, build new spawners, and form unit groups. By default, this value is true for the enemy force and false for all others.
Note: Setting this to false does not turn off biters' AI. They will still move around and attack players who come close.
Note: It is necessary for a force to be AI controllable in order to be able to create unit groups or build bases from scripts.
I am not 100% certain that this is the reason, but putting it out there won't hurt anyone !
Maybe the waring should be written in the lua doc in the function description !
Re: LuaUnitGroup's set_command not being done by group entitie
Beware, the AI_controllable might as well enable hardcoded behavior (the one biters use) on soldiers.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.