Advertisement
Guest User

changecharapterfnf

a guest
May 9th, 2022
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 KB | None | 0 0
  1. local allowCountdown = false
  2. local inSelection = true
  3. local ofsx = -210
  4. local ofsy = 0
  5. local mult = 1.25
  6. characterNames = {'bf', 'sainic', 'toils', 'egg'} --character json name
  7. characterDisplays = {'Boyfriend', 'sainic', 'toils', 'egg'} --display name for text
  8. characterLimit = {3, 2, 1, 1} --how many variations does the character have
  9. maxpage = 4 --amount of characters u have
  10. variation = 1 -- 1 = original
  11. local page = 1
  12. local inSelection = true
  13. function onCreate()
  14. if allowCountdown == false then
  15. makeLuaSprite('fader', '', -200, -200)
  16. makeGraphic('fader', 1920, 1080, '000000')
  17. addLuaSprite('fader', true)
  18. setScrollFactor('fader', 0, 0)
  19. setProperty('fader.alpha', 0)
  20. setObjectCamera('fader', 'other')
  21.  
  22. makeLuaSprite('1', 'stageback', -600, -300);
  23. setScrollFactor('1', 0.9, 0.9);
  24.  
  25. makeLuaSprite('2', 'stagefront', -650, 600);
  26. setScrollFactor('2', 0.9, 0.9);
  27. scaleObject('2', 1.1, 1.1);
  28.  
  29. makeLuaSprite('3', 'stage_light', -125, -100);
  30. setScrollFactor('3', 0.9, 0.9);
  31. scaleObject('3', 1.1, 1.1);
  32.  
  33. makeLuaSprite('4', 'stage_light', 1225, -100);
  34. setScrollFactor('4', 0.9, 0.9);
  35. scaleObject('4', 1.1, 1.1);
  36. setProperty('4.flipX', true); --mirror sprite horizontally
  37.  
  38. makeLuaSprite('5', 'stagecurtains', -500, -300);
  39. setScrollFactor('5', 1.3, 1.3);
  40. scaleObject('5', 0.9, 0.9);
  41.  
  42. addLuaSprite('1', false);
  43. addLuaSprite('2', false);
  44. addLuaSprite('3', false);
  45. addLuaSprite('4', false);
  46. addLuaSprite('5', false);
  47. makeLuaText('text1', characterDisplays[page], 600, 15, 350)
  48. setTextSize('text1', 50);--Sets text size
  49. setTextWidth('text1', 600);--Sets text width
  50. addLuaText('text1')
  51. setProperty('gf.visible', false)
  52. setProperty('dad.visible', false)
  53. playMusic('offsetSong')
  54. end
  55. end
  56. function onStartCountdown()
  57. -- Block the first countdown and start a timer of 0.8 seconds to play the dialogue
  58. if not allowCountdown and not isStoryMode and not seenCutscene then
  59. setProperty('inCutscene', true);
  60. setProperty('gf.visible', false)
  61. setProperty('dad.visible', false)
  62. allowCountdown = true;
  63. return Function_Stop;
  64. end
  65. return Function_Continue;
  66. end
  67. function onUpdate()
  68. if getPropertyFromClass('flixel.FlxG', 'keys.justPressed.ENTER') then
  69. if inSelection == true and getProperty('inCutscene') == true then
  70. removeLuaText('text1', true)
  71. stopSound('offsetSong`')
  72. playMusic('gameOverEnd', 0.5)
  73. if page < 3 then
  74. objectPlayAnimation('boyfriend', 'hey', true)
  75. else
  76. objectPlayAnimation('boyfriend', 'singUP', true)
  77. end
  78. runTimer('startsong', 5)
  79. runTimer('fadein', 2.5)
  80. runTimer('fadedelay', 1.5)
  81. setProperty('seenCutscene', true)
  82. end
  83. end
  84. if getPropertyFromClass('flixel.FlxG', 'keys.justPressed.BACKSPACE') then
  85. endSong()
  86. end
  87. if getPropertyFromClass('flixel.FlxG', 'keys.justPressed.RIGHT') then
  88. if page < maxpage and inSelection == true then
  89. variation = 1
  90. page = page+1
  91. --debugPrint(page, characterNames[page], characterDisplays[page], variation)
  92. setCharacter()
  93. end
  94. elseif getPropertyFromClass('flixel.FlxG', 'keys.justPressed.LEFT') then
  95. if page > 0 and inSelection == true then
  96. variation = 1
  97. page = page-1
  98. --debugPrint(page, characterNames[page], characterDisplays[page], variation)
  99. setCharacter()
  100. end
  101. end
  102.  
  103.  
  104. if getPropertyFromClass('flixel.FlxG', 'keys.justPressed.UP') then
  105. if variation < characterLimit[page] and inSelection == true then
  106. variation = variation+1
  107. --debugPrint(page, characterNames[page], characterDisplays[page], variation)
  108. setCharacter()
  109. end
  110. elseif getPropertyFromClass('flixel.FlxG', 'keys.justPressed.DOWN') then
  111. if variation > -1 and inSelection == true then
  112. variation = variation-1
  113. --debugPrint(page, characterNames[page], characterDisplays[page], variation)
  114. setCharacter()
  115. end
  116. end
  117. --animation player
  118. if inSelection == true then
  119. if getPropertyFromClass('flixel.FlxG', 'keys.justPressed.D') then
  120. objectPlayAnimation('boyfriend', 'singLEFT', true)
  121. elseif getPropertyFromClass('flixel.FlxG', 'keys.justPressed.J') then
  122. objectPlayAnimation('boyfriend', 'singUP', true)
  123. elseif getPropertyFromClass('flixel.FlxG', 'keys.justPressed.F') then
  124. objectPlayAnimation('boyfriend', 'singDOWN', true)
  125. elseif getPropertyFromClass('flixel.FlxG', 'keys.justPressed.K') then
  126. objectPlayAnimation('boyfriend', 'singRIGHT', true)
  127. elseif getPropertyFromClass('flixel.FlxG', 'keys.justPressed.G') then
  128. objectPlayAnimation('boyfriend', 'hey', true)
  129. elseif getPropertyFromClass('flixel.FlxG', 'keys.justPressed.H') then
  130. objectPlayAnimation('boyfriend', 'idle', true)
  131. end
  132. end
  133. end
  134. function onTimerCompleted(tag)
  135. if tag == 'startsong' then
  136. startCountdown()
  137. end
  138. if tag == 'fadein' then
  139. inSelection = false
  140. setProperty('dad.visible', true)
  141. if page == 1 then
  142. setProperty('gf.visible', true)
  143. end
  144. removeLuaSprite('1', true)
  145. removeLuaSprite('2', true)
  146. removeLuaSprite('3', true)
  147. removeLuaSprite('4', true)
  148. removeLuaSprite('5', true)
  149. runTimer('fadeout', 2.5)
  150. end
  151. if tag == 'fadedelay' then
  152. doTweenAlpha('faderfader', 'fader', 1, 0.9, 'linear')
  153. end
  154. end
  155. function setCharacter()
  156. if page > 0 and page < maxpage+1 and inSelection == true then
  157. setVariation()
  158. setTextString('text1', characterDisplays[page]);
  159. --setProperty('boyfriend', 'x', defaultBoyfriendX+characterOfsX[page])
  160. --setProperty('boyfriend', 'y', defaultBoyfriendY+characterOfsY[page])
  161. triggerEvent('Change Character', 0, characterNames[page]);
  162. objectPlayAnimation('boyfriend', 'idle', true)
  163. end
  164. end
  165. function setVariation()
  166. if variation == 1 then
  167. characterNames = {'bf', 'sainic', 'toils', 'egg'} --character json name
  168. characterDisplays = {'Boyfriend', 'sainic', 'toils', 'egg'} --display name for text
  169. elseif variation == 2 then
  170. characterNames = {'bf-christmas', 'sink', 'testtoils', 'oldegg'} --character json name
  171. characterDisplays = {'Boyfriend (Christmas)', 'sink', 'testtoils', 'oldegg'} --display name for text
  172. elseif variation == 3 then
  173. characterNames = {'3d-bf', 'sink', 'dave-3d', 'tristan'} --character json name
  174. characterDisplays = {'Boyfriend (3D)', 'sink', '3D Dave', 'Tristan'} --display name for text
  175. end
  176. end
  177. function onTweenCompleted(tag)
  178. if tag == 'faderfader' then
  179. doTweenAlpha('faderfaderBYE', 'fader', 0, 1.4, 'linear')
  180. end
  181. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement