Page 1 of 1

Looking for a good Lua example

Posted: Tue Oct 26, 2021 4:12 am
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

RE: Looking for a good Lua example

Posted: Tue Oct 26, 2021 8:38 am
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

RE: Looking for a good Lua example

Posted: Tue Oct 26, 2021 8:53 am
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

RE: Looking for a good Lua example

Posted: Sat Oct 30, 2021 11:44 am
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.

RE: Looking for a good Lua example

Posted: Sat Oct 30, 2021 12:18 pm
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

RE: Looking for a good Lua example

Posted: Sat Oct 30, 2021 12:45 pm
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

RE: Looking for a good Lua example

Posted: Sat Oct 30, 2021 1:31 pm
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 :-)

RE: Looking for a good Lua example

Posted: Sat Oct 30, 2021 1:46 pm
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.

RE: Looking for a good Lua example

Posted: Sat Oct 30, 2021 11:35 pm
by kevinkins
File sent just now via PM. Happy to discuss the contents.

RE: Looking for a good Lua example

Posted: Sun Oct 31, 2021 3:18 am
by nukkxx5058
ORIGINAL: kevinkins

File sent just now via PM. Happy to discuss the contents.
Well received, thank you !