Jump to content

Continously read and show some flight data


Mercury_1965

Recommended Posts

I wont script a training mission and I need continously read and show some flight data.

Trying with altitude ...not work

start_mes = "START MISSIOIN"
trigger.action.outText(start_mes, 10)

repeat
   local aboveSeaLevel = math.floor(Unit.getByName('gmv-1'):getPosition().p.y * 3.28084 , 0)
   trigger.action.outText(aboveSeaLevel, 3)
until( aboveSeaLevel < 7700 )
trigger.action.outText("Passed 7700" , 3)

 

 

Any suggestion ?

Link to comment
Share on other sites

It is stuck in the loop. You need to recheck the altitude at a set time interval. Anything done with while, repeat, etc loops will just keep going until they stop and iterating takes nanoseconds per check.

 

 

You can either put it in a function that gets scheduled or remove the loop and call the script via triggers.

 

local function altCheck()
  local aboveSeaLevel = math.floor(Unit.getByName('gmv-1'):getPosition().p.y * 3.28084 , 0)
  trigger.action.outText(aboveSeaLevel, 3)   
  if aboveSeaLevel > 7700 then
     timer.scheduleFunction(altCheck, {}, timer.getTime() + 1)
  end 

end
altCheck()

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