Soldier.addNewItem ▲ 380

Available from Easy Red 2 2.1.0

Adds an item to the soldier's inventory. Weapons, and from 2.1.1 mod items too, are loaded asynchronously: the function returns true at once and the item appears a moment later. DLC items are refused.


Return value

Return TypeDescription
boolReturns true if the item has been added to the soldier's inventory successfully

Parameters

ParameterTypeDescription
1stringThe id of the item to add
2bool(Optional) Should the soldier wear the clothing / equip the weapon. Default is false. For a mod item the prefab decides whether it can be worn.

Examples

Example 119

local soldier = er2.getPlayer()
soldier.addNewItem("jap_infantry_helmet_4_net", true) -- Adds to the player a japanese helmet and force equips it

Equip item to soldier

local soldier = er2.getPlayer()
soldier.addNewItem("m60", true) -- Adds an M60 to the player and force equips it

Back to Scripting API