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: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
local util = {} | local util = {} | ||
Line 12: | Line 6: | ||
util.table = {} | util.table = {} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
-- procedure | -- procedure | ||
Line 135: | Line 96: | ||
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 147: | ||
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 foodType.None then | ||
+ | return "Never eats" | ||
+ | end | ||
+ | if foodType.Tree then | ||
+ | return "Dendrovorous" | ||
+ | end | ||
+ | if foodType.Meat then | ||
+ | if foodType.VegetableOrFruit or foodType.Plant then | ||
+ | return "Omnivorous" | ||
+ | end | ||
+ | return "Carnivorous" | ||
+ | end | ||
+ | if foodType.AnimalProduct then | ||
+ | return "Ovivorous" | ||
+ | end | ||
+ | return "Herbivorous" | ||
end | end | ||
return util -- return module | return util -- return module |