Page 1 of 1

[1.1] BUG: LuaEntity.request_slot_count always read 0

Posted: Sun Nov 29, 2020 6:26 pm
by SHiRKiT
Hello,

I'd like to report that https://lua-api.factorio.com/latest/Lua ... slot_count is reading always ZERO for requester chests.

I think with the 1.1 update, it broke the value being written in request_slot_count, now I cannot figure out a way to iterate over the requester chest slots, since I cannot just go iterating and catch an error so it stops.

I think since the change on how requester chests works (to be dynamic slots), it's reading always zero for the moment.

Re: [1.1] BUG: LuaEntity.request_slot_count always read 0

Posted: Sun Nov 29, 2020 8:01 pm
by SHiRKiT
It only reads 0 when it has no requests configured, which is weird.

Re: [1.1] BUG: LuaEntity.request_slot_count always read 0

Posted: Sun Nov 29, 2020 8:15 pm
by Choumiko
it is always set to the configured request with the highest index/slot.
If you want to do something to configured request that should be enough.

Code: Select all

for i=1, request_slot_count do
--guaranteed to encouter every 
end
if you want to set requests then just iterate over your data and use set/clear_request_slot accordingly.
Factorio will auto expand the slots when using set_request_slot()

Edit:
Actually found a nice short example in my mod (it deals with the spidertron and not requester chests, but that shouldn't matter i think)
set_request()/clear() are LuaEntity.set/clear_vehicle_request_slot calls

Code: Select all

        for i = 1, requests.max_slot do --max_slot is NOT the set to request_slot_count (could be >100 or whatever)
            if config[i] then --config is created/stored via the mod and contains requests to set
                set_request(i, config[i])
            else
                clear(i)
            end
        end

Re: [1.1] BUG: LuaEntity.request_slot_count always read 0

Posted: Mon Nov 30, 2020 9:22 pm
by Daeruun
'request_slot_count ()'
returns the highest configured request slot...

there might be empty ones before, thou

Re: [1.1] BUG: LuaEntity.request_slot_count always read 0

Posted: Fri Dec 04, 2020 6:56 am
by Honktown
I just ran into this... was never noted in the changelog D:< . There's also no read on the prototype's max slots. I wanted the "last slot" for my mod, so for now I'm going with 20 (end of default second row) unless someone has a better idea.

Re: [1.1] BUG: LuaEntity.request_slot_count always read 0

Posted: Fri Dec 04, 2020 8:06 am
by Klonan
Honktown wrote:
Fri Dec 04, 2020 6:56 am
I just ran into this... was never noted in the changelog D:< . There's also no read on the prototype's max slots. I wanted the "last slot" for my mod, so for now I'm going with 20 (end of default second row) unless someone has a better idea.
The prototype has no max request, the number of requests is not limited

Internally, the max slot index is 1000

You can write to any slot you up to that and the GUI will adjust

Re: [1.1] BUG: LuaEntity.request_slot_count always read 0

Posted: Fri Dec 04, 2020 10:12 pm
by Honktown
Klonan wrote:
Fri Dec 04, 2020 8:06 am
Honktown wrote:
Fri Dec 04, 2020 6:56 am
I just ran into this... was never noted in the changelog D:< . There's also no read on the prototype's max slots. I wanted the "last slot" for my mod, so for now I'm going with 20 (end of default second row) unless someone has a better idea.
The prototype has no max request, the number of requests is not limited

Internally, the max slot index is 1000

You can write to any slot you up to that and the GUI will adjust
Is the wiki inaccurate then?
https://wiki.factorio.com/Prototype/LogisticContainer

Code: Select all

max_logistic_slots

Type: uint16
The number of request slots this logistics container has. Requester-type containers must have > 0 slots and can have a maximum of 1000 slots. Storage-type containers must have <= 1 slot. 
This implies the request slots can be limited to <1000, even if it expands when it shows 20+. Under 20 would show fewer... but if that doesn't apply to 1.1 at all... I know I've seen errors in data stage for a storage or requester not having the right value, so is this value even relevant anymore if all requesters are 20-1000? In theory maybe someone could want an unfilterable storage chest but that's the only reason I can see the parameter continuing to exist