Jump to content

Recommended Posts

I've looked through Wigfrid's code and tried that, to no luck, I've looked all over the forums and everything I tried hasn't worked, I tried to look online for the tags for the food groups to re-try the Wigfrid technique, to find that I don't know what the tags are for the food groups or how to find them, I've come to the conclusion I'm out of my depths (no pun intended) and perhaps someone else might have the right f-eel-ing (pun entirely intended) on how I can accomplish what I am trying to accomplish

It's rather simple really, all I want is a way to make it so my character will not eat any fish related item, so if you know how to, please, help me, much thanks!

local TestFood=inst.components.eater.TestFood
function inst.components.eater:TestFood(food, testvalues)
  return food is not fish and TestFood(self,food,testvalues)
end
local PrefersToEat=inst.components.eater.PrefersToEat
function inst.components.eater:PrefersToEat(food)
  return food is not fish and PrefersToEat(self,food)
end

insert it into your character's masterinitfn, replace "food is not fish" with your own function

Edited by Rickzzs
4 hours ago, Rickzzs said:
local TestFood=inst.components.eater.TestFood
function inst.components.eater:TestFood(food, testvalues)
  return food is not fish and TestFood(self,food,testvalues)
end
local PrefersToEat=inst.components.eater.PrefersToEat
function inst.components.eater:PrefersToEat(food)
  return food is not fish and PrefersToEat(self,food)
end

insert it into your character's masterinitfn, replace "food is not fish" with your own function

Thank you for your help, however I'm inexperienced, it's probable my own function part that's not making it work, which I don't really know what I need to get the code to function the way I want it to

Quote

 

local nofish = {

        "fish",

        "fish_cooked",

        "fishmeat_small",

        "fishmeat_small_cooked",

    }

 

    local TestFood = inst.components.eater.TestFood

    function inst.components.eater:TestFood(food, testvalues)

        return nofish and TestFood(self,food,testvalues)

    end

    local PrefersToEat = inst.components.eater.PrefersToEat

    function inst.components.eater:PrefersToEat(food)

        return nofish and PrefersToEat(self,food)

    end

 

I'm unsure if just putting the prefabs names would stop it but I'm still pretty lost

Edited by NeoPurpleFire
On 3/20/2023 at 11:36 PM, Rickzzs said:

for example, you need a function like

not food:HasTag('fish')

or

not table.contains(allfish,food.prefab)

with allfish={fish,fish_cooked}

I'm sorry to be a pain but I'm really struggling to figure out where to put everything, could you be a bit more specific about what goes where and where goes what

local TestFood=inst.components.eater.TestFood
function inst.components.eater:TestFood(food, testvalues)
  return not food:HasTag("fish") and TestFood(self,food,testvalues)
end
local PrefersToEat=inst.components.eater.PrefersToEat
function inst.components.eater:PrefersToEat(food)
  return not table.contains({"fish","fish_cooked"},food.prefab) and PrefersToEat(self,food)
end

Something like this. If you are not familar with Lua grammar or DST API you can learn it.

Edited by Rickzzs
15 hours ago, Rickzzs said:
local TestFood=inst.components.eater.TestFood
function inst.components.eater:TestFood(food, testvalues)
  return not food:HasTag("fish") and TestFood(self,food,testvalues)
end
local PrefersToEat=inst.components.eater.PrefersToEat
function inst.components.eater:PrefersToEat(food)
  return not table.contains({"fish","fish_cooked"},food.prefab) and PrefersToEat(self,food)
end

Something like this. If you are not familar with Lua grammar or DST API you can learn it.

Firstly, thank you for the help, it's working now which is just great, hopefully it's working for all the fish items I put in but I couldn't spawn some in to test it but that's something I can probable solve later on if it ends up not working
Secondly I am trying to learn both, it's been a bit of a struggle haha, thank you again

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...