upgrade planner's get_mapper()'s to can return nil

User avatar
Quezler
Fast Inserter
Fast Inserter
Posts: 202
Joined: Fri Mar 25, 2016 6:37 pm
Contact:

upgrade planner's get_mapper()'s to can return nil

Post by Quezler »

The from side when "empty" will still return a table, the to side when empty can return nil:

/c game.print(serpent.line(game.player.cursor_stack.get_mapper(1, "from"))) -- {type = "item"}
/c game.print(serpent.line(game.player.cursor_stack.get_mapper(1, "to"))) -- nil
Attachments
Screenshot 2025-05-08 at 13.55.53.png
Screenshot 2025-05-08 at 13.55.53.png (41.31 KiB) Viewed 244 times
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 323
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: upgrade planner's get_mapper()'s to can return nil

Post by Therenas »

Isn't this more of a bug? Returning "{type = "item"}" doesn't make sense right? Should be nil?
User avatar
Quezler
Fast Inserter
Fast Inserter
Posts: 202
Joined: Fri Mar 25, 2016 6:37 pm
Contact:

Re: upgrade planner's get_mapper()'s to can return nil

Post by Quezler »

well it makes sense in the way that the slot is reserved and there isn't a nil gap, like empty logistic filters in a section return {} and not nil too, which way belongs where is very much just in the eye of the devs :D

There's probably a technical reason here why the source needs to be set to something not-nil when there's just a destination defined, i'll leave it up to you guys to figure out whether the destination should be marked as optional, making both return a table, or making both optional :)
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 323
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: upgrade planner's get_mapper()'s to can return nil

Post by Therenas »

Alrighty updated the docs for the next release to mention this, and added some missing fields to UpgradeMapperSource and UpgradeMapperDestination . Thanks for the report.
sarfact
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Aug 19, 2024 9:35 am
Contact:

Re: upgrade planner's get_mapper()'s to can return nil

Post by sarfact »

Makes sense now, if the "from" side needs to stay non-nil for internal consistency, like how empty logistics filters return {}. Good call raising it, and thank you
Post Reply

Return to “Resolved Requests”