home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / message_print.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  2.6 KB  |  105 lines

  1. //************************************************************************************
  2. //*** displays text in the center of the screen
  3. //*** mainly used for hint text (default), but can be for anything
  4. //*** syntax --------------------------------
  5. //*** message <string> [no hint text | non-NIL - will display, NIL - won't display] [time to leave message up, default 5 | 0 - means default]
  6. //************************************************************************************
  7. message local.string local.hint local.time:
  8.  
  9. //*** check to make sure a valid string was passed
  10. if (local.string == NIL)
  11. {
  12.     println "^~^~^ A non-valid string was passed for a hint-message!!"
  13.     goto message_false_end
  14. }
  15.  
  16. //*** check to see if they want default time
  17. if (local.time == 0 || local.time == NIL)
  18. {
  19.     local.time = 5
  20. }
  21.  
  22. //*** check to see if a message is already up, if so, wait till you get the goahead
  23. while (level.message_onscreen == 1)
  24. {
  25.     level.message_waiting = 1
  26.     wait .2
  27. }
  28.  
  29. //*** set the waiting variables for when another message is waiting
  30. level.message_onscreen = 1
  31. level.message_waiting = 0
  32.  
  33. //*** turn off the indexes incase theres a message up there
  34. huddraw_alpha 26 0
  35. huddraw_alpha 27 0
  36.  
  37. //*** assign huddraw elements
  38. huddraw_string 26 "HINT:"
  39. huddraw_align 26 center center
  40. huddraw_rect 26 -150 20 0 0
  41.  
  42. //*** format the string
  43. local.formatted_string = waitthread global/string_format.scr::str_format local.string 47
  44.  
  45. huddraw_string 27 local.formatted_string
  46. huddraw_align 27 center center
  47. huddraw_rect 27 -100 20 0 0
  48.  
  49. //*** check to see if they want HINT to appear
  50. //*** fade the text onto the screen
  51. if (local.hint != NIL)
  52. {
  53.     for (local.j = 0 ; local.j <= 1 ; local.j += .2)
  54.     {
  55.         huddraw_alpha 26 local.j
  56.         huddraw_alpha 27 local.j
  57.         waitframe
  58.     }
  59. }
  60. else
  61. {
  62.     for (local.k = 0 ; local.k <= 1 ; local.k += .2)
  63.     {
  64.         huddraw_alpha 26 0
  65.         huddraw_alpha 27 local.k
  66.         waitframe
  67.     }
  68. }
  69.  
  70. //*** wait cycle, takes into account if another message is put up, to reset the time
  71. for (local.i = 1 ; local.i <= local.time ; local.i ++)
  72. {
  73.     wait 1
  74.  
  75.     //*** check to see if another message is waiting to get on the screen
  76.     if (level.message_waiting == 1)
  77.     {
  78.         goto message_abort
  79.     }
  80. }
  81.  
  82. //*** fade the text off the screen
  83. if (local.hint != NIL)
  84. {
  85.     for (local.m = 1 ; local.m >= 0 ; local.m -= .2)
  86.     {
  87.         huddraw_alpha 26 local.m
  88.         huddraw_alpha 27 local.m
  89.         waitframe
  90.     }
  91. }
  92. else
  93. {
  94.     for (local.n = 1 ; local.n >= 0 ; local.n -= .2)
  95.     {
  96.         huddraw_alpha 26 0
  97.         huddraw_alpha 27 local.n
  98.         waitframe
  99.     }
  100. }
  101.  
  102. message_abort:
  103. level.message_onscreen = 0
  104.  
  105. end