Advertisement
AFRLme

Absolute position of displayed text [VS] (works)

Dec 31st, 2012
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. --[[
  2. narrator text position script by Spacepaw
  3. modified by AFRLme
  4. -- * --
  5. script type: definition
  6. -- * --
  7. define absolute position of speaker text!
  8. -- * usuage * --
  9. in the editor set: game > speaker text alignment to "centered"!
  10. then to display text: select action part > misc > display text > add text to display!
  11. if you want to be able to walk about & do other things while narrator text is visible then ...
  12. check the "show as background text" box!
  13. only downfall to background text is you can't skip it!
  14. --]]
  15.  
  16. -- * this gets & declares the x, y position of the speaker text * --
  17. function OnStartText(text)
  18.  if text:getLink(VTextOwner):isEmpty() then
  19.   local finalPoint=game:getPoint(VGameScrollPosition)
  20.   finalPoint.x = finalPoint.x + game:getPoint(VGameWindowResolution).x / 2 -- declares game resolution x /shared by 2 to get center!
  21.   finalPoint.y = finalPoint.y + game:getPoint(VGameWindowResolution).y - 100 -- declares game resolution y (bottom) change - 100 offset to whatever you want!
  22.   text:setValue(VTextPosition, finalPoint)
  23.   isNarratorText=true
  24.   narratorText=text
  25.   print('xPos=' .. finalPoint.x .. ' yPos=' ..  finalPoint.y .. ' onStart!') -- prints the x,y position values to the log!
  26.  end
  27. end
  28.  
  29. -- * kills the loop when the text has finished displaying - I think? * --
  30. function OnStopText(text)
  31.  if text:getLink(VTextOwner):isEmpty() then
  32.   isNarratorText=false
  33.  end
  34. end
  35.  
  36. -- * loop to keep the displayed text in the same position on screen scroll * --
  37. function OnMainLoop()
  38.  if isNarratorText then
  39.   if not((game:getInt(VGameScrollDirectionHorizontal)==0) and (game:getInt(VGameScrollDirectionVertical))==0) then
  40.    local finalPoint=game:getPoint(VGameScrollPosition)
  41.    finalPoint.x = finalPoint.x + game:getPoint(VGameWindowResolution).x / 2
  42.    finalPoint.y = finalPoint.y + game:getPoint(VGameWindowResolution).y - 100
  43.    narratorText:setValue(VTextPosition, finalPoint)
  44.    print('xPos=' .. finalPoint.x .. ' yPos=' .. finalPoint.y .. ' onMain!') -- prints the x,y position values to the log!
  45.   end
  46.  end
  47. end
  48.  
  49. registerEventHandler("textStarted","OnStartText")
  50. registerEventHandler("textStopped","OnStopText")
  51. registerEventHandler("mainLoop", "OnMainLoop")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement