Page 1 of 1

Units and UnitGroups

Posted: Sat Sep 13, 2014 2:45 pm
by ludsoe
While working on the new automated attack drone for MoCombat. I've ran into the limits of the modding API. (Rather hard actually, gave me a black eye.)
Units
UnitGroups

Re: Units and UnitGroups

Posted: Mon Sep 15, 2014 8:16 am
by roothorick
You could always make your "unit" an EntityWithHealth and spam Entity.teleport()

Unfortunately that's the current state of Factorio modding. To make things that differ even slightly in behavior from something in the vanilla game, you have to go all the way back to a basic class that does next to nothing, and reimplement EVERYTHING.

-E- So wait, UnitGroups created via Lua are automatically set autonomous by the engine? Sounds more like an outright bug to me, given the existence of UnitGroup.setautonomous

The UnitGroup API makes it look like you're supposed to send commands to the entire group, through the UnitGroup i.e. UnitGroup.setcommand . Perhaps if you give the UnitGroup itself a command in the same tick as you create it, the engine will get the idea that the UnitGroup is NOT autonomous.

-E2- Caveat: you will probably want to ALWAYS set "none" for the distraction. I'd bet money that "byenemy" will NOT be triggered by biters, and WILL be triggered by radars, turrets, walls, THE PLAYER, and so on. Be very careful with Unit/UnitGroup as a whole, it's specifically hardcoded around Units being ENEMIES.

Re: Units and UnitGroups

Posted: Mon Sep 15, 2014 5:40 pm
by ludsoe
I don't want them to re-implement everything, I just want them to expose the same data that the Unit-groups have on the units them self's. As for the extra commands if those require a re-code for some reason, I imagine that can be put off.

However exposing the current command to LUA scripts, shouldn't require a re-code. And should be very easy to add.

Re: Units and UnitGroups

Posted: Sun Sep 21, 2014 3:18 am
by ludsoe
I'm going to bump this as I believe even just exposing the units current order. (And status if possible) Would be a tremendous modding leap.
roothorick wrote:-E2- Caveat: you will probably want to ALWAYS set "none" for the distraction. I'd bet money that "byenemy" will NOT be triggered by biters, and WILL be triggered by radars, turrets, walls, THE PLAYER, and so on. Be very careful with Unit/UnitGroup as a whole, it's specifically hardcoded around Units being ENEMIES.
Biters do trigger distractions, now throw money at the developers to expose the unit's current orders to LUA. (I just have problems having the bots following orders as I have to spam them to ensure they get done. Because I cant tell if they are doing them or wandering off to go die.)