Page 1 of 1

Change weapon via Lua

Posted: Thu Mar 31, 2016 7:57 am
by Anakin
Hi,

is it possible to exchange a weapon via lua script?? Let's say there is a unit with airstrike and it's stupid to have it on TantiveIV. So now i can make two different units with different weapons, but it doesn't seams to be a good solution. So i thought i can exchange the weapon via lua in the tantiveIV script. Is that possible? and how would i do that??

Re: [LUA]change weapon

Posted: Thu Mar 31, 2016 8:35 am
by thelegend
You can change a unit's weaponary through SetClassProperty in your .lua (below ScriptPostLoad):

Code: Select all

SetClassProperty("Your_Unit_Name", "WeaponName1", "Name_of_the_odf_weapon")
But make sure your replacement weapon is loaded by an unit anywhere else (In ReadDataFile), or the game won't know where to find the new weapon.