Please help me interpret this error message...

Place to get help with not working mods / modding interface.
Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Please help me interpret this error message...

Post by Celsus_Trueword »

Hello. I am currently working on a mod that adds advanced lab, beacon, accumulator, and electric furnace to the game. I modified Dysoch's More Inserters! mod to get the file structure correct. But I'm having difficulty:

Code: Select all

...error loading module 'prototypes.technology.advanced' from file ...prototypes\technology\advanced.lua':
...advanced.lua:3 0: '}' expected (to close '{' at line 3) near ')'
I understand this should tell me all I need to know to fix this error, but I lack the programming skill at present to correct this myself. Everything seems to be in the correct place in advanced.lua (ie: each section is opened and closed with braces as indicated by red highlighting within Notepad++)

If I can get some help fixing this very simple error, I will learn something fundamental about programming in lua (and about programming generally). Rather than paste a bunch of code right out of the gate, I'm linking to the zip file for the mod HERE. Thanks for any help you can give!

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Please help me interpret this error message...

Post by FreeER »

You probably used a ) instead of a }, notepad detects it as a closing the { even though Lua doesn't (same happens with 'end'). Though I could be wrong that is what the error message seems to be saying. If I'm incorrect then post the code :)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Re: Please help me interpret this error message...

Post by Celsus_Trueword »

That was my thought as well. There are only two regular brackets in the lua, right at the top and bottom:

Code: Select all

data:extend(
{  
  {
    type = "lab",
    name = "advanced-lab",
    icon = "__base__/graphics/icons/advanced-lab.png",
    flags = {"placeable-player", "player-creation"},
    minable = {mining_time = 1, result = "advanced-lab"},
    max_health = 150,
    corpse = "big-remnants",
    collision_box = {{-1.2, -1.2}, {1.2, 1.2}},
    selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
    light = {intensity = 0.75, size = 8},
    on_animation =
    {
      filename = "__base__/graphics/entity/lab/advanced-lab.png",
      frame_width = 113,
      frame_height = 91,
      frame_count = 33,
      line_length = 11,
      shift = {0.2, 0.15}
    },
    off_animation =
    {
      filename = "__base__/graphics/entity/lab/advanced-lab.png",
      frame_width = 113,
      frame_height = 91,
      frame_count = 1,
      shift = {0.2, 0.15}
    },
    energy_source =
    {
      type = "electric",
      input_priority = "secondary"
    },
    energy_usage = "100W",
    inputs =
    {
      "science-pack-1",
      "science-pack-2",
      "science-pack-3",
      "alien-science-pack"
    },
    module_slots = 3
  },
  {
    type = "accumulator",
    name = "advanced-accumulator",
    icon = "__base__/graphics/icons/advanced-accumulator.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {hardness = 0.2, mining_time = 0.5, result = "advanced-accumulator"},
    max_health = 150,
    corpse = "medium-remnants",
    collision_box = {{-0.9, -0.9}, {0.9, 0.9}},
    selection_box = {{-1, -1}, {1, 1}},
    energy_source =
    {
      type = "electric",
      buffer_capacity = "20KJ",
      input_priority = "terciary",
      input_flow_limit = "600W",
      output_priority = "terciary",
      output_flow_limit = "600W"
    },
    picture =
    {
      filename = "__base__/graphics/entity/basic-accumulator/advanced-accumulator.png",
      priority = "extra-high",
      width = 124,
      height = 103,
      shift = {0.7, -0.2}
    },
    charge_animation =
    {
      filename = "__base__/graphics/entity/basic-accumulator/advanced-accumulator-charge-animation.png",
      frame_width = 138,
      frame_height = 135,
      line_length = 8,
      frame_count = 24,
      shift = {0.482, -0.638},
      animation_speed = 0.5
    },
    charge_cooldown = 30,
    charge_light = {intensity = 0.3, size = 7},
    discharge_animation =
    {
      filename = "__base__/graphics/entity/basic-accumulator/advanced-accumulator-discharge-animation.png",
      frame_width = 147,
      frame_height = 128,
      line_length = 8,
      frame_count = 24,
      shift = {0.395, -0.525},
      animation_speed = 0.5
    },
    discharge_cooldown = 60,
    discharge_light = {intensity = 0.7, size = 7}
  },
  {
    type = "furnace",
    name = "advanced-electric-furnace",
    icon = "__base__/graphics/icons/advanced-electric-furnace.png",
    flags = {"placeable-neutral", "placeable-player", "player-creation"},
    minable = {mining_time = 1, result = "advanced-electric-furnace"},
    max_health = 150,
    corpse = "big-remnants",
    resistances = 
    {
      {
        type = "fire",
        percent = 80
      }
    },
    collision_box = {{-1.2, -1.2}, {1.2, 1.2}},
    selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
    module_slots = 3,
    smelting_categories = {"smelting"},
    result_inventory_size = 1,
    smelting_speed = 2,
    smelting_energy_consumption = "360W",
    source_inventory_size = 1,
    energy_source =
    {
      type = "electric",
      input_priority = "secondary",
      emissions = 0.005
    },
    on_animation =
    {
      filename = "__base__/graphics/entity/electric-furnace/advanced-electric-furnace.png",
      priority = "high",
      x = 131,
      frame_width = 131,
      frame_height = 102,
      frame_count = 12,
      animation_speed = 0.5,
      shift = {0.5, 0.05 }
    },
    off_animation =
    {
      filename = "__base__/graphics/entity/electric-furnace/advanced-electric-furnace.png",
      priority = "high",
      frame_width = 131,
      frame_height = 102,
      frame_count = 1,
      animation_speed = 0.5,
      shift = {0.5, 0.05 }
    },
    fast_replaceable_group = "furnace"
  },
  {
    type = "beacon",
    name = "advanced-beacon",
    icon = "__base__/graphics/icons/advanced-beacon.png",
    flags = {"placeable-player", "player-creation"},
    minable = {mining_time = 1, result = "advanced-beacon"},
    max_health = 200,
    corpse = "big-remnants",
    collision_box = {{-1.2, -1.2}, {1.2, 1.2}},
    selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
    allowed_effects = {"consumption", "speed", "pollution"},
    animation =
    {
      filename = "__base__/graphics/entity/basic-beacon/advanced-beacon.png",
      frame_width = 176,
      frame_height = 186,
      frame_count = 32,
      line_length = 6,
      shift = {1.2, 0.5},
      animation_speed = 1 / 3
    },
    radius_visualisation_picture =
    {
      filename = "__base__/graphics/entity/basic-beacon/beacon-radius-visualization.png",
      width = 48,
      height = 48
    },
    supply_area_distance = 12,
    energy_source =
    {
      type = "electric",
      input_priority = "secondary"
    },
    energy_usage = "1500W",
    distribution_effectivity = 0.75,
    num_module_slots = 3
  },
}
)

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Please help me interpret this error message...

