Question about LUA

Take command of air and naval assets from post-WW2 to the near future in tactical and operational scale, complete with historical and hypothetical scenarios and an integrated scenario editor.

Moderator: MOD_Command

Post Reply
User avatar
snowburn
Posts: 188
Joined: Mon Sep 23, 2013 9:10 pm
Location: Bovril, Argentina

Question about LUA

Post by snowburn »

Hello!!

i want to add some reserve aircraft to a mission when 5 sam sites where destroyed.
can we do something like this with the new LUA editor?



Event scenario_start:
trigger: T1
action: init_variables


Event: SAM Site destroyed
trigger: sam_site_hit
action: sam_site_count
add_fighters




Action init_variables:
ScenEdit_SetKeyValue('sam_site_destroyed', 0 )


Action: sam_site_count:
ScenEdit_SetKeyValue('sam_site_destroyed', ScenEdit_GetKeyValue('sam_site_destroyed') +1 )


Action add_fighters:
if(ScenEdit_GetKeyValue('sam_site_destroyed') == 5) {
ScenEdit_AssignUnitToMission('ac1', 'CAP')
ScenEdit_AssignUnitToMission('ac2', 'CAP')
ScenEdit_AssignUnitToMission('ac3', 'CAP')
ScenEdit_AssignUnitToMission('ac4', 'CAP')
ScenEdit_AssignUnitToMission('ac5', 'CAP')
}




ckfinite
Posts: 208
Joined: Fri Jul 19, 2013 10:33 pm

RE: Question about LUA

Post by ckfinite »

Yep, that should work.
User avatar
snowburn
Posts: 188
Joined: Mon Sep 23, 2013 9:10 pm
Location: Bovril, Argentina

RE: Question about LUA

Post by snowburn »

thanks :)
i hope we can have a release canditate soon
mx1
Posts: 76
Joined: Thu Jan 16, 2014 6:01 pm

RE: Question about LUA

Post by mx1 »

Is the ScenEdit_SetKeyValue part of API? I don't see it documented on github site.

User avatar
snowburn
Posts: 188
Joined: Mon Sep 23, 2013 9:10 pm
Location: Bovril, Argentina

RE: Question about LUA

Post by snowburn »

ORIGINAL: mx1

Is the ScenEdit_SetKeyValue part of API? I don't see it documented on github site.


http://wiki.baloogancampaign.com/index. ... etKeyValue
ckfinite
Posts: 208
Joined: Fri Jul 19, 2013 10:33 pm

RE: Question about LUA

Post by ckfinite »

I knew I forgot something, sorry about that. Yes, SetKeyValue and GetKeyValue are both valid functions.
ckfinite
Posts: 208
Joined: Fri Jul 19, 2013 10:33 pm

RE: Question about LUA

Post by ckfinite »

They are now documented, again sorry about that.
mx1
Posts: 76
Joined: Thu Jan 16, 2014 6:01 pm

RE: Question about LUA

Post by mx1 »

I've also found that ScenEdit_GetReferencePoint() works as expected but is not documented. It is pretty useful function to check whether unit is within certain area defined by RPs.
Post Reply

Return to “Command: Modern Operations series”