Page 1 of 1
[0.14.6] built_by -> last_user
Posted: Thu Sep 15, 2016 9:16 pm
by apriori
How should I make my mod compatible with pre-0.14.6 Factorio versions?
Code: Select all
if event.created_entity.built_by then --or if event.created_entity["built_by"] then - this row is bad
local player = event.created_entity.built_by --pre-0.14.6 compatibility
else
local player = event.created_entity.last_user
end
raises an event.
Re: [0.14.6] built_by -> last_user
Posted: Thu Sep 15, 2016 9:22 pm
by Zeblote
I think the idea is more like "nobody cares about old versions". If someone is using experimental with mods at all, they can just run the latest one.
Re: [0.14.6] built_by -> last_user
Posted: Thu Sep 15, 2016 9:23 pm
by Adil
By determining the
version of the "base" mod.
Factorio objects have always been raising error when checked for unexistant fields.
Re: [0.14.6] built_by -> last_user
Posted: Thu Sep 15, 2016 9:32 pm
by apriori
Re: [0.14.6] built_by -> last_user
Posted: Thu Sep 15, 2016 9:53 pm
by aubergine18
This will get player regardless of version, because `last_user` will be `nil` on older versions and thus default to `built_by`. On new version or later, it will use `last_user`.
Code: Select all
local entity = event.created_entity
local player = entity.last_user or entity.built_by
BTW, you can also set more specific `
factorio_version` in the `
info.json` (just that most people don't use it), for example look at my
Glyph mod in mod portal, I do that with this line in `info.json`:
Re: [0.14.6] built_by -> last_user
Posted: Thu Sep 15, 2016 10:47 pm
by Rseding91
aubergine18 wrote:This will get player regardless of version, because `last_user` will be `nil` on older versions and thus default to `built_by`. On new version or later, it will use `last_user`.
Code: Select all
local entity = event.created_entity
local player = entity.last_user or entity.built_by
BTW, you can also set more specific `
factorio_version` in the `
info.json` (just that most people don't use it), for example look at my
Glyph mod in mod portal, I do that with this line in `info.json`:
The API doesn't work that way. If you call a property/function that doesn't exist on the object it gives an error.
Re: [0.14.6] built_by -> last_user
Posted: Thu Sep 15, 2016 11:38 pm
by aubergine18
Rseding91 wrote:The API doesn't work that way. If you call a property/function that doesn't exist on the object it gives an error.
Ah, never realised that. It's good as it means modders will instantly know if they mistype a property name or if a new release removes a property = faster bug identification and fixing.