Page 1 of 1
Lua Command - Add item to named player inventory
Posted: Sat Apr 12, 2025 2:00 am
by DocHoss333
I'm just dipping my toes into scripting in Factorio and I can't seem to find an answer to this question directly...I want to add an item into a player's inventory in a multiplayer game. Say the character's name is "jim123"...what console command can I run to give "jim123" a stack of iron plate, for instance? All the examples I can find manipulate the inventory of the player who is playing, but I'm wanting to do this from an admin session (specifically an RCON connection, but I don't think that's really important here...right?).
Re: Lua Command - Add item to named player inventory
Posted: Sat Apr 12, 2025 3:43 am
by robot256
Replace `game.player` with `game.players["player-name"]`
Re: Lua Command - Add item to named player inventory
Posted: Sat Apr 12, 2025 2:19 pm
by DocHoss333
Nailed it. Thanks!
Re: Lua Command - Add item to named player inventory
Posted: Mon Apr 14, 2025 2:13 pm
by DocHoss333
A follow up question...how do you add items at different quality levels? Say I want to add rare iron plates...is that a property of the item insert command or is it treated as a separate item?
Example:
This inserts items into the named player's inventory. How would I modify this command to make the iron plates rare?
/c game.players["player"].insert{name = "iron-plate", count = 100}
EDIT: think I answered my own question by looking more carefully at the modding docs. Should be this...
/c game.players["player"].insert{name = "iron-plate", count = 100, quality = "rare"}