1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Trigger for adopting new personality trait

Discussion in 'CivBE - Modding Help & Mod Creation' started by Starrynite120, Jun 17, 2016.

  1. Starrynite120

    Starrynite120 Chieftain

    Joined:
    Jul 15, 2015
    Messages:
    469
    Does anyone know if there is a trigger for when you adopt a new personality trait? I know there isn't a trigger for adopting a playerperk, but I thought there's a possibility it could be different for personality traits.
     
  2. Valessa

    Valessa Communistress

    Joined:
    Aug 30, 2013
    Messages:
    8,103
    Gender:
    Female
    Events.PersonalityTraitAdded.Add();
    Events.PersonalityTraitRemoved.Add();
    Events.PersonalityTraitLeveledUp.Add();

    As found in TraitsOverview.lua.

    Those are however Events, not GameEvents, and meant to handle UI-Elements - they can sometimes act funny, so you'll need to look for yourself whether you can use them for whatever you want to do.

    PersonalitySystem.lua has a function for Events.PersonalityTraitRemoved.Add() which shows that it "transports" varables for the PlayerType and the TraitType, that's probably true for the other Events as well, but you'd need to check that yourself:

    Code:
    function OnPersonalityTraitRemoved(playerType : number, traitType : number)
    	local playerTraits : table = g_PlayerTraitScripts[playerType];
    	if(playerTraits ~= nil) then
    		for index : number, traitEntry : table in ipairs(playerTraits) do
    			if(traitEntry.id == traitType) then
    				table.remove(playerTraits, index);
    				break;
    			end
    		end
    	else
    		print("ERROR: PersonalityTraitRemoved called on player without trait scripts!");
    		AssertDueToAbove();
    	end
    end
    Events.PersonalityTraitRemoved.Add(OnPersonalityTraitRemoved);
     
  3. Starrynite120

    Starrynite120 Chieftain

    Joined:
    Jul 15, 2015
    Messages:
    469
    Wow, I'm kinda surprised someone actually knew this. I'm impressed. I'll have to check it out, thanks :)
     
  4. Valessa

    Valessa Communistress

    Joined:
    Aug 30, 2013
    Messages:
    8,103
    Gender:
    Female
    I didn't know it, I opened Notepad++, dragged the Lua- and UI-Folders into it and searched for some words until I found these. (;
     

Share This Page