Jump to content

[Beginner] Problems to show present AoA


Flyingsix

Recommended Posts

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

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

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 by Flyingsix
Link to comment
Share on other sites

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

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 by Flyingsix
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...