imbued

slow text frame counter (lua)

Dec 7th, 2021
1,027
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. itools = dofile('lib_input_tools.lua')
  2. core = dofile('lib_core.lua')
  3. mm = dofile('MM Functions.lua')
  4.  
  5. function v_advance(amount)
  6.     for i = 1, amount, 1 do
  7.         itools.vframe_advance()
  8.     end
  9. end
  10.  
  11. function v_advance_press_A(amount)
  12.     for i = 1, amount, 1 do
  13.         itools.vframe_advance({['A']=true})
  14.     end
  15. end
  16.  
  17. function v_advance_press_B(amount)
  18.     for i = 1, amount, 1 do
  19.         itools.vframe_advance({['B']=true})
  20.     end
  21. end
  22.  
  23. function v_advance_press_C_Up(amount)
  24.     for i = 1, amount, 1 do
  25.         itools.vframe_advance({['C Up']=true})
  26.     end
  27. end
  28.  
  29. mm_version = 'English'
  30.  
  31. if mm_version == 'English' then
  32.     text_active_address = 0x3FD338
  33.     ----text_active_address = 0x3FD33B
  34. elseif mm_version == 'JP 1.0' then
  35.     text_active_address = 0x3FD508
  36.     ----text_active_address = 0x3FD50B
  37. else
  38.     error("INPUT ERROR: invalid value mm_version")
  39. end
  40.  
  41. counter = 0
  42. print('MM Version is ' .. mm_version)
  43.  
  44. stored_a1 = mainmemory.readbyte(text_active_address)
  45. stored_a2 = mainmemory.readbyte(text_active_address + 1)
  46. stored_a3 = mainmemory.readbyte(text_active_address + 2)
  47. stored_a4 = mainmemory.readbyte(text_active_address + 3)
  48. text_type_changed = false
  49. while counter < 100 do
  50.  
  51.     text_open = false
  52.     frame_count = 0
  53.     text_triggered = false
  54.     done = false
  55.    
  56.     while done == false do
  57.  
  58.         a1 = mainmemory.readbyte(text_active_address)
  59.         a2 = mainmemory.readbyte(text_active_address + 1)
  60.         a3 = mainmemory.readbyte(text_active_address + 2)
  61.         a4 = mainmemory.readbyte(text_active_address + 3)
  62.        
  63.         if frame_count == 0 then
  64.             stored_a1 = a1
  65.             stored_a2 = a2
  66.             stored_a3 = a3
  67.             stored_a4 = a4
  68.         end
  69.        
  70.         --print('a1 is ' .. a1 .. 'in theory')
  71.        
  72.         if (a1 ~= 0 or a2 ~= 0 or a3 ~= 0 or a4 ~=0) and frame_count%2 == 0 then
  73.         ----if a1 ~= 0 and frame_count%2 == 0 then
  74.             text_open = true
  75.             text_triggered = true
  76.            
  77.             v_advance_press_A(1)
  78.             itools.clear_inputs()
  79.             frame_count = frame_count + 1
  80.            
  81.             --print('option 1 (if)')
  82.         ----elseif a1 ~= 0 and frame_count%2 == 1 then
  83.         elseif (a1 ~= 0 or a2 ~= 0 or a3 ~= 0 or a4 ~=0) and frame_count%2 == 1 then
  84.             text_open = true
  85.             text_triggered = true
  86.            
  87.             v_advance_press_C_Up(1)
  88.             itools.clear_inputs()
  89.             frame_count = frame_count + 1
  90.            
  91.             --print('option 2 (elseif)')
  92.         else
  93.             v_advance(1)
  94.             text_open = false
  95.             --print('option 3 (else)')
  96.         end
  97.        
  98.         --if text_open then
  99.         -- 
  100.         --  v_advance_press_A(1)
  101.         --  itools.clear_inputs()
  102.         --  frame_count = frame_count + 1
  103.     -- 
  104.     --  end
  105.    
  106.         if a1 ~= stored_a1 or a2 ~= stored_a2 or a3 ~= stored_a3 or a4 ~= stored_a4 then
  107.             text_open = false -- just to get it to trigger the next if statement when the text type changes values
  108.             text_type_changed = true
  109.             stored_text_type = " " .. bizstring.hex(stored_a1) .. bizstring.hex(stored_a2) .. bizstring.hex(stored_a3) .. bizstring.hex(stored_a4)
  110.         end
  111.        
  112.         if text_open == false and text_triggered == true then
  113.             print(frame_count)
  114.             text_triggered = false
  115.             done = true
  116.         end
  117.  
  118.     end
  119.  
  120. print('done, counter = '.. counter .. ' stored text type: ' .. stored_text_type)
  121. counter = counter + 1
  122. end
RAW Paste Data