Page 1 of 1

Need help with " ')' expected near '.' "-error

Posted: Sat Mar 09, 2019 6:50 pm
by Trblz
I've been having this error with a scenario that i build:
...Data/Roaming/Factorio/temp/currently-playing/control.lua:57: ...ta/Roaming/Factorio/temp/currently-playing/maps/grid.lua:120: ')' expected near '.'
stack traceback:
[C]: in function 'require'
...Data/Roaming/Factorio/temp/currently-playing/control.lua:57: in main chunk
but after looking at the code for hours for the mistake i need some help. The function that fails (grid.lua:120) is below tough i've attached the entire grid.lua as part of the zip file.

Code: Select all

function grid_remove_ore_in_chunk(event.area)

    local area = event.area
    local entitiesSpawned = game.surfaces["nauvis"].find_entities({area.left_top.x, area.left_top.y}, {area.right_bottom.x, area.right_bottom.y})
	
    for _,v in pairs(entitiesSpawned) do
      if(v.type == "resource" or v.type == "decorative") then
        v.destroy()
      end
    end
end
TIA!

Re: Need help with " ')' expected near '.' "-error

Posted: Sat Mar 09, 2019 7:14 pm
by SyncViews
You should indicate which line is 120.

But this bit is wrong, Lua parameter names can not contain a dot. Lua variable and function names are generally short and lower case, if you do want two words, an underscore may be used "event_area".

Code: Select all

function grid_remove_ore_in_chunk(event.area)

Re: Need help with " ')' expected near '.' "-error

Posted: Sat Mar 09, 2019 9:29 pm
by eduran
Use event, not event.area as function argument. Alternatively, if you call your function with event.area as argument, change it to area and get rid of the first line inside your function.

Re: Need help with " ')' expected near '.' "-error

Posted: Sun Mar 10, 2019 5:07 pm
by Trblz
Thanks

that solved that bug