LuaEntityPrototype doesn't contain key air_resistance.

Place to get help with not working mods / modding interface.
Post Reply
Rafiz
Inserter
Inserter
Posts: 31
Joined: Sun Jan 17, 2021 9:28 am
Contact:

LuaEntityPrototype doesn't contain key air_resistance.

Post by Rafiz »

But it should, right? In docs of LuaEntityPrototype it says LuaEntityPrototype has key air_resistance, that is either double value or nil.

my (kind of messy) mod control file. mod from mod portal isn't in newest(this) form
https://pastebin.com/5HcnzQzz
(as side note, line 47 prints that we are dealing with LuaEntityPrototype, same as error message, but just wanted to make sure)

my error (whenever train gets registered ( reload or new game->after placing train part ) ):

Code: Select all

Error while running event train_realism::on_tick (ID 0)
LuaEntityPrototype doesn't contain key air_resistance.
stack traceback:
	[C]: in function '__index'
	__train_realism__/control/debug_controller.lua:51: in function 'airResistance'
	__train_realism__/control/debug_controller.lua:86: in function 'calculateTrainAirResistance'
	__train_realism__/control/debug_controller.lua:142: in function 'createTrain'
	__train_realism__/control/debug_controller.lua:168: in function 'registerTrains'
	__train_realism__/control/debug_controller.lua:535: in function <__train_realism__/control/debug_controller.lua:530>
1365.478 Quitting: user-quit.
1365.691 Goodbye
I don't know, I think this error message is misleading. It states prototype doesn't have key that it ... really should have, according to API documentation.


Error started appearing after... I don't know, it just worked before. Now I can't place train

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: LuaEntityPrototype doesn't contain key air_resistance.

Post by Klonan »

Are you sure you're calling it on a rolling stock, and not on some other type of entity prototype?

Also there is a direct link from entity to prototype,
so all the
`game.entity_prototypes[carriage.name]`

can be just
`carriage.prototype`

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaEntityPrototype doesn't contain key air_resistance.

Post by Bilka »

I cannot reproduce the issue with the pastebin code you provided. Furthermore, even if you were calling it on something that is not a rolling stock prototype (e.g. a character prototype), it should just return nil instead of erroring. So for me, this points to a broken install (try verifying files in steam) or you posted the wrong code/error. See boskid's post after mine.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2244
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaEntityPrototype doesn't contain key air_resistance.

Post by boskid »

What version of factorio are you using? This field was added in 1.1.34.

Rafiz
Inserter
Inserter
Posts: 31
Joined: Sun Jan 17, 2021 9:28 am
Contact:

Re: LuaEntityPrototype doesn't contain key air_resistance.

Post by Rafiz »

Actually, version must (indeed) be the problem! I'm using 1.1.33
My big mistake, for looking at newest stable API. I actually must change mod requirement to be >=1.1.34

I got fooled that this mod was working previously (on 1.1.33), but control.lua must have been omitted somehow in my previous mod edits, as now I even recall debug messages not being printed...
I was very confused that it stopped working after few mod edits, and that it stopped working in such way.

Thank you for help, and for game that has so excellent modding API.



Download speeds are extremally slow for me - only from factorio site : /

Post Reply

Return to “Modding help”