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

The mystery of the missing function definition

Discussion in 'Mod Creation Help' started by criZp, Dec 1, 2017.

  1. criZp

    criZp Chieftain

    Joined:
    Jul 19, 2013
    Messages:
    675
    Location:
    Nidaros, Norway
    So I'm trying to make a mod that keeps unit icons translucent when the units go into fortify, instead of becoming semi-transparent.

    There is a function called UnitFlag.SetDim( self, bDim : boolean ), located in the UnitFlagManager.lua file, which changes the dimming state (transparency) of the unit icon. SetDim is called by another function:

    function UnitFlag.UpdateReadyState( self )
    local pUnit : table = self:GetUnit();
    if (pUnit ~= nil and pUnit:IsHuman()) then
    self:SetDim(not pUnit:IsReadyToSelect());
    end
    end

    This is the only function that calls the UnitFlag.SetDim function. The call to SetDim requires a third function, this one called IsReadyToSelect().

    Now here is the weird thing: IsReadyToSelect does not have a function definition anywhere...

    pic1.jpg

    pic2.jpg

    As you can see in the images, one function call, but zero function definition. Anyone have a clue about what's going on?
     
    Last edited: Dec 2, 2017
  2. criZp

    criZp Chieftain

    Joined:
    Jul 19, 2013
    Messages:
    675
    Location:
    Nidaros, Norway
    Alright so I found a mention of IsReadyToSelect in the GameCOre_Base_FinalRelease.dll file (in civ6/base/binaries/Win64Steam):

    pic3.jpg

    Is this a clue that the function is defined inside of the .dll file?

    Then I came over this link: http://modiki.civfanatics.com/index.php?title=Basic_DLL_tasks

    Where it says "The Civilization V SDK ships with the C++ source code for the Civilization V CvGameCoreDLL. This is the most powerful tool modders have, as it allows us to directly alter game code and game logic"

    But that, of course, is for civ 5. I looked through the civ 6 SDK folder for source code, but didn't find any, althought I don't really know what it should look like.

    So, is it impossible to view the code of the .dll file?
     
  3. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,289
    Location:
    Illinois, USA
    Firaxis have not released the DLL for Civ6. So, no, you cannot access it.

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

    And yes, the Unit:IsReadyToSelect() would be part of the API built into the DLL and so would not be defined within any of the lua files anywhere.

    This "built into the DLL" will be true for any Unit:X(), City:X(), Player:X(), etc functions, and not all such functions are valid in UI context nor in GameplayScript context (some that are valid in UI are not valid in Gameplay, and Vice Versa). You should see Gedemon's thread in the tutorials for what functions are valid in which contexts.
     
  4. criZp

    criZp Chieftain

    Joined:
    Jul 19, 2013
    Messages:
    675
    Location:
    Nidaros, Norway
    Ah, ok. Thanks.

    But what does UI/script context mean?
     
  5. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,289
    Location:
    Illinois, USA
    UI is for lua that runs a User Interface panel, like the city production panel where you select what to build.

    GameplayScripts is for lua that creates a direct in-game effect, like giving more money to the player, or adding a building to a city, based on the code set up in the script.
     

Share This Page