[1.1] BUG: LuaEntity.request_slot_count always read 0

Place to get help with not working mods / modding interface.
User avatar
SHiRKiT
Filter Inserter
Filter Inserter
Posts: 706
Joined: Mon Jul 14, 2014 11:52 pm
Contact:

[1.1] BUG: LuaEntity.request_slot_count always read 0

Post 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.
User avatar
SHiRKiT
Filter Inserter
Filter Inserter
Posts: 706
Joined: Mon Jul 14, 2014 11:52 pm
Contact:

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

Post by SHiRKiT »

It only reads 0 when it has no requests configured, which is weird.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

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

Post 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
Daeruun
Inserter
Inserter
Posts: 43
Joined: Thu May 04, 2017 8:37 pm
Contact:

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

Post by Daeruun »

'request_slot_count ()'
returns the highest configured request slot...

there might be empty ones before, thou
Honktown
Smart Inserter
Smart Inserter
Posts: 1042
Joined: Thu Oct 03, 2019 7:10 am
Contact:

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

Post 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.
I have mods! I guess!
Link
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5267
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

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

Post 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
Honktown
Smart Inserter
Smart Inserter
Posts: 1042
Joined: Thu Oct 03, 2019 7:10 am
Contact:

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

Post 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
I have mods! I guess!
Link
Post Reply

Return to “Modding help”