New .has_request_slots property to easily determine if entity is requester chest.
Background: viewtopic.php?f=34&t=30079
entity.has_request_slots
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
entity.has_request_slots
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.
Re: entity.has_request_slots
Added LuaEntity::request_slot_count read for 0.13.13.
If you want to get ahold of me I'm almost always on Discord.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: entity.has_request_slots
Instead of returning 0 if the entity has no request slots, would it be worth returning nil instead?
Then I could simplify this:
To this:
Just makes the code a little cleaner when I only want to do a quick check to determine if entity is a requestor...
Then I could simplify this:
Code: Select all
if someEntity.request_slot_count > 0 then ...
Code: Select all
if someEntity.request_slot_count then ...
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.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: entity.has_request_slots
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*
*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.