DarkScythe
Hunkalicious Holo
- Joined
- May 6, 2014
- Messages
- 804
Hello, everyone,
I'm in the middle of making my first ever mod for Civ5, and it is fairly ambitious -- a whole new Civ. Thanks to everyone's help here, I've gotten virtually all of the XML finished extremely quickly and basically working without issue.
I'm at the point where I need to finish off the last couple parts of the UA with Lua, but unfortunately, I have no experience with Lua.
I've been looking at examples, and reading up where I can, though documents that get too technical are beyond my ability. I've also had some help from a few members here for specific issues, and a general guide through various little things I can/should do in Lua.
Right now, though, I am stuck.
I am attempting to come up with code that will iterate through all of a city's plots to determine a few conditions, namely its owner and if it has any resources on it.
That part is done, and it works. However, I need to be able to save this data as I have a need to check these plots each turn, and as I was advised it would not really be possible, I was recommended to use either ShareUtils or TableSaverLoader. I chose the latter, since it appeared to be newer, but otherwise either one would probably do what I need it to do.
I've already gotten some of the code in place, and have properly hooked it up to my Lua scripts, and it is at least hooking into the autosave system correctly.
My problem is that TableSaverLoader did not really come with any documentation. The author, in his thread, states that he provides an ExampleMain.lua, but I cannot seem to find it. Without the documentation, I have been working off of referencing code from other mods (such as the CL Australia civ) and trying to reverse-engineer the code necessary to communicate updates with the database. Unfortunately, as I have little experience with Lua, on top of lacking the documentation to explain how to properly utilize TableSaverLoader, I have not been successful at getting it to work.
A snippet of my code, at the stage where it needs to inject values into a table for storage, is as follows:
To explain my code:
While I am iterating through a city's plots, selected plots will have their pPlot (pointer?) and its X/Y coordinates, as well as what improvement has been built on it, saved to the database. My desire is that with this data, upon successive "scans" over the city's plots, the code can link it back up to data stored in this database, and compare to see if anything (notably, the improvement on it) has changed or not. There are a few other scenarios I need to handle, but for now I'm limiting myself to this, until I get a working prototype for me to expand on.
I am unsure if my syntax is even correct, which only exacerbates the problem.
Edit: I've also tried wrapping the data being assigned to the table fields in curly braces (for example, {pPlotX}) but it doesn't seem to matter. Either way, the Lua log / Firetuner complains that the table index is nil.
Any help, advice, or direction would be deeply appreciated.
Thank you!
I'm in the middle of making my first ever mod for Civ5, and it is fairly ambitious -- a whole new Civ. Thanks to everyone's help here, I've gotten virtually all of the XML finished extremely quickly and basically working without issue.
I'm at the point where I need to finish off the last couple parts of the UA with Lua, but unfortunately, I have no experience with Lua.
I've been looking at examples, and reading up where I can, though documents that get too technical are beyond my ability. I've also had some help from a few members here for specific issues, and a general guide through various little things I can/should do in Lua.
Right now, though, I am stuck.
I am attempting to come up with code that will iterate through all of a city's plots to determine a few conditions, namely its owner and if it has any resources on it.
That part is done, and it works. However, I need to be able to save this data as I have a need to check these plots each turn, and as I was advised it would not really be possible, I was recommended to use either ShareUtils or TableSaverLoader. I chose the latter, since it appeared to be newer, but otherwise either one would probably do what I need it to do.
I've already gotten some of the code in place, and have properly hooked it up to my Lua scripts, and it is at least hooking into the autosave system correctly.
My problem is that TableSaverLoader did not really come with any documentation. The author, in his thread, states that he provides an ExampleMain.lua, but I cannot seem to find it. Without the documentation, I have been working off of referencing code from other mods (such as the CL Australia civ) and trying to reverse-engineer the code necessary to communicate updates with the database. Unfortunately, as I have little experience with Lua, on top of lacking the documentation to explain how to properly utilize TableSaverLoader, I have not been successful at getting it to work.
A snippet of my code, at the stage where it needs to inject values into a table for storage, is as follows:
Code:
print("Plot does not already exist in the table, adding it now..")
gT.TestStorage[pPlot] = {}
gT.TestStorage[pPlot][iX] = pPlotX
gT.TestStorage[pPlot][iY] = pPlotY
gT.TestStorage[pPlot][sImprovement] = sPlotImprovement
To explain my code:
While I am iterating through a city's plots, selected plots will have their pPlot (pointer?) and its X/Y coordinates, as well as what improvement has been built on it, saved to the database. My desire is that with this data, upon successive "scans" over the city's plots, the code can link it back up to data stored in this database, and compare to see if anything (notably, the improvement on it) has changed or not. There are a few other scenarios I need to handle, but for now I'm limiting myself to this, until I get a working prototype for me to expand on.
I am unsure if my syntax is even correct, which only exacerbates the problem.
Edit: I've also tried wrapping the data being assigned to the table fields in curly braces (for example, {pPlotX}) but it doesn't seem to matter. Either way, the Lua log / Firetuner complains that the table index is nil.
Any help, advice, or direction would be deeply appreciated.
Thank you!