Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Editor-LUA Help

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> Editor-LUA Help Page: [1]
Login
Message << Older Topic   Newer Topic >>
Editor-LUA Help - 6/10/2017 4:54:55 PM   
s1nnfe1n

 

Posts: 6
Joined: 6/10/2017
Status: offline
Hello, I am posting this here, i hope i am in the right section.

I am building a scenario where 2 strike packages will destroy 2 bridges, each bridge compromised from 3 sections, East, Center and West grouped together.

And 3 strike packages will SEAD, 3 different sections. South, Center, North. South has 4 radar sites, center has 2 radar sites and north has 4 radar sites.

My problem is that i do not want the scenario to be point based but objective based with time limit.

For the bridges in the Event Editor its something like this.

Trigger
NorthBridgeEastDestroyed (Unit Destroyed Trigger)
NorthBridgeWestDestroyed (Unit Destroyed Trigger)
NorthBridgeCenterDestroyed (Unit Destroyed Trigger)
Condition
Not Have
Action
BridgeDestroyed (Message)

Now i want to end the scenario when all the targets are destroyed.

So in the Event Editor is like:
Trigger
Site A (Unit Destroyed Trigger)
Site B (Unit Destroyed Trigger)
Bridge Etc (Unit Destroyed Trigger)
Condition
Not have
Action
Congratulations bluh bluh (Message)
End Scenario

The problem is that once the first site is destroyed the scenario ends of course. The triggers together are connected with "or".

Did i miss something in the event editor?
Can i do this with Lua Scripting? If Yes How?

Thank you in advance.


Post #: 1
RE: Editor-LUA Help - 6/10/2017 5:32:07 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
The events fire whenever any of triggers are fired.
What I suggest is:
Trigger
NorthBridgeEastDestroyed (Unit Destroyed Trigger)
NorthBridgeWestDestroyed (Unit Destroyed Trigger)
NorthBridgeCenterDestroyed (Unit Destroyed Trigger)
Condition
Return false if all 3 'units' have not been destroyed, else return true
Action
BridgeDestroyed (Message)


---

Trigger
Site A (Unit Destroyed Trigger)
Site B (Unit Destroyed Trigger)
Bridge Etc (Unit Destroyed Trigger)
Condition
Return false if all 'units' have not been destroyed, else return true.
Action
Congratulations bluh bluh (Message)
End Scenario


_____________________________

Michael

(in reply to s1nnfe1n)
Post #: 2
RE: Editor-LUA Help - 6/10/2017 6:22:23 PM   
s1nnfe1n

 

Posts: 6
Joined: 6/10/2017
Status: offline
Thank you for your response.

I was thinking the same but in conditions the only way to do this is with Lua. Which i do not know how to use. I read some tutorials to start with by i did nt find anything similar. Only unit related codes, lke changing loads, behaviour, spawn etc.


(in reply to michaelm75au)
Post #: 3
RE: Editor-LUA Help - 6/10/2017 6:42:35 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Yes conditions are basically Lua scripts that return true or false.

Sample condition:
-- this is the bridge group 
local unit = ScenEdit_GetUnit({name='North Bridge'})
if unit == nil then
  -- no group unit, so linked units destroyed
  return true
end
return false
--

Or you could check the individual units of the group in case someone un-grouped them

_____________________________

Michael

(in reply to s1nnfe1n)
Post #: 4
RE: Editor-LUA Help - 6/10/2017 7:28:00 PM   
s1nnfe1n

 

Posts: 6
Joined: 6/10/2017
Status: offline
I see.
So You use the units not the triggers to code.

If there are more than one unit for the condition to be true how do i do it?


local unit1 = ScenEdit_GetUnit({name='Rad1'})
if unit1 == nil
and
local unit2 = ScenEdit_GetUnit({name='Rad2'})
if unit2 == nil then
return true
end
return false

or
local unit = ScenEdit_GetUnit({name='Rad1','Rad2','Rad3'})
if unit == nil
return true
end
return false

Is this correct? do i need the -- because i am looking into lua tutorial syntax and i cannot find what -- is for.
Sorry if i ask stupid things but i am new to coding. I understand the principles but the syntax is look chinese to me.

(in reply to michaelm75au)
Post #: 5
RE: Editor-LUA Help - 6/11/2017 3:34:44 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Looking at Lua tutorials in general will give you a background on how to interpret the code.
Best way then is to look at some of the community scenarios; a number of the more recent ones make use of Lua to some degree.
To handle multiple unit checks, I usually create a table of the units in question and then cycle thru it.
Something like ...
-- it is better to use the GUID from the units when you have added them. 
-- Protects against units with same name or player changing the name during play
local units = {'Rad1', 'Rad2', 'Rad3'}
local result = true -- assume condition will pass with all units destroyed
for i = 1, #units do
local unit = ScenEdit_GetUnit({ name = units[i]})
if unit ~= nil then
  -- unit not destroyed
  result = false
  -- no need to check further
  break
end
return result
--


< Message edited by michaelm -- 6/11/2017 5:29:29 AM >


_____________________________

Michael

(in reply to s1nnfe1n)
Post #: 6
RE: Editor-LUA Help - 6/11/2017 5:20:59 AM   
s1nnfe1n

 

Posts: 6
Joined: 6/10/2017
Status: offline
Thank you very much mate, that was great help.

I will try it out.

(in reply to michaelm75au)
Post #: 7
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> Editor-LUA Help Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.219