[GS] Help with lua for Civs Project

cuso210

Warlord
Joined
Apr 6, 2012
Messages
124
Hi! I am currently updating most of the civilization and leader mods in the workshop so they can be used in Gathering Storm, while updating their cultures and fixing some errors in the sql files. Right now, I've managed to make them all appear in the leader screen selection and they all load into the game, as they are almost done.

The problem is that some mods use some lua functions, which mark errors in the lua.log. I know nothing about lua (I am not a programmer and don't know much about sql too, as I learned while I worked on this), so if any of you could help me fix them I'd really appreciate it, and you would have a new and functional civ to play with.

Right now I'm stuck with Leugi's Haiti civ ( https://steamcommunity.com/sharedfiles/filedetails/?id=1562787583 ). I've already managed to make them appear and it all works great, except for it's builder and era score bonuses. The file "Leugi_Haiti_GameplayFunctions" has this lines that cause RunTime error:

include("Civ6Common.lua")

include("AdjacencyBonusSupport.lua")

And also the lua.log shows this:

Runtime Error: E:\Games\steam\steamapps\workshop\content\289070\1562787583\lua\Leugi_Haiti_GameplayFunctions.lua:372: operator - is not supported for nil - number

stack traceback:

E:\Games\steam\steamapps\workshop\content\289070\1562787583\lua\Leugi_Haiti_GameplayFunctions.lua:372: in function 'OnTurnActivatedEraScoreCheck'

[C]: in function 'func'

[C]: in function '(anonymous)'

If anyone can help me, I can send you the files I've edited so you could try it and maybe help me finish update these mods. I only need to understand why the error occurs on this mod, so then I can aplly the fix in the rest of them. Thank you in advance.
 

cuso210

Warlord
Joined
Apr 6, 2012
Messages
124
Thanks for replying! I don't know if I should upload the code, as it's not mine, it's Leugi's. Do you mind if I send you a PM?
 

Infixo

Deity
Joined
Jan 9, 2016
Messages
3,832
Location
Warsaw
The problem is probably caused by the separation of UI and Gameplay contexts that was done by Fraxis some time ago. Could be with GS, can't remember. That is why this mod works with R&F only and not GS.

Line 372 is: ScoreDifference = Age_EraScore - loadEraScore

And Age_EraScore is nil atm. It is supposed to be not nil, but it is only done via Leu_Haiti_GetAge which in turn is called via LuaEvents from UI context.

If I am correct then there is no easy way fix this, especially if you are not skilled in Lua.
To fix this, to need to change LuaEvents calls so the scripts will communicate via shared table ExposedMembers.
Maybe there is some easier way, whicj I am not aware of, but I would do this and I am sure it would work.
 

cuso210

Warlord
Joined
Apr 6, 2012
Messages
124
Thanks Infixo! Yes, that's the line in question. Do you know how can I change it or can you point me out to a guide to see if I can change the LuaEvents calls? I know nothing about lua but I'm a fast learner
 

Gedemon

Modder
Super Moderator
Joined
Oct 4, 2004
Messages
10,635
Location
France
Top Bottom