Facocero Posted February 9, 2022 Posted February 9, 2022 Hi everyone. I would like to ask you experts: once I design a small mission, will ME generate a corresponding lua file somewhere? For example a simple mission as shown in the screen
cfrag Posted February 9, 2022 Posted February 9, 2022 Yes and no. Open the .miz with an archiving utility (it’s a zip file) and inside you’ll find a file called mission, which is basically a lua script. It won’t do much for you, because it ties deeply into the core binary, so you won’t learn a lot from studying the code except how to create units and define zones. So it rather depends on why you are looking for that mission file, and what you want to achieve or learn from it. in any event, it’s worth a look.
Facocero Posted February 10, 2022 Author Posted February 10, 2022 Thanks for the reply. Yes, I was already aware of the miz file, and I've also looked at the files inside it, but actually, it's not much help. I wanted to understand more about very simple things, and to be able to do something independently. The various scripts "" MIST - MOOSE - CTLD- and many others "" are too complex for me and are used to do many things that for now I do not need.
cfrag Posted February 10, 2022 Posted February 10, 2022 (edited) Indeed, that file isn't helpful. Perhaps another approach may be more helpful - outline a simple task that you want to achieve in Lua, and I'm sure that we can come up with some demo code for you to explore and expand upon. After all, that's what every Lua scripter has to go through eventually IMHO, a good starting point is creating a simple skeleton 'shell' of a mission Lua script that does two things: subscribe to the world event handler an update() method that calls itself every second or so to check various things that interest you Finally, you start that script by invoking update once, and you are good to go. Once that shell works, you can start intercepting the world events that interest you, or test if something specific happened in update(). Something like this: skel = {} function skel:onEvent(event) if event.id == 31 then -- landing_after_eject -- handle this event if you are interested in it end end function skel.update() -- schedule next update invocation timer.scheduleFunction(skel.update, {}, timer.getTime() + 1) -- check states and act accordingly -- do something cool end function skel.start() world.addEventHandler(skel) update() end -- let's go! skel.start() Paste above in a START trigger as DOSCRIPT, and that's all. (WARNING: typed freehand, may contain some errors). Edited February 10, 2022 by cfrag
Facocero Posted February 10, 2022 Author Posted February 10, 2022 Thank you for the tip!! I'll try to play around with this. Let's see what I can do. Thanks again
Recommended Posts