Editor-LUA Help (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support



Message


s1nnfe1n -> Editor-LUA Help (6/10/2017 4:54:55 PM)

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.






michaelm75au -> RE: Editor-LUA Help (6/10/2017 5:32:07 PM)

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




s1nnfe1n -> RE: Editor-LUA Help (6/10/2017 6:22:23 PM)

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.





michaelm75au -> RE: Editor-LUA Help (6/10/2017 6:42:35 PM)

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




s1nnfe1n -> RE: Editor-LUA Help (6/10/2017 7:28:00 PM)

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.




michaelm75au -> RE: Editor-LUA Help (6/11/2017 3:34:44 AM)

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
--




s1nnfe1n -> RE: Editor-LUA Help (6/11/2017 5:20:59 AM)

Thank you very much mate, that was great help.

I will try it out.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
2.920898