• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

C++/Lua Request Thread

Never mind, the one for improvements doesn't even do what I would expect. No wonder none of this is making sense to me. It's all about graphics events and when stuff is drawn or becomes visible.

GameEvents.Anything() trigger in response to events within the game core for all players - typically these are the ones you want

Events.SerialEventAnything() trigger when the visible map needs to be updated - typically these are no use whatsoever (as they won't trigger for the AI players unless the human player has revealed the plot they happen on)

Where's the beef?
RESOURCE_COW ;)
 
Taken from tutorial:
"A good idea in theory would be to detect when the user is going to save his game so that you only write data at this point. Unfortunately there is no event for this circumstance"

That's insane! I am supposed to do database writes to presist data on every do turn? Is there a DLL fix for this performance nightmare?
 
Taken from tutorial:
"A good idea in theory would be to detect when the user is going to save his game so that you only write data at this point. Unfortunately there is no event for this circumstance"

That's insane! I am supposed to do database writes to presist data on every do turn? Is there a DLL fix for this performance nightmare?

You can always hack the Lua to intercept the Save button click ... from multiple menus. And don't forget auto-save and quick save ... and save to cloud ... and probably a few others I've forgotten.
 
You can always hack the Lua to intercept the Save button click ... from multiple menus. And don't forget auto-save and quick save ... and save to cloud ... and probably a few others I've forgotten.
Ah yes, nothing like handling things all the hell all over the place instead of at some clean pinch point :)
 
Ah yes, nothing like handling things all the hell all over the place instead of at some clean pinch point :)

You forgot "or copy-and-paste instead of using functions". And what's really sad is that the C++ is no better than the Lua
 
Is there a DLL fix for this performance nightmare?

No. As the save code (UI.SaveGame()) is in the UI DLL and we don't have the source code for that
 
UI is a C++ object with a Lua wrapper, not a Lua object
 
At the bottom of this post is a file called ExampleMain.lua. It shows how to intercept the 4 gamesave types in Lua: cntl-S, save from menu, F11 quicksave, and endturn for autosave (now coded for every turn but could perhaps be changed to reflect user autosave setting). It's slightly strange for the user at first because cntl-S and save from menu don't take you to the save menu, but instead save the game (with a Lua generated name) and give a notification in game. I would assume though that the save menu is a typical UI lua/xml system that could be triggered -- I just haven't gotten around to that yet. I use this to drive my TableSaverLoader.
 
You can always hack the Lua to intercept the Save button click ... from multiple menus. And don't forget auto-save and quick save ... and save to cloud ... and probably a few others I've forgotten.

How can I intercept clicks like these?
 
How can I intercept clicks like these?

Pretty sure the TableSaverLoader mod utils do this, so that would be a good place to find some examples.

Other than that, you just need to find the Lua files with those functions in, copy them to your mod, set VFS=true, and then make any required edits to do what you need to do in addition to the standard stuff
 
Methods to Add :c5faith: :c5culture: and :c5happy: (How impossible is it?)

Code:
City.ChangeBaseYieldRateFromMisc(GameInfoTypes.YIELD_FAITH, LOCAL_NAME)
City.ChangeBaseYieldRateFromMisc(GameInfoTypes.YIELD_CULTURE, LOCAL_NAME)
City.ChangeBaseYieldRateFromMisc(GameInfoTypes.YIELD_HAPPINESS, LOCAL_NAME)
 
I have a request, a way of making specialists actually yield faith. Right now the mechanic for specialists is hard coded so neither culture nor faith may be yielded from Specialists, even if you do declare it via database (either through xml or sql), with culture it isn't such an isse, as there's a different tag that allos Artists to generate culture, but there's no way of making a specialist yield religion via xml or sql.
 
Back
Top Bottom