Remove_Weapon

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Remove_Weapon

Post by Parel803 »

Struggling with a weapon remove.
I added a VLS system but that has already weapons in it. Wanna remove those to add different.
I added: ScenEdit_UpdateUnit({guid='50PVO4-xxxxx-U2T2SG', mountid=2262, mode='remove_weapon',dbid=1195})
Try to remove the SM2's: ScenEdit_UpdateUnit({guid='50PVO4-xxxxx-U2T2SG', mountid=2262, mode='remove_weapon',dbid=1195})
and: ScenEdit_UpdateUnit({guid='50PVO4-xxxxx-U2T2SG', mode='remove_weapon',dbid=1195, mountid='50PVO4-0HM5N6IMEQO1O'})

Request help to know what I'm doing wrong?

If the GuiD of the mount is needed can I set this Guid myself. So I can use that in the same part of the text or do I have to find it from the senario every time.

with regards GJ
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Remove_Weapon

Post by KnightHawk75 »

Missing the weapon id, see my attachment in the recent b1bomber thread for example of how to add vls mount and then clean it....before adding stuff to it. In the above looks your giving it the mountid guid but not weaponid guid for the specific weapon record you want removed.

ScenEdit_UpdateUnit({guid=theUnitobj.guid,mode='remove_weapon',dbid=v.wpn_dbid,mountid=v.Mguid,weaponid=v.Wguid});


Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Remove_Weapon

Post by Parel803 »

Thx again.
with regards GJ
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Remove_Weapon

Post by Parel803 »

Knighthawk thx. Did you wanna send a attachment with it?
ScenEdit_UpdateUnit({guid='50PVO4-xxx-U2T2SG',mode='remove_weapon',dbid=1195,mountid='50PVO4-0HM5P5SCQBKPL',weaponid='50PVO4-0HM5P5SCQBKPN'})
This line worked. But still questions in that damaged brain of mine. So I hope I can do follow up questions?
Can I add the VLS and delete the SM2's without searching for there GuiD nrs. Is that why you have the v. & Mguid & Wguid in yor line?
If it a stupid question, sorry for that
with regards GJ


KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Remove_Weapon

Post by KnightHawk75 »

ORIGINAL: Parel803

Knighthawk thx. Did you wanna send a attachment with it?
ScenEdit_UpdateUnit({guid='50PVO4-xxx-U2T2SG',mode='remove_weapon',dbid=1195,mountid='50PVO4-0HM5P5SCQBKPL',weaponid='50PVO4-0HM5P5SCQBKPN'})
This line worked. But still questions in that damaged brain of mine. So I hope I can do follow up questions?
Can I add the VLS and delete the SM2's without searching for there GuiD nrs. Is that why you have the v. & Mguid & Wguid in yor line?
If it a stupid question, sorry for that
with regards GJ
that line was taken from the attachment in post #9 here which is the b-1b fictional aircraft script I posted:
fb.asp?m=4936126
Can I add the VLS and delete the SM2's without searching for there GuiD nrs.
Not if you are adding the VLS tubes dynamically via lua and then wanting to operate on them because there is no other way to know what those guid's will be. You either gotta search for them via matching index, weapon_recorddbid, or by name or couple other ways you could do it. If you are manually adding the VLS and just want to remove the SM2's, like at a particular time or something, yeah you totally can. Just look up the guid in the mount table by dumping it to the console ahead of time.

u = SE_GetUnit({name='Red_Pansir_1', guid='4FH7PU-0HM5J7B9C4CHQ'})
print(u.mounts);

or more pretty version:

Code: Select all

 u = SE_GetUnit({guid='EXAMPL-UNITGUIDHERE'})
 print("Dumping mounts on unit " .. u.name);
 for k,v in pairs(u.mounts) do
   print("mount index #: ".. k .. "  mount name: " .. tostring(v.mount_name) .. " mount guid: " .. tostring(v.mount_guid) .. "  weapons entries: ")
     if v.mount_weapons ~=nil then
       for i,j in ipairs(v.mount_weapons) do
         print("  Entry#" .. i .. "  wpn_name: " .. j.wpn_name .. "  wpn_guid: " .. j.wpn_guid)
       end
     else 
         print("  No weapons on this mount.")
     end
 end
Which should out put something like this for you.
Dumping mounts on unit Red_Pansir_1
mount index #: 1   mount name: SA-22 Greyhound [Pantsir-SM ER]   mount guid: 4FH7PU-0HM5J7B9C4CHU   weapons entries:
  Entry#1   wpn_name: SA-22 Greyhound ER [57E6]   wpn_guid: 4FH7PU-0HM5J7B9C4CI4
  Entry#2   wpn_name: 30mm 2A38M Burst [50 rnds]   wpn_guid: 4FH7PU-0HM5J7B9C4CI5
mount index #: 2   mount name: SA-22 Greyhound [Pantsir-SM ER]   mount guid: 4FH7PU-0HM5J7B9C4CI6   weapons entries:
  Entry#1   wpn_name: SA-22 Greyhound ER [57E6]   wpn_guid: 4FH7PU-0HM5J7B9C4CIC
  Entry#2   wpn_name: 30mm 2A38M Burst [50 rnds]   wpn_guid: 4FH7PU-0HM5J7B9C4CID
Mguid = Blue
Wguid = Red\purple
OR..
You could could just build yourself a delta file that includes all your changes and then SceneEdit_UpdateUnit({guid=theguidoftheunit, mode="delta" file="...path to your delta file"}, if that works for what you're doing. Just the guid in the delta will need to match the guid of the unit as I recall.



Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: Remove_Weapon

Post by Parel803 »

Thank you, much appriciated. See you been very busy and doing a lot of work for the community and the game. thx again
with regards GJ
Post Reply

Return to “Lua Legion”