Looking for a good Lua example

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
User avatar
nukkxx5058
Posts: 3141
Joined: Thu Feb 03, 2005 2:57 pm
Location: France

Looking for a good Lua example

Post by nukkxx5058 »

Hi, which scenario do you recommend me to open with scenEdit in order to get a good example on how to use Lua ?
Thx
Winner of the first edition of the Command: Modern Operations COMPLEX PBEM Tournament (IKE) (April 2022) :-)
User avatar
kevinkins
Posts: 2465
Joined: Wed Mar 08, 2006 11:54 am

RE: Looking for a good Lua example

Post by kevinkins »

I would take a look at the commercial scenarios first. I think the older scenarios in the community pack tend to use less lua. Over the years I copied code fragments into a text file. I will send it to you if you want.

Kevin
“The study of history lies at the foundation of all sound military conclusions and practice.”
Alfred Thayer Mahan
thewood1
Posts: 10295
Joined: Sun Nov 27, 2005 6:24 pm
Location: Boston

RE: Looking for a good Lua example

Post by thewood1 »

Just making sure you see this. Lot of questions get answered and their are resources available.

https://www.matrixgames.com/forums/tt.asp?forumid=1681
User avatar
nukkxx5058
Posts: 3141
Joined: Thu Feb 03, 2005 2:57 pm
Location: France

RE: Looking for a good Lua example

Post by nukkxx5058 »

ORIGINAL: kevinkins

I would take a look at the commercial scenarios first. I think the older scenarios in the community pack tend to use less lua. Over the years I copied code fragments into a text file. I will send it to you if you want.

Kevin

Yes sure. I'd like to have a look.

What I don't get is where Lua scripts are stored. I see the "scenario attachments" in the editor menu but each time I look for possible Lua script, it's empty.
Can't find any existing Lua script so maybe I'm not searching at the right place ? Or does it mean that all the scenarios I opened are without Lua scripting ?

Hence my initial question.
Winner of the first edition of the Command: Modern Operations COMPLEX PBEM Tournament (IKE) (April 2022) :-)
User avatar
kevinkins
Posts: 2465
Joined: Wed Mar 08, 2006 11:54 am

RE: Looking for a good Lua example

Post by kevinkins »

You will have to have the scenario open in editor mode and then look into the actions related to an event. Lua is executed based on events and triggers. The code resides in the "action". If others can assist, it would be great. I am not a real expert but wanted to get back to you. Will send my text file tonight via PM.

Kevin
“The study of history lies at the foundation of all sound military conclusions and practice.”
Alfred Thayer Mahan
thewood1
Posts: 10295
Joined: Sun Nov 27, 2005 6:24 pm
Location: Boston

RE: Looking for a good Lua example

Post by thewood1 »

This scenario was built as an example of how lua functions work. I would also suggest going through some of the videos on using lua that are floating around. If you can't find them, ask in the lua section posted above.

https://www.matrixgames.com/forums/tm.asp?m=4442259
User avatar
nukkxx5058
Posts: 3141
Joined: Thu Feb 03, 2005 2:57 pm
Location: France

RE: Looking for a good Lua example

Post by nukkxx5058 »

Thanks. I had a look at the scen example in the link. And yes, could find some piece of code in "special actions" (thanks kevinkins). But this raises even more questions :-)) Will ask in the Lua section, as suggested.

Re tutorials: the tutorials I started to watch were not very informative for me as they were teaching basics of coding and not architecture of programs (ie how Lua is incorporated into CMO). Kevinkins hint that code is attached to actions was quite helpful, as a starting point.

And thanks in advance for the file :-)
Winner of the first edition of the Command: Modern Operations COMPLEX PBEM Tournament (IKE) (April 2022) :-)
User avatar
BeirutDude
Posts: 2811
Joined: Sat Apr 27, 2013 9:44 am
Location: Jacksonville, FL, USA

RE: Looking for a good Lua example

Post by BeirutDude »

Lua is very useful to set "Conditions" to determine if an event happens. Folks don't use the conditions section in the events a lot but it has a LOT of power.
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
PRESIDENT RONALD REAGAN, 1985

I was Navy, but Assigned TAD to the 24th MAU Hq in Beirut. By far the finest period of my service!
User avatar
kevinkins
Posts: 2465
Joined: Wed Mar 08, 2006 11:54 am

RE: Looking for a good Lua example

Post by kevinkins »

File sent just now via PM. Happy to discuss the contents.
“The study of history lies at the foundation of all sound military conclusions and practice.”
Alfred Thayer Mahan
User avatar
nukkxx5058
Posts: 3141
Joined: Thu Feb 03, 2005 2:57 pm
Location: France

RE: Looking for a good Lua example

Post by nukkxx5058 »

ORIGINAL: kevinkins

File sent just now via PM. Happy to discuss the contents.
Well received, thank you !
Winner of the first edition of the Command: Modern Operations COMPLEX PBEM Tournament (IKE) (April 2022) :-)
Post Reply

Return to “Command: Modern Operations series”