Post by FreeER »

Hm, this is actually loading for me just fine (after adding some fake items, changing picture file locations to base graphics, etc.)...
no } syntax error...I'm assuming that your require statement is just require("prototypes.technology.advanced") and the file is actually within modname/prototypes/technology/advanced.lua ? (trying to rule things out :))
Though from what's in this file I'd assume it was within entities rather than technology...

Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Re: Please help me interpret this error message...

Post by Celsus_Trueword »

There is a repeated error in the entity\advanced.lua - looking for graphics in the wrong folders. (eg: "__base__/graphics/entity/lab/advanced-lab.png" instead of "__base__/graphics/entity/advanced-lab/advanced-lab.png") Fixing this doesn't fix the original error though. I'm surprised it works for you.
FreeER wrote:...after adding some fake items, changing picture file locations to base graphics, etc.
I think the picture locations problem is fixed with the above correction, but I'm not sure what you mean by 'adding some fake items'.
FreeER wrote:...I'm assuming that your require statement is just require("prototypes.technology.advanced") and the file is actually within modname/prototypes/technology/advanced.lua ?
Haha, assume nothing. :) I just hacked apart Dysoch's mod for it's structure, so there may be unnecessary parts still attached. If I can get this to run at all, I'm going to make new graphic files, play with the footprints, and make reasonable requirements/new techs for each machine. But I'm just trying to make sure everything is in the right place and working for now. Can't even get past a mismatched bracket. :D

Here's a crazy thought: is it the encoding? I'm working from a new Win7x64 install, so a fresh NP++ as well. Encoding for these .lua files is showing UTF-8 without BOM. Is that right?

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Please help me interpret this error message...

Post by FreeER »

