LUA Scripting:- Time On Target/On Station

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
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

LUA Scripting:- Time On Target/On Station

Post by butch4343 »

Folks

A quick question, is there anyone can see to create a scoring event that scores based on being in a place at a particular time?

The reason I ask is this, lets say I have a couple of EF111s,Growlers,Prowlers, they are supporting a strike package crossing the FEBA into enemy territory, they have a patrol box to be in, now at the moment I can only create an event that scores if they enter/remain in the area. However the player could push them into the patrol box before the package arrives or after and still score.

So I wondered if theres a way (the eaiser the better lol) of setting up an event that says:

Growler 1 enters patrol box 1 and its between 06:00:00Z and 10:00:Z

Then

Score 5 Points.

Any ideas if this is possible folks??

Regards

Butch

User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: LUA Scripting:- Time On Target/On Station

Post by michaelm75au »

Doesn't the 'unit in area' give you option to set the times?
Michael
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: LUA Scripting:- Time On Target/On Station

Post by butch4343 »

Michaelm,

The unit in area you mention is a Unit Remains in Area trigger, so it says that if the unit remains in the area for a period of time, 5 minutes, five hours then it will trigger an action such as scoring .

What am looking to do is a little diffrent, I am looking to see if I can set something up where, a player has to ensure an EF111 reaches is on station in its patrol area at exactly 0100Z until 01115Z if the player gets the aircraft on station by that time he scores 10 points, if he/she is early or late then they dont score.

Sorry if I was unclear in my origional post.
User avatar
somi83
Posts: 59
Joined: Sat Feb 06, 2016 12:59 pm
Location: Novi Sad, Serbia

RE: LUA Scripting:- Time On Target/On Station

Post by somi83 »

Hi,

I think I managed to accomplish what you asked for

Set up event like this:
Trigger: unit remains in area I have just set up side, you can specify what unit exactly trigger's the event.

Condition: I used Lua with the code like this

Code: Select all

local ut = ScenEdit_CurrentTime ()
 local t1 = (os.time({year=2016, month=5, day=20, hour=14, min=0, sec=0})) --input your year, month, day, hour and time (from)
 local t2 = (os.time({year=2016, month=5, day=20, hour=15, min=0, sec=0})) --input your year, month, day, hour and time (to)
 local t3 = t1 + 7200
 local t4 = t2 + 7200
 	if ut >= t3 and ut <= t4 then return true
 	elseif ut > t3 and ut > t4 then return false
 	elseif ut < t3 and ut < t4 then return false
 	end
Action: I have used Lua to set up scoring

Code: Select all

local side=ScenEdit_UnitX().side
 local score=ScenEdit_GetScore(side)
 local score=score+10
 local reason = "Ship is in area"
 ScenEdit_SetScore(side, score, reason)

I have attached my test mission, watch Petr Velikiy 099.
I hope that I have helped you, and if the code is complicated maybe someone can correct me and make it shorter. I am new to Lua, so I am still at the basics. [:)]
Attachments
Test.zip
(18.95 KiB) Downloaded 7 times
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: LUA Scripting:- Time On Target/On Station

Post by michaelm75au »

My 'enters area ' trigger shows start and end time range.

Image
Attachments
eventtrigger.jpg
eventtrigger.jpg (139.77 KiB) Viewed 200 times
Michael
User avatar
tjhkkr
Posts: 2431
Joined: Wed Jun 02, 2010 11:15 pm
Contact:

RE: LUA Scripting:- Time On Target/On Station

Post by tjhkkr »

ORIGINAL: somi83

Hi,

I think I managed to accomplish what you asked for

Set up event like this:
Trigger: unit remains in area I have just set up side, you can specify what unit exactly trigger's the event.

Condition: I used Lua with the code like this

Code: Select all

local ut = ScenEdit_CurrentTime ()
 local t1 = (os.time({year=2016, month=5, day=20, hour=14, min=0, sec=0})) --input your year, month, day, hour and time (from)
 local t2 = (os.time({year=2016, month=5, day=20, hour=15, min=0, sec=0})) --input your year, month, day, hour and time (to)
 local t3 = t1 + 7200
 local t4 = t2 + 7200
 	if ut >= t3 and ut <= t4 then return true
 	elseif ut > t3 and ut > t4 then return false
 	elseif ut < t3 and ut < t4 then return false
 	end
Action: I have used Lua to set up scoring

Code: Select all

local side=ScenEdit_UnitX().side
 local score=ScenEdit_GetScore(side)
 local score=score+10
 local reason = "Ship is in area"
 ScenEdit_SetScore(side, score, reason)

I have attached my test mission, watch Petr Velikiy 099.
I hope that I have helped you, and if the code is complicated maybe someone can correct me and make it shorter. I am new to Lua, so I am still at the basics. [:)]

Thank you SOMI83!
Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: LUA Scripting:- Time On Target/On Station

Post by butch4343 »

Gents,

I have been a complete Doughnut!!!!!

ORIGINAL: somi83

Hi,

I think I managed to accomplish what you asked for

Set up event like this:
Trigger: unit remains in area I have just set up side, you can specify what unit exactly trigger's the event.

Condition: I used Lua with the code like this

Code: Select all

local ut = ScenEdit_CurrentTime ()
 local t1 = (os.time({year=2016, month=5, day=20, hour=14, min=0, sec=0})) --input your year, month, day, hour and time (from)
 local t2 = (os.time({year=2016, month=5, day=20, hour=15, min=0, sec=0})) --input your year, month, day, hour and time (to)
 local t3 = t1 + 7200
 local t4 = t2 + 7200
 	if ut >= t3 and ut <= t4 then return true
 	elseif ut > t3 and ut > t4 then return false
 	elseif ut < t3 and ut < t4 then return false
 	end
Action: I have used Lua to set up scoring

Code: Select all

local side=ScenEdit_UnitX().side
 local score=ScenEdit_GetScore(side)
 local score=score+10
 local reason = "Ship is in area"
 ScenEdit_SetScore(side, score, reason)

I have attached my test mission, watch Petr Velikiy 099.
I hope that I have helped you, and if the code is complicated maybe someone can correct me and make it shorter. I am new to Lua, so I am still at the basics. [:)]

Somi83, thank you , yet again Ive given the wizards of LUA a problem, and you have come through and solved it for me, thanks again buddy.
ORIGINAL: michaelm

My 'enters area ' trigger shows start and end time range.

Image


Michael, of course it does, I cant beleive I missed that mate, talk about getting blinkered into thinking in one dimension.

Thanks for pointing out the obvious.

Regards

Butch
Post Reply

Return to “Command: Modern Operations series”