diff --git a/media/lua/client/DogFoodIsntThatBad.lua b/media/lua/client/DogFoodIsntThatBad.lua new file mode 100644 index 0000000..59ca482 --- /dev/null +++ b/media/lua/client/DogFoodIsntThatBad.lua @@ -0,0 +1,39 @@ +local base_perform = ISEatFoodAction.perform + +function ISEatFoodAction:perform() + if getPlayer():getTraits():contains("NotAPickyEater") then + self.item:setUnhappyChange(math.min(self.item:getUnhappyChange(), 0)) + self.item:setBoredomChange(math.min(self.item:getBoredomChange(), 0)) + print("NotAPickyEater trait active, removing negative effects from food") -- DEBUG + end + base_perform(self) +end + +local base_tooltip_render = ISToolTipInv.render + +function ISToolTipInv:render() + local unhappyChange = self.item:getUnhappyChange() + local boredomChange = self.item:getBoredomChange() + if getPlayer():getTraits():contains("NotAPickyEater") then + self.item:setUnhappyChange(math.min(unhappyChange, 0)) + self.item:setBoredomChange(math.min(boredomChange, 0)) + end + base_tooltip_render(self) + if getPlayer():getTraits():contains("NotAPickyEater") then + self.item:setUnhappyChange(unhappyChange) + self.item:setBoredomChange(boredomChange) + end +end + +local function initTraits() + TraitFactory.addTrait( + "NotAPickyEater", + getText("UI_trait_NotAPickyEater"), + -1, + getText("UI_trait_NotAPickyEater_description"), + false, + false + ) +end + +Events.OnGameBoot.Add(initTraits) diff --git a/media/lua/client/dogfoodtraits.lua b/media/lua/client/dogfoodtraits.lua deleted file mode 100644 index fb9ac44..0000000 --- a/media/lua/client/dogfoodtraits.lua +++ /dev/null @@ -1,12 +0,0 @@ -local function initMyTraits() - local UnpickyEater = TraitFactory.addTrait("unpickyeater", getText("UI_trait_UnpickyEater"), -1, getText("UI_trait_UnpickyEater_description"), false, false) -end - -local function onKeyPressed(key) - if player:HasTrait("unpickyeater") then - getPlayer():Say("Hello world") - end -end - -Events.OnGameBoot.Add(initMyTraits); -Events.OnKeyPressed.Add(onKeyPressed); diff --git a/media/lua/shared/Translate/EN/UI_EN.txt b/media/lua/shared/Translate/EN/UI_EN.txt index f62c89f..3edafe1 100644 --- a/media/lua/shared/Translate/EN/UI_EN.txt +++ b/media/lua/shared/Translate/EN/UI_EN.txt @@ -1,4 +1,4 @@ UI_EN = { - UI_trait_UnpickyEater = "Unpicky Eater", - UI_trait_UnpickyEater_description = "Eating never increases unhappiness or boredom.", + UI_trait_NotAPickyEater = "Not a Picky Eater", + UI_trait_NotAPickyEater_description = "No foods make you unhappy or bored.", } diff --git a/mod.info b/mod.info index 959d37b..292b21f 100644 --- a/mod.info +++ b/mod.info @@ -1,4 +1,4 @@ name=Dog Food Isn't That Bad -id=dogFoodTraits -description=Adds the new positive trait Unpicky Eater. -url=https://github.com/nettika-cat/dogfoodtraits +id=dogFoodIsntThatBad +description=Adds the trait "Not a Picky Eater". +url=https://github.com/nettika-cat/DogFoodIsntThatBad