Page 1 of 1

How to get and set item-request-proxy slots

Posted: Tue Mar 07, 2017 2:44 am
by can00336
How do you get and set the items in the item request proxy entites?

Re: How to get and set item-request-proxy slots

Posted: Fri Apr 28, 2017 6:07 am
by gheift
Hi can,

use http://lua-api.factorio.com/latest/LuaE ... m_requests

To get the items use something like this:

Code: Select all

/c local p,s=game.player,game.player.selected for w,a in pairs(s.item_requests) do p.print(w .. \": \" .. a) end
To update the items it requests, you have to set the item_requests, not update it:

Code: Select all

/c local p,s=game.player,game.player.selected s.item_requests={["speed-module"] = 2} for w,a in pairs(s.item_requests) do p.print(w .. \": \" .. a) end
To create a proxy for an entity, you have to specify the target and the modules, see also viewtopic.php?f=25&t=40570:

Code: Select all

/c local p,s=game.player,game.player.selected p.surface.create_entity{name="item-request-proxy",target=s,force=s.force,position=s.position,modules={{item="speed-module",count=1}}}