Jump to content

Recommended Posts

sadly picky eater mod is not using prefabs, just tracking a list of food names

if food you are about to eat.name ~= allowed food name, then you are not allowed to eat

I want to be able to check properties via food name only

updated eat your veggies mod for modern recipes and warly

https://steamcommunity.com/sharedfiles/filedetails/?id=3014792878

had to implement it the hard way sadly

37 minutes ago, loopuleasa said:

sadly picky eater mod is not using prefabs, just tracking a list of food names

if food you are about to eat.name ~= allowed food name, then you are not allowed to eat

I want to be able to check properties via food name only

updated eat your veggies mod for modern recipes and warly

https://steamcommunity.com/sharedfiles/filedetails/?id=3014792878

had to implement it the hard way sadly

isn't it easier to just do

local allowed_foods = {"meat", "banana"} -- a table containing allowed foods' prefab names

local function CanEatTest(food)
  for k,v in pairs(allowed_foods)
    if v == food.prefab then return true
  end
  return false
end

why would you use the food's actual name rather than prefab name?

or you can do this:

foods = {}
for _,v in pairs({"meat", "banana",}) do -- all the foods you allow to eat
  foods[v] = true
end

local function CanEatTest(food)
  return foods[food.prefab]
end

 

Edited by _zwb
1 hour ago, _zwb said:

isn't it easier to just do

local allowed_foods = {"meat", "banana"} -- a table containing allowed foods' prefab names

local function CanEatTest(food)
  for k,v in pairs(allowed_foods)
    if v == food.prefab then return true
  end
  return false
end

why would you use the food's actual name rather than prefab name?

or you can do this:

foods = {}
for _,v in pairs({"meat", "banana",}) do -- all the foods you allow to eat
  foods[v] = true
end

local function CanEatTest(food)
  return foods[food.prefab]
end

 

I am using prefab name, but as string.

for instance "barnaclepita"

the problem is that it is in a string format, and I don't know if I can access properties (like meat or veg value)

the mod has been updated but I have duplicated the lists for wurt and wigfrid
 

https://steamcommunity.com/sharedfiles/filedetails/?id=3014792878

43 minutes ago, loopuleasa said:

he problem is that it is in a string format, and I don't know if I can access properties (like meat or veg value)

You can access that by requiring the preparedfoods.lua file

local require = GLOBAL.require

local preparedfoods = require("preparedfoods")
local preparedfoods_warly = require("preparedfoods_warly")

local food_list = {}

for k,v in pairs(preparedfood_list) do
    table.insert(food_list, {k, v.foodtype})
end
for k,v in pairs(preparedfood_list_warly) do
    table.insert(food_list, {k, v.foodtype})
end

 

2 minutes ago, Rickzzs said:

Spawn one and then remove it.

I bet there would be random food items spawning at (0,0,0):lol:

Edited by _zwb

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
×
  • Create New...