Celsus_Trueword wrote:looking for graphics in the wrong folders
Yes, I assumed that you hadn't gotten around to adding them yet (lol). Also note that __base__ needs to be changed to the name of the mod (assuming that you are placing your graphics within the mod's folder rather than the base graphics, which would be an 'incorrect' way of adding graphics :)) I changed the file paths to match those of the regular (base/vanilla) entities so that it would work.
By adding 'fake items' I meant that I do not have (because the base game does not have) "advanced-x" items (which are referenced as the result items for mining the entities you've created), so I copy/pasted the code for some armor from DyTech and changed the names to match what the entities asked for (I suppose I could have just changed what the mining results were though...)
Celsus_Trueword wrote:I just hacked apart Dysoch's mod for it's structure
Ah, yeah. Always make sure to remove anything you are not going to use. Not doing so usually causes unexpected results, like errors.
encoding is utf-8 without BOM
Same for all of mine, I'm not sure if it would actually make a difference

The basic setup for any prototype file is

Code: Select all

data:extend({
{ --initial table for a prototype, if you are copy/pasting then overwrite this table, but don't forget the comma
},
})
excluding the data which is something like

Code: Select all

require("prototypes.entity.entities")
require("prototypes.item.items")
require("prototypes.technology.technologies")
require("prototypes.recipe.recipes")
actually you could have all prototypes within data.lua but people usually separate each type into their own file (to make it more orderly).

If you'd like to upload the mod as a zip I can take a look at the mod as a whole and see what the issue is :)

Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Re: Please help me interpret this error message...

Post by Celsus_Trueword »

I made the change you suggested (__base__) so the zip file here is current to where we are. Still gives me the same error though.

Thanks for helping me out. I really appreciate it. Know that your efforts are not going to waste. :)

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Please help me interpret this error message...

Post by rk84 »

You are looking the wrong file. Error points to technology and you posted entity definitions.

Edit: Oh and you need to start path like this __advanced__/... to point the right folder.
Edit2: Sorry FreeER. I didn't read your post properly.
Last edited by rk84 on Tue Jan 28, 2014 8:41 am, edited 2 times in total.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Please help me interpret this error message...

Post by FreeER »

Ok, simple error there. In the advanced/prototypes/technology/advanced.lua file you are missing two }s, one to close the effects table and another to close the Advanced tech table. Because Lua uses the one before the ) (that is actually meant to close the data:extend table) to close the effects table, it errors on line 3 (attempting to close the tech's table). An easy way to catch this is to always add a new line at the end of the file (which will cause notepad++ to show that a table has not been closed), assuming that 'hide folder margin' is not enabled under view..

After that, there is an error loading prototype "Advanced": No such node (unit.count). which is because you have not told Factorio what science packs are required to research the Advanced technology. (I'll admit that this stumped me for a moment, lol) I used this to get past it, but you can of course modify it as you like.

Code: Select all

unit =
      {
        count = 20,
        ingredients =
          {
            {"science-pack-1", 1},
            {"science-pack-2", 1}
          },
        time = 15
      }
then there is the error
path advanced/graphics/entity/.... not matching resource path pattern: __source__/path
Which is because you've replaced __base__ with advanced rather than __advanced__ (in the entities, items, and technologies) :) The __modname__ is used as a variable to tell Factorio in which mod directory to look for your graphics files, this allows you to not need to create multiple versions of your mod for multiple OSs, as well as use graphics from other installed mods (like base graphics, or as Dysoch did, having a separate mod for graphics that do not change as often as the code).

After those changes, this loads quite well :)

Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Re: Please help me interpret this error message...

Post by Celsus_Trueword »

Still having issues. Could you set me up with a .zip of the folder you have working so I could compare them?

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Please help me interpret this error message...

Post by FreeER »

Sure, note that I changed the names of the prototype files (trying to get more specific info on the unit.count error than just in "Prototype Advanced"), but other than that the rest of the changes were to get the mod to load :)
advanced.zip
bugfixed
(1.31 MiB) Downloaded 115 times

Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Re: Please help me interpret this error message...

Post by Celsus_Trueword »

Sorry it seemed that I dropped out there. I didn't realize there were two pages to the thread now, so I assumed you were away. Having a look at the zip now. And thanks again!

Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Re: Please help me interpret this error message...

Post by Celsus_Trueword »

I see how the naming system is simpler, and makes debugging much easier. Not sure why I thought all the files should be named advanced.lua. :/

I also found the differences in the number/placement of brackets (braces?) That was one thing throwing me, and the advice you gave about adding a carriage return to the end shows orphaned brackets. Nice.

Now that things are working, I found out the proper group names so the new items will appear in "production" and "energy" instead of "logistics". I tweaked the graphic files a bit more, so all that's left is to look up the list of technology names and determine which ones need to be prerequisites, and finally to make the recipes more complex than one basic inserter. ;)

Thanks again for the help, sir! I'll be releasing the mod soon and you'll definitely be credited.

Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Re: Please help me interpret this error message...

Post by Celsus_Trueword »

While I've got you, perhaps you could explain something the wiki isn't clear on. In the item.lua you corrected, you have:

