Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Conditional Subtype on Unit X

 
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 Operations series >> Mods and Scenarios >> Lua Legion >> Conditional Subtype on Unit X Page: [1]
Login
Message << Older Topic   Newer Topic >>
Conditional Subtype on Unit X - 9/5/2021 4:52:16 PM   
BDukes

 

Posts: 1450
Joined: 12/27/2017
Status: online
Hi All

I'm rusty. With the code below I'm trying to simulate a 50% chance of a bailout from an aircraft that isn't the subtype 8201 (UAV). Problem is it is not excluding 8201. Code runs fine if I take out the if destroyedUnit.subtype ~= 8201. Feels like I'm missing something stupid. Can somebody take a look?


quote:



local destroyedUnit = ScenEdit_UnitX()
if destroyedUnit.subtype ~= 8201 then
local aircrewsurvival = math.random(1,2)
if aircrewsurvival==1 then
local crew = ScenEdit_AddUnit({
type='Facility',
dbid=2441,
side=destroyedUnit.side,
name=destroyedUnit.name .. " " .. "Aircrew",
latitude=destroyedUnit.latitude,
longitude=destroyedUnit.longitude
})
end
end


< Message edited by BDukes -- 9/5/2021 5:50:17 PM >


_____________________________

Don't call it a comeback...
Post #: 1
RE: Conditional Subtype on Unit X - 9/5/2021 6:21:28 PM   
BDukes

 

Posts: 1450
Joined: 12/27/2017
Status: online
Did this a different way! Used subtype in the triggers.

Mike

_____________________________

Don't call it a comeback...

(in reply to BDukes)
Post #: 2
RE: Conditional Subtype on Unit X - 9/5/2021 7:01:45 PM   
BDukes

 

Posts: 1450
Joined: 12/27/2017
Status: online
Well almost. Can't see all the subtypes in the edit trigger drop down. Reported

Think I got most.

Mike

_____________________________

Don't call it a comeback...

(in reply to BDukes)
Post #: 3
RE: Conditional Subtype on Unit X - 9/5/2021 8:36:53 PM   
KnightHawk75

 

Posts: 1244
Joined: 11/15/2018
Status: offline
change 8201 to "8201" or change to ~= tostring(8201) if the number is a var, as subtype code is returned as a string somewhat oddly.
local destroyedUnit = ScenEdit_UnitX()
if destroyedUnit.subtype ~= "8201" then
  local aircrewsurvival = math.random(1,2)
  if aircrewsurvival==1 then
    local crew = ScenEdit_AddUnit({
    type='Facility',
    dbid=2441,
    side=destroyedUnit.side,
    name=destroyedUnit.name .. " " .. "Aircrew",
    latitude=destroyedUnit.latitude,
    longitude=destroyedUnit.longitude
    })
  end
end 



< Message edited by KnightHawk75 -- 9/5/2021 8:37:43 PM >

(in reply to BDukes)
Post #: 4
RE: Conditional Subtype on Unit X - 9/5/2021 10:05:04 PM   
BDukes

 

Posts: 1450
Joined: 12/27/2017
Status: online
Perfect. Thank you!

Mike

_____________________________

Don't call it a comeback...

(in reply to KnightHawk75)
Post #: 5
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Conditional Subtype on Unit X 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.348