LUA to Add Weapons to Magazine

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
tmoilanen
Posts: 111
Joined: Wed Oct 19, 2011 4:28 pm

LUA to Add Weapons to Magazine

Post by tmoilanen »

Good morning - I'm trying to add weapons to a magazine...syntax and error message are shown below. Any help would be appreciated.

>> local a = ScenEdit_QueryDB('weapon',51)
print(a)

ScenEdit_AddWeaponToUnitMagazine({unitname='Eareckson Air Station Ammo Revetment #1', dbid='51'})

weapon {
name = 'AIM-120D AMRAAM P3I.4',
dbid = '51',
type = '6',
subtype = 'Guided Weapon',
validTargetList = 'table',
}
ScenEdit_AddWeaponToUnitMagazine 0 : ,No weapon defined.
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: LUA to Add Weapons to Magazine

Post by TitaniumTrout »

You need more information.
ScenEdit_AddWeaponToUnitMagazine({side='Coalition',unitname='Bunker',wpn_dbid='51',number=10,maxcap=250}))
User avatar
Randomizer
Posts: 1535
Joined: Sat Jun 28, 2008 8:31 pm

RE: LUA to Add Weapons to Magazine

Post by Randomizer »

For The V-Bombers I used the following script to add weapons to magazines at random times.

ScenEdit_AddWeaponToUnitMagazine({name='Ammo Pad', guid='760ad4e1-064b-44e6-831e-
4e9ffa24c146', wpn_dbid='727', number='4'})
ScenEdit_AddWeaponToUnitMagazine({name='Ammo Pad', guid='760ad4e1-064b-44e6-831e-
4e9ffa24c146', wpn_dbid='1161', number='8'})
ScenEdit_AddWeaponToUnitMagazine({name='Ammo Pad', guid='760ad4e1-064b-44e6-831e-
4e9ffa24c146', wpn_dbid='90', number='6'})
ScenEdit_AddWeaponToUnitMagazine({name='Ammo Pad', guid='760ad4e1-064b-44e6-831e-
4e9ffa24c146', wpn_dbid='615', number='1'})

One of the Lua gods out there (forget which) later advised that the unit name is superfluous if the GUID is used, which simplifies the script slightly.

-C
Post Reply

Return to “Lua Legion”