Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Reloading TBMs

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Reloading TBMs Page: [1]
Login
Message << Older Topic   Newer Topic >>
Reloading TBMs - 5/28/2017 3:52:46 PM   
SeaQueen


Posts: 672
Joined: 4/14/2007
From: Washington D.C.
Status: offline
I have a trigger that goes off periodically and it's working fine. My issue is with the function ScenEdit_AddReloadsToUnit() for some reason it's not taking the reloads I'm giving it. Not sure why.

local s="Red"
local w=2145 --- DF-15C db ID
local n=1

local df15_units ={ -- array of all units to be replenished
"1-815MB (DF-15)",
"2-815MB (DF-15)",
"3-815MB (DF-15)",
"4-815MB (DF-15)",
"1-817MB (DF-15)",
"2-817MB (DF-15)",
"3-817MB (DF-15)",
"4-817MB (DF-15)",
"1-818MB (DF-15)",
"2-818MB (DF-15)",
"3-818MB (DF-15)",
"4-818MB (DF-15)",
"1-819MB (DF-15)",
"2-819MB (DF-15)",
"3-819MB (DF-15)",
"4-819MB (DF-15)"
"1-820MB (DF-15)",
"2-820MB (DF-15)",
"3-820MB (DF-15)",
"4-820MB (DF-15)"}

i = 1
while df15_units\[i\] ~= nil do
ScenEdit_AddReloadsToUnit({side=s, unitname=df15_units\[i\], wpn_dbid=w})
i =i+1
end

< Message edited by SeaQueen -- 5/28/2017 3:55:33 PM >
Post #: 1
RE: Reloading TBMs - 5/28/2017 6:49:14 PM   
mikmykWS

 

Posts: 11531
Joined: 3/22/2005
Status: offline
quote:


df15_units ={ -- array of all units to be replenished
"1-815MB (DF-15)",
"2-815MB (DF-15)",
"3-815MB (DF-15)",
"4-815MB (DF-15)",
"1-817MB (DF-15)",
"2-817MB (DF-15)",
"3-817MB (DF-15)",
"4-817MB (DF-15)",
"1-818MB (DF-15)",
"2-818MB (DF-15)",
"3-818MB (DF-15)",
"4-818MB (DF-15)",
"1-819MB (DF-15)",
"2-819MB (DF-15)",
"3-819MB (DF-15)",
"4-819MB (DF-15)"
"1-820MB (DF-15)",
"2-820MB (DF-15)",
"3-820MB (DF-15)",
"4-820MB (DF-15)"}
for i, name in ipairs(df15_units) do
ScenEdit_AddReloadsToUnit({unitname=(name),wpn_dbid=2145,number=4,maxcap=4})
end


Try this. You want to check for nils which is what the ipairs part does(well sorta).

Mike

< Message edited by mikmyk -- 5/28/2017 6:53:13 PM >


_____________________________


(in reply to SeaQueen)
Post #: 2
RE: Reloading TBMs - 5/29/2017 10:19:08 AM   
michaelm75au


Posts: 12012
Joined: 5/5/2001
From: Sydney, Australia
Status: offline
As Mike points out, if one of units being reloaded has been destroyed, then the script will terminate.
It is always a good idea to check if a unit is still around before using it:
if ScenEdit_GetUnit({name='my unit name'}) ~= nil then
--do something as unit exists
else
--it died
end


_____________________________

Michael

(in reply to mikmykWS)
Post #: 3
RE: Reloading TBMs - 5/30/2017 5:16:15 PM   
SeaQueen


Posts: 672
Joined: 4/14/2007
From: Washington D.C.
Status: offline
quote:

ORIGINAL: mikmyk
Try this. You want to check for nils which is what the ipairs part does(well sorta).


Thanks for the clarification. I looked at the documentation for the ipairs() function originally, and it confused me. It works like a charm now.

(in reply to mikmykWS)
Post #: 4
RE: Reloading TBMs - 5/30/2017 5:31:15 PM   
mikmykWS

 

Posts: 11531
Joined: 3/22/2005
Status: offline
Yeah lua is very readable... if you speak Klingon.

Mike

_____________________________


(in reply to SeaQueen)
Post #: 5
RE: Reloading TBMs - 5/30/2017 10:31:16 PM   
Sniper31


Posts: 83
Joined: 9/15/2015
Status: offline

quote:

ORIGINAL: mikmyk

Yeah lua is very readable... if you speak Klingon.

Mike


Haha...now that was funny....and appropriate I might add!

_____________________________

"I say again, expend ALL remaining in my perimeter!" - Platoon

"This is JB27, on target...fire for effect.." - Me

(in reply to mikmykWS)
Post #: 6
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Reloading TBMs Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.152