Mark Signal.signal as optional

sparr
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Mark Signal.signal as optional

Post by sparr »

https://lua-api.factorio.com/latest/cla ... get_signal says "Returned Signal will not contain signal if none is set for the index." but https://lua-api.factorio.com/latest/con ... tml#Signal doesn't mark the signal field as optional. I think the type of Signal.signal should be SignalID? instead of SignalID
curiosity
Filter Inserter
Filter Inserter
Posts: 484
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Mark Signal.signal as optional

Post by curiosity »

Absolutely not. Other places guarantee the signal field exists, not to mention it's mandatory for write. The function should return a different type.
(although I question the utility of returning anything other than nil in that case, but that's an API change)
robot256
Filter Inserter
Filter Inserter
Posts: 948
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Mark Signal.signal as optional

Post by robot256 »

Right, the docs should be changed so that the return type of "get_signal" is "Signal or { }" for example.
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Mark Signal.signal as optional

Post by Bilka »

This is solved for 2.0.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Resolved Requests”