Trait Tag Framework

If you liked this item, please rate it up on Steam Workshop page.

Author: Badonn

Last revision: 21 Jun, 2023 at 06:51 UTC

File size: 50.24 KB

On Steam Workshop

Description:

A Project Zomboid framework for adding user-defined strings correlating to player traits. Trait tags are stored in a table accessed by a module and has built-in functions.

A message from the creator

Do you really use this mod, or even better want to build off of it? Please consider donating to me[ko-fi.com] so I can pay my bills. I’m recently unemployed and every little bit helps!

How to Use:

Declare the module before it’s needed (typically at the beginning of the file) with

local TTF = require("TraitTagFramework");

Depending on your use case, you’ll want to add your tags before the player is created. To do this, make a function that gets added to the OnGameBoot event with

Events.OnGameBoot.Add([your function here])

If you’re creating new traits, feel free to mingle your trait and tag declarations together, like so:

local AT_Carpenter = TraitFactory.addTrait("AT_Carpenter", getText("UI_trait_AT_Carpenter"), 2, getText("UI_trait_AT_Carpenter_desc"), false); AT_Carpenter:addXPBoost(Perks.Woodwork, 1) TTF.Add("AT_Carpenter", "Anthro,HabitatBuilder");

Available Functions
  • ToString()

    Returns the entirety of the table and tags in a string.

  • TagTableToString(string traitName)

    Returns the tags associated with a trait as a string

  • Add(string traitName, string tags)

    Add(s) tag(s) to the TraitTags module.
    Note: For tags, use alphanumeric symbols only, and separate each tag with a comma.

  • Remove(string traitName)

    Removes a trait and all of its tags from the TraitTags module.

  • RemoveTag(string traitName, string tag)

    Removes the specified tag from the specified trait in the TraitTags module.

  • GetTable()

    Returns the entirety of the TraitTags table as a table.

  • GetTagTable(string traitName)

    Returns the table of tags associated with a trait as a table.

  • GetTagStatistics()

    Returns a string containing each tag used, and how many times they’re used.
    Note: I find this helpful for balancing purposes.

  • GetPlayerTraitTags(Player player)

    Returns a string containing each tag a player has.

  • GetPlayerTagStatistics(Player player)

    Returns a string containing each tag and the amount(count) of each the player has. This list in the string is ordered by count.
    String format: "[tag]: [count]; [tag]: [count];…"

  • PlayerHasTag(Player player, string targetTag)

    Returns a boolean, which is true if the player has the targetTag.

  • PlayerTagCountLargerThan(Player player, string subjectTag, string comparatorTag)

    Returns a boolean, which is true only if the subjectTag’s count is larger than the comparatorTag’s count.
    Note: This will also return false if one of the tags cannot be found (with a console print warning of a nil if debug mode is on).

  • GetAllTraitsWithTag(string subjectTag)

    Returns a collection of Traits that have the subject tag.

All Vanilla Traits put in .Add

Here’s a list of all vanilla traits with an example name for your Trait Tags module. This will work in whatever function you add it, just add your own tags and run. (current as of build 41):
TTF.add("Axeman", "");
TTF.add("Handy", "");
TTF.add("SpeedDemon", "");
TTF.add("SundayDriver", "");
TTF.add("Brave", "");
TTF.add("Cowardly", "");
TTF.add("Clumsy", "");
TTF.add("Graceful", "");
TTF.add("ShortSighted", "");
TTF.add("HardOfHearing", "");
TTF.add("Deaf", "");
TTF.add("KeenHearing", "");
TTF.add("EagleEyed", "");
TTF.add("HeartyAppitite", "");
TTF.add("LightEater", "");
TTF.add("ThickSkinned", "");
TTF.add("Unfit", "");
TTF.add("Out of Shape", "");
TTF.add("Fit", "");
TTF.add("Athletic", "");
TTF.add("Nutritionist", "");
TTF.add("Nutritionist2", "");
TTF.add("Emaciated", "");
TTF.add("Very Underweight", "");
TTF.add("Underweight", "");
TTF.add("Overweight", "");
TTF.add("Obese", "");
TTF.add("Strong", "");
TTF.add("Stout", "");
TTF.add("Weak", "");
TTF.add("Feeble", "");
TTF.add("Resilient", "");
TTF.add("ProneToIllness", "");
TTF.add("Agoraphobic", "");
TTF.add("Claustophobic", "");
TTF.add("Lucky", "");
TTF.add("Unlucky", "");
TTF.add("Marksman", "");
TTF.add("NightOwl", "");
TTF.add("Outdoorsman", "");
TTF.add("FastHealer", "");
TTF.add("FastLearner", "");
TTF.add("FastReader", "");
TTF.add("AdrenalineJunkie", "");
TTF.add("Inconspicuous", "");
TTF.add("NeedsLessSleep", "");
TTF.add("NightVision", "");
TTF.add("Organized", "");
TTF.add("LowThirst", "");
TTF.add("Burglar", "");
TTF.add("FirstAid", "");
TTF.add("Fishing", "");
TTF.add("Gardener", "");
TTF.add("Jogger", "");
TTF.add("SlowHealer", "");
TTF.add("SlowLearner", "");
TTF.add("SlowReader", "");
TTF.add("NeedsMoreSleep", "");
TTF.add("Conspicuous", "");
TTF.add("Disorganized", "");
TTF.add("HighThirst", "");
TTF.add("Illiterate", "");
TTF.add("Insomniac", "");
TTF.add("Pacifist", "");
TTF.add("Thinskinned", "");
TTF.add("Smoker", "");
TTF.add("Tailor", "");
TTF.add("Dextrous", "");
TTF.add("AllThumbs", "");
TTF.add("Desensitized", "");
TTF.add("WeakStomach", "");
TTF.add("IronGut", "");
TTF.add("Hemophobic", "");
TTF.add("Asthmatic", "");
TTF.add("Cook", "");
TTF.add("Cook2", "");
TTF.add("Herbalist", "");
TTF.add("Brawler", "");
TTF.add("Formerscout", "");
TTF.add("BaseballPlayer", "");
TTF.add("Hiker", "");
TTF.add("Hunter", "");
TTF.add("Gymnast", "");
TTF.add("Mechanics", "");
TTF.add("Mechanics2", "");

Credits

Special thanks to the Project Zomboid discord modding community for their tireless answering of my questions. Particular thanks to Albion, who has a seemingly encyclopedic knowledge of PZ properties, functions, and modding. You helped a lot 🙂

Workshop ID: 2987177652
Mod ID: TraitTagFramework

Workshop ID: 2987177652
Mod ID: TraitTagFramework