Units and UnitGroups

Post Reply
User avatar
ludsoe
Fast Inserter
Fast Inserter
Posts: 243
Joined: Tue Feb 11, 2014 8:16 am
Contact:

Units and UnitGroups

Post 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

roothorick
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Mon Aug 11, 2014 5:22 am
Contact:

Re: Units and UnitGroups

Post 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.

User avatar
ludsoe
Fast Inserter
Fast Inserter
Posts: 243
Joined: Tue Feb 11, 2014 8:16 am
Contact:

Re: Units and UnitGroups

Post 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.

User avatar
ludsoe
Fast Inserter
Fast Inserter
Posts: 243
Joined: Tue Feb 11, 2014 8:16 am
Contact:

Re: Units and UnitGroups

Post 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.)

Post Reply

Return to “Implemented mod requests”