Advertisement
imbuedl

reverse pf script safekeeping (simple, backwalk, spin)

Jan 12th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.90 KB | None | 0 0
  1. itools = dofile('lib_input_tools.lua')
  2. core = dofile('lib_core.lua')
  3.  
  4. function i_advance(amount)
  5.     for i = 1, amount, 1 do
  6.         itools.iframe_advance()
  7.     end
  8. end
  9.  
  10. function v_advance(amount)
  11.     for i = 1, amount, 1 do
  12.         itools.vframe_advance()
  13.     end
  14. end
  15.  
  16. function v_advance_hold_up_and_A(amount)
  17.     for i = 1, amount, 1 do
  18.         itools.vframe_advance({['A']=true,['X Axis']=0,['Y Axis']=127})
  19.     end
  20. end
  21.  
  22. function v_advance_hold_up(amount)
  23.     for i = 1, amount, 1 do
  24.         itools.vframe_advance({['X Axis']=0,['Y Axis']=127})
  25.     end
  26. end
  27.  
  28. function v_advance_press_A(amount)
  29.     for i = 1, amount, 1 do
  30.         itools.vframe_advance({['A']=true})
  31.     end
  32. end
  33.  
  34. function v_advance_press_Z(amount)
  35.     for i = 1, amount, 1 do
  36.         itools.vframe_advance({['Z']=true})
  37.     end
  38. end
  39.  
  40. function v_advance_press_C_Right(amount)
  41.     for i = 1, amount, 1 do
  42.         itools.vframe_advance({['C Right']=true})
  43.     end
  44. end
  45.  
  46. function v_advance_press_C_Right_and_hold_up(amount)
  47.     for i = 1, amount, 1 do
  48.         itools.vframe_advance({['C Right']=true,['X Axis']=0,['Y Axis']=127})
  49.     end
  50. end
  51.  
  52. function v_advance_press_R(amount)
  53.     for i = 1, amount, 1 do
  54.         itools.vframe_advance({['R']=true})
  55.     end
  56. end
  57.  
  58. function v_advance_hold_up(amount)
  59.     for i = 1, amount, 1 do
  60.         itools.vframe_advance({['X Axis']=0,['Y Axis']=127})
  61.     end
  62. end
  63.  
  64. function v_advance_hold_left(amount)
  65.     for i = 1, amount, 1 do
  66.         itools.vframe_advance({['X Axis']=-128,['Y Axis']=0})
  67.     end
  68. end
  69.  
  70. function v_advance_hold_left_and_target(amount)
  71.     for i = 1, amount, 1 do
  72.         itools.vframe_advance({['X Axis']=-128,['Y Axis']=0,['Z']=true})
  73.     end
  74. end
  75.  
  76. function v_advance_hold_up_and_target(amount)
  77.     for i = 1, amount, 1 do
  78.         itools.vframe_advance({['X Axis']=0,['Y Axis']=127,['Z']=true})
  79.     end
  80. end
  81.  
  82. function v_advance_hold_down(amount)
  83.     for i = 1, amount, 1 do
  84.         itools.vframe_advance({['X Axis']=0,['Y Axis']=-128})
  85.     end
  86. end
  87.  
  88. function v_advance_hold_down_and_target(amount)
  89.     for i = 1, amount, 1 do
  90.         itools.vframe_advance({['X Axis']=0,['Y Axis']=-128,['Z']=true})
  91.     end
  92. end
  93.  
  94. function v_advance_hold_right(amount)
  95.     for i = 1, amount, 1 do
  96.         itools.vframe_advance({['X Axis']=127,['Y Axis']=0})
  97.     end
  98. end
  99.  
  100. function v_advance_hold_right_and_target(amount)
  101.     for i = 1, amount, 1 do
  102.         itools.vframe_advance({['X Axis']=127,['Y Axis']=0,['Z']=true})
  103.     end
  104. end
  105.  
  106. function Turn_Right()
  107.    
  108.     -- Press Z to target for 1 visual frame, then do nothing for 5 visual frames, then hold Right for 1 visual frame
  109.     -- clear inputs at the start of each function for safety
  110.     -- advance visual frame at the start for safety
  111.    
  112.     itools.clear_inputs()
  113.    
  114.     itools.vframe_advance()
  115.    
  116.     itools.vframe_advance({['Z']=true})
  117.    
  118.     v_advance(5)
  119.    
  120.     itools.vframe_advance({['X Axis']=127,['Y Axis']=0})
  121.    
  122.     itools.clear_inputs()
  123.    
  124.     itools.vframe_advance()
  125.    
  126. end
  127.  
  128. function Turn_Left()
  129.    
  130.     itools.clear_inputs()
  131.    
  132.     itools.vframe_advance()
  133.    
  134.     itools.vframe_advance({['Z']=true})
  135.    
  136.     v_advance(5)
  137.    
  138.     itools.vframe_advance({['X Axis']=-128,['Y Axis']=0})
  139.    
  140.     itools.clear_inputs()
  141.    
  142.     itools.vframe_advance()
  143.    
  144. end
  145.  
  146. function Turn_Down()
  147.    
  148.     itools.clear_inputs()
  149.    
  150.     itools.vframe_advance()
  151.    
  152.     itools.vframe_advance({['Z']=true})
  153.    
  154.     v_advance(5)
  155.    
  156.     itools.vframe_advance({['X Axis']=0,['Y Axis']=-128})
  157.    
  158.     itools.clear_inputs()
  159.    
  160.     itools.vframe_advance()
  161.    
  162. end
  163.  
  164. function Turn_Up()
  165.    
  166.     itools.clear_inputs()
  167.    
  168.     itools.vframe_advance()
  169.    
  170.     itools.vframe_advance({['Z']=true})
  171.    
  172.     itools.clear_inputs()
  173.    
  174.     v_advance(5)
  175.    
  176.     itools.vframe_advance({['X Axis']=0,['Y Axis']=127})
  177.    
  178.     itools.clear_inputs()
  179.    
  180.     itools.vframe_advance()
  181.    
  182. end
  183.  
  184. ------------------------------------------------------------------------
  185. ------------------------------------------------------------------------
  186.  
  187. -- Assume the savestate is oriented for a backwalk, so you need to turn down before
  188. -- doing the spin. Assume initial position is in savestate (3). After drowning, save
  189. -- to savestate (4).
  190.  
  191. ------------------------------------------------------------------------
  192. ------------------------------------------------------------------------
  193.  
  194. Movement_Options = {'Backwalk', 'Spin'}
  195. Movement_Directions = {'Neutral', 'Up', 'Down', 'Left', 'Right', 'Neutral + Target', 'Up + Target', 'Down + Target', 'Left + Target', 'Right + Target'}
  196. Fly_Directions = {'Neutral', 'Up', 'Down', 'Left', 'Right'}
  197.  
  198. M = 20
  199.  
  200. file_write = io.open('reverse pf climb ladder mask and target same frame backwalk and spin.txt', 'w+')
  201.  
  202. Left_Clip_Exists = false
  203. Right_Clip_Exists = false
  204.  
  205. for i = 1, table.getn(Movement_Options), 1 do
  206.    
  207.     itools.clear_inputs()
  208.    
  209.     option = Movement_Options[i]
  210.    
  211.     if option == 'Backwalk' then
  212.        
  213.         itools.clear_inputs()
  214.        
  215.         -- load state (3)
  216.         itools.load_state(3)
  217.        
  218.         --- Determine when the fourth bounce is
  219.        
  220.         Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  221.         previous_y_position = false
  222.         bounce_count = 0
  223.         frame_count = 0
  224.        
  225.         while bounce_count < 4 do
  226.            
  227.             Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  228.            
  229.             v_advance_hold_down_and_target(1)
  230.             frame_count = frame_count + 1
  231.            
  232.             if Y_Position == -400 and previous_y_position == false then
  233.                 bounce_count = bounce_count + 1
  234.                 previous_y_position = true
  235.             elseif Y_Position ~= -400 then
  236.                 previous_y_position = false
  237.             end
  238.         end
  239.        
  240.         itools.clear_inputs()
  241.         -- load state (3)
  242.         itools.load_state(3)
  243.         v_advance_hold_down_and_target(frame_count - 3)
  244.         -- save state (4) to test every movement direction more efficiently
  245.         itools.save_state(4)
  246.        
  247.         for j = 1, table.getn(Movement_Directions), 1 do
  248.            
  249.             movement_direction = Movement_Directions[j]
  250.            
  251.             In_Updraft = false
  252.             Left_Clip_Down = false
  253.             Right_Clip_Down = false
  254.             Left_Clip_Up = false
  255.             Right_Clip_Up = false
  256.             Left_Clip_Left = false
  257.             Right_Clip_Left = false
  258.             Left_Clip_Right = false
  259.             Right_Clip_Right = false
  260.             Left_Clip_Neutral = false
  261.             Right_Clip_Neutral = false
  262.            
  263.             -- because this is redunant (just test individually or add elseif to test it once)
  264.             if movement_direction ~= 'Down + Target' then
  265.                
  266.                 for k = 0, M, 1 do
  267.                    
  268.                     print('i: ' .. i .. '  j: ' .. j .. '  k: ' .. k .. '    Left: ' .. tostring(Left_Clip_Exists) .. '    Right ' .. tostring(Right_Clip_Exists))
  269.                    
  270.                     itools.clear_inputs()
  271.                     itools.load_state(4)
  272.  
  273.                     v_advance_hold_down_and_target(k)
  274.                     itools.clear_inputs()
  275.                    
  276.                     if movement_direction == 'Up' then
  277.                         v_advance_hold_up(M - k + 12)
  278.                     elseif movement_direction == 'Down' then
  279.                         v_advance_hold_down(M - k + 12)
  280.                     elseif movement_direction == 'Right' then
  281.                         v_advance_hold_right(M - k + 12)
  282.                     elseif movement_direction == 'Left' then
  283.                         v_advance_hold_left(M - k + 12)
  284.                     elseif movement_direction == 'Neutral' then
  285.                         v_advance(M - k + 12)
  286.                     elseif movement_direction == 'Up + Target' then
  287.                         v_advance_hold_up_and_target(M - k + 12)
  288.                     elseif movement_direction == 'Down + Target' then
  289.                         v_advance_hold_down_and_target(M - k + 12)
  290.                     elseif movement_direction == 'Right + Target' then
  291.                         v_advance_hold_right_and_target(M - k + 12)
  292.                     elseif movement_direction == 'Left + Target' then
  293.                         v_advance_hold_left_and_target(M - k + 12)
  294.                     elseif movement_direction == 'Neutral + Target' then
  295.                         v_advance_press_Z(M - k + 12)
  296.                     end
  297.                    
  298.                    
  299.                     ---- Check if in updraft after waiting 12 frames
  300.                    
  301.                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  302.                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  303.                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  304.                    
  305.                     if Z_Position >= -218 and Z_Position <= -107 and X_Position <= 2446.1 and X_Position >= 2375 then
  306.                         In_Updraft = true
  307.                         itools.save_state(5)
  308.                     else
  309.                         In_Updraft = false
  310.                     end
  311.                    
  312.                     if In_Updraft == true then
  313.                        
  314.                         itools.load_state(5)
  315.                         itools.clear_inputs()
  316.                        
  317.                         for m = 1, table.getn(Fly_Directions), 1 do
  318.                            
  319.                             direction = Fly_Directions[m]
  320.                            
  321.                             itools.load_state(5)
  322.                             itools.clear_inputs()
  323.                            
  324.                             if direction == 'Up' then
  325.                                 --v_advance_hold_up(60)
  326.                                
  327.                                 t = 0
  328.                                 while t < 60 and Left_Clip_Up == false and Right_Clip_Up == false do
  329.                                    
  330.                                     v_advance_hold_up(1)
  331.                                    
  332.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  333.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  334.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  335.                                    
  336.                                     t = t + 1
  337.                                    
  338.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  339.                                         Left_Clip_Up = true
  340.                                         Left_Clip_Exists = true
  341.                                         print('Left Clip!!!!!!')
  342.                                     elseif Z_Position < -868 and Y_Position > -290 then
  343.                                         Right_Clip_Up = true
  344.                                         Right_Clip_Exists = true
  345.                                         print('Right Clip!!!!!!')
  346.                                     end
  347.                                    
  348.                                 end
  349.                                
  350.                             elseif direction == 'Down' then
  351.                                 --v_advance_hold_down(60)
  352.                                
  353.                                 t = 0
  354.                                 while t < 60 and Left_Clip_Down == false and Right_Clip_Down == false do
  355.                                    
  356.                                     v_advance_hold_down(1)
  357.                                    
  358.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  359.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  360.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  361.                                    
  362.                                     t = t + 1
  363.                                    
  364.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  365.                                         Left_Clip_Down = true
  366.                                         Left_Clip_Exists = true
  367.                                         print('Left Clip!!!!!!')
  368.                                     elseif Z_Position < -868 and Y_Position > -290 then
  369.                                         Right_Clip_Down = true
  370.                                         Right_Clip_Exists = true
  371.                                         print('Right Clip!!!!!!')
  372.                                     end
  373.                                    
  374.                                 end
  375.                             elseif direction == 'Left' then
  376.                                 --v_advance_hold_left(60)
  377.                                
  378.                                 t = 0
  379.                                 while t < 60 and Left_Clip_Left == false and Right_Clip_Left == false do
  380.                                    
  381.                                     v_advance_hold_left(1)
  382.                                    
  383.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  384.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  385.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  386.                                    
  387.                                     t = t + 1
  388.                                    
  389.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  390.                                         Left_Clip_Left = true
  391.                                         Left_Clip_Exists = true
  392.                                         print('Left Clip!!!!!!')
  393.                                     elseif Z_Position < -868 and Y_Position > -290 then
  394.                                         Right_Clip_Left = true
  395.                                         Right_Clip_Exists = true
  396.                                         print('Right Clip!!!!!!')
  397.                                     end
  398.                                    
  399.                                 end
  400.                             elseif direction == 'Right' then
  401.                                 --v_advance_hold_right(60)
  402.                                
  403.                                 t = 0
  404.                                 while t < 60 and Left_Clip_Right == false and Right_Clip_Right == false do
  405.                                    
  406.                                     v_advance_hold_right(1)
  407.                                    
  408.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  409.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  410.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  411.                                    
  412.                                     t = t + 1
  413.                                    
  414.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  415.                                         Left_Clip_Right = true
  416.                                         Left_Clip_Exists = true
  417.                                         print('Left Clip!!!!!!')
  418.                                     elseif Z_Position < -868 and Y_Position > -290 then
  419.                                         Right_Clip_Right = true
  420.                                         Right_Clip_Exists = true
  421.                                         print('Right Clip!!!!!!')
  422.                                     end
  423.                                    
  424.                                 end
  425.                             elseif direction == 'Neutral' then
  426.                                 --v_advance(60)
  427.                                
  428.                                 t = 0
  429.                                 while t < 60 and Left_Clip_Neutral == false and Right_Clip_Neutral == false do
  430.                                    
  431.                                     v_advance(1)
  432.                                    
  433.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  434.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  435.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  436.                                    
  437.                                     t = t + 1
  438.                                    
  439.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  440.                                         Left_Clip_Neutral = true
  441.                                         Left_Clip_Exists = true
  442.                                         print('Left Clip!!!!!!')
  443.                                     elseif Z_Position < -868 and Y_Position > -290 then
  444.                                         Right_Clip_Neutral = true
  445.                                         Right_Clip_Exists = true
  446.                                         print('Right Clip!!!!!!')
  447.                                     end
  448.                                    
  449.                                 end
  450.                             end
  451.                            
  452.                            
  453.                            
  454.                            
  455.                         end
  456.                        
  457.                        
  458.                        
  459.                        
  460.                        
  461.                        
  462.                     end
  463.                    
  464.                     ----- after testing all 5 fly directions...
  465.                        
  466.                     file_write:write(option .. '     ' .. movement_direction .. '     ' .. k .. '\n')
  467.                    
  468.                     if In_Updraft == true then
  469.                         file_write:write('In Updraft? Yes\n')
  470.                     elseif In_Updraft == false then
  471.                         file_write:write('In Updraft? No\n')
  472.                     end
  473.                    
  474.                     if Left_Clip_Up == true then
  475.                         file_write:write('Left Clip Up? Yes\n')
  476.                     elseif Left_Clip_Up == false then
  477.                         file_write:write('Left Clip Up? No\n')
  478.                     end
  479.                    
  480.                     if Right_Clip_Up == true then
  481.                         file_write:write('Right Clip Up? Yes\n')
  482.                     elseif Right_Clip_Up == false then
  483.                         file_write:write('Right Clip Up? No\n')
  484.                     end
  485.                    
  486.                     if Left_Clip_Down == true then
  487.                         file_write:write('Left Clip Down? Yes\n')
  488.                     elseif Left_Clip_Down == false then
  489.                         file_write:write('Left Clip Down? No\n')
  490.                     end
  491.                    
  492.                     if Right_Clip_Down == true then
  493.                         file_write:write('Right Clip Down? Yes\n')
  494.                     elseif Right_Clip_Down == false then
  495.                         file_write:write('Right Clip Down? No\n')
  496.                     end
  497.                    
  498.                     if Left_Clip_Right == true then
  499.                         file_write:write('Left Clip Right? Yes\n')
  500.                     elseif Left_Clip_Right == false then
  501.                         file_write:write('Left Clip Right? No\n')
  502.                     end
  503.                    
  504.                     if Right_Clip_Right == true then
  505.                         file_write:write('Right Clip Right? Yes\n')
  506.                     elseif Right_Clip_Right == false then
  507.                         file_write:write('Right Clip Right? No\n')
  508.                     end
  509.                    
  510.                     if Left_Clip_Left == true then
  511.                         file_write:write('Left Clip Left? Yes\n')
  512.                     elseif Left_Clip_Left == false then
  513.                         file_write:write('Left Clip Left? No\n')
  514.                     end
  515.                    
  516.                     if Right_Clip_Left == true then
  517.                         file_write:write('Right Clip Left? Yes\n')
  518.                     elseif Right_Clip_Left == false then
  519.                         file_write:write('Right Clip Left? No\n')
  520.                     end
  521.                    
  522.                     file_write:write('---\n')
  523.                    
  524.                 end
  525.             end
  526.            
  527.         end
  528.        
  529.     elseif option == 'Spin' then
  530.        
  531.         itools.clear_inputs()
  532.        
  533.         -- load state (3)
  534.         itools.load_state(3)
  535.        
  536.         Turn_Down()
  537.         v_advance_press_Z(6)
  538.        
  539.         --- Determine when the fourth bounce is
  540.        
  541.         Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  542.         previous_y_position = false
  543.         bounce_count = 0
  544.         frame_count = 0
  545.        
  546.         while bounce_count < 4 do
  547.            
  548.             Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  549.            
  550.             -- the first A press + Up starts the spin, the rest continue holding Up
  551.             v_advance_hold_up_and_A(1)
  552.             frame_count = frame_count + 1
  553.            
  554.             if Y_Position == -400 and previous_y_position == false then
  555.                 bounce_count = bounce_count + 1
  556.                 previous_y_position = true
  557.             elseif Y_Position ~= -400 then
  558.                 previous_y_position = false
  559.             end
  560.         end
  561.        
  562.         itools.clear_inputs()
  563.         -- load state (3)
  564.         itools.load_state(3)
  565.         v_advance_hold_up(frame_count - 3)
  566.         -- save state (4) to test every movement direction more efficiently
  567.         itools.save_state(4)
  568.        
  569.         for j = 1, table.getn(Movement_Directions), 1 do
  570.            
  571.             movement_direction = Movement_Directions[j]
  572.            
  573.             In_Updraft = false
  574.             Left_Clip_Down = false
  575.             Right_Clip_Down = false
  576.             Left_Clip_Up = false
  577.             Right_Clip_Up = false
  578.             Left_Clip_Left = false
  579.             Right_Clip_Left = false
  580.             Left_Clip_Right = false
  581.             Right_Clip_Right = false
  582.             Left_Clip_Neutral = false
  583.             Right_Clip_Neutral = false
  584.            
  585.             -- because this is redunant (just test individually or add elseif to test it once)
  586.             if movement_direction ~= 'Up' then
  587.                
  588.                 for k = 0, M, 1 do
  589.                    
  590.                     print('i: ' .. i .. '  j: ' .. j .. '  k: ' .. k .. '    Left: ' .. tostring(Left_Clip_Exists) .. '    Right ' .. tostring(Right_Clip_Exists))
  591.                    
  592.                     itools.clear_inputs()
  593.                     itools.load_state(4)
  594.  
  595.                     v_advance_hold_up(k)
  596.                     itools.clear_inputs()
  597.                    
  598.                     if movement_direction == 'Up' then
  599.                         v_advance_hold_up(M - k + 12)
  600.                     elseif movement_direction == 'Down' then
  601.                         v_advance_hold_down(M - k + 12)
  602.                     elseif movement_direction == 'Right' then
  603.                         v_advance_hold_right(M - k + 12)
  604.                     elseif movement_direction == 'Left' then
  605.                         v_advance_hold_left(M - k + 12)
  606.                     elseif movement_direction == 'Neutral' then
  607.                         v_advance(M - k + 12)
  608.                     elseif movement_direction == 'Up + Target' then
  609.                         v_advance_hold_up_and_target(M - k + 12)
  610.                     elseif movement_direction == 'Down + Target' then
  611.                         v_advance_hold_down_and_target(M - k + 12)
  612.                     elseif movement_direction == 'Right + Target' then
  613.                         v_advance_hold_right_and_target(M - k + 12)
  614.                     elseif movement_direction == 'Left + Target' then
  615.                         v_advance_hold_left_and_target(M - k + 12)
  616.                     elseif movement_direction == 'Neutral + Target' then
  617.                         v_advance_press_Z(M - k + 12)
  618.                     end
  619.                    
  620.                    
  621.                     ---- Check if in updraft after waiting 12 frames
  622.                    
  623.                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  624.                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  625.                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  626.                    
  627.                     if Z_Position >= -218 and Z_Position <= -107 and X_Position <= 2446.1 and X_Position >= 2375 then
  628.                         In_Updraft = true
  629.                         itools.save_state(5)
  630.                     else
  631.                         In_Updraft = false
  632.                     end
  633.                    
  634.                     if In_Updraft == true then
  635.                        
  636.                         itools.load_state(5)
  637.                         itools.clear_inputs()
  638.                        
  639.                         for m = 1, table.getn(Fly_Directions), 1 do
  640.                            
  641.                             direction = Fly_Directions[m]
  642.                            
  643.                             itools.load_state(5)
  644.                             itools.clear_inputs()
  645.                            
  646.                             if direction == 'Up' then
  647.                                 --v_advance_hold_up(60)
  648.                                
  649.                                 t = 0
  650.                                 while t < 60 and Left_Clip_Up == false and Right_Clip_Up == false do
  651.                                    
  652.                                     v_advance_hold_up(1)
  653.                                    
  654.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  655.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  656.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  657.                                    
  658.                                     t = t + 1
  659.                                    
  660.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  661.                                         Left_Clip_Up = true
  662.                                         Left_Clip_Exists = true
  663.                                         print('Left Clip!!!!!!')
  664.                                     elseif Z_Position < -868 and Y_Position > -290 then
  665.                                         Right_Clip_Up = true
  666.                                         Right_Clip_Exists = true
  667.                                         print('Right Clip!!!!!!')
  668.                                     end
  669.                                    
  670.                                 end
  671.                                
  672.                             elseif direction == 'Down' then
  673.                                 --v_advance_hold_down(60)
  674.                                
  675.                                 t = 0
  676.                                 while t < 60 and Left_Clip_Down == false and Right_Clip_Down == false do
  677.                                    
  678.                                     v_advance_hold_down(1)
  679.                                    
  680.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  681.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  682.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  683.                                    
  684.                                     t = t + 1
  685.                                    
  686.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  687.                                         Left_Clip_Down = true
  688.                                         Left_Clip_Exists = true
  689.                                         print('Left Clip!!!!!!')
  690.                                     elseif Z_Position < -868 and Y_Position > -290 then
  691.                                         Right_Clip_Down = true
  692.                                         Right_Clip_Exists = true
  693.                                         print('Right Clip!!!!!!')
  694.                                     end
  695.                                    
  696.                                 end
  697.                             elseif direction == 'Left' then
  698.                                 --v_advance_hold_left(60)
  699.                                
  700.                                 t = 0
  701.                                 while t < 60 and Left_Clip_Left == false and Right_Clip_Left == false do
  702.                                    
  703.                                     v_advance_hold_left(1)
  704.                                    
  705.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  706.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  707.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  708.                                    
  709.                                     t = t + 1
  710.                                    
  711.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  712.                                         Left_Clip_Left = true
  713.                                         Left_Clip_Exists = true
  714.                                         print('Left Clip!!!!!!')
  715.                                     elseif Z_Position < -868 and Y_Position > -290 then
  716.                                         Right_Clip_Left = true
  717.                                         Right_Clip_Exists = true
  718.                                         print('Right Clip!!!!!!')
  719.                                     end
  720.                                    
  721.                                 end
  722.                             elseif direction == 'Right' then
  723.                                 --v_advance_hold_right(60)
  724.                                
  725.                                 t = 0
  726.                                 while t < 60 and Left_Clip_Right == false and Right_Clip_Right == false do
  727.                                    
  728.                                     v_advance_hold_right(1)
  729.                                    
  730.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  731.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  732.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  733.                                    
  734.                                     t = t + 1
  735.                                    
  736.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  737.                                         Left_Clip_Right = true
  738.                                         Left_Clip_Exists = true
  739.                                         print('Left Clip!!!!!!')
  740.                                     elseif Z_Position < -868 and Y_Position > -290 then
  741.                                         Right_Clip_Right = true
  742.                                         Right_Clip_Exists = true
  743.                                         print('Right Clip!!!!!!')
  744.                                     end
  745.                                    
  746.                                 end
  747.                             elseif direction == 'Neutral' then
  748.                                 --v_advance(60)
  749.                                
  750.                                 t = 0
  751.                                 while t < 60 and Left_Clip_Neutral == false and Right_Clip_Neutral == false do
  752.                                    
  753.                                     v_advance(1)
  754.                                    
  755.                                     X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
  756.                                     Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
  757.                                     Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
  758.                                    
  759.                                     t = t + 1
  760.                                    
  761.                                     if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
  762.                                         Left_Clip_Neutral = true
  763.                                         Left_Clip_Exists = true
  764.                                         print('Left Clip!!!!!!')
  765.                                     elseif Z_Position < -868 and Y_Position > -290 then
  766.                                         Right_Clip_Neutral = true
  767.                                         Right_Clip_Exists = true
  768.                                         print('Right Clip!!!!!!')
  769.                                     end
  770.                                    
  771.                                 end
  772.                             end
  773.                            
  774.                         end
  775.                     end
  776.                    
  777.                     ----- after testing all 5 fly directions...
  778.                        
  779.                     file_write:write(option .. '     ' .. movement_direction .. '     ' .. k .. '\n')
  780.                    
  781.                     if In_Updraft == true then
  782.                         file_write:write('In Updraft? Yes\n')
  783.                     elseif In_Updraft == false then
  784.                         file_write:write('In Updraft? No\n')
  785.                     end
  786.                    
  787.                     if Left_Clip_Up == true then
  788.                         file_write:write('Left Clip Up? Yes\n')
  789.                     elseif Left_Clip_Up == false then
  790.                         file_write:write('Left Clip Up? No\n')
  791.                     end
  792.                    
  793.                     if Right_Clip_Up == true then
  794.                         file_write:write('Right Clip Up? Yes\n')
  795.                     elseif Right_Clip_Up == false then
  796.                         file_write:write('Right Clip Up? No\n')
  797.                     end
  798.                    
  799.                     if Left_Clip_Down == true then
  800.                         file_write:write('Left Clip Down? Yes\n')
  801.                     elseif Left_Clip_Down == false then
  802.                         file_write:write('Left Clip Down? No\n')
  803.                     end
  804.                    
  805.                     if Right_Clip_Down == true then
  806.                         file_write:write('Right Clip Down? Yes\n')
  807.                     elseif Right_Clip_Down == false then
  808.                         file_write:write('Right Clip Down? No\n')
  809.                     end
  810.                    
  811.                     if Left_Clip_Right == true then
  812.                         file_write:write('Left Clip Right? Yes\n')
  813.                     elseif Left_Clip_Right == false then
  814.                         file_write:write('Left Clip Right? No\n')
  815.                     end
  816.                    
  817.                     if Right_Clip_Right == true then
  818.                         file_write:write('Right Clip Right? Yes\n')
  819.                     elseif Right_Clip_Right == false then
  820.                         file_write:write('Right Clip Right? No\n')
  821.                     end
  822.                    
  823.                     if Left_Clip_Left == true then
  824.                         file_write:write('Left Clip Left? Yes\n')
  825.                     elseif Left_Clip_Left == false then
  826.                         file_write:write('Left Clip Left? No\n')
  827.                     end
  828.                    
  829.                     if Right_Clip_Left == true then
  830.                         file_write:write('Right Clip Left? Yes\n')
  831.                     elseif Right_Clip_Left == false then
  832.                         file_write:write('Right Clip Left? No\n')
  833.                     end
  834.                    
  835.                     file_write:write('---\n')
  836.                    
  837.                 end
  838.             end
  839.            
  840.         end
  841.        
  842.        
  843.     end
  844.    
  845.    
  846. end
  847.  
  848. file_write:close()
  849. print('done')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement