[Solved, Thanks :)]Unexpected Symbol Near "}"

Place to get help with not working mods / modding interface.
Post Reply
Starfoth
Inserter
Inserter
Posts: 27
Joined: Thu Sep 22, 2016 10:29 pm
Contact:

[Solved, Thanks :)]Unexpected Symbol Near "}"

Post by Starfoth »

I'm trying to make a medikit mod, but the game won't let me. It keeps telling me I have an unexpected symbol near "}". Can someone help me? I just copied the code for fish and edited some things that I needed to edit

Code: Select all

{
    type = "capsule",
    name = "Medkit",
    icon = "Starfoth's_Simple_Medkit_Mod_0.13.0/graphics/ugly_medkit.png",
    flags = { "goes-to-quickbar" },
    subgroup = "ammo",
    capsule_action =
    {
      type = "use-on-self",
      attack_parameters =
      {
        type = "projectile",
        ammo_category = "capsule",
        cooldown = 15,
        range = 0,
        ammo_type =
        {
          category = "capsule",
          target_type = "position",
          action =
          {
            type = "direct",
            action_delivery =
            {
              type = "instant",
              target_effects =
              {
                type = "damage",
                damage = { type = "physical", amount = -200 },
              }
            }
          }
        }
      }
    }
    order = "g[medicine]-a[basicmed]",
    stack_size = 20,
}
Last edited by Starfoth on Sat Oct 22, 2016 1:57 am, edited 1 time in total.

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 334
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: Unexpected Symbol Near "}"

Post by LuziferSenpai »

Code: Select all

{
 type = "capsule",
 name = "Medkit",
 icon = "Starfoth's_Simple_Medkit_Mod_0.13.0/graphics/ugly_medkit.png",
 flags = { "goes-to-quickbar" },
 subgroup = "ammo",
 capsule_action = { type = "use-on-self", attack_parameters = { type = "projectile", ammo_category = "capsule", cooldown = 15, range = 0, ammo_type = { category = "capsule", target_type = "position", action =
 				  { type = "direct", action_delivery = { type = "instant", target_effects = { type = "damage", damage = { type = "physical", amount = -200 }, } } } } } }, <-- This comma is missing! Everything else is okay!
 order = "g[medicine]-a[basicmed]",
 stack_size = 20,
}
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

Starfoth
Inserter
Inserter
Posts: 27
Joined: Thu Sep 22, 2016 10:29 pm
Contact:

Re: Unexpected Symbol Near "}"

Post by Starfoth »

LuziferSenpai wrote:

Code: Select all

{
 type = "capsule",
 name = "Medkit",
 icon = "Starfoth's_Simple_Medkit_Mod_0.13.0/graphics/ugly_medkit.png",
 flags = { "goes-to-quickbar" },
 subgroup = "ammo",
 capsule_action = { type = "use-on-self", attack_parameters = { type = "projectile", ammo_category = "capsule", cooldown = 15, range = 0, ammo_type = { category = "capsule", target_type = "position", action =
 				  { type = "direct", action_delivery = { type = "instant", target_effects = { type = "damage", damage = { type = "physical", amount = -200 }, } } } } } }, <-- This comma is missing! Everything else is okay!
 order = "g[medicine]-a[basicmed]",
 stack_size = 20,
}
I appreciate the help, but I'm still getting "Unexpected symbol near "{"
I added in the comma, but it still doesn't go

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Unexpected Symbol Near "}"

Post by aubergine18 »

You need a proper code editor with syntax highlighting, it would have shown you the problem immediately:

Code: Select all

<-- This comma is missing! Everything else is okay!
The `<` at start of that precedes the `--` comment marker, so its seen by Lua as an error.

There's a list of decent editors, linters, etc., available in this topic: viewtopic.php?f=34&t=29919

Also, start indenting stuff properly, it makes code much easier to read and errors much easier to spot:

Code: Select all

{
  type = "capsule",
  name = "Medkit",
  icon = "Starfoth's_Simple_Medkit_Mod_0.13.0/graphics/ugly_medkit.png",
  flags = { "goes-to-quickbar" },
  subgroup = "ammo",
  capsule_action = {
    type = "use-on-self",
    attack_parameters = {
      type = "projectile",
      ammo_category = "capsule",
      cooldown = 15,
      range = 0,
      ammo_type = {
        category = "capsule",
        target_type = "position",
        action = {
          type = "direct",
          action_delivery = {
            type = "instant",
            target_effects = {
              type = "damage",
              damage = {
                type = "physical",
                amount = -200
              },
            }
          }
        }
      }
    }
  },
  order = "g[medicine]-a[basicmed]",
  stack_size = 20,
}
Last edited by aubergine18 on Fri Oct 21, 2016 11:00 pm, edited 1 time in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Unexpected Symbol Near "}"

Post by ssilk »

Simple programmers rule with such syntax errors (and no syntax highlight): Comment out until it is working. The bug must be in the latest comment.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Starfoth
Inserter
Inserter
Posts: 27
Joined: Thu Sep 22, 2016 10:29 pm
Contact:

Re: Unexpected Symbol Near "}"

Post by Starfoth »

Thanks everyone, you guys helped me and it looks like it's working.
It looks like I'll be able to make my first Factorio mod.

I'll also probably write better, more readable code in the future, thank-you all :)

Starfoth
Inserter
Inserter
Posts: 27
Joined: Thu Sep 22, 2016 10:29 pm
Contact:

Re: Unexpected Symbol Near "}"

Post by Starfoth »

I've uploaded it, but it doesn't work. I downloaded it from the mod portal, and it doesn't show up in game. However, if I place my original .zip file, the one that I uploaded in the mod folder, it actually works.

Anyone know what might cause this?

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Unexpected Symbol Near "}"

Post by daniel34 »

Starfoth wrote:I've uploaded it, but it doesn't work. I downloaded it from the mod portal, and it doesn't show up in game. However, if I place my original .zip file, the one that I uploaded in the mod folder, it actually works.

Anyone know what might cause this?
Your files and folders are starting with an uppercase letter, you should have them all in lowercase, including the ones in the subfolders.
starfoth-medkit-mod.png
starfoth-medkit-mod.png (5.82 KiB) Viewed 4760 times
quick links: log file | graphical issues | wiki

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Unexpected Symbol Near "}"

Post by aubergine18 »

Uppercase letter doesn't matter, there are loads of mods with uppercase first letter, spaces, etc.

What matters is the following:

Mod filename must be <name>_<version>

Where <name> and <version> are exactly the same as those defined in the info.json (case sensitive).

So if info.json has

"name" = "Foo Bar"
"version" = "0.1.2"

The mod folder/zip name must be: Foo Bar_0.1.2

Likewise the subfolders can be upper or lower case, they're just there to better organise the files (there's no mandatory need to use subfolders, everything could just go in main folder and several mods already do this). What matters is that in the `requires` statements and also any paths mentioned in prototypes and elsewhere, those must be exactly the same case.

For exmaple, a path in a prototype might look like:

icon = "__Foo Bar__/Graphics/something.png"

And a require statement might look like:

require 'Prototypes.whatever'

As long as the same case is used everywhere, it will work just fine.

All that being said, lowercase is so much easier to type, which I why I always use lowercase folder names. One exception though: I usually use Title Case for my mod name (and thus mod folder) because it looks nicer in-game when you hover over a modded entity/item/tech etc and the yellow mod name is shown in the UI.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Unexpected Symbol Near "}"

Post by aubergine18 »

Just downloaded the mod, the problem is clear:

The zip uses Title Case

When you unzip it, the folder created is in lower case (that means it was lower case to start with, before it was zipped)

The info.json has Title Case "name" value:

"name": "Starfoth Medkit Mod",
"version": "0.13.2",

So what's needed to fix it is that before zipping it up, make sure the main folder is using Title Case for the mod name. The zip it and make sure the zip is also using Title Case, and it will work.

Or, if it's simpler, just put everything lowercase. But whatever you do, be consistent - any inconsistency in case sensitivity will break the mod.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Starfoth
Inserter
Inserter
Posts: 27
Joined: Thu Sep 22, 2016 10:29 pm
Contact:

Re: Unexpected Symbol Near "}"

Post by Starfoth »

daniel34 wrote:
Starfoth wrote:I've uploaded it, but it doesn't work. I downloaded it from the mod portal, and it doesn't show up in game. However, if I place my original .zip file, the one that I uploaded in the mod folder, it actually works.

Anyone know what might cause this?
Your files and folders are starting with an uppercase letter, you should have them all in lowercase, including the ones in the subfolders.
starfoth-medkit-mod.png
Got it fixed and now the mod works completely :D

It's up on the mod portal

Thank-you everyone

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Unexpected Symbol Near "}"

Post by daniel34 »

aubergine18 wrote:When you unzip it, the folder created is in lower case (that means it was lower case to start with, before it was zipped)
When I unzip it (with WinRar on Windows 7 NTFS) the folders/files still use Title case, as it also was before he zipped them up. When I then start Factorio the mod suddenly works without any further changes as it did on his machine before he zipped it up.

The reason this problem only happens after zipping it up is that the mod was written on Windows and its filesystem is case-insensitive. When Factorio is looking for the prototypes folder then Windows will happily provide the Prototypes folder instead without Factorio noticing. But once the mod is zipped up the zip-library that Factorio uses when reading the file is case-sensitive and won't find a folder named prototypes in there.

In fact, it won't even find a valid control.lua or data.lua because the .zip contains them in Title case, that's why ingame at the mod list it says Synchronisation: Not needed (Missions only) which means it won't be included in the installed mods list when connecting to multiplayer as it is not able to alter the gamestate in any way (TL;DR you can join vanilla servers with it installed and active).
aubergine18 wrote:All that being said, lowercase is so much easier to type, which I why I always use lowercase folder names. One exception though: I usually use Title Case for my mod name (and thus mod folder) because it looks nicer in-game when you hover over a modded entity/item/tech etc and the yellow mod name is shown in the UI.
Completely agreed. I did write they should be (not had to be) in lowercase as it (1) is good advice and (2) fixes the issue. I've seen such issues in the past and am aware that files can be mixed case as long as their case is the same everywhere they are used. By simply keeping all of them lowercase you not only can not mix them up, you also prevent issues like this from happening.
quick links: log file | graphical issues | wiki

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: [Solved, Thanks :)]Unexpected Symbol Near "}"

Post by aubergine18 »

In fact, it won't even find a valid control.lua or data.lua because the .zip contains them in Title case
This is a valid point, you are correct.

By the time I downloaded the mod those had already been converted to lowercase, along with all the internal folder names. The zip was title case, the info.json was title case, the unzipped mod folder was lowercase, so it still wasn't working for me due to that mismatch. (I'm on a Mac with case sensitive FS).
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Post Reply

Return to “Modding help”