Page 1 of 1

entity.has_request_slots

Posted: Fri Jul 29, 2016 10:15 pm
by aubergine18
New .has_request_slots property to easily determine if entity is requester chest.

Background: viewtopic.php?f=34&t=30079

Re: entity.has_request_slots

Posted: Sat Jul 30, 2016 1:54 pm
by Rseding91
Added LuaEntity::request_slot_count read for 0.13.13.

Re: entity.has_request_slots

Posted: Sat Jul 30, 2016 10:58 pm
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...

Re: entity.has_request_slots

Posted: Sun Jul 31, 2016 1:28 pm
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*