Code: Select all

    type = "item",
    name = "advanced-lab",
    icon = "__advanced__/graphics/icons/advanced-lab.png",
    flags = {"goes-to-quickbar"},
    group = "production", [I changed this from "logistics")
    order = "h-e-b", <<< HERE
    place_result = "advanced-lab",
    stack_size = 64
The wiki says: "The order will determine what items come before and after them in an inventory." But I don't understand how the letters are determined. I gather that the middle letter represents the item being described, and the ones to either side indicate other items in the menu that it should be placed between... ???

Edit: Reading your guide a bit more carefully. :) You wrote:
...it determines the order items are sorted in the player's inventory and goes in alphabetical order, thus a is before b and a-e is after a-d.
I understand this, but it's still not clear how the letters are determined. What I'm trying to do is place the advanced version I created right next to the basic version if possible, so I guess I'm trying to figure out the letter representing the basic beacon (for example) and placing that in the first position of the three... ???

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Please help me interpret this error message...

Post by FreeER »

If you want to have the advanced beacon appear after the basic beacon then you first find the order string for the basic beacon (which surprisingly is just "l") so then you either use "m" for the advanced beacon or "l-a" (or any other letter in the english alphabet that appears after l). If you have two items, say one with "h-h-d" and one with "h-h-g", to place a new item between them you could use "h-h-e" or "h-h-e-a-b-c-d-e-f-h" or "h-h-f" or "h-h-f-a-a-a-a-a-a-a-a-a-a-a". When determining which item comes first Factorio looks at the first letter in the order string, if they are the same then it looks at the next, otherwise which ever would appear first in the alphabet is used first and the other second. If you have "l-a" vs "l" the "l" would come first because it is shorter.

Celsus_Trueword
Burner Inserter
Burner Inserter
Posts: 16
Joined: Tue Jan 21, 2014 9:37 pm
Contact:

Re: Please help me interpret this error message...

Post by Celsus_Trueword »

It's working great. I'm working on the new techs now, then it's ready to go. :)

I appreciate you taking the time to engage with me this fully, especially since your detailed guide on the forum should have been adequate.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Please help me interpret this error message...

Post by FreeER »

Celsus_Trueword wrote:I'm working on the new techs now, then it's ready to go. :)
Good to hear :D
Celsus_Trueword wrote:I appreciate you taking the time to engage with me this fully
My pleasure :)
Celsus_Trueword wrote:since your detailed guide on the forum should have been adequate.
It's long, which leads to complications :) The most obvious is that you have to be willing to sit down and read it, a less obvious issue is that while reading your eyes can skip over things accidentally. Beyond that there are people who simply learn better when talking to another person rather than reading a guide or manual, and not just because they get the relevant information to their problem in a condensed form either :D Also, even experienced modders make mistakes (and sometimes fail to recognize that it was was a mistake), including myself :lol:
Failing to close a table is one of the most common mistakes that can be made (and thus one of the most common errors), another is forgetting to add a ',' after an entry in a table :)

Arko
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Mar 30, 2017 5:17 pm
Contact:

Re: Please help me interpret this error message...

Post by Arko »

Code: Select all

data:extend({
	{
		
		type = "technology",
		name = "Chest", 
		icon = "__base__/graphics/icons/wooden-chest.png"
		
	},
	  effects =
		{
			{
				type = "unlock-recipe",
				recipe = "bchest"
			},
		},
      unit =
		{
			
			count = 30,
				
			ingredients =
			{
				{"science-pack-1", 2},
			},
			time = 10
			
		},
 })
I'm testing to create my first mod and I've got an error when i launch factorio :

Code: Select all

Error while loading technology prototype "Chest (technology): no such node (unit.count) 
Modifications:Chest

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

Re: Please help me interpret this error message...

Post by daniel34 »

You are closing the technology too early, the } in line 8 after icon.
The effects and unit section have to be within the same section as the technology (type, name, icon) itself.

This should work (not tested though):

Code: Select all

data:extend({
   {
      
    type = "technology",
    name = "Chest", 
    icon = "__base__/graphics/icons/wooden-chest.png"
    effects =
      {
         {
            type = "unlock-recipe",
            recipe = "bchest"
         },
      },
    unit =
      {
         
         count = 30,
            
         ingredients =
         {
            {"science-pack-1", 2},
         },
         time = 10
         
      },
   },
})
Also, don't necro 3 year old threads, start a new one or ask in a very recent thread with a similar issue.
quick links: log file | graphical issues | wiki

Post Reply

Return to “Modding help”