Editing Module:Test/lib/util
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | + | ---@diagnostic disable: lowercase-global | |
− | |||
− | |||
− | |||
− | |||
− | |||
local util = {} | local util = {} | ||
Line 12: | Line 7: | ||
util.table = {} | util.table = {} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function util.table.isIn(var, table) | function util.table.isIn(var, table) | ||
Line 135: | Line 108: | ||
for k, v in pairs(tbl) do | for k, v in pairs(tbl) do | ||
− | + | formatting = string.rep(" ", indent) .. k .. ": " | |
if type(v) == "table" then | if type(v) == "table" then | ||
print(formatting) | print(formatting) | ||
Line 186: | Line 159: | ||
end | end | ||
− | function util. | + | ---------- |
− | return | + | -- diet -- |
+ | ---------- | ||
+ | |||
+ | util.diet = {} | ||
+ | |||
+ | util.diet.foodType = { | ||
+ | None = true, | ||
+ | VegetableOrFruit = true, | ||
+ | Meat = true, | ||
+ | Fluid = true, | ||
+ | Corpse = true, | ||
+ | Seed = true, | ||
+ | AnimalProduct = true, | ||
+ | Plant = true, | ||
+ | Tree = true, | ||
+ | Meal = true, | ||
+ | Processed = true, | ||
+ | Liquor = true, | ||
+ | Kibble = true, | ||
+ | VegetarianAnimal = { | ||
+ | VegetableOrFruit = true, | ||
+ | Seed = true, | ||
+ | Meal = true, | ||
+ | Processed = true, | ||
+ | Liquor = true, | ||
+ | Kibble = true | ||
+ | }, | ||
+ | VegetarianRoughAnimal = { | ||
+ | VegetableOrFruit = true, | ||
+ | Seed = true, | ||
+ | Plant = true, | ||
+ | Meal = true, | ||
+ | Processed = true, | ||
+ | Liquor = true, | ||
+ | Kibble = true | ||
+ | }, | ||
+ | CarnivoreAnimal = { | ||
+ | Meat = true, | ||
+ | Corpse = true, | ||
+ | Meal = true, | ||
+ | Processed = true, | ||
+ | Kibble = true | ||
+ | }, | ||
+ | CarnivoreAnimalStrict = { | ||
+ | Meat = true, | ||
+ | Corpse = true | ||
+ | }, | ||
+ | OmnivoreAnimal = { | ||
+ | VegetableOrFruit = true, | ||
+ | Meat = true, | ||
+ | Corpse = true, | ||
+ | Seed = true, | ||
+ | Meal = true, | ||
+ | Processed = true, | ||
+ | Liquor = true, | ||
+ | Kibble = true | ||
+ | }, | ||
+ | OmnivoreRoughAnimal = { | ||
+ | VegetableOrFruit = true, | ||
+ | Meat = true, | ||
+ | Corpse = true, | ||
+ | Seed = true, | ||
+ | Plant = true, | ||
+ | Meal = true, | ||
+ | Processed = true, | ||
+ | Liquor = true, | ||
+ | Kibble = true | ||
+ | }, | ||
+ | DendrovoreAnimal = { | ||
+ | VegetableOrFruit = true, | ||
+ | Seed = true, | ||
+ | Tree = true, | ||
+ | Processed = true, | ||
+ | Kibble = true | ||
+ | }, | ||
+ | OvivoreAnimal = { | ||
+ | AnimalProduct = true, | ||
+ | Meal = true, | ||
+ | Processed = true, | ||
+ | Kibble = true | ||
+ | }, | ||
+ | OmnivoreHuman = { | ||
+ | VegetableOrFruit = true, | ||
+ | Meat = true, | ||
+ | Fluid = true, | ||
+ | Corpse = true, | ||
+ | Seed = true, | ||
+ | AnimalProduct = true, | ||
+ | Meal = true, | ||
+ | Processed = true, | ||
+ | Liquor = true, | ||
+ | Kibble = true | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function util.diet.resolveDietCategory(foodType) | ||
+ | if util.diet[foodType].None then | ||
+ | return "Never eats" | ||
+ | end | ||
+ | if util.diet[foodType].Tree then | ||
+ | return "Dendrovorous" | ||
+ | end | ||
+ | if util.diet[foodType].Meat then | ||
+ | if util.diet[foodType].VegetableOrFruit or util.diet[foodType].Plant then | ||
+ | return "Omnivorous" | ||
+ | end | ||
+ | return "Carnivorous" | ||
+ | end | ||
+ | if util.diet[foodType].AnimalProduct then | ||
+ | return "Ovivorous" | ||
+ | end | ||
+ | return "Herbivorous" | ||
end | end | ||
return util -- return module | return util -- return module |