So are you saying there may be a way (Sostratus, LeeS) of doing this in lua?
Lee would be the expert (make sure you read his modding guide, there are some chapter on Lua) but generally:
-You choose an appropriate thing to trigger your script. This may be when the player's resources are refreshed, or perhaps the beginning of a turn is enough.
-Your script would grab the unit indexes of the units you want this "no build without fuel" applies to. You may want it to only be units which have a material cost differing from their fuel cost. This could be looking through the units + units xp2 table, or you could hard code in a short list if there aren't that many.
-You grab the player's resources. You can see an example in steamapps\common\Sid Meier's Civilization VI\DLC\Expansion2\UI\Replacements\TopPanel_Expansion2.lua that the RefreshResources() function manipulates the player resources in a number of ways, specifically you can just ask for the current amount on hand for a given resource type:
Code:
local localPlayerID = Game.GetLocalPlayer();
local localPlayer = Players[localPlayerID];
local pPlayerResources:table = localPlayer:GetResources();
...
local stockpileAmount:number = pPlayerResources:GetResourceAmount(resource.ResourceType);
-You would go through the list of relevant units you're targeting
that the player has unlocked or can otherwise build, and disable/enable them via the method Lee mentioned if the player has the needed fuel. I'm guessing the method lee gave is persistent so you'll need to turn units back on, too. But you don't want to enable redcoats just because Suleiman has built a niter mine.
Yes when they added the resources for units in GS I thought great but who builds a Battleship with Coal? So I thought no build with Iron/Steel then fuel with Oil.
Realistic to me.
Speaking from a game design standpoint:
You need to ask yourself if it makes sense that a civilization should be able to build things that they cannot
adequately fuel. Look at German military effectiveness late in ww2 for an army that was oil constrained but could still fight. Having no oil reserves doesn't necessarily mean you have no oil income.
If you think that's okay to have the combat debuff stand in for a fuel shortage, then just the way things are now if fine.
If you feel that using iron to build, while realistic, isn't the ultimate thing you want to block construction, and you'd rather have construction be blocked by fuel, then you can follow the example of other late game units and have it require the fuel resource to build in a token amount, since that already gives the "block construction if no fuel" behavior.
If you still prefer your idea, then by all means. But a
good engineer will try to think about what the end user really needs vs what they asked for. Sometimes gameplay trumps realism, and you want to make sure the mod is fun! Even if only you use it.