Great! I look forward to hearing about what you come up with.
Unfortunately I've changed my mind since then about posting that thread. Working through that proof of concept gave me an idea of how difficult it would be to create a usable & reasonably complete interface between Lua and the Civ 3 executable, of course that was the point of the exercise. I'd estimate it would take 2-3 months to create that interface at the rate I'm currently working on C3X, which is too much work to be appealing. I don't want to post a thread teasing something I don't intend to do. The proof of concept, reimplementing disorder warning in Lua, is up on my GitHub if you want to have a look. It's on a branch called "integrate_lua". Here's the important portion, the actual disorder warning code:
Code:
local civ3 = require("civ3")
function CheckHappinessAtEndOfTurn()
local numUnhappyCities, firstUnhappyCity = 0, nil
for city in civ3.mainScreenForm:GetController():Cities() do
city:RecomputeHappiness()
local numHappy, numUnhappy = 0, 0
for citizen in city:Citizens() do
if citizen.Mood == civ3.CitizenMood.Happy then
numHappy = numHappy + 1
end
if citizen.Mood == civ3.CitizenMood.Unhappy then
numUnhappy = numUnhappy + 1
end
end
if numUnhappy > numHappy then
numUnhappyCities = numUnhappyCities + 1
if firstUnhappyCity == nil then firstUnhappyCity = city end
end
end
if firstUnhappyCity ~= nil then
local response
if numUnhappyCities > 1 then
response = civ3.ShowPopup(civ3.GetC3XScriptPath(), "C3X_DISORDER_WARNING_MULTIPLE", firstUnhappyCity:GetName(), numUnhappyCities)
else
response = civ3.ShowPopup(civ3.GetC3XScriptPath(), "C3X_DISORDER_WARNING_ONE", firstUnhappyCity:GetName())
end
if response == 2 then -- zoom to city
civ3.mainScreenForm.turnEndFlag = true
firstUnhappyCity:ZoomTo()
elseif response == 1 then -- just cancel turn end
civ3.mainScreenForm.turnEndFlag = true
-- else do nothing, let turn end
end
end
end
It's pretty easy to understand, right? Not shown is another ~200 lines of Lua and ~50 lines of C necessary to make the above code work. For example,
civ3.mainScreenForm:GetController():Cities() creates an iterator over the sitting human player's cities,
city:Citizens() creates an iterator over the citizens in a city, and
civ3.ShowPopup(...) is an easy way to throw up a popup window. Those things aren't available with only bare C bindings to the game's internals; they all require extra work to set up. I don't think it's worth the effort unless this is something people really want and will actually use.
One interesting feature of Lua scripting is that the scripts could be made compatible with both the original Firaxis EXE and C7, the open source recreation. It's "only" a matter of making the Civ 3 interface the same for both. It would be easier for self-contained things like map generation and maybe unit AI, making gameplay modifications compatible with both would be more difficult. C7 doesn't support Lua at the moment, I think everyone has in mind to write the whole thing in C#, but I know
@Puppeteer has at least toyed with the possibility before. Again, I'm not sure it's worth the effort, this would add another layer of complications to C7.
When I click on "Preferences > C3X Info," it says:
Version 13 Config files loaded: 1. (base)
Is that what everyone else sees, or am I missing something?
That's normal. Why do you think you're missing something, is it because there are no INI config files listed? The INI files are only loaded when you load into a game. The reason for that is that they can only be loaded after some scenario has been, since they potentially refer to things in the scenario, like the names of units and buildings. The "(base)" config is listed there as a reminder that there's technically still a config present even if all of the INI files are missing. Its settings match the unedited default.c3x_config.ini. Normally the base config doesn't matter since its settings are all overwritten by the default INI.
Is there away to have the option of making city improvements that one does not have the tech for or those that are obsolete disappear? The AI will not sell obsolete improvements and will only lose them if they can't pay maintenance. This is a problem with custom civ traits and their trait specific improvements in captured cities.
That would not be difficult to program in. I could make it an optional game rule that improvements disappear when their tech requirement is not met, but I'd rather enhance the AI to be smart enough to sell buildings it could never use, if possible. Could there ever be a disadvantage to selling an obsolete building? If the AI doesn't have the tech to use a building, it should only sell it if it could never acquire that tech, is there an easy way to determine that? Are all those techs "era zero"?
Thinking more about (hopefully) relatively minor fixes to C3C, have you looked at the bug that broke "capture the princess" functionality between PTW and Conquests?
On the larger side, I am another modder who would very much like to be able to make units equally capable of travelling over land and water without distinction...
I have not looked at it, in fact I don't even know what that bug is about, could you describe it? I don't think I've ever played a game of Civ 3 with "capture the princess" rules in play. I suspect that allowing units to travel on both land and sea is the sort of thing that would be easy to do at a basic level, e.g. by editing one movement function, but would break many other things like combat. We could always try it and see. Other changes to the game's movement rules, limiting railroad movement and restricting trespassing, turned out to be surprisingly easy, for what that's worth.
As these "special resources" offer such a cornucopia of new modding options, it would be great if now at least the multiple pop-ups of the Hyperlink Bug could be wiped out...
--------------------------------------------------------------------------------------------------------
There were some posts in this thread about giving cities only one additional shield as 25 % more is considered to be too much and the possibility even to create new traits for civs:
Those special resources could be an interesting way to "fine tune" such settings, as these resources can provide a very different amount of shields, commerce and food to a city, but unfortunately at present there is an obstacle for doing this: These resources improve city tiles where these resources are appearing. As such a resource is not appearing in any city tile, there is no improvement in shields, commerce and food in those cities. It would be nice, if the bonuses of such a special resource, that is appearing in a city could be added to the city, even without an appearance of that resource in the city radius.
The hyperlink bug is one of those things I've had in the back of my mind for a while now but haven't gotten around to looking into. I'll try to get around to it sooner rather than later. That's an interesting suggestion that buildings could grant the yield bonuses from their generated resources to the city tile. I suppose it's fair for generated resources to give bonuses like ones gathered from the map. It would also make it easy to create buildings with yield bonuses in the editor, and easy to read in those rules for the mod, but unfortunately it would not make it easier to program the actual effect. Still, the programming is doable. Good idea.