Page 1 of 1

Error on closing parenthesis. Fixed

Posted: Fri Nov 21, 2014 10:23 pm
by Zuzak
edit: I fixed it, it seems that lua code is crazy sensitive to spacing and indent changes.

Why error on closing parenthesis saying its not there?
Why does factorio not read the last ) on some of my files?
It is there! I SEE it!
It seems to be entirely random to me
relevant bit of error message:
')' expected to close '(' at line 1 near '}"
or when I change order or closeness of final) :
unexpected symbol near }
?What is going on here??
contents of file:

Code: Select all

data:extend(
{
    {
    type = "recipe",
    name = "energy-shield-mkz-equipment",
    enabled = "false",
    energy_required = 12,
    ingredients =
    {
      {energy-shield-mk2-equipment, 3},
     },
    result = "energy-shield-mkz-equipment"
    },
}
)
Tell me what I'm missing please. It is driving me insane. This is not the only file that it does this, I use Notepad++, and the opening and closing parts of dataextend are copy-pasted from files that do work. I have reloaded, recopied, renamed, with comma, without comma, spacing;etc in different programs to 'fix' this issue, but nothing works.
I must be insane because I've been repeating myself in the hopes that it will work

Or am I just hallucinating that a closing parenthesis even exists in that copy-pasta from the file? That is the only plausible explanation I can come up with for why cannot the game read it. :shock:
I am unable to comprehend this.
I fixed it by copy pasting from below post and modifying.
somewhere in one of my other recipes, something fubared.
I compared the new, working file to the old with the compare plugin it seems that lua code is crazy sensitive to spacing and indent changes.

Re: Why error on closing parenthesis saying its not there?

Posted: Fri Nov 21, 2014 10:59 pm
by L0771

Code: Select all

data:extend(
{
    {
    type = "recipe",
    name = "energy-shield-mkz-equipment",
    enabled = "false",
    energy_required = 12,
    ingredients =
    {
      {"energy-shield-mk2-equipment", 3}, -- i only was added quotes
     },
    result = "energy-shield-mkz-equipment"
    },
}
)
i've changed ingredient and result and i can load perfectly(add quotes), but i haven't your problem

Re: Why error on closing parenthesis saying its not there?

Posted: Sat Nov 22, 2014 1:30 am
by Zuzak
somewhere in one of my other recipes, something fubared.
I compared the new, working file to the old with the compare plugin it seems that lua code is crazy sensitive to spacing and indent changes.

Thank you L0771

I'll leave this here for a example to others.

Re: Error on closing parenthesis. Fixed

Posted: Sat Nov 22, 2014 7:38 pm
by cartmen180
lua is not at all affected by spacing or indents. The only reason i use spacing is to make the code more readable, otherwise it would be one long line per file :p

the error is because of this:

Code: Select all

ingredients =
    {
      {energy-shield-mk2-equipment, 3},
     },
which should be:

Code: Select all

ingredients =
    {
      {"energy-shield-mk2-equipment", 3}
     },