Jump to content

Add traits after / at the end of the character creation - Traits Enhancement


Onkeen

Recommended Posts

Hi all, thank you for taking the time to read this

 

I would like to enhance traits to make traits combinaison with modifyer. The Idea is to create a trait exclusive to the one he is composed and then use the "hasTrait" function to enhance it.

 

Simple Example :

 

In the trait code

Trait "Extremely Noisy Handyman" Excusive to ("Handy","Clumsy")

When the player click on "PLAY"

player.addfreetraits(clumsy)player.addfreetraits(handy)

When the player build something

if player:hastrait(Extremely Noisy Handyman) {    play a custom noise;    make as much noise as a gun shot;} 

But I simply fail to add new traits to the player, at the end of character creation or enven during the game  :???:

 

Any Ideas, leads on how to add these traits ? Thanks for helping  :-)

Link to comment
Share on other sites

I found a trick by overiding the function called to save the player profession :

function CharacterCreationProfession:initPlayer()	-- get the trait you want and add it to the player traits table before saving it	local fromFactoryTrait = TraitFactory.getTrait("EagleEyed");	local newTrait = CharacterCreationProfession.instance.listboxTraitSelected:addItem(fromFactoryTrait:getLabel(), fromFactoryTrait);	newTrait.tooltip = fromFactoryTrait:getDescription();	-- The Indie Stone standard code for saving the profession	MainScreen.instance.desc:setForename(MainScreen.instance.charCreationHeader.forenameEntry:getText());	MainScreen.instance.desc:setSurname(MainScreen.instance.charCreationHeader.surnameEntry:getText());	if self.listboxProf.selected > -1 then		MainScreen.instance.desc:setProfession(self.listboxProf.items[self.listboxProf.selected].item:getType());    else        MainScreen.instance.desc:setProfession(self.listboxProf.items[0].item:getType());    endend

BUT : Now I need to do it when the player has selected the trait needed to activate this passive trait, but this means a if condition on the player traits, but I can't use .hasTraits oviously because the player is not created yet... 

 

It also seem to be that the selected traits are only accessible via an iterator in the listboxTraitSelected table, should I do a "for" on the list and check names until I find the trait, or is there an easier way to work around this problem ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...