Page 1 of 1

} expectet but it is there

Posted: Sun Mar 24, 2019 12:46 pm
by coolian
i am trying to leanrn how i can make a mod for factorio i have made an armor for which i want to make a research now the code i am using for that is this:
data:extend({
{
type = "technology",
name = "firearmor",
icon = "__FireArmor__/graphics/tech/r.png",
icon_size = 16,
effects =
{
{
type = "unlock-recipe",
recipe = "fire-armor"
},
},
prerequisites = {"military-2"},
unit =
{
count = 194,
ingredients =
{
{"science-pack-1", 1},
{"science-pack-2", 2},
{"military-science-pack", 1}
},
time = 1
},
}}),

notepad++ tells me all { are closed and i see it the same way but factorio tells me that at the last line (26) theres an } missing to close the { at line 1 how can i get the error togo away

Re: } expectet but it is there

Posted: Sun Mar 24, 2019 2:32 pm
by Bary
Try like that, i'm not great in lua, but in my code there isn't round bracket after data:extend

data:extend{
{
type = "technology",
name = "firearmor",
icon = "__FireArmor__/graphics/tech/r.png",
icon_size = 16,
effects =
{
{
type = "unlock-recipe",
recipe = "fire-armor"
},
},
prerequisites = {"military-2"},
unit =
{
count = 194,
ingredients =
{
{"science-pack-1", 1},
{"science-pack-2", 2},
{"military-science-pack", 1}
},
time = 1
},
}},

Re: } expectet but it is there

Posted: Sun Mar 24, 2019 3:40 pm
by Helfima
Use a better IDE
remove the comma line 26
bug-coolian.PNG
bug-coolian.PNG (56.17 KiB) Viewed 1630 times
me I use eclipse with lua plugin
after lauch eclipe, go help->install new software
search lua after selected work with "Eclipse LDT Update Site (stable)"
eclipse-lua.PNG
eclipse-lua.PNG (16.53 KiB) Viewed 1630 times
create a lua project :lol:

Re: } expectet but it is there

Posted: Sun Mar 24, 2019 9:57 pm
by Hiladdar
Bottom line up front, I think there is extra stuff in your code, (extra commas on line 12 and 25) causing the problem. Without the rest of the module, it is nearly impossible to verify if that is the correct or the only fix required.

I like the Helfima's recommendation of using a program editor which is capable of some debugging within the editor. Personally I am old school, and if a text editor has line count to the left side that is enough for me.

data:extend({
{
type = "technology",
name = "firearmor",
icon = "__FireArmor__/graphics/tech/r.png",
icon_size = 16,
effects =
{
{
type = "unlock-recipe",
recipe = "fire-armor"
} -- Line 12
},
prerequisites = {"military-2"},
unit =
{
count = 194,
ingredients =
{
{"science-pack-1", 1},
{"science-pack-2", 2},
{"military-science-pack", 1}
},
time = 1
} -- Line 25
}
})

Pasting the code from an editor into the window does not correctly paste the indentation used within the code and makes it much more difficult to read, especially where the line numbers are not included.

Hiladdar

Re: } expectet but it is there

Posted: Mon Mar 25, 2019 5:07 am
by thereaverofdarkness
Those syntax error messages are incorrect approximately 100% of the time. At best, they just tell you which line has the error. It's up to you to find it from there, and fixing it probably won't involve whatever the error message said it expects to find.

Re: } expectet but it is there

Posted: Mon Mar 25, 2019 10:48 am
by BlueTemplar
Hiladdar wrote: Sun Mar 24, 2019 9:57 pm Pasting the code from an editor into the window does not correctly paste the indentation used within the code and makes it much more difficult to read, especially where the line numbers are not included.
That's why there's the code tag :

Code: Select all

data:extend({
  {
    type = "technology",
    name = "firearmor",
    icon = "__FireArmor__/graphics/tech/r.png",
    icon_size = 16,
    effects =
    {
      {
        type = "unlock-recipe",
        recipe = "fire-armor"
      }                                             -- Line 12
    },
    prerequisites = {"military-2"},
    unit =
    {
      count = 194,
      ingredients =
      {
        {"science-pack-1", 1},
        {"science-pack-2", 2},
        {"military-science-pack", 1}
      },
      time = 1
    }                                                -- Line 25
  }
})