Jump to content

Recommended Posts

1 hour ago, . . . said:

There doesn't seem to be a "inst:HasTag(FOODTYPE.MEAT.."_eater")" tag.. so is there any other way?

Check out the eater component's diet handling.  Most of it's inside a table being stored, but there are other functions that may change how you go about doin' some things.

  • Like 2
44 minutes ago, CarlZalph said:

Check out the eater component's diet handling.  Most of it's inside a table being stored, but there are other functions that may change how you go about doin' some things.

I did check basically everything from the eater component

I thought there could be a way to see what the character can eat using

 

inst.components.eater.preferseating == { FOODTYPE.MEAT }

but it didn't do anything 

I got no idea how I can check if inst.components.eater.preferseating has a certain value in it either which I assume would be an easy way to see if they only ate meat or not :wilson_resigned:

 

everything else in eater seemed useless for what I was trying to do because the only other thing which can check if you can eat something "inst.components.eater.CanEat(food)" only takes into account the player's foodgroup and not foodtypes they will refuse so using that code to check would say like wigfrid can eat carrots :(

Edited by . . .
6 minutes ago, . . . said:

inst.components.eater.preferseating == { FOODTYPE.MEAT }

but it didn't do anything 

That'd be comparing a table to a new table, which in LUA would mean they're not identical.

You'd need to iterate over the table and check if your target entries are there.

  • Like 2
26 minutes ago, CarlZalph said:

You'd need to iterate over the table and check if your target entries are there.

Do you know how I'd do this? I don't really know anything about how tables work or how to check what's in a table

27 minutes ago, . . . said:

Do you know how I'd do this? I don't really know anything about how tables work or how to check what's in a table

This is getting a bit into basic LUA, which I'd recommend reading up on the user manuals for.  But here's a quick example of iterating an ipairs table and checking for one value.

local a = {23, 45, 67,}
for i, v in ipairs(a)
do
    print(i, v, v == 45)
end
Quote

1    23    false
2    45    true
3    67    false

 

  • Like 2

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