Page 1 of 1
What are the new ways of getting request_slot_count?
Posted: Tue Oct 22, 2024 7:15 am
by sensenmann
Removed LuaEntity::clear_request_slot(), get_request_slot() and set_request_slot() methods.
Removed LuaEntity::request_slot_count read.
What are the new ways of getting request_slot_count?
How do i migrate get_request_slot and set_request_slot in my mod to 2.0?
My code is
Code: Select all
for i = 1, entity.request_slot_count do
local slot = entity.get_request_slot(i)
if slot ~= nil and slot.name == "alien-hyper-module-" .. storage.currentmodulelevel[forceName] - 1 then
entity.set_request_slot({ name = "alien-hyper-module-" .. storage.currentmodulelevel[forceName], count = slot.count }, i)
end
if settings.startup["alien-module-hyper-ammo-enabled"].value and slot ~= nil and slot.name == "alien-hyper-magazine-" .. storage.currentmodulelevel[forceName] - 1 then
entity.set_request_slot({ name = "alien-hyper-magazine-" .. storage.currentmodulelevel[forceName], count = slot.count }, i)
end
end
Re: What are the new ways of getting request_slot_count?
Posted: Tue Oct 22, 2024 8:37 am
by Koub
[Koub] Split from the release thread, and made it into its own thread in the modding help subforum
Re: What are the new ways of getting request_slot_count?
Posted: Thu Oct 24, 2024 9:54 am
by firebladed3
This appears to require iterating through the
LuaLogisticPoint.sections you can get from LuaControl.
get_requester_point()
Re: What are the new ways of getting request_slot_count?
Posted: Sun Oct 27, 2024 9:18 pm
by sensenmann
Thanks that did the trick.
Heres my code if someone wonders how it is done (no guarantee its bug-free
Code: Select all
-- upgrade logistc requests
local logistics_point = entity.get_requester_point()
if logistics_point ~= nil then
for i = 1, logistics_point.sections_count do
local section = logistics_point.get_section(i)
for ii = 1, section.filters_count do
if section.get_slot(ii).value.name == "alien-hyper-module-" .. storage.currentmodulelevel[forceName] - 1 then
local current_filter = section.get_slot(ii)
section.set_slot(ii, { value = { name = "alien-hyper-module-" .. storage.currentmodulelevel[forceName], quality = current_filter.value.quality, comparator = current_filter.value.comparator },
min = current_filter.min,
max = current_filter.max })
end
end
end
end
Re: What are the new ways of getting request_slot_count?
Posted: Sat Nov 02, 2024 4:37 pm
by Silari
I've had to look into this for Manual Logistics, and it looks like using the # operator on the filters property of the logistic point works if you just want the count.
Code: Select all
mylogpt = mychar.get_logistic_point(defines.logistic_member_index.character_requester)
log(#mylogpt.filters)
gives the output of 35, which is how many requests I have set on my character.
Filters also seems to work for what I need in general, since it outputs an array with every request with the name and count for each.
Code: Select all
{comparator = "=",
count = 200,
index = 35,
name = "advanced-circuit",
quality = "normal"},
For manipulating the requests, it does look like you need to iterate the sections for that.