Changing lua scripts on Sukritact's events to fit with mod

Rob (R8XFT)

Ancient Briton
Retired Moderator
Joined
Aug 11, 2002
Messages
10,866
Location
Leeds (UK)
Having introduced Sukritact's events system into my Anno Domini mod, I've modified its use for the eras covered by the mod. I'm now converting some modders' extra events, such as the ones by JFD, to not be civ specific and to be "Anno-Dominised" for extra variety.

On the whole, I understand how to do this and am keeping it to one long lua script to cover all the possibilities. My questions surround the change in individual scripting of this:

Code:
---- 
Globals
----------------------------------------------------------------------------------------
local buildingIDThingstead = GameInfoTypes["BUILDING_JFD_THINGSTEAD"]
local civilisationID = GameInfoTypes["CIVILIZATION_JFD_ICELAND"]
local eraMedievalID = GameInfoTypes["ERA_MEDIEVAL"] 
local isUsingPietyPrestige = JFD_IsUsingPietyPrestige()
local mathCeil = math.ceil
local religionID = nil
local unitBerserkerID = GameInfoTypes["UNIT_DANISH_BERSERKER"]
local unitSkaldID = GameInfoTypes["UNIT_JFD_SKALD"]

Clearly I can delete the local civilisationID as long as I then delete the relevant line(s) below as I'm making the events generic (and changing the criteria and wording). However, how do I integrate the globals if it's just for that specific event? If I had it all on one separate lua script, would it still be available to be chosen? Should I instead do this, i.e. squeeze the locals between the local Event_ definition, or is it wrong? Would doing that still affect the whole file?

Code:
--  Iceland: Religious Hermit
--------------------------------------------------------------------------------------------------------------------------
local Event_JFDIcelandHermit = {}
local eraMedievalID = GameInfoTypes["ERA_MEDIEVAL"]
local mathCeil = math.ceil
local religionID = nil
	Event_JFDIcelandHermit.Name = "TXT_KEY_EVENT_JFD_ICELAND_RELIGIOUS_HERMIT"
	Event_JFDIcelandHermit.Desc = "TXT_KEY_EVENT_JFD_ICELAND_RELIGIOUS_HERMIT_DESC"
	Event_JFDIcelandHermit.Weight = 5
	Event_JFDIcelandHermit.CanFunc = (
		function(pPlayer)
(....etc)
 
It doesn't actually matter where in the file you put those globals, just so long as they're outside any function (so that any function can access them). So putting them as you have in second code would be fine - but they could also just be kept at the very beginning of the file (probably best for ones that will be sought after by more than one event, like mathCeil, which will probably be accessed by almost every event), or above the Iceland: Religious Hermit comment (best for globals that pertain only to that event) - but that's just a matter of what's tidy and easy to understand when reading it. Just make sure you don't have duplicates of the same global (most of my events have the mathCeil variable, so make sure you only keep one).
 
Back
Top Bottom