Advertisement
Blazephlozard

It's Mr. Pants Lua

Mar 23rd, 2020
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.51 KB | None | 0 0
  1. function checkDirections(thePad)
  2.     if (thePad["Up"] or thePad["Right"] or thePad["Down"] or thePad["Left"]) then return true
  3.     else return false end
  4. end
  5.  
  6. function checkRotations(thePad)
  7.     if (thePad["L"] or thePad["R"] or thePad["B"]) then return true
  8.     else return false end
  9. end
  10.  
  11. function checkPlacement(thePad)
  12.     if (thePad["A"]) then return true
  13.     else return false end
  14. end
  15.  
  16. function checkAll(thePad)
  17.     if (checkDirections(thePad) or checkRotations(thePad) or checkPlacement(thePad)) then return true
  18.     else return false end
  19. end
  20.  
  21. lastBE0 = memory.readbyte(0x000BE0)
  22. curBE0  = lastBE0
  23.  
  24. function update()
  25.     lastBE0 = curBE0
  26.     curBE0  = memory.readbyte(0x000BE0)
  27. end
  28.  
  29. while(true) do
  30.     memory.usememorydomain("IWRAM")
  31.     if(memory.readbyte(0x2B51) == 240 and memory.readbyte(0x2B52) == 250 and
  32.         (movie.getinputasmnemonic(emu.framecount()) ~= "|    0,    0,    0,  100,.......A...|" and movie.getinputasmnemonic(emu.framecount()-1) ~= "|    0,    0,    0,  100,.......A...|")) then
  33.         --THIS GIVES FALSE POSITIVES IN MENUS
  34.         print(emu.framecount() .. " BAD PUZZLE ENTRY?")
  35.     end
  36.     --3318 167, 331A 225, 3320 68, 3322 239
  37.     if(memory.readbyte(0x3318) == 167 and memory.readbyte(0x331A) == 225 and movie.getinputasmnemonic(emu.framecount()) ~= "|    0,    0,    0,  100,.......A...|") then
  38.         --THIS MIGHT NOT BE THOROUGH ENOUGH TO GET POSITIVES
  39.         print(emu.framecount() .. " BAD PUZZLE EXIT?")
  40.     end
  41.     memory.usememorydomain("Combined WRAM")
  42.     update()
  43.     --000BE0 = 0 two frames after we regain control
  44.     --000DED = Fade timer (000BE0 falsely equals 0 during the fadein/out between levels)
  45.     --025EF0 = 176 on the between levels screen
  46.     if(curBE0 == 0 and memory.readbyte(0x000DED) <= 2 and memory.readbyte(0x025EF0) ~= 176 and emu.framecount() > 900) then
  47.         rotation = movie.getinput(emu.framecount()-2)
  48.         movement = movie.getinput(emu.framecount()-1)
  49.         placement = movie.getinput(emu.framecount())
  50.         if (lastBE0 == 6) then
  51.             weRotated = false
  52.             if (rotation["B"] or rotation["R"] or rotation["L"]) then weRotated = true end
  53.             weMoved = false
  54.             if (movement["Up"] or movement["Right"] or movement["Down"] or movement["Left"]) then weMoved = true end
  55.             wePlaced = false
  56.             if (placement["A"]) then wePlaced = true end
  57.             if (not weRotated and not weMoved and not wePlaced) then
  58.                 print(emu.framecount() .. " BAD PIECE PLACING?")
  59.             end
  60.         else
  61.             if (not checkAll(rotation) and not checkAll(movement) and not placement["A"]) then
  62.                 print(emu.framecount() .. " BAD PIECE PLACING?")
  63.             end
  64.         end
  65.     end
  66.     emu.frameadvance()
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement