1. Firaxis celebrates the "Asian American and Pacific Islander Heritage Month", and offers a give-away of a Civ6 anthology copy (5 in total)! For all the details, please check the thread here. .
    Dismiss Notice

LUA play animation?

Discussion in 'Mod Creation Help' started by FurionHuang, Aug 10, 2017.

  1. FurionHuang

    FurionHuang Warlord

    Joined:
    Apr 27, 2017
    Messages:
    171
    Gender:
    Male
    Hey folks,

    I was looking into Fire Tuner's panel codes and found these lines:
    Code:
    <Action>if (g_SelectedPlayer ~= nil and g_SelectedPlayer &gt;= 0 and g_SelectedUnitID ~= nil and g_SelectedUnitID &gt;= 0) then
        local pPlayer = Players[g_SelectedPlayer];
        if pPlayer ~= nil then
            local pUnit = pPlayer:GetUnits():FindID(g_SelectedUnitID);
            if (pUnit ~= nil) then
                SimUnitSystem.SetAnimationState(pUnit, "DEATH");
            end
        end
    end
    </Action>
    That makes think it might be possible to trigger some unit animations in game play via lua.
    YET, I also discovered this "SimUnitSystem" was only FT code. When copy-paste into lua script, the game doesn't know what function was that.
    So I believe there must be somewhere we can find how to translate this "SimUnitSystem.SetAnimationState" to an actual LUA code. I started looking at FT .dll files but found nothing relevant. Would you guys happen to have any idea?
    @LeeS would you be interested?
     
  2. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    10,604
    Location:
    France
    It seems that SimUnitSystem is not available in gameplay script context, only UI context.
     
  3. FurionHuang

    FurionHuang Warlord

    Joined:
    Apr 27, 2017
    Messages:
    171
    Gender:
    Male
    Oh I totally forgot that! I see hope now. Thanks so much!
     
  4. FurionHuang

    FurionHuang Warlord

    Joined:
    Apr 27, 2017
    Messages:
    171
    Gender:
    Male
    So how do I add LUA script to my MOD as UI context? Gameplay is straight forward, but when I added the script under AddUserInterface, game went back to start menu when initiating. And then I created another xml file with this code:
    Code:
    <Context Name="DS_PlayAnim">
    </Context>
    This "DS_PlayAnim" is both lua and xml name. Ran the game, nothing happened. Moved the xml under AddUserInterface, back to start menu again.
     
  5. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    10,604
    Location:
    France
    modinfo
    Code:
            <UserInterface>       
                <Properties>
                    <Context>InGame</Context>
                </Properties>
                <Items>
                    <File>Scripts/YnAMP_InGame.xml</File>
                </Items>
            </UserInterface>
     
  6. FurionHuang

    FurionHuang Warlord

    Joined:
    Apr 27, 2017
    Messages:
    171
    Gender:
    Male
    Ahhh properties. Got it!
    Thanks!
     
  7. Tiramisu

    Tiramisu Warlord

    Joined:
    Aug 16, 2013
    Messages:
    141
    Location:
    Leonberg (BW, Germany)
    Is it possible to change the position of unit graphics?
    My problem is that you can start the attack animation using
    Code:
    SimUnitSystem.SetAnimationState(pUnit, "ATTACK");
    
    but I have not found a way to let the unit graphics move on the opponent's plot like in a real combat animation.
     

Share This Page