test_2.lua 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. EntityContainer = {}
  2. EntityContainer[ "Player" ] = {
  3. on_start = function( self )
  4. local player = entity_manager:get_entity( "Player" )
  5. entity_manager:set_player_entity( "Player" )
  6. player:set_solid_radius( 0.3 )
  7. player:set_solid( true )
  8. while true do
  9. local triangle_id = player:get_move_triangle_id()
  10. if triangle_id == 0 then
  11. -- remove player control
  12. entity_manager:unset_player_entity()
  13. player:set_solid( false )
  14. -- move to ladder
  15. player:move_to_position( -1, 0 )
  16. player:move_sync()
  17. -- move to up platform 1
  18. player:set_rotation( 180 )
  19. player:linear_to_position( -2, 3.5, 3, Entity.DOWN_TO_UP, "Climb" )
  20. player:linear_sync()
  21. -- tell something
  22. -- message:show_text(1, "I runned away!", 100, 100, 130, 25);
  23. -- script:wait(2);
  24. -- message:hide(1);
  25. -- move to jump position
  26. player:move_to_position( -2, 6 )
  27. player:move_sync()
  28. -- jump to platform 2
  29. player:set_rotation( 90 )
  30. player:move_auto_animation( false )
  31. player:play_animation_stop( "Jump" )
  32. script:wait( 0.5 ) -- wait to start of jump in animation
  33. player:jump_to_position( 2, 6, 3, 0.567 ) -- triangle 24
  34. player:jump_sync()
  35. script:wait( 0.667 ) -- wait to end of animation
  36. player:move_auto_animation( true )
  37. -- move to ladder
  38. player:move_to_position( 2, 3.5 )
  39. player:move_sync()
  40. -- tell something
  41. -- message:show_text(1, "I returned!", 100, 100, 130, 25)
  42. -- script:wait(2)
  43. -- message:hide(1)
  44. -- ladder down
  45. player:set_rotation( 180 )
  46. player:linear_to_position( 1, 0, 0, Entity.DOWN_TO_UP, "Climb" )
  47. player:linear_sync()
  48. -- return player control
  49. player:set_solid( true )
  50. entity_manager:set_player_entity( "Player" )
  51. end
  52. script:wait( 0.5 )
  53. end
  54. return 0
  55. end,
  56. on_collide = function( self )
  57. return 0
  58. end,
  59. }
  60. EntityContainer[ "Chaser_Slow" ] = {
  61. on_start = function( self )
  62. local chaser_slow = entity_manager:get_entity( "Chaser_Slow" )
  63. local player = entity_manager:get_entity( "Player" )
  64. chaser_slow:set_move_auto_speed( 0.5 )
  65. chaser_slow:set_solid_radius( 0.35 )
  66. chaser_slow:move_auto_animation( false )
  67. script:wait( 1 )
  68. while true do
  69. chaser_slow:set_solid( true )
  70. chaser_slow:move_to_entity( player )
  71. chaser_slow:move_sync()
  72. chaser_slow:set_solid( false )
  73. script:wait( 5 )
  74. end
  75. return 0
  76. end,
  77. on_collide = function( self )
  78. return 0
  79. end,
  80. }
  81. EntityContainer[ "Chasers_Speed1" ] = {
  82. on_start = function( self )
  83. local chaser1 = entity_manager:get_entity( "Chasers_Speed1" )
  84. local player = entity_manager:get_entity( "Player" )
  85. chaser1:set_move_auto_speed( 3 )
  86. chaser1:set_solid_radius( 0.15 )
  87. chaser1:set_solid( true )
  88. chaser1:move_auto_animation( false )
  89. script:wait( 1 )
  90. while true do
  91. chaser1:set_position( 0, 0.5, 0 )
  92. chaser1:move_to_entity( player )
  93. chaser1:move_sync()
  94. end
  95. return 0
  96. end,
  97. on_collide = function( self )
  98. return 0
  99. end,
  100. }
  101. EntityContainer[ "Chasers_Speed2" ] = {
  102. on_start = function( self )
  103. local chaser2 = entity_manager:get_entity( "Chasers_Speed2" )
  104. local player = entity_manager:get_entity( "Player" )
  105. chaser2:set_move_auto_speed( 3 )
  106. chaser2:set_solid_radius( 0.15 )
  107. chaser2:set_solid( true )
  108. chaser2:move_auto_animation( false )
  109. script:wait( 1 )
  110. while true do
  111. chaser2:set_position( -1, 1, 0 )
  112. chaser2:move_to_entity( player )
  113. chaser2:move_sync()
  114. end
  115. return 0
  116. end,
  117. on_collide = function( self )
  118. return 0
  119. end,
  120. }
  121. EntityContainer[ "Chasers_Speed3" ] = {
  122. on_start = function( self )
  123. local chaser3 = entity_manager:get_entity( "Chasers_Speed3" )
  124. local player = entity_manager:get_entity( "Player" )
  125. chaser3:set_move_auto_speed( 3 )
  126. chaser3:set_solid_radius( 0.15 )
  127. chaser3:set_solid( true )
  128. chaser3:move_auto_animation( false )
  129. script:wait( 1 )
  130. while true do
  131. chaser3:set_position( 1, 1, 0 )
  132. chaser3:move_to_entity( player )
  133. chaser3:move_sync()
  134. end
  135. return 0
  136. end,
  137. on_collide = function( self )
  138. return 0
  139. end,
  140. }
  141. EntityContainer[ "Watcher1" ] = {
  142. on_start = function( self )
  143. local watcher1 = entity_manager:get_entity( "Watcher1" )
  144. local player = entity_manager:get_entity( "Player" )
  145. watcher1:set_move_auto_speed( 1.5 )
  146. watcher1:set_solid_radius( 0.3 )
  147. watcher1:set_solid( true )
  148. script:wait( 1 )
  149. while true do
  150. watcher1:turn_to_entity( player, Entity.CLOSEST, 2 )
  151. watcher1:turn_sync()
  152. script:wait( 0.5 )
  153. watcher1:turn_to_direction( 0, Entity.CLOSEST, Entity.SMOOTH, 2 )
  154. watcher1:turn_sync()
  155. script:wait( 1 )
  156. watcher1:move_to_position( 7.5, -6.5 )
  157. watcher1:move_sync()
  158. watcher1:turn_to_entity( player, Entity.CLOSEST, 2 )
  159. watcher1:turn_sync()
  160. script:wait( 0.5 )
  161. watcher1:turn_to_direction( 180, Entity.CLOSEST, Entity.SMOOTH, 2 )
  162. watcher1:turn_sync()
  163. script:wait( 1 )
  164. watcher1:move_to_position( 7.5, 1.5 )
  165. watcher1:move_sync()
  166. end
  167. return 0
  168. end,
  169. on_collide = function( self )
  170. return 0
  171. end,
  172. }
  173. EntityContainer[ "Lifter" ] = {
  174. on_start = function( self )
  175. local lifter = entity_manager:get_entity( "Lifter" )
  176. lifter:set_solid( false )
  177. lifter:offset_to_position( 0, 0, 3, Entity.NONE, 0 )
  178. while true do
  179. script:wait( 1 )
  180. lifter:offset_to_position( 0, 0, 0, Entity.SMOOTH, 5 )
  181. lifter:offset_sync()
  182. script:wait( 1 )
  183. lifter:offset_to_position( 0, 0, 3, Entity.SMOOTH, 5 )
  184. lifter:offset_sync()
  185. end
  186. return 0
  187. end,
  188. on_collide = function( self )
  189. return 0
  190. end,
  191. }