Flyingsix Posted January 20, 2018 Share Posted January 20, 2018 Hey Folks, I read a lot about scripting and the possibilities. Presently I want to use MIST for a simple task --> showing the actual AoA in a message. The data has to refresh itself instantly, if it changes. Later on I want to exploit other flight data as well like speed, height (AGL), power-setting. Reason behind is to configure a basic flight training mission for each of my module. I want to fly analogical to the manual and get a information on screen for reference data vs. present data. I found the mist.demos.printFlightData () part in the mist.lua but I have problems to adapt it to my mission. At Mission Start Master Mist.lue file is loaded after 1 second. Here is my script which I open via DO SCRIPT FILE: do local AoA = mist.getAoA (player1) trigger.action.outText (string.format('%-25s', 'AoA: ') .. AoA .. ' degrees\n') end I'm not very experienced with lua-scripting, but eager to learn it. :pilotfly: Cheers Link to comment Share on other sites More sharing options...
Grimes Posted January 20, 2018 Share Posted January 20, 2018 You have to get the "object" that belongs to the player aircraft. For example if the unit is named "player1" do local AoA = mist.getAoA (Unit.getByName('player1')) trigger.action.outText (string.format('%-25s', 'AoA: ') .. AoA .. ' degrees\n') end The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
Flyingsix Posted January 20, 2018 Author Share Posted January 20, 2018 (edited) Oh yes, I see! Due to the object "unit" which contains in the mist.getAoA(UNIT) prompt I have to connect the string player1 to unit. Thank you. Nevertheless the script doesn't work correctly. It seems the MIST.lua file doesn't initialize in the right manner. With init-trigger order: MISSION START > TIME MORE (2) > DO SCRIPT FILE (mist_4_3_74.lua) I got the error: "...attempt to index global mist (a nil file) .." Next step. As stated in another thread I used this init-order: MISSION START > TIME LESS (2) > DO SCRIPT FILE (mist_4_3_74.lua) I got the error: " ... attempt to index local 'unit' (a nil file) ... 1: in function 'getAoA ... " Is this a script-error or a init-error with the master MIST.lua file? Edited January 20, 2018 by Flyingsix Link to comment Share on other sites More sharing options...
Grimes Posted January 20, 2018 Share Posted January 20, 2018 The mission start only occurs directly at mission start when the time is basically 0. So the time more condition doesn't work with it. So you want to have a completely unmodified version of mist loaded. You can change the trigger to Once > Time More (2)> Do Script File(mist) So that loads mist, now you need to have a trigger for your own code. Once>Time more (3) > Do Script (yourCode) Note that it is setup to load AFTER mist loads. If you did it before then the mist code simply doesn't exist yet and you would get an error when you call mist.getAoA() The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
Flyingsix Posted January 25, 2018 Author Share Posted January 25, 2018 (edited) Ok, guys. First I tried it like Grimes described it. Then in different other ways.... Increased the time for mist.lua file, local or global variables, etc., etc., but no way. Always the same error (refer to #3). In last instance I extracted the local variable unit via: do [u]local myUnit = Unit.getByName('player1')[/u] local AoA = mist.getAoA (myUnit) trigger.action.outText (string.format('%-25s', 'AoA: ') .. AoA .. ' degrees\n') end Step by step I commented out every line and always the script stuck at the 3rd line: local AoA = mist.getAoA (myUnit) Edited January 25, 2018 by Flyingsix Link to comment Share on other sites More sharing options...
Grimes Posted January 25, 2018 Share Posted January 25, 2018 Compare what you are doing to this file and see what is different. Heh, I did realize a slight stupid mistake on my part though. The outtext needs to have another variable.. do local myUnit = Unit.getByName('player1') local AoA = mist.getAoA (myUnit) trigger.action.outText (string.format('%-25s', 'AoA: ') .. AoA .. ' degrees', 5, true) end getAoA.miz The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
Flyingsix Posted January 25, 2018 Author Share Posted January 25, 2018 Hey Grimes, thank you for the .miz file. That helped a lot. I did a VERY stupid mistake by using the unitname player1 as groupname... :doh: Oh my godness... Thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts