1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

I added a new Happiness level with a mod, but it blocks the City info screen.

Discussion in 'Civ6 - Creation & Customization' started by pokiehl, May 2, 2017.

  1. pokiehl

    pokiehl Chieftain

    Joined:
    Mar 5, 2017
    Messages:
    174
    So I added a new happiness level, Euphoric, when your city gets to +5 amenities. Here's the code.

    Code:
    INSERT INTO Types (Type, Kind) VALUES ('HAPPINESS_EUPHORIC', 'KIND_HAPPINESS') ;
    INSERT INTO Happinesses (HappinessType, Name, MinimumAmenityScore, GrowthModifier, NonFoodYieldModifier, RebellionPoints) VALUES ('HAPPINESS_EUPHORIC', 'LOC_HAPPINESS_EUPHORIC_NAME', '5', '30', '20', '-1') ;
    UPDATE Happinesses SET MaximumAmenityScore = '4' WHERE HappinessType = 'HAPPINESS_ECSTATIC' ;
    In the code, I also added a maximum amenity for Ecstatic. The code is activated via InGame UpdateDatabase, and there's also a text file.

    The issue is, whenever a city gets +5 amenities and achieves Euphoric status, you can no longer look at the city info screen. The bonuses are working, but the city info screen is blocked. Any ideas what might cause this? There are no Database errors logged.
     
  2. Infixo

    Infixo Warlord

    Joined:
    Jan 9, 2016
    Messages:
    2,072
    Gender:
    Male
    Location:
    Warsaw
  3. TheMarshmallowBear

    TheMarshmallowBear Benelovent Chieftain of the BearKingdom

    Joined:
    Dec 27, 2006
    Messages:
    6,934
    Location:
    Inside an Ikanda.
    I bet it requires a reference in the UI for Euphoric which you have not designed.
     
  4. Doomturtle

    Doomturtle Chieftain

    Joined:
    Nov 7, 2017
    Messages:
    5
    Gender:
    Male
    Did you ever find a solution? I am working on a mod that adds happiness levels and running into the same issue. I suspect that the issue lies in CityPanel.lua and/or CityPanelOverview.lua since they seem to assume the default happiness levels. Each of these scripts initializes a table as:

    local UV_CITIZEN_GROWTH_STATUS :table = {};
    UV_CITIZEN_GROWTH_STATUS[0] = {u=0, v=0 }; -- revolt
    UV_CITIZEN_GROWTH_STATUS[1] = {u=0, v=0 }; -- unrest
    UV_CITIZEN_GROWTH_STATUS[2] = {u=0, v=0}; -- unhappy
    UV_CITIZEN_GROWTH_STATUS[3] = {u=0, v=50}; -- displeased
    UV_CITIZEN_GROWTH_STATUS[4] = {u=0, v=100}; -- content (normal)
    UV_CITIZEN_GROWTH_STATUS[5] = {u=0, v=150}; -- happy
    UV_CITIZEN_GROWTH_STATUS[6] = {u=0, v=200}; -- ecstatic


    CityPanelOverview.lua references this table as:

    Controls.CitizenGrowthStatus:SetTextureOffsetVal( UV_CITIZEN_GROWTH_STATUS[data.Happiness].u, UV_CITIZEN_GROWTH_STATUS[data.Happiness].v );

    I haven't worked with lua before, but I think that the possible values for data.Happiness are determined by the Happinesses table in the database where you added the Euphoric happiness level. Euphoric should be index 7 for data.Happiness. I think that when one of your cities reaches Euphoric happiness, CityPanelOverview.lua tries to reference index 7 in UV_CITIZEN_GROWTH_STATUS, which does not exist. I am going to play with this to see if I can fix it.
     
  5. Doomturtle

    Doomturtle Chieftain

    Joined:
    Nov 7, 2017
    Messages:
    5
    Gender:
    Male
    I was able to get the City Details panel to work by editing CityPanel.lua and CityPanelOverview.lua. I have attached an amended version of your Euphoric mod. I would appreciate if someone who has edited lua files in a mod before could take a look at it. I copied and pasted the lua files from the game's Assets folder into my mod and then edited them. I set the mod to have those edited files replace the originals. This was the only way that I could see to do it, but it doesn't feel like this is the way that a mod should make changes to lua files.
     

    Attached Files:

  6. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,289
    Location:
    Illinois, USA
    This is in fact the way mods alter existing UI files.

    ---------------------------------

    As a side note, it is generally better to attach the mod itself rather than the modbuddy project. Unless someone specifically asks to see your modbuddy project it is far easier to look at a completed and executable mod than to have to copy a project for a mod into our modbuddy folders and then build it, and then hope that what you have attached is actually creating the same content as you currently have within the built version of the mod existing in the game's "Mods" folder.
     
  7. Doomturtle

    Doomturtle Chieftain

    Joined:
    Nov 7, 2017
    Messages:
    5
    Gender:
    Male
    I configured the lua file replacing incorrectly when I the modified Euphoric mod earlier. It worked on my machine because I had previously changed the lua files in the game's Assets folder. Use this version instead.
     

    Attached Files:

Share This Page