Lua Command - Add item to named player inventory
-
- Burner Inserter
- Posts: 6
- Joined: Thu Jan 23, 2025 4:25 pm
- Contact:
Lua Command - Add item to named player inventory
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
Replace `game.player` with `game.players["player-name"]`
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
-
- Burner Inserter
- Posts: 6
- Joined: Thu Jan 23, 2025 4:25 pm
- Contact:
Re: Lua Command - Add item to named player inventory
Nailed it. Thanks!
-
- Burner Inserter
- Posts: 6
- Joined: Thu Jan 23, 2025 4:25 pm
- Contact:
Re: Lua Command - Add item to named player inventory
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"}
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"}