Implement "Not A Picky Eater" trait functionality
- Rename "Unpicky Eater" to "Not a Picky Eater" - Wrap around the `ISEatFoodAction:perform` and `ISToolTipInv:render` methods, adjusting unhappiness and boredom increase if the trait is present. - Reorganize files
This commit is contained in:
parent
cd53ab1a34
commit
da7344d749
4 changed files with 44 additions and 17 deletions
39
media/lua/client/DogFoodIsntThatBad.lua
Normal file
39
media/lua/client/DogFoodIsntThatBad.lua
Normal file
|
|
@ -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)
|
||||||
|
|
@ -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);
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
UI_EN = {
|
UI_EN = {
|
||||||
UI_trait_UnpickyEater = "Unpicky Eater",
|
UI_trait_NotAPickyEater = "Not a Picky Eater",
|
||||||
UI_trait_UnpickyEater_description = "Eating never increases unhappiness or boredom.",
|
UI_trait_NotAPickyEater_description = "No foods make you unhappy or bored.",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
mod.info
6
mod.info
|
|
@ -1,4 +1,4 @@
|
||||||
name=Dog Food Isn't That Bad
|
name=Dog Food Isn't That Bad
|
||||||
id=dogFoodTraits
|
id=dogFoodIsntThatBad
|
||||||
description=Adds the new positive trait Unpicky Eater.
|
description=Adds the trait "Not a Picky Eater".
|
||||||
url=https://github.com/nettika-cat/dogfoodtraits
|
url=https://github.com/nettika-cat/DogFoodIsntThatBad
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue