Jump to content

Problem with some lines of code

Recommended Posts

local function FindFriend(inst)
    local x, y, z = inst.Transform:GetWorldPosition()
    local ents = TheSim:FindEntities(x, y, z, 3, {"pig"}, {"player","werepig","guard","nanachifriend"})
    for k, v in pairs(ents) do
        if not v:IsAsleep() and not v.components.sleeper:IsAsleep() then
            if inst.components.leader:CountFollowers() >= 1 then return end
            if v.components.health and not v.components.health:IsDead() then

Stole this code from Nanachi mod by Haori, and the idea is that it would check for any pigs around u and make them your followers, at least that is what i understood, and it would cap at 1 follower, but it isn't working, can anyone explain to me how this code works?

Link to comment
Share on other sites

3 hours ago, Somnei said:


How is it not working? Are you getting an error or is it simply that nothing is happening? How is the function used in your code?

Please provide a little more information so it's easier to help

Of course, my bad for the lack of information. It runs no problem, doesn't crash or give an error, but in theory it should make a single pig near u loyal, but it doesn't, at least i think, i cant tell, so thats why i wanted to know how the code worked

Link to comment
Share on other sites

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