Crash when opening electric network information

Place to get help with not working mods / modding interface.
Post Reply
User avatar
NooBxGockeL
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Aug 02, 2014 7:20 pm
Contact:

Crash when opening electric network information

Post by NooBxGockeL »

Good morning :D
I have a pretty wierd bug in my mod and have no idea on how to fix it, or what exactly causes this issue...
Another user pointed this out pretty well here: https://forums.factorio.com/forum/vie ... 299#p41242

Does this mean i have an error in the entity prototype ? or even item prototype ?

Basically i just copy-pasta'ed from long-handed-inserter and customized to a small extent.
Key Things i changed:
minable 'result' node is removed (allready tested returning iron-plate, cant be the problem)
flags = {"player-creation"} (cant add the other 2 usual candidates, error gets thrown that he cant find an order string for the entity ???)

I am using different names for my items and entities, could that cause the problem and wouldnt that be a vanilla bug then ? (e.g. item=fast-short-MIinserter, entity=fast-short-MIinserter-straight)

Entity-Prototype: https://github.com/noobxgockel/moarinse ... tityOO.lua

Any Ideas would be much appreciated!
~Markus

EDIT:
Well it really was because of the stupid flags...
Kinda unneccessary that the complete game crashes when those 2 flags arent in place...
Will report to devs!
#closed

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

Re: Crash when opening electric network information

Post by FreeER »

If Factorio is crashing (and it is lol) then it's a vanilla bug (even if it's getting horrendously improper input it should fail gracefully with an error message back to the main menu, not crash).

So a tiny bit of checking and it appears that just having the "placeable-player" flag prevents the crash (see below for entity order string), though you can have any combination.
NooBxGockeL wrote:cant add the other 2 usual candidates, error gets thrown that he cant find an order string for the entity ???
Entities require an order string, it just so happens that the devs were nice enough to make it so that entities can 'inherit' it from an item that places them so you don't have to give it explicity, at least not most of the time. Not all of your inserter entities have items however (only the 'straight' ones), so the others need to be given one in their prototype. My solution is this in entityOO's init:

Code: Select all

if not data.raw.item[baseName] or not data.raw.item[baseName].order then
    obj.order = "a[moarinserters]-" .. getOrderCharacter(rangeArg) .. "[range]"
  end
getOrderCharacter was copied from itemOO, you might want that in the scripts/util file in case you want to change it at some point. Since it's checking the item prototypes that have been loaded into data.raw I swapped the data.raw require lines for item and entity (obviously if items don't get loaded first entities get one anyways but if the order string gen ever changes that would lead to differences, and possibly issues though unlikely). Obviously, you could perform the check based on the entity's direction itself if you wanted.

Post Reply

Return to “Modding help”