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

[GS] [Help] Combining UI Script and Gameplay script in lua

Discussion in 'Mod Creation Help' started by __jack__, Oct 11, 2019.

  1. __jack__

    __jack__ Warlord

    Joined:
    Dec 29, 2009
    Messages:
    141
    Hi,

    I am working on something relatively simple: allowing a player to change his view to another player by pressing a specifc key.

    Using a gameplay script I can easily shift a specific player's view using:
    PlayerManager.SetLocalPlayerAndObserver(i)

    Using a UI script I can easily trigger a command using a specific key using:
    function OnInputHandler( pInputStruct:table )
    local uiMsg:number = pInputStruct:GetMessageType();
    if uiMsg == KeyEvents.KeyUp then
    if pInputStruct:GetKey() == Keys.U then
    print("test");
    end
    end
    end

    Now why in there devious minds the Dev of CIV6 won't allow me to combine both by replacing the print by a PlayerManager.SetLocalPlayerAndObserver(0) ?

    Is there a way to use a UI script to call a function from a Gameplay script ?
     
  2. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,569
    Location:
    France
  3. __jack__

    __jack__ Warlord

    Joined:
    Dec 29, 2009
    Messages:
    141
    very cool, thanks !
     

Share This Page