Page 1 of 1

LUA Scripting:- Time On Target/On Station

Posted: Tue Aug 22, 2017 5:09 am
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


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

Posted: Tue Aug 22, 2017 6:56 am
by michaelm75au
Doesn't the 'unit in area' give you option to set the times?

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

Posted: Tue Aug 22, 2017 10:09 am
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.

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

Posted: Tue Aug 22, 2017 3:08 pm
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. [:)]

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

Posted: Wed Aug 23, 2017 6:28 am
by michaelm75au
My 'enters area ' trigger shows start and end time range.

Image

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

Posted: Wed Aug 23, 2017 11:58 pm
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!

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

Posted: Thu Aug 24, 2017 6:07 am
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