Page 1 of 1

[LUA] Activate Mission

Posted: Wed Feb 03, 2016 7:45 pm
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.

RE: [LUA] Activate Mission

Posted: Wed Feb 03, 2016 8:55 pm
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.

RE: [LUA] Activate Mission

Posted: Wed Feb 03, 2016 8:58 pm
by snowburn
Thanks apache85, i will try that.

i hope the devs add a function to change mission status.

RE: [LUA] Activate Mission

Posted: Wed Feb 03, 2016 9:01 pm
by mikmykWS
Its in the event editor itself. Look for the Action change Mission Status.

RE: [LUA] Activate Mission

Posted: Thu Feb 04, 2016 2:25 pm
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.

RE: [LUA] Activate Mission

Posted: Thu Feb 04, 2016 2:34 pm
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

RE: [LUA] Activate Mission

Posted: Thu Feb 04, 2016 2:41 pm
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.