entity.has_request_slots

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

entity.has_request_slots

Post by aubergine18 »

New .has_request_slots property to easily determine if entity is requester chest.

Background: viewtopic.php?f=34&t=30079
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15997
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: entity.has_request_slots

Post by Rseding91 »

Added LuaEntity::request_slot_count read for 0.13.13.
If you want to get ahold of me I'm almost always on Discord.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: entity.has_request_slots

Post by aubergine18 »

Instead of returning 0 if the entity has no request slots, would it be worth returning nil instead?

Then I could simplify this:

Code: Select all

if someEntity.request_slot_count > 0 then ...
To this:

Code: Select all

if someEntity.request_slot_count then ...
Just makes the code a little cleaner when I only want to do a quick check to determine if entity is a requestor...
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: entity.has_request_slots

Post by aubergine18 »

Ignore my comment above, I was having a senior moment. Using nil instead of zero would make simple check as to whether entity has request slots faster, but it would make all other operations much slower due to first having to check that the value isn't nil before being able to compare to some other value.

*Note to self: Get some sleep before posting flawed suggestions*
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Post Reply

Return to “Implemented mod requests”