[SOLVED] ItemStack Question with requestslot

Place to get help with not working mods / modding interface.
Post Reply
LordLoki
Inserter
Inserter
Posts: 25
Joined: Tue Apr 12, 2016 7:17 am
Contact:

[SOLVED] ItemStack Question with requestslot

Post by LordLoki »

Hi together,

I just started to get into the whole Modding thing and i am stucl with this

Code: Select all

for i = 1, ent.request_slot_count do
	local slotinfo = ent.get_request_slot(i)
	message_all(slotinfo)
end	
this code works but it prints only Unknown Key:"Fast inserter" (given i have a fast inserter in the slot)
but i also need to grab the requested amount.

I tried to treat slotinfo like a table with a for loop in pais cause the documentation says (An item stack may be specified either as a string (in which case it represents a full stack containing the specified item), or as the following table:) but that is not working.

Can somebody help me and tell me how do i get the itemcount and name from that slot?

Thanks and greets Loki
Last edited by LordLoki on Sat Oct 01, 2016 11:08 pm, edited 1 time in total.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: ItemStack Question with requestslot

Post by DaveMcW »

Code: Select all

message_all(slotinfo.name .. " " .. slotinfo.count)
The table also works with pairs(), but name and count are the only keys so it is not very useful.

LordLoki
Inserter
Inserter
Posts: 25
Joined: Tue Apr 12, 2016 7:17 am
Contact:

Re: ItemStack Question with requestslot

Post by LordLoki »

Hi There,

I just figured out my mistake :)
i tried it with slotinfo.name before but that was an error too.
problem was he did not like the empty slots....
when you print it out as string it does not seem to bother him but if he expects a table and gets a nil he is not happy :D

Code: Select all

for i = 1, ent.request_slot_count do
      local slotinfo = ent.get_request_slot(1)
              if slotinfo ~= nil then
                    message_all(slotinfo.name .. ": " .. slotinfo.count)
              end	
end		

Post Reply

Return to “Modding help”