Page 1 of 2

Prototype error(s) improvements

Posted: Tue Oct 04, 2016 5:51 am
by Rseding91
In attempts to improve errors given when some prototype isn't setup correctly I was wondering if you (the modding community) would be willing to tell me which errors you find most confusing and why in hopes that I can improve them.

Recently someone on reddit was having an error that I've long known was super confusing: https://www.reddit.com/r/factorio/comme ... irst_time/ so if you know of others please let me know. It's highly likely that I can make the error(s) give much better information.

Re: Prototype error(s) improvements

Posted: Tue Oct 04, 2016 12:47 pm
by bobingabout
I think some of the most confusing ones for me are those like this:
viewtopic.php?f=51&t=33539
Not because it's a confusing error in itself, it quite clearly states that an item with that name doesn't exist. The confusion is well... what mod is causing this?

in this specific case, it was Angel's mod for my mods that wanted an item from one of the mods that wasn't installed. and unlike my mods, it doesn't check if it exists before trying to access it. But when you get a bug report like that, it does make it a little difficult to diagnose the issue.

From my understanding, when the mod name, and even file line isn't given, it's because the line itself doesn't cause an error, so the problem goes un-noticed until everything is being parsed at the end of the stage.
Perhaps something that could help is to list a specific recipe that referenced the item, and what mod/mods add/edit said recipe, similar to the list in game that might say "bobores->bobplates->5dim->angelores" when you hover over a recipe that was added in my mod, then edited several times. At least it narrows down the field of what we need to look at.

Re: Prototype error(s) improvements

Posted: Tue Oct 04, 2016 1:38 pm
by aubergine18
I was stumped by a stack overflow error recently, turned out that I'd missed a `pairs()` in a `for` loop.

Code: Select all

for k,v in foobar do
  -- my code here caused a stack overflow
end
It's one of those blunders where you can end up starting at the screen for hours without spotting the obvious mistake. If possible, when a stack overflow occurs, could the error message state "Did you forget to use pairs() or ipairs() in a for loop?"

Re: Prototype error(s) improvements

Posted: Tue Oct 04, 2016 2:07 pm
by aubergine18
Using dots in item/entity/etc names gives confusing error: viewtopic.php?f=25&t=33734

Typos in image/sound file names causes confusion (especially if industrious factorian modders have automated their scripts and thus can't do a simple "find in files" to track down the typo).

Re: Prototype error(s) improvements

Posted: Tue Oct 04, 2016 4:26 pm
by Rseding91
bobingabout wrote:I think some of the most confusing ones for me are those like this:
viewtopic.php?f=51&t=33539
Not because it's a confusing error in itself, it quite clearly states that an item with that name doesn't exist. The confusion is well... what mod is causing this?

in this specific case, it was Angel's mod for my mods that wanted an item from one of the mods that wasn't installed. and unlike my mods, it doesn't check if it exists before trying to access it. But when you get a bug report like that, it does make it a little difficult to diagnose the issue.

From my understanding, when the mod name, and even file line isn't given, it's because the line itself doesn't cause an error, so the problem goes un-noticed until everything is being parsed at the end of the stage.
Perhaps something that could help is to list a specific recipe that referenced the item, and what mod/mods add/edit said recipe, similar to the list in game that might say "bobores->bobplates->5dim->angelores" when you hover over a recipe that was added in my mod, then edited several times. At least it narrows down the field of what we need to look at.
Did.. did you read what I said in the first post? The linked reddit comment? :)

Re: Prototype error(s) improvements

Posted: Tue Oct 04, 2016 4:31 pm
by Rseding91
aubergine18 wrote:I was stumped by a stack overflow error recently, turned out that I'd missed a `pairs()` in a `for` loop.

Code: Select all

for k,v in foobar do
  -- my code here caused a stack overflow
end
It's one of those blunders where you can end up starting at the screen for hours without spotting the obvious mistake. If possible, when a stack overflow occurs, could the error message state "Did you forget to use pairs() or ipairs() in a for loop?"
That's an error from the Lua engine itself - not one that we can control.

Re: Prototype error(s) improvements

