Advertisement
Guest User

Untitled

a guest
May 26th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. local M = {}
  2.  
  3. local function onInit()
  4. end
  5.  
  6. local function onStart()
  7. end
  8.  
  9. local function onEnd()
  10. end
  11.  
  12. local function onWaypoint() -- TODO args
  13. end
  14.  
  15. local function onTick( dt )
  16. end
  17.  
  18. local function onScenarioResult()
  19.     local endPoint = scenetree.findObject('training_acceleration_braking_wp2')
  20.     local vehicle = scenetree.findObject('scenario_player0')
  21.     if not endPoint or not vehicle then return true end
  22.    
  23.     local distance =  math.abs( ( endPoint:getPosition() - vehicle:getPosition() ):len() )
  24.     if distance > endPoint.scale.x then
  25.         guihooks.trigger('ScenarioFlashMessage', {{'You failed!', 2}, {'Not in end point', 2}})
  26.         return false
  27.     end
  28.  
  29.     return true
  30. end
  31.  
  32. M.onInit = onInit
  33. M.onStart = onStart
  34. M.onEnd = onEnd
  35. M.onWaypoint = onWaypoint
  36. M.onTick = onTick
  37. M.onScenarioResult = onScenarioResult
  38.  
  39. return M
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement