1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[BNW] Lua Functions do not work properly

Discussion in 'Civ5 - Creation & Customization' started by RoxyRiku94, Feb 26, 2017.

  1. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    Hey Guys, I'm RoxyRiku94 again. I managed to complete my first civilization, but whenever I try to load the mod for testing purposes into the game, Civilization V crashes. I loaded the mod alone to make sure that it was my modded civ that causes the CTD.

    This particular log entry has took my attention:
    Code:
    [278608.051] near ",": syntax error
    [278608.051] no such table: DecisionsAddin_Support
    [278608.066] no such table: JFD_GlobalUserSettings
    [278608.066] no such table: JFD_GlobalUserSettings
    [278608.082] no such table: JFD_GlobalUserSettings
    [278608.082] no such table: JFD_GlobalUserSettings
    [278608.082] no such table: DecisionsAddin_Support
    [278609.923] Validating Foreign Key Constraints...
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278609.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
    [278613.667] Invalid Reference on Leader_SharedTraits.TraitTwo - "POLICY_SPIRITUAL_X" does not exist in Policies
    [278613.667] Invalid Reference on Leader_SharedTraits.TraitOne - "POLICY_PHILOSOPHICAL_X" does not exist in Policies
    [278613.667] Failed Validation.
    However, for some reason, I can't seem to detect where the error causing the CTD might be. Never mind the first syntax error entry, I've fixed this in my other solution, but the other errors within the Database.log still persist.


    EDIT: Temporarily solved the issue by replacing the faulty pillage Torii Model with the ordinary one. Changed the Title to reflect other issues, and removed some unneeded links.

    Any help regarding these issues is appreciated!
     
    Last edited: Mar 5, 2017
  2. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    1. It's better to just take the mod from the game's MODS folder, zip it, and attach the result directly to a post.
    2. Very often what a new modder thinks the problem is and what the problem actually is are two different things. Having the actual mod as you are currently trying to use it allows us to look for the actual problem, and if all else fails to simply drop the mis-behaving mod into our MODS folder and run the mod to see what the game tells us.
    3. Zip the version of the mod the game is actually trying to use, which will be found as a sub-folder in ~\Documents\My Games\Sid Meier's Civilization 5\MODS. Zip the whole sub-folder for your mod.
    4. See: whoward69's zip your mods and attach tutorial Just bear in mind that the process for actually adding the zip to a forum post is now different since the CFC website software was updated a few months ago. Look for a button called "Upload A File" when composing your thread reply: this button opens a browse menu where you can select the zipped folder to attach directly to a forum post.
    5. If the zipped folder is too large for the forum to accept then upload the zipped mod to a file-sharing site such as dropbox and provide a link where the mod can be downloaded.
    And btw mediafire is riddled with spyware and attempts to get you to download stuff you don't need or are which are actually detrimental to your computer. dropbox does not currently try to trick you into downloading unecessary software or outright malware.
     
  3. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    Removed the old links as these aren't necessary anymore.
     
    Last edited: Feb 27, 2017
  4. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    but that still is not a mod that can be run by the game. you're supplying the folder from the modbuddy project.

    executable mods do not contain xxxx.civ5proj files or xxxx.civ5sln files. Only projects within the modbuddy folders have these, and what is in the modbuddy folders is never actually executable by the game.

    executable mods have a xxxx.modinfo file which tells the game what to do with the files within the mod. There is no modinfo file in what you are linking,
     
  5. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    Last edited: Feb 27, 2017
  6. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    1. no lua file should ever be both ImportIntoVFS=true and "InGameUIAddin"
    2. whoward69's what ModBuddy setting for what file types tutorial
    3. you have the following errors which are fatal to portions of the contents within the sql files where they occur. Fatal syntax errors in SQL files cause the game to cease reading-in data where the error occurs, and the remainder of the file is not implemented.
      • this error
        Code:
        [874155.671] no such column: BuildType
        has a timestamp that matches with these files in the stopwatch.log
        Code:
        [874155.671] , 					Update Database - ModSupport/Cities in Development/KobayakawaCIDGameText.xml, 0.066772
        [874155.671] , 					Update Database - ModSupport/Cities in Development/KobayakawaCIDModSupport.sql, 0.001847
        [874155.671] , 					Update Database - ModSupport/Cities in Development/KobayakawaLeaderTraitCID.sql, 0.000456
        [874155.671] , 					Update Database - ModSupport/Events & Decisions/Events/SQL/KobayakawaEvents.sql, 0.000379
        and the error appears to be in this part of the code
        Code:
        INSERT INTO Unit_Builds 
        		(UnitType,		BuildType)
        SELECT		'UNIT_JFD_SLAVE',	BuildType
        AND NOT BuildType IN ('BUILD_RR94_KOBAYAKAWA_FLOATING_TORII')
        AND EXISTS (SELECT * FROM JFD_GlobalUserSettings WHERE Type = 'JFD_CID_SLAVERY_UNIT_ADDITIONS_SLAVE_WORKER' AND Value = 1);
        BuildType does not appear anywhere in any of the other files listed in Stopwatch.log with the same timestamp.
      • This error in the database.log:
        Code:
         [874155.671] no such column: Type
        would appear to be coming from this:
        Code:
        UPDATE  	Trait_MaintenanceModifierUnitCombats
        SET			MaintenanceModifier	= -25
        WHERE Type = 'CIVILIZATION_RR94_KOBAYAKAWA'
        AND EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_KOBAYAKAWA_HEALTH_BONUS_AT_RIVERS' AND Value = 1)
        AND EXISTS (SELECT * FROM JFD_GlobalUserSettings WHERE Type = 'JFD_CID_HEALTH_CORE' AND Value = 1);
        Table Trait_MaintenanceModifierUnitCombats has no such column called Type. It uses TraitType, and you need to specify a Trait-Name, not a Civilization-Name. You have also referecned the Civilization-Name and not the Trait-Name in this bit of code just above the problem with the usage of "Type" in the wrong table:
        Code:
        -- Update Text if only Exploration Continued Expanded is activated
        UPDATE  	Traits
        SET			Description	= 'TXT_KEY_TRAIT_TWIN_RIVERS_EXCE'
        WHERE Type = 'CIVILIZATION_RR94_KOBAYAKAWA'
        AND EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_KOBAYAKAWA_TRAIT_CHANGE_EXCE_TRIBES' AND Value = 1)
        AND EXISTS (SELECT * FROM JFD_GlobalUserSettings WHERE Type = 'JFD_CID_HEALTH_CORE' AND Value != 1)
        AND EXISTS (SELECT * FROM JFD_GlobalUserSettings WHERE Type = 'JFD_EXCE_TRIBES_CORE' AND Value = 1);
      • This error:
        Code:
        [874155.812] near "~": syntax error
        is coming from here in file KobayakawaLeaderTraitExCE.sql:
        Code:
        -- Update Text if only Exploration Continued Expanded is activated
        UPDATE  	Traits
        SET			Description	= 'TXT_KEY_TRAIT_TWIN_RIVERS_EXCE'
        WHERE Type = 'CIVILIZATION_RR94_KOBAYAKAWA'
        AND EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_KOBAYAKAWA_TRAIT_CHANGE_EXCE_TRIBES' AND Value = 1)
        AND EXISTS (SELECT * FROM JFD_GlobalUserSettings WHERE Type = 'JFD_CID_HEALTH_CORE' AND Value ~= 1)
        AND EXISTS (SELECT * FROM JFD_GlobalUserSettings WHERE Type = 'JFD_EXCE_TRIBES_CORE' AND Value = 1);
        character "~" is valid in lua but I think SQL only want "!=" or "<>" for mathematical "not equal to".
      • Note that when you attempt to re-run the mod, the timestamps on the error messages you will get will be different than the ones I have shown becuase the time will be different, and you may very well get more errors because once you fix one within a file you may find another error within the same file lower-down in the code.
    4. Your CTD problem is in the Unique Improvement. Since your SQL code does not seem to be generating an error I would guess something in the actual improvmeent model files is no good. I altered import=1 to import=0 for all your improvement model files, and altered your improvement to use the Fising Boat model and the CTD was eliminated.
    5. When adding an lua file as a "InGameUIAddin", etc, select the file name from the dropdown before you select the "InGameUIAddin", "DiplomacyUIAddin", etc., type. This ensures you get the entire file-path string needed by the game to find the lua file.
    6. don't use special characters in the names of files and folders. The game often does not like the usage of &%$#@! etc in folder or file names.
    7. you still have some errors with missing textures (icons or dds files not loading or missing), and you are getting some TXT_KEY instead of the text you want.
     
  7. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    Now that the CTD is fixed you also have some errors related to lua code showing in the lua.log
    Code:
    [885459.796] Runtime Error: C:\Users\Lee\Documents\My Games\Sid Meier's Civilization 5\MODS\[BNW] Sengoku Musou - Kobayakawa Clan (v 1)\ModSupport/Cities in Development/Decisions/Lua/BuildingsToNearbyImprovements.lua:101: bad argument #1 to 'ConvertTextKey' (string expected, got nil)
    [885459.796] Runtime Error: Error loading C:\Users\Lee\Documents\My Games\Sid Meier's Civilization 5\MODS\[BNW] Sengoku Musou - Kobayakawa Clan (v 1)\ModSupport/Cities in Development/Decisions/Lua/BuildingsToNearbyImprovements.lua.
    [885459.859] Syntax Error: C:\Users\Lee\Documents\My Games\Sid Meier's Civilization 5\MODS\[BNW] Sengoku Musou - Kobayakawa Clan (v 1)\Lua/KobayakawaTraitScript.lua:97: 'then' expected near '='
    [885459.875] Runtime Error: Error loading C:\Users\Lee\Documents\My Games\Sid Meier's Civilization 5\MODS\[BNW] Sengoku Musou - Kobayakawa Clan (v 1)\Lua/KobayakawaTraitScript.lua.
    
    The first of these errors comes from this line in my handler
    Code:
    local sRealBuildingName = Locale.ConvertTextKey(GameInfo.Buildings[BuildingID].Description)
    because it is looking for a valid TXT_KEY definition for the dummy building's <Description> field and you probably have not supplied one or the text file where you have it defined is failing to load properly. You should always provide a valid <Description> TXT_KEY for any building and building-class, even a dummy, because there are game systems that can lock the game in the correct circumstances when they expect to see a <Description> TXT_KEY and cannot find it for a building. Plus too many mod-makers are expecting buildings to have valid <Description> fields even for dummy buildings, and failure to provide one can make their code mis-fire.
     
  8. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    Regarding the TXT_KEY errors, from where exactly are the sources from? I'm asking that because if the TXT_KEY errors are from the Dialogue, then I'd may need to add more Lines to the Dialog SQL file. The only code I added there is to replace the Generic Lines with the Leader Specific ones.

    Code:
    INSERT INTO Diplomacy_Responses
               (LeaderType,       ResponseType,   Response,                                           Bias)
    SELECT        ('LEADER_TAKAKAGE'),   ResponseType,   REPLACE(Response, '_GENERIC_', '_LEADER_TAKAKAGE_'),   500
    FROM Diplomacy_Responses WHERE LeaderType = 'GENERIC' AND Response LIKE ('%GENERIC%');
    
    INSERT OR IGNORE INTO Diplomacy_Responses
               (LeaderType,       ResponseType,   Response,                                           Bias)
    SELECT        ('LEADER_TAKAKAGE'),   ResponseType,   REPLACE(Response, 'TXT_KEY_', 'TXT_KEY_LEADER_TAKAKAGE_'),   500
    FROM Diplomacy_Responses WHERE LeaderType = 'GENERIC' AND Response NOT LIKE ('%LEADER_TAKAKAGE%');
    
    INSERT OR IGNORE INTO Diplomacy_Responses      
               (LeaderType,            ResponseType,                Response,                                    Bias)
    VALUES       ('LEADER_TAKAKAGE',    'RESPONSE_DEFEATED',        'TXT_KEY_LEADER_TAKAKAGE_DEFEATED%',        500),  
               ('LEADER_TAKAKAGE',    'RESPONSE_FIRST_GREETING',    'TXT_KEY_LEADER_TAKAKAGE_FIRSTGREETING%',   500);
    
     
  9. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    If I do this:
    Code:
    <GameData>
    	<Buildings>
    		<Row>
    			<Type>BUILDING_CITY_SEWER</Type>
    			<BuildingClass>BUILDINGCLASS_CITY_SEWER</BuildingClass>
    			<Cost>150</Cost>
    			<GoldMaintenance>1</GoldMaintenance>
    			<PrereqTech>TECH_ENGINEERING</PrereqTech>
    			<Description>TXT_KEY_BUILDING_CITY_SEWER</Description>
    			<MinAreaSize>-1</MinAreaSize>
    			<NeverCapture>true</NeverCapture>
    			<HurryCostModifier>25</HurryCostModifier>
    			<IconAtlas>MED-REN_ICONATLAS</IconAtlas>
    			<PortraitIndex>4</PortraitIndex>
    		</Row>
    	</Buildings>
    </GameData>
    But I never do this:
    Code:
    <GameData>
    	<Language_en_US>
    		<Row Tag="TXT_KEY_BUILDING_CITY_SEWER">
    			<Text>City Sewer</Text>
    		</Row>
    	</Language_en_US>
    </GameData>
    I get missing text-key errors in the Database.log, and in-game I get TXT_KEY_BUILDING_CITY_SEWER instead of City Sewer.

    This is what I mean by a missing TXT_KEY error. When I tested the mod you had referenced a few TXT_KEY Tag-Names but never defined them within the <Language_en_US> table. Or else you did define them, but the game rejected the code or the entire file because of a fatal error.
     
  10. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    Okay, I managed to trace down what exactly caused the CTD problem. The normal Torii model worked fine, but it was the pillaged Torii Model which caused the CTD. Apparently Civ V and Granny Viewer don't like it if I use the rotation slider to turn the object meshes. I may try it later out if it still causes the CTD problem when I manually move and turn the object mesh.
     
  11. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    I fixed most of the major bugs and missing files and got into testing. While the Unique Components work normally, the Lua traits however do not. And I have no idea what might be the problem.

    1. The Promotion is not updating properly when the Yumi stands on a hill (I've mostly took the reference from Vice Virtuoso's God's Quiver Unit and adjusted it to my liking, but the Promotion still doesn't change depending on the situation.

    2. The Ancient Ruins Trait of randomly getting units doesn't seem to fire. Either I have very bad luck (20% chance to get an unit) or more likely, there's some Lua Error within the Script itself, which causes the Function not to trigger.

    Here's the updated Civilization Mod: https://www.dropbox.com/s/hy4dx1vr3zfamxc/[BNW] Sengoku Musou - Kobayakawa Clan.zip?dl=0
     
  12. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    1. Mismatch between variable names here. player is undefined and is therefore "nil". It does not match to local pPlayer:
      Code:
      local pPlayer = Players[iPlayer]
      	if JFD_GetRandom(1,100) <= 20 then	-- 20% chance to get an Archery Unit, only change the last number if you want to change the value!
      		if player:CanTrain(iGoodyHutUnitBonusChanceMedieval) then
      			player:InitUnit(iGoodyHutUnitBonusChanceMedieval, iX, iY)
      		elseif player:CanTrain(iGoodyHutUnitBonusChanceClassical) then
      			player:InitUnit(iGoodyHutUnitBonusChanceClassical, iX, iY)
      		elseif player:CanTrain(iGoodyHutUnitBonusChanceAncient) then
      			player:InitUnit(iGoodyHutUnitBonusChanceAncient, iX, iY)
      		end
      	if iPlayer == Game:GetActivePlayer() then
      		Events.GameplayAlertMessage(Locale.ConvertTextKey("TXT_KEY_ALERT_KOBAYAKAWA_FREE_ARCHER_UNIT"))
      	end
      end
      
      This is from function RR94_GoodyHutsOnUnitSetXY
    2. With this defned in this way:
      Code:
      local TERRAIN = {
      	[GameInfoTypes.TERRAIN_HILL] = true
      }
      this will never be true
      Code:
      bSet = TERRAIN[pPlot:GetTerrainType()] and true or false
      because a plot's GetTerrainType() never returns GameInfoTypes.TERRAIN_HILL
    3. Mountains and Hills are not "real" terrains, they are actually just graphic overlays, and both of them have this in their definition under table <Terrains>:
      Code:
      <GraphicalOnly>true</GraphicalOnly>
    4. This error in the database log
      Code:
      [823430.888] no such table: MinorCivSounds
      Comes from this
      Code:
      ------------------------------
      -- MinorCivSounds
      ------------------------------		
      INSERT INTO MinorCivSounds
      		(ID, 											AudioScript)
      SELECT	'MINOR_CIV_RR94_NOSHIMA_MURAKAMI',				'AS2D_RR94_NOSHIMA_MURAKAMI_MINOR_CIV_MARITIME'
      WHERE EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_NOSHIMA_MURAKAMI_MINOR_CIV' AND Value = 1)
      AND EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_NOSHIMA_MURAKAMI_MINOR_CIV_TRAIT' AND Value = 0);
      
      INSERT INTO MinorCivSounds
      		(ID, 											AudioScript)
      SELECT	'MINOR_CIV_RR94_NOSHIMA_MURAKAMI',				'AS2D_RR94_NOSHIMA_MURAKAMI_MINOR_CIV_MILITARISTIC'
      WHERE EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_NOSHIMA_MURAKAMI_MINOR_CIV' AND Value = 1)
      AND EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_NOSHIMA_MURAKAMI_MINOR_CIV_TRAIT' AND Value = 1);
    5. This error in the database log
      Code:
      [823430.888] table Policies has no column named IsDummy
      Comes from this
      Code:
      INSERT INTO Policies
      		(Type, 						Description,					IsDummy) 
      SELECT		'POLICY_MINOR_CIV_RR94_NOSHIMA_MURAKAMI',	'TXT_KEY_CITYSTATE_RR94_NOSHIMA_MURAKAMI',	1
      WHERE EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_NOSHIMA_MURAKAMI_MINOR_CIV' AND Value = 1)
      AND EXISTS (SELECT * FROM RR94_KobayakawaUserOptions WHERE Type = 'RR94_NOSHIMA_MURAKAMI_MINOR_CIV_SUZERAINTY' AND Value = 1);
    6. You appear to be missing a comma here after the entry for the help TXT_KEY reference.
      Code:
      INSERT INTO Buildings
      			(Type,																		BuildingClass,	
      			Cost,	FaithCost,	GreatWorkCount, Description,																			Help,
      			PrereqTech,	NeverCapture,	NukeImmune)
      VALUES		('BUILDING_DECISIONS_RR94_KOBAYAKAWA_FAMILY_UNITY_BONUS_NO_LIMIT_DUMMY',	'BUILDINGCLASS_DECISIONS_RR94_KOBAYAKAWA_FAMILY_UNITY_BONUS_NO_LIMIT_DUMMY',
      			-1,		-1,			-1,				'TXT_KEY_BUILDING_DECISIONS_RR94_KOBAYAKAWA_FAMILY_UNITY_BONUS_NO_LIMIT_DUMMY',			'TXT_KEY_BUILDING_DECISIONS_RR94_KOBAYAKAWA_FAMILY_UNITY_BONUS_NO_LIMIT_DUMMY_HELP'
      			null,		1,				1);
      This causes the Buildings-to-Improvements link Lua file to fail because no such building is registered within the database.
    7. you've never defined this table for use with E&D:
      Code:
      INSERT INTO DecisionsAddin_Support		
      			(FileName)
      VALUES		('KobayakawaDecisionsCID.lua');
      This causes your DecisionsRtP and DecisionsCID sql files to both fail if E&D etc are not being used, which causes the runtime error in the Buildings-to-Improvements linkages lua and likely in other lua files.
    8. The runtime error message for the Building-to-Improvements linkages file is not fatal to the mod in any way when E&D etc are not being used, but it is annoying to the user and will likely get reported multiple times as a bug.
     
  13. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,711
    Gender:
    Male
    Location:
    Warsaw
    What happens if you do something like this?
    And secondly, does this also apply to the situation where you overwrite Lua from another mod? Example. Mod A has LuaX with Import=0 & registered as InGameUIAddin. Then Mod B has also LuaX (with some changes), loads AFTER Mod A, and has Import = 1. Would it cause a problem or not?
     
  14. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    Would it work if the TERRAIN_HILL defines are replaced with pPlot:IsHills?

    I'm aware of this bug, but I'm not sure how to fix it. Perhaps merging the RTP and CID SQL files and placing them into the E&D folder?
    I've already looked within Sukritact's Events and Decisions folder, but there doesn't seem to be an option SQL file.
     
  15. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    Importing in these cases really does nothing but clutters the VFS system. Adding Joes.lua in your mod as ImportIntoVFS=1 has no effect on Joe's mod and the version of Joes.lua running from there. It would have the same effect as not even importing the file into the VFS system.

    The problem is where the file is meant as a UI replacer, for example, because then whenever the panel opens the code executes, and whenever the events that the UI uses within its code (if any) fire as normal parts of gameplay execution, those events will re-fire from the file that should only be added to the mod as Import=true but is now having two different "activation" methods running independant of each other. One of the two things InGameUIAddin is for is actually creating a new UI that the game does not have from Firaxis. The other is used in Civ5 as a catchall activation method for the main-level lua file(s) of a mod that is not actually adding a new UI to the game, but is making gameplay changes based on what happens in-game, like a unit moving from one plot to another.
     
    Last edited: Mar 5, 2017
  16. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    1. Yes, replacing this line
      Code:
      bSet = TERRAIN[pPlot:GetTerrainType()] and true or false
      with
      Code:
      bSet = pPlot:IsHills()
      should cure the issue. And you will not really even need this
      Code:
      local TERRAIN = {
      	[GameInfoTypes.TERRAIN_HILL] = true
      }
      But I realized you have another logical error
      Code:
      		local pUnit = pPlayer:GetUnitByID(iUnit)
      		if pUnit then
      			--do stuff
      		else pUnit:SetHasPromotion(unitPromotionFollowTheWindInfoID, true)
      		end
      You are asking whether the unit is not nil with this line
      Code:
      if pUnit then
      because the line can be re-written as
      Code:
      if (pUnit ~= nil) then
      so the only way you can get to this line
      Code:
      else pUnit:SetHasPromotion(unitPromotionFollowTheWindInfoID, true)
      is if the unit is nil (ie, does not exist), and you cannot add or remove a promotion from a non-existant unit. And you will get firings of the GameEvents.UnitSetXY for units that are nil by the time your code executes. This is because the event fires for far more than just units actually moving from one tile to another.

      It is good practice to check against pPlayer:GetUnitByID(iUnit) returning a nil value, but in such a case you really want your code to do nothing.

      I think you just mis-positioned your "else" line, but I am not really sure what it is you want the code to do.
    2. SQL code before the lines that are causing the error
      Code:
      CREATE TABLE IF NOT EXISTS DecisionsAddin_Support(FileName);
      So you should really have for example
      Code:
      CREATE TABLE IF NOT EXISTS DecisionsAddin_Support(FileName);
      INSERT INTO DecisionsAddin_Support	
      			(FileName)
      VALUES		('KobayakawaDecisionsCID.lua');
     
  17. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    Yeah, I misplaced the end before the else pUnit:SetHasPromotion(unitPromotionFollowTheWindInfoID, true), as this part is to be meant to remove the unnecessary Info Promotion if eligible for the actual promotion. I still need to test my mod to ensure that it really works, then I can continue to check the E&D functions. Thanks for helping me regarding the issues.
     
  18. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,711
    Gender:
    Male
    Location:
    Warsaw
    That's not entirely true. Actually, if I add Joes.lua to my mod and set ImportVFS=1 it will overwrite original Joes.lua from Joe's mod.
    I just did some testing to confirm that and it is working like this:
    Joe's mod: Joes.lua / ImportVFS = 0 / InGameUIAddin YES
    My mod: Joes.lua
    a) ImportVFS=0 / InGameUIAddin = NO => nothing happens, original Joes.lua is working
    b) ImportVFS=0 / InGameUIAddin = YES => both versions are working (as expected, 2 entry points and 2 separate scripts)
    c) ImportVFS=1 / InGameUIAddin = NO => my Joes.lua is working (overwrites original one, only 1 entry point that leads to my script now)
    d) ImportVFS=1 / InGameUIAddin = YES => my Joes.lua is working 2 times (2 entry points that lead to the same script or maybe two copies, as the original one was overwritten by mine)

    Sorry for being a little off-topic (I mean, thread) but I am trying to fix a CTD and running out of ideas. Thought for a moment that it could be related to import-into-VFS-or-not situation. Anyway, I'd appreciate if maybe you could spare a moment and take a look at my real problem here: http://forums.civfanatics.com/threads/nasty-ctd.611501/
     
  19. RoxyRiku94

    RoxyRiku94 Detective Agent

    Joined:
    Jan 30, 2016
    Messages:
    141
    Gender:
    Male
    Location:
    Souzai Daigaku
    Is there any chance to get custom city-state music working? I've tried replacing MinorCivSounds/MinorCivSound, but it still doesn't work.
     
  20. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,073
    Location:
    Illinois, USA
    I guess I was wrong about it overwriting a file from a different mod.

    Though I'm not sure how often it would be fair to do so, since the other mod maker would be getting all the bug reports (if any) about her mod from actions you did in your mod.

    --------

    You have to be careful about this anyway, because many mod-makers have reported that when multiple mods are all overwriting the same file within the VFS, they don't always seem to see the final mod's version being used. Generally you would think the last mod to activate would be the one whose code would be used in a UI replacement situation, but quite a few people have reported it is not always so, nor is it always so apparently when adding a file to the VFS so that its contents can be included within another lua file via the include() command. This last is in addition to the known issues with using include() and the filename structure used for the file to be included and the exact structure of the include() command.
     
    Last edited: Mar 5, 2017

Share This Page