Jump to content

How do I use health as an ingredient in my mod?


Recommended Posts

Everything else works except the health, and I want to know what the code is for using health as an ingredient? (It isn't "health_decrease", as I hoped)

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local resolvefilepath = GLOBAL.resolvefilepath

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local Recipe = GLOBAL.Recipe
local TECH = GLOBAL.TECH

local guactab = AddRecipeTab( "Avocado Tab", 996, 
"images/hud/guactab.xml", "guactab.tex")

local guacamole_recipe = Recipe("guacamole", 
{Ingredient("mole", 1), Ingredient("health_decrease", 30)}, 
guactab, TECH.NONE)

guacamole_recipe.sortkey = 1
guacamole_recipe.atlas = resolvefilepath("images/inventoryimages/Guacamole.xml")

STRINGS.RECIPE_DESC.GUACAMOLE = "Made of fleshy avocado... and mole!"

local rock_avocado_fruit_ripe_recipe = Recipe("rock_avocado_fruit_ripe", 
{Ingredient("health_decrease", 10)}, 
guactab, TECH.NONE)

rock_avocado_fruit_ripe_recipe.sortkey = 2
rock_avocado_fruit_ripe_recipe.atlas = resolvefilepath("images/inventoryimages/stonefruit.xml")

STRINGS.RECIPE_DESC.ROCK_AVOCADO_FRUIT_RIPE = "It's green because it's lucky!"

Link to comment
Share on other sites

27 minutes ago, bullbro said:

Everything else works except the health, and I want to know what the code is for using health as an ingredient? (It isn't "health_decrease", as I hoped)

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local resolvefilepath = GLOBAL.resolvefilepath

local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local Recipe = GLOBAL.Recipe
local TECH = GLOBAL.TECH

local guactab = AddRecipeTab( "Avocado Tab", 996, 
"images/hud/guactab.xml", "guactab.tex")

local guacamole_recipe = Recipe("guacamole", 
{Ingredient("mole", 1), Ingredient("health_decrease", 30)}, 
guactab, TECH.NONE)

guacamole_recipe.sortkey = 1
guacamole_recipe.atlas = resolvefilepath("images/inventoryimages/Guacamole.xml")

STRINGS.RECIPE_DESC.GUACAMOLE = "Made of fleshy avocado... and mole!"

local rock_avocado_fruit_ripe_recipe = Recipe("rock_avocado_fruit_ripe", 
{Ingredient("health_decrease", 10)}, 
guactab, TECH.NONE)

rock_avocado_fruit_ripe_recipe.sortkey = 2
rock_avocado_fruit_ripe_recipe.atlas = resolvefilepath("images/inventoryimages/stonefruit.xml")

STRINGS.RECIPE_DESC.ROCK_AVOCADO_FRUIT_RIPE = "It's green because it's lucky!"

Recipe("livinglog", 	{Ingredient(CHARACTER_INGREDIENT.HEALTH, 20)}, CUSTOM_RECIPETABS.NATURE, TECH.NONE, nil, nil, nil, nil, "plantkin")

you can see the livinglog recipe here, the ingredient is CHARACTER_INGREDIENT.HEALTH

Link to comment
Share on other sites

but... it didn't work... 

[string "../mods/lucky_avocado/modmain.lua"]:63: attempt to index global 'CHARACTER_INGREDIENT' (a nil value)

I tried in quotes, and that didn't work either

maybe I need to add something else, like local Recipe = CHARACTER_INGREDIENT.Recipe

do you have the file you got that from?

Edited by bullbro
Link to comment
Share on other sites

14 minutes ago, bullbro said:

but... it didn't work... 

[string "../mods/lucky_avocado/modmain.lua"]:63: attempt to index global 'CHARACTER_INGREDIENT' (a nil value)

I tried in quotes, and that didn't work either

maybe I need to add something else, like local Recipe = CHARACTER_INGREDIENT.Recipe

do you have the file you got that from?

It's defined in constants.lua:

CHARACTER_INGREDIENT =
{
    --NOTE: Value is used as key for NAME string and inventory image
    HEALTH = "decrease_health",
    MAX_HEALTH = "half_health",
    SANITY = "decrease_sanity",
    MAX_SANITY = "half_sanity",
}

Which if you're using this in modmain, you should prefix it with `GLOBAL.`

So for you, use: GLOBAL.CHARACTER_INGREDIENT.HEALTH

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
 Share

×
×
  • Create New...