Game Maker RPG Text Box Scripts


SUBMITTED BY: Guest

DATE: Nov. 15, 2013, 9:42 p.m.

FORMAT: Text only

SIZE: 7.0 kB

HITS: 1113

  1. scr_dialogbox
  2. //made by Miles Lombardi
  3. //argument0 = the text
  4. //argument1 = whether or not to draw the box at the end
  5. //argument2 = whether or not to initiate the text
  6. //argument3 = whether or not to draw the text box
  7. //argument4 = the font to use
  8. //` = white text
  9. //^ = red text
  10. //{ = blue text
  11. //} = green text
  12. global.drawingtext = true //the game is drawing text
  13. if argument2 = true //if it is the first time through
  14. {
  15. self.position = 1//set the position as 1
  16. self.done = false //the text isn't done
  17. }
  18. global.text = argument0
  19. global.more = argument1
  20. global.font = spr_letters //set the font at the beggining of the script
  21. //sets the postion of the pointer, so it knows how much text should be drawn
  22. if keyboard_check(vk_enter) = true //if enter is pushed
  23. {
  24. self.done = true //you are done
  25. self.position = string_length(global.text) //end the text
  26. self.curstring = global.text //set the string to the text
  27. keyboard_clear(vk_enter) //stop generating events
  28. }
  29. if self.done = false //if the text line isn't done
  30. {
  31. self.curstring = string_copy(global.text, 1, self.position) //the first line is a part of the actual first line
  32. if string_length(self.curstring) = string_length(global.text) //if the text is done
  33. {
  34. self.done = true //this line is done
  35. self.position = 1 //reset the start point
  36. }
  37. }
  38. if self.done = false //if not all text is done
  39. {
  40. self.position += 1 //add one to the position
  41. }
  42. //draws the important stuff
  43. if argument3 = true //if you should draw the text box
  44. {
  45. draw_sprite(spr_textbox, 0, view_xview[1] + 16, view_yview[1] + 160) //draw the text box
  46. }
  47. self.pointx = 22 //a little to the right...
  48. self.pointy = 166 //a little down...
  49. for(i = 1; i < string_length(self.curstring) + 1; i += 1) //once for every character
  50. {
  51. self.lettertemp = string_copy(self.curstring, i, 1) //get the letter
  52. if self.pointx >= 290 //if it is too far over
  53. {
  54. self.pointx = 22 //go back a bit
  55. self.pointy += 16 //go down a line
  56. }
  57. if self.lettertemp <> " " and self.lettertemp <> "~" //if it isn't a space or a tilde
  58. {
  59. if self.lettertemp <> "`" and self.lettertemp <> "^" and self.lettertemp <> "{" and self.lettertemp <> "}" //if it's not changing the font
  60. {
  61. self.todraw = scr_getletter(self.lettertemp) //get the imagesingle of the value
  62. draw_sprite(global.font, self.todraw, view_xview[1] + self.pointx, view_yview[1] + self.pointy)
  63. self.pointx += 8//move over for the next letter
  64. }
  65. else //if it is changing the font
  66. {
  67. if self.lettertemp = "`" //set it white
  68. {
  69. global.font = spr_letters //sets it
  70. }
  71. if self.lettertemp = "^" //the caret
  72. {
  73. global.font = spr_letters//sets it
  74. }
  75. if self.lettertemp = "{" //blue
  76. {
  77. global.font = spr_letters //sets it
  78. }
  79. if self.lettertemp = "}" //green
  80. {
  81. global.font = spr_letters//sets it
  82. }
  83. }
  84. }
  85. if self.lettertemp = " " //if it is a space
  86. {
  87. self.pointx += 8 //move over for the next letter
  88. }
  89. if self.lettertemp = "~" //if it is a tilde
  90. {
  91. self.pointy += 16 //move down for the next letter
  92. self.pointx = 22 //reset to the start of the line
  93. }
  94. }
  95. screen_refresh() //refreshes the screen so you can actually see it
  96. if self.done = true and global.more = true //if we need to draw an arrow
  97. {
  98. draw_sprite(spr_textmore, 0, view_xview[1] + 155, view_yview[1] + 216) //draw the arrow
  99. }
  100. if self.done = false //if the text isn't done
  101. {
  102. sound_play(snd_letter)
  103. sleep(30)
  104. scr_dialogbox(argument0, argument1, false, argument3) //do it all again
  105. }
  106. else //yer done!
  107. {
  108. screen_refresh() //refresh the screen
  109. keyboard_wait() //wait for the keyboard
  110. sleep(30)
  111. keyboard_clear(vk_space)
  112. keyboard_clear(vk_shift)
  113. sound_stop(snd_letter)
  114. global.drawingtext = false //get on with your regular life
  115. }
  116. ___________________________________________________________________________________________________________________
  117. scr_getletter:
  118. //made by Miles Lombardi
  119. letter = argument0
  120. if ord(letter) >= ord("A") and ord(letter) <= ord("Z") //if it is an uppercase letter
  121. {
  122. return (32 + (ord(letter) - ord("A"))) //return a value for the letter
  123. }
  124. if ord(letter) >= ord("a") and ord(letter) <= ord("z") //if it is a lowercase letter
  125. {
  126. return (64 + (ord(letter) - ord("a"))) //return a value for the letter
  127. }
  128. if letter = "!" //exclamation mark
  129. {
  130. return 0
  131. }
  132. if letter = '"' //quotations
  133. {
  134. return 1
  135. }
  136. if letter = "#" //number sign
  137. {
  138. return 2
  139. }
  140. if letter = "$" //dollar sign
  141. {
  142. return 3
  143. }
  144. if letter = "%" //percent sign
  145. {
  146. return 4
  147. }
  148. if letter = "&" //ampersand
  149. {
  150. return 5
  151. }
  152. if letter = "'" //semi-qute
  153. {
  154. return 6
  155. }
  156. if letter = "(" //parentheses
  157. {
  158. return 7
  159. }
  160. if letter = ")" //parentheses
  161. {
  162. return 8
  163. }
  164. if letter = "*" //asterisk
  165. {
  166. return 9
  167. }
  168. if letter = "+" //plus sign
  169. {
  170. return 10
  171. }
  172. if letter = "," //comma
  173. {
  174. return 11
  175. }
  176. if letter = "-" //dash
  177. {
  178. return 12
  179. }
  180. if letter = "." //period
  181. {
  182. return 13
  183. }
  184. if letter = "/" //slash
  185. {
  186. return 14
  187. }
  188. if letter = "0" //0
  189. {
  190. return 15
  191. }
  192. if letter = "1" //1
  193. {
  194. return 16
  195. }
  196. if letter = "2" //2
  197. {
  198. return 17
  199. }
  200. if letter = "3" //3
  201. {
  202. return 18
  203. }
  204. if letter = "4" //4
  205. {
  206. return 19
  207. }
  208. if letter = "5" //5
  209. {
  210. return 20
  211. }
  212. if letter = "6" //6
  213. {
  214. return 21
  215. }
  216. if letter = "7" //7
  217. {
  218. return 22
  219. }
  220. if letter = "8" //8
  221. {
  222. return 23
  223. }
  224. if letter = "9" //9
  225. {
  226. return 24
  227. }
  228. if letter = ":" //colon
  229. {
  230. return 25
  231. }
  232. if letter = ";" //semi colon
  233. {
  234. return 26
  235. }
  236. if letter = "<" //less than
  237. {
  238. return 27
  239. }
  240. if letter = "=" //equal to
  241. {
  242. return 28
  243. }
  244. if letter = ">" //greater than
  245. {
  246. return 29
  247. }
  248. if letter = "?" //question mark
  249. {
  250. return 30
  251. }
  252. if letter = "@" //at sign
  253. {
  254. return 31
  255. }
  256. if letter = "[" //bracket
  257. {
  258. return 58
  259. }
  260. if letter = "\" //slash
  261. {
  262. return 59
  263. }
  264. if letter = "]" //bracket
  265. {
  266. return 60
  267. }
  268. if letter = "^" //carot
  269. {
  270. return 61
  271. }
  272. if letter = "_" //underscore
  273. {
  274. return 62
  275. }
  276. if letter = "'" //quotation mark
  277. {
  278. return 63
  279. }

comments powered by Disqus