Advertisement
jayd00

example TIMERS 32@ 33@ instead of Wait

Oct 25th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.52 KB | None | 0 0
  1. /* example TIMERS 32@, 33@, instead of Wait
  2. by J16D
  3. */
  4. /*-------------------- EXAMPLE 1 ----------------------------*/
  5. const
  6. path_song1 = "cleo\mp3\MyMusic.MP3"
  7. end
  8.  
  9. {$CLEO}
  10. 0000:
  11. /// check if song exist, if not, end_this_thread
  12. if 8AAB: not file_exists path_song1
  13. then 0A93: end_custom_thread
  14. end
  15.  
  16. :start // main loop
  17. wait 0
  18. if and
  19. Player.Defined($PLAYER_CHAR)
  20. 0AB0: key_pressed 9 // tab
  21. jf @start
  22. ///goto @action // this "jump" isn't needed, the code anyway will continue with "action" label
  23.  
  24. :action
  25. 0AAC: 0@ = load_audiostream path_song1 // load audio
  26. 0AAD: set_mp3 0@ perform_action 1 // play audio
  27.  
  28. 32@ = 0 // Set the TIMER count in 0, automatically increase its value by 1 {in MilliSeconds}
  29. // TIMER starts at the same time you play the audio
  30. :loop
  31. wait 0
  32. // check if actor is defined, if not, it means is Dead or Wasted.
  33. if
  34. not Player.Defined($PLAYER_CHAR)
  35. jf @loop1
  36. 0AAD: set_mp3 0@ perform_action 0 // stop song
  37. 0AAE: release_mp3 0@ // release song
  38. goto @isWastedOrBusted
  39.  
  40. :loop1
  41. // this can be used instead of -wait 3000- which makes delay any action.
  42. if
  43. 32@ > 3000 // if has passed 3 seconds, then, continue, else go back to loop
  44. jf @loop
  45. // song has finished
  46. 0AAD: set_mp3 0@ perform_action 0 // stop song
  47. 0AAE: release_mp3 0@ // release song
  48. goto @start
  49.  
  50. :isWastedOrBusted
  51. wait 2500 // delay time, until actor is Not Dead, or Wasted
  52. goto @start
  53.  
  54.  
  55. /*-------------------- EXAMPLE 2 ----------------------------*/
  56. const
  57. path_song1 = "cleo\mp3\MyMusic.MP3"
  58. end
  59.  
  60. {$CLEO}
  61. 0000:
  62. /// check if song exist, if not, end_this_thread
  63. if 8AAB: not file_exists path_song1
  64. then 0A93: end_custom_thread
  65. end
  66.  
  67. :start // main loop
  68. wait 0
  69. if and
  70. Player.Defined($PLAYER_CHAR)
  71. 0AB0: key_pressed 9 // tab
  72. jf @start
  73. ///goto @action // this "jump" isn't needed, the code anyway will continue with "action" label
  74.  
  75. :action
  76. 0AAC: 0@ = load_audiostream path_song1 // load audio
  77. 0AAD: set_mp3 0@ perform_action 1 // play audio
  78.  
  79. 32@ = 0 // Set the TIMER count in 0, automatically increase its value by 1 {in MilliSeconds}
  80. // TIMER starts at the same time you play the audio
  81. :loop
  82. wait 0
  83. // check if actor is defined, if not, it means is Dead or Wasted.
  84. if
  85. not Player.Defined($PLAYER_CHAR)
  86. jf @loop1
  87. 0AAD: set_mp3 0@ perform_action 0 // stop song
  88. 0AAE: release_mp3 0@ // release song
  89. goto @isWastedOrBusted
  90.  
  91. :loop1
  92. if
  93. 32@ > 1000 // if has passed 1 second, do something; check key press, play second audio, do an animation, etc.
  94. jf @loop2
  95. // do something here
  96.  
  97. :loop2
  98. if
  99. 32@ > 2000 // if has passed 2 seconds, do something; check key press, play second audio, do an animation, etc.
  100. jf @loop3
  101. // do something here
  102.  
  103. :loop3
  104. if
  105. 32@ > 5000 // if has passed 5 seconds, do something; check key press, play second audio, do an animation, etc.
  106. jf @loop
  107. // song has finished
  108. 0AAD: set_mp3 0@ perform_action 0 // stop song
  109. 0AAE: release_mp3 0@ // release song
  110. goto @start
  111.  
  112. :isWastedOrBusted
  113. wait 2500
  114. goto @start
  115.  
  116. /*-------------------- EXAMPLE 3 ----------------------------*/
  117. const
  118. path_song1 = "cleo\mp3\MyMusic.MP3"
  119. end
  120.  
  121. {$CLEO}
  122. 0000:
  123. /// check if song exist, if not, end_this_thread
  124. if 8AAB: not file_exists path_song1
  125. then 0A93: end_custom_thread
  126. end
  127.  
  128. :start // main loop
  129. wait 0
  130. if and
  131. Player.Defined($PLAYER_CHAR)
  132. 0AB0: key_pressed 9 // tab
  133. jf @start
  134. ///goto @action // this "jump" isn't needed, the code anyway will continue with "action" label
  135.  
  136. :action
  137. 0AAC: 0@ = load_audiostream path_song1 // load audio
  138. 0AAF: 1@ = get_mp3_length 0@ // get length in Seconds
  139. 1@ *= 1001 // 1@-> in Seconds, there is need to convert the length in MilliSeconds (1@ * 1001)
  140. 0AAD: set_mp3 0@ perform_action 1 // play audio
  141.  
  142. 32@ = 0 // Set the TIMER count in 0, automatically increase its value by 1 {in MilliSeconds}
  143. // TIMER starts at the same time you play the audio
  144. :loop
  145. wait 0
  146. // check if actor is defined, if not, it means is Dead or Wasted.
  147. if
  148. not Player.Defined($PLAYER_CHAR)
  149. jf @loop1
  150. 0AAD: set_mp3 0@ perform_action 0 // stop song
  151. 0AAE: release_mp3 0@ // release song
  152. goto @isWastedOrBusted
  153.  
  154. :loop1
  155. // check if counter of Timer is bigger than Audio Duration,
  156. // if so, song has finished, No longer needed, release the song.
  157. if
  158. 001D: 32@ > 1@ // (int)
  159. jf @loop
  160. 0AAD: set_mp3 0@ perform_action 0
  161. 0AAE: release_mp3 0@
  162. goto @start
  163.  
  164. :isWastedOrBusted
  165. wait 2500
  166. goto @start
  167.  
  168. /*-------------------- EXAMPLE 4 (2 songs) ----------------------------*/
  169. const
  170. path_song1 = "cleo\mp3\MyMusic.MP3"
  171. path_song2 = "cleo\mp3\MyMusic2.MP3"
  172. end
  173.  
  174. {$CLEO}
  175. 0000:
  176. /// check if/or any song exist, if not, end_this_thread
  177. if or
  178. 8AAB: not file_exists path_song1
  179. 8AAB: not file_exists path_song2
  180. then 0A93: end_custom_thread
  181. end
  182.  
  183. :start // main loop
  184. wait 0
  185. if and
  186. Player.Defined($PLAYER_CHAR)
  187. 0AB0: key_pressed 9 // tab
  188. jf @start
  189. ///goto @action // this "jump" isn't needed, the code anyway will continue with "action" label
  190.  
  191. :action
  192. 0AAC: 0@ = load_audiostream path_song1 // load FIRST audio
  193. 0AAD: set_mp3 0@ perform_action 1 // play FIRST audio
  194.  
  195. 32@ = 0 // Set the TIMER count in 0, automatically increase its value by 1 {in MilliSeconds}
  196. // TIMER starts at the same time you play the audio
  197. :loop
  198. wait 0
  199. // check if actor is defined, if not, it means is Dead or Wasted.
  200. if
  201. not Player.Defined($PLAYER_CHAR)
  202. jf @loop1
  203. 0AAD: set_mp3 0@ perform_action 0 // stop song
  204. 0AAE: release_mp3 0@ // release song
  205. goto @isWastedOrBusted
  206.  
  207. :loop1
  208. // this makes the game waits 1 second to continue
  209. if
  210. 32@ > 1000 // if has passed 1 second;
  211. jf @loop
  212. // LOAD and play SECOND audio, simultaneously.
  213. 0AAC: 5@ = load_audiostream path_song2 // load SECOND audio
  214. 0AAD: set_mp3 5@ perform_action 1 // play SECOND audio
  215.  
  216. /// you can RESET the timer -here-, to start the counter Again.
  217. /// to play a THIRD song, and so on.
  218. /// Reset timer; 32@ = 0
  219.  
  220. /*
  221. MORE CODE
  222.  
  223. */
  224. // AUDIO is no longer needed.
  225. 0AAD: set_mp3 0@ perform_action 0 // stop song
  226. 0AAD: set_mp3 5@ perform_action 0 // stop song
  227. 0AAE: release_mp3 0@ // release song
  228. 0AAE: release_mp3 5@ // release song
  229. goto @start
  230.  
  231. :isWastedOrBusted
  232. wait 2500
  233. goto @start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement