[1.1.80] set_request_slot does not allow a count of 0

Post Reply
vklein52
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat May 20, 2023 10:53 am
Contact:

[1.1.80] set_request_slot does not allow a count of 0

Post by vklein52 »

It seems there may be a small bug in the condition within set_request_slot. I am trying to set spidertron logistic requests to 0 from a mod function, but when I try to run a line like

Code: Select all

spidertron_entity.set_request_slot({name=item.name, count=0}, slot)
I get the following error

Code: Select all

Error while running event spidertron-construction-qol::on_entity_damaged (ID 103)
count must be positive)
stack traceback:
	[C]: in function 'set_request_slot'
	__spidertron-construction-qol__/control.lua:44: in function 'add_not_requested_items'
	__spidertron-construction-qol__/control.lua:56: in function <__spidertron-construction-qol__/control.lua:51>
Since logistic requests can be set to 0 (always trash), shouldn't count have to be non-negative rather than positive like it is now? Also, I can see many count = 0 for existing logistic requests when logged.

It is also definitely possible I am just doing something wrong lol. Appreciate any help/confirmation!

Honktown
Smart Inserter
Smart Inserter
Posts: 1026
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: [1.1.80] set_request_slot does not allow a count of 0

Post by Honktown »

set_request_slot is for requester chests, which can't auto-trash. It's more of a bug that the function works on non-requesters, though it's probably there for legacy reasons.

https://lua-api.factorio.com/1.1.80/Lua ... istic_slot
-->

Code: Select all

 LogisticParameters :: table
Table fields
name 	:: string?

The item. nil clears the filter.
min 	:: uint?
max 	:: uint? 
this works because count is actually ignored min is set to 0 and max is infinite because count isn't checked:

Code: Select all

/c
game.player.selected.set_vehicle_logistic_slot(1, {name="wooden-chest", count=0})
this is explicitly 0 and 0:

Code: Select all

/c
game.player.selected.set_vehicle_logistic_slot(1, {name="wooden-chest", min = 0, max = 0})
I have mods! I guess!
Link

vklein52
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat May 20, 2023 10:53 am
Contact:

Re: [1.1.80] set_request_slot does not allow a count of 0

Post by vklein52 »

Agh that was exactly my issue. Your recommendation worked perfectly!

Thank you very much :)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13240
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.80] set_request_slot does not allow a count of 0

Post by Rseding91 »

Thanks for the report. set_request_slot was removed in 2.0 in favor of a unified API for accessing all logistic requests/filters. In the meantime you can use the other functions as mentioned.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Fixed for 2.0”