[Lua] Basic Modding Guide for Civ5

Question:
Does objects have the same name like the name they have in game? I mean, culture is culture, right?
 
Hey!
If you're having any difficulties, why don't you say it so I can help you and then we can make this guide better for another new modders?

A really big hurdle for me was handling persistent data, and I think a post on this topic would be useful.

Pazyryk's method is reliable, and good for saving massive amounts of data, but not ideal for small projects because it requires save routine interception.

I currently use a table serializer in conjunction with lua's loadstring and memoization, which is very fast and versatile. But it does have some serious limitations (reloading from autosaves for example).

I know some modders use whys' SaveUtils (I never have), and there are some methods in the Firaxis scenarios that are good for saving small discreet data. I think there may even be a way to save data tied to specific map tiles (MapModData), and directly into a unit (ScriptData).

At any rate a post on persistent data would be welcome.

EDIT: I see you mentioned a post on tables... that would definitely be useful for beginners.
 
Does objects have the same name like the name they have in game? I mean, culture is culture, right?
Not necessarily, and it's not even consistent sometimes. Sometimes you have to do a little detective work. Culture is culture, though most methods addressing it are named "JONSCulture" (referring to Jon Shafer). City states are internally "MinorCivilizations;" Ideologies are actually special Policies; the Giant Death Robot is a "UNIT_MECH;" that kind of thing...

At any rate a post on persistent data would be welcome.
There's this article on the modiki, for a start at least.
 
Just a question/ a suggestion. I was hoping I there would be a section on implementing Lua code into the game. I have looked at some of the tutorials at the modiki and some other places and I am still confused. What exactly would be the equivalent way to edit the lua coding in the same way one would in xml or sql. For example what I'm trying to do right now is get my tech tree to display.
 
I would like to know, how I can put some additional information into the savefile with lua.
For example I want to make a mod, in order to let the player label his current game with a name. This name should be saved in the Civ5Save-data as well, in order to be able to distinguish between different games with different labels (without relying on the name of the Civ5Save-data).
So when the player does his turn, some datas of the game (like the costs of the technologies of the current player) should be saved as a txt-datas in a file with respect to the game's label, instead of mixing up the datas in one folder for different games.
(If you are wondering why I want to do this: the technology costs and the players score helps you to find out the technologies of your opponents :D)

I am also interested in changing some lua methods in the GameCore.dll. For example there are some lua function which would allow you to cheat with FireTuner. I dont like this cheats like revealing the whole map or changing a units hitpoints, since I am playing PBEMs. :(
 
Hello, sorry if it's been asked already but I'm complete noob in this. In most of the mods and even in vanilla game inflection doesn't work. How can I simply change the Lua code to make it work?

Typical example is "TXT_KEY_NOTIFICATION_SUMMARY_CITY_CULTURE_ACQUIRED_NEW_PLOT" and "TXT_KEY_MISC_SOMEONE_DECLARED_WAR" - even though in text file is "Hranice {1_CityName[2]} se rozrostly" - (Borders of {CityName[2]} grew)
the result is always uninflect (how it should look like: Hranice Londýna se rozrostly; how it is: Hranice Londýn se rozrostly). It might seem as a silly detail but sometimes it can lead to a misunderstanding. Thanks for help
 
I'm not sure how many modders here speak Czech, so we may need a little help. Is the inflected suffix always going to be an "a"? If so, just update the appropriate localization database entries; in this case, by adding the "a" immediately after the closing curly brace ( } ) and before the space. No Lua required.
 
Well that would be just case of this particular case in Czech... Londýn (masculine, genetive => suffix -a, but when feminine genetive the word core changes - like nominatives Praha, Vídeň, Budapešť (Prague, Vien, Budapest) - genetives are Prahy, Vídně, Budapešti... the same issue with neuters (Brno -> Brna) and plurals (Athény => Athén [Athens]). That's for all slavic languages... It get's worse for Greek that recognises masculine, feminine and neuter article "The" and it's used even before names... So for example: Ta synora tón Athénón diastalthékan, Ta synora tés Rómés diastalthékan, Ta synora tou Londinou dias... but it's always uninflected with wrong article -> tou Athénai, tou Rómé, tou Londino. And also... "Alexander declared war on Attila" should look like -> O(masc.nom.) Alexandros(masc.nom) echei keryxei polemo ston(masc.accusative+additional N because of next word starting with vowel) Attila(masc.acc.) but it turn out like O Alexandros(masc.nom. uninflect) echei keryxei polemo sto(masc.nom. uninflect) Attitilas(masc.nom. = uninflect). Or É Elisabet (feminine.nom) echei keryxei polemo stén (fem.acc.+additional suffix N) Aikateriné (fem.acc.)... but the result is: O(masc.nom. uninflect) Elisabet (feminine.nom) echei keryxei polemo sto(masc.nom. uninflect) Aikateriné (fem.acc. uninflect)... I'm giving you just few examples... in the game there are more of it, also I'm 100% sure solution for this would be helpful for more languages than for just Slavic and Greek :)
 
Wow, that's really sloppy on Firaxis' part. I've been annoyed by the inconsistency in their localization techniques before, but obviously English is much more forgiving.

This would be quite an undertaking. Unfortunately, the CvLocalization library is not part of the released source code. The nominative/accusative routine would be doable (though certainly not trivial) with a Lua string parser, especially since we already have the database of gender/plurality (even if Firaxis ignores it half the time), but you'd still have to make a lot of changes to a lot of Lua files.
 
Top Bottom