[GS] LUA function not working after update

TC_

Chieftain
Joined
Jul 8, 2017
Messages
77
Hi all,

I am working through updating my mods to work with the recent updates, though I did not purchase the expansion. Apparently I am no longer able to set a plot owner in the following way:


local plot = Map.GetPlot(locX, locY);
local playerCapital = Players[owner]:GetCities():GetCapitalCity();

WorldBuilder.CityManager():SetPlotOwner(plot, playerCapital);


Lua.log shows "function expected instead of nil" on the SetPlotOwner line. Parameters "plot" and "playerCapital" are holding the correct values, checked by printing them out before trying to run SetPlotOwner.

I skimmed through the .diff file posted by Gedemon here (https://forums.civfanatics.com/threads/change-to-modding-from-the-gathering-storm-patch.642080/), but didn't identify any obvious issue. I haven't modded here in a while, and am pretty rusty. If the required parameters for that function have changed, I don't know how to go about finding the updated ones. Any help in fixing this issue would be greatly appreciated.
 
A quick search through the game's lua files (including GS files) doesn't show where the syntax has changed at all. Are you sure you're not running the function from an incorrect Context ? Ie, UI instead of Gameplay ? Erm, actually a second closer look shows only the TunerWorldBuilder version is using the old syntax.

C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\UI\WorldBuilderPlacement.lua shows:
Code:
WorldBuilder.CityManager():SetPlotOwner( plot:GetX(), plot:GetY(), entry.PlayerIndex, entry.ID );
		end
	else
		WorldBuilder.CityManager():SetPlotOwner( plot:GetX(), plot:GetY(), false );
Educated guess would be the entry.PlayerIndex is for a player ID# and the entry.ID would be for a city ID#

C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\UI\WorldBuilderPlotEditor.lua shows identical syntax.

Only C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\UI\Tuner\TunerWorldBuilderCityPanel.lua shows the old syntax

Otherwise the short answer at the moment is *shrug* since we haven't all figured out all the changes as yet.

Many of us stopped using lua plot-acquiring in our mods for Leader Abilities and the like because even using the WorldBuilder.CityManager version of SetPlotOwner modifiers that ought to be applied to a plot so acquired do not implement until a save and a reload are conducted.
 
Last edited:
Thanks for the response LeeS, you've helped me out in the past and I'm glad to see you're still around to do it again!

So the line in question is part of a mod I wrote and have been using for quite some time, Strategic Forts:
https://steamcommunity.com/sharedfiles/filedetails/?id=1142306094

It worked, as intended, as recently as an hour before I accepted the update.

I tried using the parameters ( plot:GetX(), plot:GetY(), entry.PlayerIndex, entry.ID ) but am not having any luck with that either.

Think I'm just screwed for now? This is the mod I'm most proud of, so I'll keep trying, but I'm totally lost atm.
 
So far as I can tell either of the following two syntax methods still work for Gathering Storm:
Code:
WorldBuilder.CityManager():SetPlotOwner(pPlot:GetX(), pPlot:GetY(), iPlayer, pCity:GetID());
WorldBuilder.CityManager():SetPlotOwner(pPlot, pCity);
 
Any chance you would test it on the mod I linked? I am receiving an error on that exact line, and have tried both methods.

Maybe you would test to see if my mod works for you with the GS expansion purchased? Surely there's no difference in lua functions available between those who purchased the expansion and those who didn't... right?
 
Attached. Thanks a ton
 

Attachments

  • TC Strategic Forts.zip
    26.7 KB · Views: 157
That's very strange. There are plenty of comments on the steam page of it not working for others as well. I do not have R&F or GS, would you mind trying it with R&F disabled? Do you think I should try a clean install?

Here is the report block on lua.log:
Code:
StrategicForts: OnImprovementAddedToMapTC()---------------------
StrategicForts:    OnImprovementAddedToMapTC(): plotIndex = 1424
StrategicForts:    OnImprovementAddedToMapTC: this improvement was a fort
StrategicForts:    OnImprovementAddedToMapTC: plot:GetResourceType() = -1
StrategicForts: AddToFortTable--------------------------
StrategicForts:     AddToFortTable(): Adding plot to table fortPlots - plotIndex = 1424
StrategicForts:     AddToFortTable(): fortPlots table length = 1
StrategicForts: OnImprovementAddedToMapTC: not conquered - granting fort plots for player 0
StrategicForts: GrantFortPlots()-------------------------
StrategicForts:     GrantFortPlots(): owner = 0, plotIndex = 1424, playerCapital = LOC_CITY_NAME_KYOTO
StrategicForts:     GrantFortPlots(): FortPlot: Setting Owner
Runtime Error: C:\Users\...\Sid Meier's Civilization VI\Mods\TC Strategic Forts\StrategicForts.lua:405: function expected instead of nil
stack traceback:
      C:\Users\...\Sid Meier's Civilization VI\Mods\TC Strategic Forts\StrategicForts.lua:405: in function 'GrantFortPlots'
      C:\Users\...\Sid Meier's Civilization VI\Mods\TC Strategic Forts\StrategicForts.lua:101: in function 'OnImprovementAddedToMapTC'
      [C]: in function 'func'
      [C]: in function '(anonymous)'
 
If i shut off both RaF and GS in additional content menu then I get the error.

Apparently the GS patch borked the API for Vanilla.

You could try pPlot:SetOwner(iPlayer) but as I recall the "Plot" version of "SetOwner()" resulted in plots that were unworkable.
 
Ok thanks so much for testing it for me. That's incredibly frustrating.

I did try the plot:setOwner hoping that the change had fixed it, but unfortunately it seems to not work still.
 
Yep looks like I'm a card carrying member now.

It feels pretty sketchy that I'd have to pay $30-40 ($60-80 for my household) just to play with the mods I made.
 
Do you think this modifier could be used in a fake unit or fake improvement or fake something to change plots ownership ?
Code:
        <Row>
            <ModifierType>MODIFIER_UNIT_GRANT_PLOT</ModifierType>
            <CollectionType>COLLECTION_OWNER</CollectionType>
            <EffectType>EFFECT_GRANT_PLOT</EffectType>
        </Row>
 
Not sure since it is only used in Marcus Crassus' Great Person ability so far as I know. And all those great person modifiers are directly tied into their special actions when "used".

Don't remember whether Vanilla has the Culture Bomb thing when the right player completes a Holy Site or whatever it was.

Tho it wouldn't really help TC's issue with forts changing ownership and the change in ownership of the fort taking the surrounding plots with it.
 
What would happen if we set that modifier as an unit ability, not a GP action ?
 
Thank you for reporting this Gedemon, and LeeS for following up with the report
 
Top Bottom