Jump to content

Recommended Posts

I've been trying to get this work for a while but I don't understand why It isn't working , every time I try and run my mod it comes up with the same problem. it says something about the (<eof>) this is the code I am using 

local function perdking_update( inst )
    local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
    
    if owner and owner.components.leader then
    local x,y,z = inst.Transform:GetWorldPosition()
    local ents = TheSim:FindEntities(x,y,z, 15, {"berrythief"})
    for k,v in pairs(ents) do
    if v.components.follower and not v.components.follower.leader  and not owner.components.leader:IsFollower(v) and owner.components.leader.numfollowers < 10 then
    owner.components.leader:AddFollower(v)
        end
end

if owner and owner.components.leader then
    local x,y,z = inst.Transform:GetWorldPosition()
    local ents = TheSim:FindEntities(x,y,z, 15, {"berrythief"})
    for k,v in pairs(ents) do
    if v.components.follower and not v.components.follower.leader  and not owner.components.leader:IsFollower(v) and owner.components.leader.numfollowers < 10 then
    owner.components.leader:AddFollower(v)
            end
        end

    end
end

 

EoF means usually that you miss a "end" somewhere (it's short for "End of Function"). Maybe you need another "end" after this part

local function perdking_update( inst )
    local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
    
    if owner and owner.components.leader then
    local x,y,z = inst.Transform:GetWorldPosition()
    local ents = TheSim:FindEntities(x,y,z, 15, {"berrythief"})
    for k,v in pairs(ents) do
    if v.components.follower and not v.components.follower.leader  and not owner.components.leader:IsFollower(v) and owner.components.leader.numfollowers < 10 then
    owner.components.leader:AddFollower(v)
        end
end

If you don't do that already i suggest using a text editor that highlight the lua code, like notepad++. Sublime should work too since it's in the don't starve mod tool. It make the process of finding mistake a lot easier.

Edited by Lumina
27 minutes ago, thomas4845 said:

i'm using sublime but I don't know how to use that function sorry

I don't use sublime so i don't know how to enable it. This is how it shows on notepad++

function1.png.0c67a6ad8eedf76bcc5a3091734920f6.png

Here you can see the red line, showing where the function start ( local function perdking_update( inst ), line 1 ) and where it stop (end, line 23)

function2.png.88eea3adb0acb433b8aa2cf5f9504acf.png

Here you can see that you open a function (if owner and owner.components.leader then, line 4), that close only on line 23. But it's not possible since your main function too end in this line. It should probably close before, something like this :

function3.png.923e7a7cc967dc740dddf228eb87858c.png

Here you can see that the function you open line 4 is closed line 12.

Also, i'm not sure because i'm not good at spotting errors, but isn't the same code twice ? I don't see any difference between code for line 4 to 9 and 13 to 18.

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