Mod location:
steamapps/ common/ PZ/ mods/ ModName/ Media, mod.info/ Media/ Lua/ Shared/ EatableToothpaste.lua
I need help with just checking if the way i wrote the script is correct or any wrong or errors
I can't find any trace of the local file in the PZ mod menu
My mod.info:
{
"name": "Eatable Toothpaste",
"id": "ToothpasteEatMod",
"description": "Eat Toothpaste",
"authors": "Marshmelloen",
"version": "1.0",
"requires": "No required mods",
"lua": "media/lua/EatableToothpasteScript.lua"
}
script:
EatToothpaste = {}
EatToothpaste.perform = function(player, item)
if item:getType() == "Toothpaste" then
player:getStats():setHunger(player:getStats():getHunger() + 8)
player:getStats():setThirst(player:getStats():getThirst() - 10)
player:getStats():setStress(player:getStats():getStress() - 20)
player:getInventory():Remove(item)
player:getEmitter():playSound("EatFood")
player:Say("You eat the toothpaste. It doesn't taste great, but it helps with hunger.")
player:getStats():sync()
end
end
EatToothpasteAction = {}
EatToothpasteAction.type = "EatToothpaste"
EatToothpasteAction.maxTime = -1
EatToothpasteAction.actionAnim = "Eat"
EatToothpasteAction.OnFillContextMenu = function(player, items, context)
if not context:isReallyVisible() then
return
end
if items:size() > 0 then
local item = items:get(0)
if item:getType() == "Toothpaste" then
context:addOption("Eat Toothpaste", item, EatToothpaste.perform)
end
end
end
-- Register the item action
Events.OnFillInventoryObjectContextMenu.Add(EatToothpasteAction.OnFillContextMenu)