Bigger more dynamic mods with less memory

Things that we aren't going to implement
der Papst
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sun Mar 20, 2016 6:15 pm
Contact:

Re: Bigger more dynamic mods with less memory

Post by der Papst »

I want to dig this out because it's still my biggest problem with factorio:
Factorio seems to be an hard-coded game, only reading values from editable files - and it makes (at least for me) modding for factorio really frustrating because so much potential is wasted here and the restrictions are not even consistent...
It seems every option the devs didn't foresee and hard-code into the game is simply impossible.

2 examples from my work:
  • I've created a tank shooting rockets (viewtopic.php?f=93&t=25935) - it wasn't hard, factorio simply supports a tank armed with rockets, so no problem at all.

    I tried to create a solar-thermic boiler (sun heats water) which seems to have no simple solution: Only 1 entity is able to heat water: The boiler.
    And boilers only support burning solid fuels - no oil, no gas, no electric energy, no solar energy
Wouldn't it even be simpler to develop to create a group of energy sources (burner, electric, solar) and every machine with a slot for an energy source?


At least a little help would be a function which is called for every instance of an object in every tick, so i could create (for my example above) my solar boiler as an instance of a small pump which heats the water in it's fluid box according to solar intensity...

(sry for my bad english)

Edit: Just to prevent misunderstandings:
FreeER wrote: However, all I see with the xml here is another way to specify the exact same things that lua already does without having to rework how anything is loaded.
The problem is not the unit description in the lua-files, it's the non-modular binary code of the game (and sometimes the documentation)

>This game could be twice as great if mods could create nearly everything

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

Re: Bigger more dynamic mods with less memory

Post by Rseding91 »

der Papst wrote:>This game could be twice as great if mods could create nearly everything
It's never going to happen. If you want to see what happens to performance when you build the game around that concept go look at modded Minecraft.

Just *loading* the main menu screen takes 3-5 minutes (or more depending on your computer). Loading into a game takes another 30-60 seconds and then performance quickly drops off to garbage as everything has to be runtime checked. Crafting a stack of a random recipe has to re-lookup and re-process the recipe each time checking against every single mod that's loaded.

Compare that to Factorio:

Startup time: 4-10 seconds depending on how you've configured VRAM usage and your PC speed. Loading a game: 1-10 seconds depending on how large your map is. Processing *any* recipe at *any* count: constant O(1) time.

It's just never going to happen. Just like you can't make Factorio into a FPS - you can't do everything you ever think of. There are limits to what you can mod into any given games modding system.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Bigger more dynamic mods with less memory

Post by Mooncat »

It's never going to happen.
Somehow I knew Rseding91 would say it when he see this post. :lol:
(Though I'm a bit disagree with the example. Factorio can also lag if too many mods are installed. xd)

One great thing about Factorio is the heavy optimization. Thanks to the hard work from the devs, Factorio has so much better performance compared to other games. But one main drawback of optimization is it introduces more constrains to the framework. It makes it less moddable.

An example is transport belts. There were mods that change the behaviours of transport belts, like this one: Belt Blocker. These were the days before the transport belt optimization in 0.12. Since then, because the "items" on transport belts are no longer actual items, there is no way to block a transport line.

So, why is Factorio hard-coded? Because it has to be heavily optimized. To do so, you have to understand the behaviours of entities, know what situations are possible and what are not. Based on this information, you can organize the entities in a better way, write better algorithms and get better performance.

TL;DR performance and moddability cannot coexist. Freedom comes at a price. :P


Actually, I think it is true that, for every game on earth, what a mod can do is limited by what API is provided by the devs. You can't make a sandbox game into a FPS game, unless there is such API, or the game is hacked and decompiled so you can modify it freely, which is the case of Minecraft.

(Off topic, but still about performance: a few days ago, I saw that Cities: Skyline uses C# for modding. It lead to me thinking that what if Factorio also uses C#, C++ or any compiled language for modding. Mod performance will be boosted! Maybe I am just dreaming. :lol: )
Edit: fixed a typo.
Last edited by Mooncat on Fri Feb 10, 2017 1:53 am, edited 1 time in total.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Bigger more dynamic mods with less memory

Post by DaveMcW »

Mooncat wrote:a few days ago, I saw that Cities: Skyline uses C# for modding. It lead to me thinking that what if Factorio also uses C#, C++ or any compiled language for modding. Mod performance will be bursted!
Civ4 has the best of both worlds. It has a Lua API similar to Factorio, and an open-source C++ engine that you can edit and recompile to make big, performance-heavy changes.

Of course, Civ4 mods compiled on a PC can't be run on a Mac. Freedom comes at a price. :P

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Bigger more dynamic mods with less memory

Post by posila »

DaveMcW wrote:Civ4 has the best of both worlds. It has a Lua API similar to Factorio, and an open-source C++ engine that you can edit and recompile to make big, performance-heavy changes.
I thought Civ4 mods were written in python, I didn't know about open-source engine.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Bigger more dynamic mods with less memory

Post by DaveMcW »

Oops, you're right, it is python. Civ5 used Lua.

Yoyobuae
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Nov 04, 2016 11:04 pm
Contact:

Re: Bigger more dynamic mods with less memory

Post by Yoyobuae »

der Papst wrote:
  • I tried to create a solar-thermic boiler (sun heats water) which seems to have no simple solution: Only 1 entity is able to heat water: The boiler.
    And boilers only support burning solid fuels - no oil, no gas, no electric energy, no solar energy
Wouldn't it even be simpler to develop to create a group of energy sources (burner, electric, solar) and every machine with a slot for an energy source?
Best would be for boiler entity to accept electric energy as input. And then a way to build electric networks via lua script and customize entities connected to it. This has two effects:
  • The solar part of the boiler could link together in a same electric network, taking advantage of the optimizations for solar panels
  • The solar boilers wouldn't connect to the normal electric network
  • The boiler part gets an amount of power proportional to the solar energy production
der Papst wrote:At least a little help would be a function which is called for every instance of an object in every tick, so i could create (for my example above) my solar boiler as an instance of a small pump which heats the water in it's fluid box according to solar intensity...
There's the on_tick event, but that already destroys performance if it is overused.

I think flexibility of the mod API could be improved further simply by having access to a few key things. The electric network would be awesome for anything requiring instant+efficient energy transfer. ElectricEnergyInterface entity is a nice example of stuff which would help modding a lot.

Maybe there's also some events which are missing, specially events tied to entities. Stuff which now one has to poll for using the on_tick handler (for example, checking which gui a player has opened, like Mooncat did in Creative Mode).

With good access to key data and the right set of events mods could implement almost anything, without hurting performance too much.

Post Reply

Return to “Won't implement”