Posted: Wed Oct 05, 2016 12:15 pm
by mexmer
error "Bad conversion"
what is this about?

see viewtopic.php?f=7&t=33790 how to get this error

will be fixed, so maybe i should delete it from here.

Re: Prototype error(s) improvements

Posted: Wed Oct 05, 2016 2:46 pm
by aubergine18
Just had this error:

Code: Select all

Error while loading entity prototype "stone" (resource): No such node (amount_min)
Modifications: base › Epoch
Does it mean I should or shouldn't have `amount_min`? ("No such node" is ambiguous to me; it could be that I've tried to set something that doesn't exist, or that I've failed to set something that must exist).

Re: Prototype error(s) improvements

Posted: Wed Oct 05, 2016 6:01 pm
by aubergine18
Not strictly error related, but could `log()` be given a second, optional parameter (default 1) to define which level of the stack hierarchy should be used to generate the script name and line number shown in the log file? It would be similar to how Lua `error()` function works.

Code: Select all

-- in foo.lua
function utilFunc1( val )
  log( val ) -- Script foo.lua:2: abc
end

function utilFunc2( val )
  log( val, 2 ) -- Script bar.lua:3 def
end

-- in bar.lua
require 'foo'
utilFunc1( "abc" )
utilFunc2( "def" )
This would enable logging done in helper/util functions to be much more useful (as it's usually the calling scope that logging relates to).

Re: Prototype error(s) improvements

Posted: Thu Oct 06, 2016 5:25 pm
by keyboardhack
I made a few one liners that gives bad error messages.

Code: Select all

data.raw["car"]["car"].animation.layers[1].frame_count = 3
data.raw["car"]["car"].animation.layers[1].stripes[1].width_in_frames = 3
Spawns this cryptic error message.
Image

As a new modder i had no idea what a stripeLine was or what combination of things that controlled the height of one.
Not sure exactly what the error message should say but it would atleast be nice if it said which stripe is wrong as a car has multiple stripes.




Code: Select all

data.raw["car"]["car"].animation.layers[1].stripes[1].height_in_frames = 3
data.raw["car"]["car"].animation.layers[1].direction_count = 65
data.raw["cargo-wagon"]["cargo-wagon"].horizontal_doors.layers[1].line_length = -1
Each of the above lines gives the following error:
Image

No idea what a stripe iterator is and usually no idea what the issue is.

Re: Prototype error(s) improvements

Posted: Thu Oct 06, 2016 9:08 pm
by aubergine18
Just run in to the node error again:

Code: Select all

Error while loading tile prototype "wood-floor" (tile): No such node (side)
Would be better if it said something like:

Code: Select all

Prototype error in "wood-floor" (tile): Mandatory "side" property not found.
Note: Even with that improved error message, I'd still struggle in the absence of documentation about prototypes and their properties. For example, it would take some time to track down that `side` is a property of the `variants` property (in this case I already know that to be the case as I know that tiles have a `side` property in that locaiton).

Re: Prototype error(s) improvements

Posted: Fri Oct 07, 2016 3:56 pm
by mexmer
aubergine18 wrote:Just run in to the node error again:

Code: Select all

Error while loading tile prototype "wood-floor" (tile): No such node (side)
Would be better if it said something like:

Code: Select all

Prototype error in "wood-floor" (tile): Mandatory "side" property not found.
Note: Even with that improved error message, I'd still struggle in the absence of documentation about prototypes and their properties. For example, it would take some time to track down that `side` is a property of the `variants` property (in this case I already know that to be the case as I know that tiles have a `side` property in that locaiton).
tell me that, when i was searching for "no such node (north)"

Re: Prototype error(s) improvements

Posted: Mon Oct 10, 2016 10:09 pm
by aubergine18
Just ran in to this error

Code: Select all

   1.283 Error Util.cpp:57: Failed to load mod "Epoch 0.0.1"
__Epoch__/data.lua:19: ...io/factorio.app/Contents/data/core/lualib/dataloader.lua:16:
Missing name or type in the following prototype definition {} --[[table: 0x0000000116368890]]
Seems it was caused by a copy/paste blunder in one of my protos:

Code: Select all

data:extend {
  {
  }
}

Re: Prototype error(s) improvements

Posted: Mon Oct 10, 2016 10:25 pm
by aubergine18
Would it be possible to make this error mode descriptive (ie. what is invalid about it)?

Code: Select all

   2.125 Error Util.cpp:57: Error while loading entity prototype "stone-well" (storage-tank):
Invalid pipe connections specification for offset {0.0000000000, 2.0000000000}.
Modifications: Epoch
It used to be {0,3} (which worked, but was in wrong place) and I just changed it to {0,2} (which threw error) - but not sure how or why that's invalid.

Re: Prototype error(s) improvements

Posted: Mon Oct 10, 2016 11:23 pm
by Rseding91
aubergine18 wrote:Just ran in to this error

Code: Select all

   1.283 Error Util.cpp:57: Failed to load mod "Epoch 0.0.1"
__Epoch__/data.lua:19: ...io/factorio.app/Contents/data/core/lualib/dataloader.lua:16:
Missing name or type in the following prototype definition {} --[[table: 0x0000000116368890]]
Seems it was caused by a copy/paste blunder in one of my protos:

Code: Select all

data:extend {
  {
  }
}
That literally tells you everything wrong and what you need to do to fix it.. I don't see how it can be any *more* descriptive.

Re: Prototype error(s) improvements

Posted: Tue Oct 11, 2016 1:55 am
by Mooncat
I don't know if anyone has encountered this before:

Code: Select all

Failed to load mod "my-mod 0.1.0" __mod__/data.lua:1: ...io/factorio.app/Contents/data/core/lualib/dataloader.lua:11: Invalid prototype array nil
Took me 30 minutes to figure out I shouldn't try to manually type the prototype files, because I typed

Code: Select all

data.extend(
but not

Code: Select all

data:extend(
I should have copied it from the existing files instead. :(
Maybe a hint about this when invalid prototype array nil error occurs?

Also, I agree with aubergine18, we really need an updated document about prototypes. Currently, making prototypes is a puzzle game. Everyone knows a little bit about it. We gather information from the others to create a complete mod. It is fun, but also time consuming. A document will be much helpful. :)

Re: Prototype error(s) improvements

Posted: Tue Oct 11, 2016 8:01 am
by mexmer
Mooncat wrote:I don't know if anyone has encountered this before:

Code: Select all

Failed to load mod "my-mod 0.1.0" __mod__/data.lua:1: ...io/factorio.app/Contents/data/core/lualib/dataloader.lua:11: Invalid prototype array nil
Took me 30 minutes to figure out I shouldn't try to manually type the prototype files, because I typed

Code: Select all

data.extend(
but not

Code: Select all

data:extend(
I should have copied it from the existing files instead. :(
Maybe a hint about this when invalid prototype array nil error occurs?

Also, I agree with aubergine18, we really need an updated document about prototypes. Currently, making prototypes is a puzzle game. Everyone knows a little bit about it. We gather information from the others to create a complete mod. It is fun, but also time consuming. A document will be much helpful. :)
well, main issue with prototypes is, that we don't know which attributes are mandatory, and which are optional.
you might assume, that "all" attributes you find on vanilla item definition are mandatory, but that's not always true, you need to find "right" prototype you can copy and reuse (i'm writing prototypes, but i have not found any single real prototype in item definitions, so i take "base vanilla items" as prototypes, although that is not correct)

also there is that difference between "item definition" prototype, and "parser" prototype

Re: Prototype error(s) improvements

Posted: Tue Oct 11, 2016 8:54 am
by Mooncat
mexmer wrote:well, main issue with prototypes is, that we don't know which attributes are mandatory, and which are optional.
you might assume, that "all" attributes you find on vanilla item definition are mandatory, but that's not always true, you need to find "right" prototype you can copy and reuse (i'm writing prototypes, but i have not found any single real prototype in item definitions, so i take "base vanilla items" as prototypes, although that is not correct)

also there is that difference between "item definition" prototype, and "parser" prototype
That's why we need the devs to make the doc. Only they know all the possibilities of prototypes. :)

To me, item prototype is not a big issue. There are not too many possible attributes.
The main issue is entity prototype. There are many different entity types, and each entity type has different set of attributes.
And not only entities, but attributes can also have different types. Here is part of the land-mine entity:

Code: Select all

    action =
    {
      type = "direct",
      action_delivery =
      {
        type = "instant",
        source_effects =
        {
          {
            type = "nested-result",
            affects_target = true,
            action =
            {
              type = "area",
              perimeter = 6,
              collision_mask = { "player-layer" },
              action_delivery =
              {
                type = "instant",
                target_effects =
                {
                  type = "damage",
                  damage = { amount = 40, type = "explosion"}
                }
              }
            },
          },
          {
            type = "create-entity",
            entity_name = "explosion"
          },
          {
            type = "damage",
            damage = { amount = 1000, type = "explosion"}
          }
        }
      }
    },
My mind was nearly blown when I first saw this. So many different "type"s. Yet, there may be more somewhere in the prototype files, waiting to be explored by us.
With the doc, I expect it can tell us what are the possible contents inside "action", "action_delivery", "source_effects", and what are the possible values of those "type"s.
I know it will take time to write the doc. I just hope we will have it in the future. :)

Edit: and please prepare the doc when you, the devs, are creating new prototype (e.g. entity) types.

Re: Prototype error(s) improvements

Posted: Tue Oct 11, 2016 9:46 am
by mexmer
Mooncat wrote:
mexmer wrote:well, main issue with prototypes is, that we don't know which attributes are mandatory, and which are optional.
you might assume, that "all" attributes you find on vanilla item definition are mandatory, but that's not always true, you need to find "right" prototype you can copy and reuse (i'm writing prototypes, but i have not found any single real prototype in item definitions, so i take "base vanilla items" as prototypes, although that is not correct)

also there is that difference between "item definition" prototype, and "parser" prototype
That's why we need the devs to make the doc. Only they know all the possibilities of prototypes. :)

To me, item prototype is not a big issue. There are not too many possible attributes.
The main issue is entity prototype. There are many different entity types, and each entity type has different set of attributes.
And not only entities, but attributes can also have different types. Here is part of the land-mine entity:

Code: Select all

    action =
    {
      type = "direct",
      action_delivery =
      {
        type = "instant",
        source_effects =
        {
          {
            type = "nested-result",
            affects_target = true,
            action =
            {
              type = "area",
              perimeter = 6,
              collision_mask = { "player-layer" },
              action_delivery =
              {
                type = "instant",
                target_effects =
                {
                  type = "damage",
                  damage = { amount = 40, type = "explosion"}
                }
              }
            },
          },
          {
            type = "create-entity",
            entity_name = "explosion"
          },
          {
            type = "damage",
            damage = { amount = 1000, type = "explosion"}
          }
        }
      }
    },
My mind was nearly blown when I first saw this. So many different "type"s. Yet, there may be more somewhere in the prototype files, waiting to be explored by us.
With the doc, I expect it can tell us what are the possible contents inside "action", "action_delivery", "source_effects", and what are the possible values of those "type"s.
I know it will take time to write the doc. I just hope we will have it in the future. :)

Edit: and please prepare the doc when you, the devs, are creating new prototype (e.g. entity) types.
for item/entity prototype we don't need exactly doc, validation schema should be enough.
i suspect they are using something like this http://json-schema.org/ otherwise writing validator for any and every item type will be tedious task.

Re: Prototype error(s) improvements

Posted: Tue Oct 11, 2016 10:15 am
by Mooncat
mexmer wrote:for item/entity prototype we don't need exactly doc, validation schema should be enough.
i suspect they are using something like this http://json-schema.org/ otherwise writing validator for any and every item type will be tedious task.
Validator can only tell you whether you are doing it right or not, but it can't tell you what you can actually do.
There was some time people don't know the "localised_name" attribute exists, because it is not found in vanilla files, and I bet many people still don't know there is also "localised_description". I knew it by accident. 8-)

To me, I didn't know about sprite prototype until I saw aubergine's github issue here: https://github.com/aubergine10/Style/issues/33

There are still much we need to figure out. So I would say, we do need a detailed document for what we can put in the prototype files.