Page 1 of 1

LUA to Add Weapons to Magazine

Posted: Mon Mar 30, 2020 11:35 am
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.

RE: LUA to Add Weapons to Magazine

Posted: Mon Mar 30, 2020 11:40 am
by TitaniumTrout
You need more information.
ScenEdit_AddWeaponToUnitMagazine({side='Coalition',unitname='Bunker',wpn_dbid='51',number=10,maxcap=250}))

RE: LUA to Add Weapons to Magazine

Posted: Mon Mar 30, 2020 1:24 pm
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