Exposing all player action to the Unit API

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
jmickle_
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri Feb 03, 2017 1:23 pm
Contact:

Exposing all player action to the Unit API

Post by jmickle_ »

Hi! Been really enjoying Factorio and have been very impressed with the modding API, I've done various experiments from small new items to seeing how far I could take a total conversion of the game to create something entirely new!

For the most part it's been at least possible with some work if not really smooth to implement any ideas that came to mind. Being able to "overwrite" the map generation with my own algorithms was really fun and had a lot of possibilities. However, there was one area that unfortunately didn't appear to have any possibilities of getting working.

I wanted to try and build an AI character for the game, with the ability to mine resources, craft items they needed and build little factories of their own. However, after building the appropriate unit and getting them to detect and travel to nearby resources etc., I quickly realised there were some essential player actions that were seemingly impossible to use in my unit. The first issue was the ability to mine resources like Coal or Trees, but it looks like there may be many more actions that aren't currently available.

From an API design standpoint it seems like there's definitely room to fit these kinds of actions in, but of course I don't know the effort from the game's code standpoint. I would love to hear if exposing these actions is possible or even planned! I think the potential is huge for such features, for instance AI PvP, or even new "races" that exist alongside the player and the biters.

Edit: Apologies, didn't notice this forum section before, where I believe this thread belongs: viewforum.php?f=28

Rseding91
Factorio Staff
Factorio Staff
Posts: 13226
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Exposing all player action to the Unit API

Post by Rseding91 »

If you want to get ahold of me I'm almost always on Discord.

jmickle_
Burner Inserter
Burner Inserter
Posts: 17
Joined: Fri Feb 03, 2017 1:23 pm
Contact:

Re: Exposing all player action to the Unit API

Post by jmickle_ »

That function isn't available to entities of type "unit". I was hoping to take one of two approaches to creating an AI character, either by having a "unit" type entity, that is capable of the player's functions, or being able to create a new "player" entity that I can control with set_command(). Unless I am missing something, neither of these are possible? From some research it looks like I'll have to reimplement mining manually for my AI unit I believe?

Apologies if I am just missing something, I am still getting comfortable with the structure of the API.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13226
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Exposing all player action to the Unit API

Post by Rseding91 »

Units aren't players and as such they don't have any of the backing logic or properties that the player does.

We would have to re-program the "unit" type entity to support all of that and that's not something we're ever likely to do. The "unit" type entity is built for attacking things that pollute and military structures. It does nothing else besides that.

What you're asking for is something like "Take the flight control system from a jet and put it into the control system for my Roomba so I can instruct the Roomba to take off and land at airports or clean my room". The two things just aren't compatible in any way and have nothing to do with each other :)
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Ideas and Suggestions”