Unit command - target vs destination

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Unit command - target vs destination

Post by FreeER »

The attack command requires a "target" variable/key, but every other command requires "destination". I'd suggest changing one, though I'm not sure which, attack would be obvious since there would be less to change, but I believe it is the only command used in any control.lua (both base and mod, unless the old CC mod used more) besides wander (which won't change)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: Unit command - target vs destination

Post by SilverWarior »

FreeER wrote:I'd suggest changing one, though I'm not sure which, attack would be obvious since there would be less to change
I don't think they will ever change attack command. Why? If you change attack command to accept location instead of target you lose the ability to attack moving targets since their location is constantly changing.

I asume you would like to be able to to send units to certain location and attack whatever it is out there.
If my asumption is correct then I suggest you check how crepers "distraction" was set up since their primary target was always player character. I think that might be able to work with combination of move to location command.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Unit command - target vs destination

Post by FreeER »

Actually, what I meant was not to change how the command actually functions but how you call it. The attack command is {type=defines.command.attack, target=entity, distraction=defines.distraction.whatever} where every other command is {type, destination, distraction}. I made a wiki page from what I saw in the code (and what I tested ingame) here. You might notice that gotolocation will accept either a location or an entity even though it uses destination (which makes sense).
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: Unit command - target vs destination

Post by SilverWarior »

FreeER wrote:You might notice that gotolocation will accept either a location or an entity even though it uses destination (which makes sense).
But does it update this location when entity moves? If the answer is yes then your suggestion could be valid.
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Unit command - target vs destination

Post by FreeER »

SilverWarior wrote: But does it update this location when entity moves? If the answer is yes then your suggestion could be valid.
hm, good question. I'm not sure since I used a nearby tree :) I kind of doubt it but I'll find out and edit

edit:hm...apparently I did not personally check the gotolocation command with an entity, there is c++ code for goto to work with an entity* but the lua interface only tries to get a RealPosition, thus passing an entity fails (with a "LuaEntity doesn't contain readable property x")
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Unit command - target vs destination

Post by kovarex »

Both move to and attack should accept both entity or position.
Similar to starcraft, where you have either attack or attack move. (Or follow/move)
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Unit command - target vs destination

Post by FreeER »

kovarex wrote:Both move to and attack should accept both entity or position.
Similar to starcraft, where you have either attack or attack move. (Or follow/move)
should as in: they already do or should as in: this is what we wanted to happen but is not currently happening and will be fixed soon?
because I've already mentioned passing an entity to gotolocation fails (property x) and passing a position (like {61.2, -300.9}) to attack fails due to "Given object is not lua entity".

However given there are two lua commands for attack, why should attack also work with position? It makes more sense (to me) to have it only use entity and have attackarea use position and radius (as is the case now).

Admittedly I've done this testing through the console but I don't think that matters here :) (not to mention, if I'm reading it right, the LuaHelper parseCommand and it's switch will back me up lol)

however, to remention the original topic, the attack command wants a table with target (ex: {target=game.player.selected}) and the other commands want a table with destination ({destination={x,y}} or {destination=game.player.selected.position}), admittedly if attack is the only command that accepts an entity this makes some sense.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net
Post Reply

Return to “Modding interface requests”