Prototype error(s) improvements
Prototype error(s) improvements
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.
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.
If you want to get ahold of me I'm almost always on Discord.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Prototype error(s) improvements
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.
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.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Prototype error(s) improvements
I was stumped by a stack overflow error recently, turned out that I'd missed a `pairs()` in a `for` loop.
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?"
Code: Select all
for k,v in foobar do
-- my code here caused a stack overflow
end
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.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Prototype error(s) improvements
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).
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).
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.
Re: Prototype error(s) improvements
Did.. did you read what I said in the first post? The linked reddit comment?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.
If you want to get ahold of me I'm almost always on Discord.
Re: Prototype error(s) improvements
That's an error from the Lua engine itself - not one that we can control.aubergine18 wrote:I was stumped by a stack overflow error recently, turned out that I'd missed a `pairs()` in a `for` loop.
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?"Code: Select all
for k,v in foobar do -- my code here caused a stack overflow end
If you want to get ahold of me I'm almost always on Discord.
Re: Prototype error(s) improvements
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.
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.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Prototype error(s) improvements
Just had this error:
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).
Code: Select all
Error while loading entity prototype "stone" (resource): No such node (amount_min)
Modifications: base › Epoch
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.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Prototype error(s) improvements
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.
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).
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" )
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.
-
- Filter Inserter
- Posts: 478
- Joined: Sat Aug 23, 2014 11:43 pm
- Contact:
Re: Prototype error(s) improvements
I made a few one liners that gives bad error messages.
Spawns this cryptic error message.
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.
Each of the above lines gives the following error:
No idea what a stripe iterator is and usually no idea what the issue is.
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
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
No idea what a stripe iterator is and usually no idea what the issue is.
Waste of bytes : P
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Prototype error(s) improvements
Just run in to the node error again:
Would be better if it said something like:
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).
Code: Select all
Error while loading tile prototype "wood-floor" (tile): No such node (side)
Code: Select all
Prototype error in "wood-floor" (tile): Mandatory "side" property not found.
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.
Re: Prototype error(s) improvements
tell me that, when i was searching for "no such node (north)"aubergine18 wrote:Just run in to the node error again:
Would be better if it said something like:Code: Select all
Error while loading tile prototype "wood-floor" (tile): No such node (side)
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).Code: Select all
Prototype error in "wood-floor" (tile): Mandatory "side" property not found.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Prototype error(s) improvements
Just ran in to this error
Seems it was caused by a copy/paste blunder in one of my protos:
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]]
Code: Select all
data:extend {
{
}
}
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.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Prototype error(s) improvements
Would it be possible to make this error mode descriptive (ie. what is invalid about it)?
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.
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
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.
Re: Prototype error(s) improvements
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.aubergine18 wrote:Just ran in to this error
Seems it was caused by a copy/paste blunder in one of my protos: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]]
Code: Select all
data:extend { { } }
If you want to get ahold of me I'm almost always on Discord.
Re: Prototype error(s) improvements
I don't know if anyone has encountered this before:
Took me 30 minutes to figure out I shouldn't try to manually type the prototype files, because I typed
but not
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.
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
Code: Select all
data.extend(
Code: Select all
data:extend(
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
well, main issue with prototypes is, that we don't know which attributes are mandatory, and which are optional.Mooncat wrote:I don't know if anyone has encountered this before:Took me 30 minutes to figure out I shouldn't try to manually type the prototype files, because I typedCode: 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
but notCode: Select all
data.extend(
I should have copied it from the existing files instead.Code: Select all
data:extend(
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.
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
That's why we need the devs to make the doc. Only they know all the possibilities of prototypes.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
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"}
}
}
}
},
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
for item/entity prototype we don't need exactly doc, validation schema should be enough.Mooncat wrote:That's why we need the devs to make the doc. Only they know all the possibilities of prototypes.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
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: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.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"} } } } },
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.
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
Validator can only tell you whether you are doing it right or not, but it can't tell you what you can actually do.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.
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.
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.