Page 1 of 1

[SOLVED] ItemStack Question with requestslot

Posted: Sat Oct 01, 2016 10:08 pm
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

Re: ItemStack Question with requestslot

Posted: Sat Oct 01, 2016 10:56 pm
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.

Re: ItemStack Question with requestslot

Posted: Sat Oct 01, 2016 11:07 pm
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