imjustglue Posted August 28, 2022 Share Posted August 28, 2022 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 inst:PushEvent("makefriend") inst.components.leader:AddFollower(v) v.components.follower:AddLoyaltyTime(240) v:AddTag("nanachifriend") v:DoTaskInTime(480,function() v:RemoveTag("nanachifriend") end) end end end end 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 https://forums.kleientertainment.com/forums/topic/142887-problem-with-some-lines-of-code/ Share on other sites More sharing options...
Somnei Posted August 30, 2022 Share Posted August 30, 2022 Hi! 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. Link to comment https://forums.kleientertainment.com/forums/topic/142887-problem-with-some-lines-of-code/#findComment-1596304 Share on other sites More sharing options...
imjustglue Posted August 30, 2022 Author Share Posted August 30, 2022 3 hours ago, Somnei said: Hi! 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 https://forums.kleientertainment.com/forums/topic/142887-problem-with-some-lines-of-code/#findComment-1596321 Share on other sites More sharing options...
Somnei Posted August 30, 2022 Share Posted August 30, 2022 How are you using that function? Can you please show your entire modmain.lua so we can see when the function is used. Link to comment https://forums.kleientertainment.com/forums/topic/142887-problem-with-some-lines-of-code/#findComment-1596339 Share on other sites More sharing options...
imjustglue Posted August 30, 2022 Author Share Posted August 30, 2022 4 hours ago, Somnei said: How are you using that function? Can you please show your entire modmain.lua so we can see when the function is used. of course, there u go dreamer.lua Link to comment https://forums.kleientertainment.com/forums/topic/142887-problem-with-some-lines-of-code/#findComment-1596367 Share on other sites More sharing options...
hhh2 Posted September 10, 2022 Share Posted September 10, 2022 How old is the mod this is from? On 8/28/2022 at 7:42 PM, imjustglue said: v:AddTag("nanachifriend") v:DoTaskInTime(480,function() v:RemoveTag("nanachifriend") end) These lines can be removed. Link to comment https://forums.kleientertainment.com/forums/topic/142887-problem-with-some-lines-of-code/#findComment-1597584 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now