[BNW] Could I load all Lua scripts of other mods for integrating unique abilities?

Lenin1870

Chieftain
Joined
Mar 16, 2013
Messages
50
I planned to make unique ability that is able to select other civs' unique abilities as 'Advanced Policies', but embodied unique abilities using Lua are not available using normal ways.

My idea about Lua scripts is following:
I wrote 'include("%w+.lua", true)' first for loading all Lua scripts, but I have no idea how I can insert conditions for my mod civ to integrate other mod civs' unique abilities into the all Lua scripts of other mods. For instance, If other scripts contain statements like 'if Players[iPlayerID] == GameInfoTypes[OtherCivsName]', I just convert it to statements including my mod civ info like 'if Players[iPlayerID] == GameInfoTypes[OtherCivsName] or Players[iPlayerID] == GameInfoTypes[MyCivsName]'.

But I don't confirm that method, and it may be impossible. Thus, I seek your advice.
 
First:

Players[iPlayerID] will never be equal to any GameInfoTypes["CIVILIZATION_SOMETHING"]
Players[iPlayerID] is a game object pointer, and can never be equal to any GameInfoType

In order to determine whether any value currently held within variable "iPlayerID" is the player using "CIVILIZATION_RUSSIA" you need to write an evaluation statement as
Code:
if Players[iPlayerID]:GetCivilizationType() == GameInfoTypes["CIVILIZATION_RUSSIA"] then
    print(iPlayerID .. " is running the game as CIVILIZATION_RUSSIA")
end

Second:

So far as including all the scripts all other mods are running, adding everything lua into your code using a global "include()" command would literally copy the contents of every single lua file existing in the game's systems into your script at the point in your file where the include command appears. But this is only done internally within the game's lua system -- the contents of your mod's actual lua file will not be alterred. Most likely you would simply crash the game if for no other reason than your script is an lua file, which would be included into the contents of your lua file along with all the others, and which would then as the contents of your original file is included into the contents of your original script then attempt to include everything that is an lua file within the game's files system, which would .... until the game promptly crashes as it attempted to spiral down the rabbit hole of these self-referential endlessly looping "include" commands.

Even if you add the necessary commands to only add the contents of certain specified lua scripts from other mods, this would not accomplish your goal because those scripts would be copied in their unalterred entirety into your script, and which would then "double-down" the effects of the original mod since now two lua scripts are executing the exact same commands. In order for your script to "adapt" the code of the other mod to your civilization you would have to rewrite within your script all the functions in the other lua scripts so that they would now work upon your civilization.

It is simply impossible for you to know how many different mods are running at any one time, and for you to keep adding code to cover the lua scripting needed to "add-in" the effect of each and every new mod added to the total sum number of all custom-civilization mods.

Far simpler to just pick the effects from other mods you want to copy and just actually copy and edit as necessary the code needed directly into your lua file. After, of course, doing everything you can to ensure the original author of the mod you are copying has no objections to such a sort of .. uh .. effect borrowing. One mod that does "X" as a custom effect for a unique unit is, well, unique -- two mods is not.
 
Last edited:
First:

Players[iPlayerID] will never be equal to any GameInfoTypes["CIVILIZATION_SOMETHING"]
Players[iPlayerID] is a game object pointer, and can never be equal to any GameInfoType

In order to determine whether any value currently held within variable "iPlayerID" is the player using "CIVILIZATION_RUSSIA" you need to write an evaluation statement as
Code:
if Players[iPlayerID]:GetCivilizationType() == GameInfoTypes["CIVILIZATION_RUSSIA"] then
    print(iPlayerID .. " is running the game as CIVILIZATION_RUSSIA")
end

Second:

So far as including all the scripts all other mods are running, adding everything lua into your code using a global "include()" command would literally copy the contents of every single lua file existing in the game's systems into your script at the point in your file where the include command appears. But this is only done internally within the game's lua system -- the contents of your mod's actual lua file will not be alterred. Most likely you would simply crash the game if for no other reason than your script is an lua file, which would be included into the contents of your lua file along with all the others, and which would then as the contents of your original file is included into the contents of your original script then attempt to include everything that is an lua file within the game's files system, which would .... until the game promptly crashes as it attempted to spiral down the rabbit hole of these self-referential endlessly looping "include" commands.

Even if you add the necessary commands to only add the contents of certain specified lua scripts from other mods, this would not accomplish your goal because those scripts would be copied in their unalterred entirety into your script, and which would then "double-down" the effects of the original mod since now two lua scripts are executing the exact same commands. In order for your script to "adapt" the code of the other mod to your civilization you would have to rewrite within your script all the functions in the other lua scripts so that they would now work upon your civilization.

It is simply impossible for you to know how many different mods are running at any one time, and for you to keep adding code to cover the lua scripting needed to "add-in" the effect of each and every new mod added to the total sum number of all custom-civilization mods.

Far simpler to just pick the effects from other mods you want to copy and just actually copy and edit as necessary the code needed directly into your lua file. After, of course, doing everything you can to ensure the original author of the mod you are copying has no objections to such a sort of .. uh .. effect borrowing. One mod that does "X" as a custom effect for a unique unit is, well, unique -- two mods is not.
Thank you. I was wondering if it was possible, but it's impossible. I'll think about other effects.
 
Top Bottom