[LUA] Activate Mission

Post new mods and scenarios here.

Moderator: MOD_Command

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

[LUA] Activate Mission

Post by snowburn »

Hello!!

Is any way to change the status (from inactive to active) of a mission?
I got the following script:

local number=ScenEdit_GetKeyValue('destroyedScud')
number=number+1
ScenEdit_SetKeyValue('destroyedScud', number)

print(ScenEdit_GetKeyValue('destroyedScud'))

ScenEdit_SpecialMessage('United States', number..' Scud groups destroyed, '..9-number..' remains' )

if number==3 then
ScenEdit_SpecialMessage('United States', 'INIT MISSION 1' )

elseif number==5 then
ScenEdit_SpecialMessage('United States', 'INIT MISSION 2' )

elseif number==7 then
ScenEdit_SpecialMessage('United States', 'INIT MISSION 3' )

end

i need to active mission 1, 2 and 3 when the player destroy 3,5 and 7 scuds sites.

Thanks.
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: [LUA] Activate Mission

Post by Rory Noonan »

There doesn't seem to be a lua function for activating missions. What you could do instead is create the missions and have them active with no units assigned, then use the 'ScenEdit_AssignUnitToMission' function to assign desired units to the mission. It should have the same end effect.
Image
User avatar
snowburn
Posts: 188
Joined: Mon Sep 23, 2013 9:10 pm
Location: Bovril, Argentina

RE: [LUA] Activate Mission

Post by snowburn »

Thanks apache85, i will try that.

i hope the devs add a function to change mission status.
mikmykWS
Posts: 7185
Joined: Tue Mar 22, 2005 4:34 pm

RE: [LUA] Activate Mission

Post by mikmykWS »

Its in the event editor itself. Look for the Action change Mission Status.
User avatar
snowburn
Posts: 188
Joined: Mon Sep 23, 2013 9:10 pm
Location: Bovril, Argentina

RE: [LUA] Activate Mission

Post by snowburn »

ORIGINAL: mikmyk

Its in the event editor itself. Look for the Action change Mission Status.

Can i use an action inside an lua script? i need to activate the mission when the the player destroy 3 SCUD sites.
Yokes
Posts: 298
Joined: Tue Mar 13, 2007 9:27 pm

RE: [LUA] Activate Mission

Post by Yokes »

snowburn,

One way to make it work would be to have some hidden units somewhere in the middle of nowhere. When you want to activate a mission, have one of these units (I like to use city markers) move inside a set of waypoints. Then have a "unit remains inside area" trigger set for 1 second with an action of activating the mission.

Kinda klugy, but it should work.

Yokes
mx1
Posts: 76
Joined: Thu Jan 16, 2014 6:01 pm

RE: [LUA] Activate Mission

Post by mx1 »

Why don't you define a mission with no units assigned to it, and then assign units to mission with Lua ScenEdit_AssignUnitToMission() when conditions are met?

By the way the example Lua code might work incorrectly. If you are dealing with numerical values (like counting number of SCUD destroyed) the proper way is:

Code: Select all

 x = tonumber(ScenEdit_GetKeyValue("X"))
 x = x+1
 ScenEdit_SetKeyValue("X",X)
 

as the KeyValue is stored as string.

Post Reply

Return to “Mods and Scenarios”