Guest User

Untitled

a guest
Aug 27th, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.70 KB | None | 0 0
  1. --[[
  2.  
  3. This is a lua-script to show some useful informations about blocks in Super Mario World.
  4. It shows the frame when you have to throw an item, to duplicate the chosen block in which direction
  5. (So it has to show "LEFT" if you want to duplicate to the left) or you can choose a line where you wanna duplicate.
  6. It also shows when you can Walljump or Cornerclip.
  7.  
  8. Leftclick: Show/Hide the selection with informations
  9. Rightclick: Toggle betweeen a box and a line around your mouse
  10.  
  11. Script by Masterjun
  12.  
  13. ]]--
  14.  
  15. local left = true --touching block from left
  16. local right = true --touching block from right
  17. local bottom = true --for duplicating
  18. local walljump = true --walljump help
  19. local cornerclip = true --cornerclip help
  20.  
  21. ---------------------------------------------------
  22.  
  23. --from smwutils.lua
  24. local keys, lastkeys= input.get(), input.get()
  25. local function UpdateKeys() lastkeys= keys;  keys= input.get() end
  26. local function Press(k) return keys[k] and (not lastkeys[k]) end
  27.  
  28. local showbox = true
  29. local x1box
  30. local y1box
  31. local x2box
  32. local y2box
  33.  
  34. --find out which item is in mario's hands (if doublegrab, then it will use the highest slot)
  35. function carry()
  36.     temp=nil
  37.     for i = 0,11 do
  38.         if memory.readbyte(0x7E14C8 + i) == 11 then
  39.             temp=i
  40.         end
  41.     end
  42.     slot=temp
  43.     return slot
  44. end
  45.  
  46. function main(slot)
  47.     UpdateKeys()
  48.     local xspeed = memory.readbytesigned(0x7E007B)
  49.     local input=input.get()
  50.    
  51.     local lastxcam
  52.     if xcamc then
  53.         lastxcam=xcamc
  54.     else
  55.         lastxcam=memory.readword(0x7E001A)
  56.     end
  57.     local lastycam
  58.     if ycamc then
  59.         lastycam=ycamc
  60.     else
  61.         lastycam=memory.readword(0x7E001A)
  62.     end
  63.    
  64.     local xcam=memory.readword(0x7E001A)
  65.     xcamc=memory.readword(0x7E001A)
  66.     local ycam=memory.readword(0x7E001C)
  67.     ycamc=memory.readword(0x7E001C)
  68.     local x1=input.xmouse-(xcam+input.xmouse)%16
  69.     local y1=input.ymouse-((ycam+input.ymouse)+1)%16
  70.     local x2=x1+15
  71.     local y2=y1+15
  72.     local nearblock=false
  73.     local xoffset=lastxcam-xcam
  74.     local yoffset=lastycam-ycam
  75.    
  76.     if Press("rightclick") then
  77.         if showbox then
  78.             showbox=false
  79.         else
  80.             showbox=true
  81.         end
  82.     end
  83.    
  84.     gui.transparency(2)
  85.     if showbox then gui.box(x1-xoffset,y1-yoffset,x2-xoffset,y2-yoffset,"#FFFFFF")
  86.     else
  87.         if not y1line then
  88.             gui.line(0,y1-yoffset,256,y1-yoffset)
  89.             gui.line(0,y2-yoffset,256,y2-yoffset)
  90.         end
  91.     end
  92.    
  93.     --This is a grid for the boxes
  94.     --[[
  95.     gui.transparency(2)
  96.     for i=xcam%16,256,16 do
  97.         gui.line(256-i,0,256-i,224)
  98.         gui.line(255-i,0,255-i,224)
  99.     end
  100.     for i=ycam%16,224,16 do
  101.         gui.line(0,223-i,256,223-i)
  102.         gui.line(0,222-i,256,222-i)
  103.     end
  104.     gui.transparency(0)
  105.     ]]--
  106.    
  107.     if Press("leftclick") then
  108.         if showbox then
  109.             if not x1box then
  110.                 x1box=x1
  111.                 y1box=y1
  112.                 x2box=x2
  113.                 y2box=y2
  114.                 xcambox=xcam
  115.                 ycambox=ycam
  116.             elseif x1box-xdiff==x1 and y1box-ydiff==y1 then x1box=nil
  117.             else
  118.                 x1box=x1
  119.                 y1box=y1
  120.                 x2box=x2
  121.                 y2box=y2
  122.                 xcambox=xcam
  123.                 ycambox=ycam
  124.             end
  125.         else
  126.             if not y1line then
  127.                 y1line=y1
  128.                 y2line=y2
  129.                 ycambox=ycam
  130.             elseif y1line==y1 then y1line=nil
  131.             else
  132.                 y1line=y1
  133.                 y2line=y2  
  134.                 ycambox=ycam
  135.             end
  136.         end
  137.     end
  138.  
  139.     if showbox==true then
  140.         y1line=nil
  141.     else
  142.         x1box=nil
  143.     end
  144.    
  145.     if y1line then
  146.         ydiff=ycam-ycambox
  147.         gui.line(0,y1line-ydiff-yoffset,256,y1line-ydiff-yoffset)
  148.         gui.line(0,y2line-ydiff-yoffset,256,y2line-ydiff-yoffset)
  149.         gui.transparency(0)
  150.         if bottom then gui.text(8,y2line-ydiff+1,y1line+ycambox+15) end
  151.     end
  152.    
  153.     if x1box then
  154.         xdiff=xcam-xcambox
  155.         ydiff=ycam-ycambox
  156.         gui.box(x1box-xdiff-xoffset,y1box-ydiff-yoffset,x2box-xdiff-xoffset,y2box-ydiff-yoffset,"#FFFFFF")
  157.         gui.transparency(0)
  158.         --The three values for the box
  159.         if bottom then gui.text(x2box-xdiff-13-xoffset,y2box-ydiff+1-yoffset,y1box+ycambox+15) end
  160.         if right then gui.text(x2box-xdiff+2-xoffset,y2box-ydiff-13-yoffset,x1box+xcambox+13) end
  161.         if left then gui.text(x1box-xdiff-16-xoffset,y2box-ydiff-13-yoffset,x1box+xcambox-14) end
  162.     end
  163.    
  164.     --Duplication help
  165.     if slot then
  166.         local yposh=memory.readbyte(0x7E14D4+slot)
  167.         local xposh=memory.readbyte(0x7E14E0+slot)
  168.         local yposl=memory.readbyte(0x7E00D8+slot)
  169.         local xposl=memory.readbyte(0x7E00E4+slot)
  170.         local ysubpos=memory.readbyte(0x7E14EC+slot)
  171.         local guiypos=58
  172.         local ypositem=yposl+yposh*256
  173.         local xpositem=xposl+xposh*256
  174.         local all=(ypositem)*16+ysubpos/16
  175.        
  176.         if y1line then nearblock=true
  177.         elseif x1box and xpositem <= x1box+xcambox+7 and xpositem >= x1box+xcambox+4 then nearblock=true
  178.         elseif x1box and xpositem >= x1box+xcambox-8 and xpositem <= x1box+xcambox-5 then nearblock=true
  179.         else nearblock=false
  180.         end
  181.        
  182.         if (bottom and x1box) or (bottom and y1line) then
  183.             local blockbottom=y1box+ycambox+15
  184.             gui.text(210,50,string.format("%d.%02x",ypositem, ysubpos))
  185.             j=nil
  186.             for i = 0,15,3 do
  187.                 all=all-(112-i)
  188.                 if y1box and (all-all%16)/16 == (blockbottom) then
  189.                     j=i
  190.                 end
  191.                 --if y1box then gui.text(100,guiypos+42,string.format("%d %d",(all-all%16)/16,(blockbottom)+1)) end
  192.                 if j==i-3 and (all-all%16)/16 == (blockbottom)-7 and nearblock then
  193.                     if (j/3)%2==0 then
  194.                         if memory.readbyte(0x7E0013)%2==1 then
  195.                             gui.text(236,guiypos,"LEFT","#FF0000")
  196.                         else
  197.                             gui.text(236,guiypos,"RIGHT","#FF0000")
  198.                         end
  199.                     else
  200.                         if memory.readbyte(0x7E0013)%2==0 then
  201.                             gui.text(236,guiypos,"LEFT","#FF0000")
  202.                         else
  203.                             gui.text(236,guiypos,"RIGHT","#FF0000")
  204.                         end
  205.                     end
  206.                 end
  207.                 gui.text(210,guiypos,string.format("%d.%02x",(all-all%16)/16,all%16*16))
  208.                 guiypos=guiypos+8
  209.             end
  210.            
  211.             if ypositem > (blockbottom)-8 and ypositem < (blockbottom)+1 and nearblock then
  212.                 if memory.readbyte(0x7E0013)%2==0 then
  213.                     gui.text(236,50,"LEFT","#FF0000")
  214.                 else
  215.                     gui.text(236,50,"RIGHT","#FF0000")
  216.                 end
  217.             end
  218.                
  219.             if ypositem == (blockbottom)-8 and nearblock then
  220.                 if memory.readbyte(0x7E0013)%2==0 then
  221.                     gui.text(236,50,"LEFT","#FF0000")
  222.                 else
  223.                     gui.text(236,50,"RIGHT","#FF0000")
  224.                 end
  225.             end
  226.                
  227.             if ypositem == (blockbottom)-9 and nearblock then
  228.                 if memory.readbyte(0x7E0013)%2==0 then
  229.                     gui.text(236,50,"LEFT","#FF0000")
  230.                 else
  231.                     gui.text(236,50,"RIGHT","#FF0000")
  232.                 end
  233.             end
  234.                
  235.             if ypositem == (blockbottom)-8 and nearblock then
  236.                 if memory.readbyte(0x7E0013)%2==0 then
  237.                     gui.text(236,50,"LEFT","#FF0000")
  238.                 else
  239.                     gui.text(236,50,"RIGHT","#FF0000")
  240.                 end
  241.             end
  242.                
  243.             if ypositem == (blockbottom)-9 and nearblock then
  244.                 if memory.readbyte(0x7E0013)%2==0 then
  245.                     gui.text(236,50,"LEFT","#FF0000")
  246.                 else
  247.                     gui.text(236,50,"RIGHT","#FF0000")
  248.                 end
  249.             end
  250.                
  251.             if ypositem == (blockbottom)-8 or ypositem == (blockbottom)-9 and nearblock then
  252.                 gui.text(236,42,"TOP","#FF0000")
  253.             end
  254.         end
  255.     end
  256.     if x1box then
  257.         local xspeed = memory.readbytesigned(0x7E007B)
  258.         local xsubspeed = memory.readbyte(0x7E007A)
  259.         local xpos = memory.readword(0x7E0094)
  260.         local xsubpos = memory.readbyte(0x7E13DA)
  261.         local allpos = xpos*16 + xsubpos/16
  262.         local r = (x1box+xcambox+13)*16
  263.         local l = (x1box+xcambox-14)*16
  264.         if walljump or cornerclip then 
  265.         gui.text(28,38,xspeed)
  266.             if xspeed>32 and xpos-8<l/16 then
  267.                 local calpos=allpos
  268.                 while calpos<l do
  269.                     calpos=calpos+xspeed
  270.                 end
  271.                 calpos=calpos-xspeed*2
  272.                 for i = 0,4 do
  273.                     local tpos=calpos+i*xspeed
  274.                     if tpos-15 <= l then
  275.                         j=i
  276.                     end
  277.                     if tpos-15 <= l+32 then
  278.                         k=i
  279.                     end
  280.                     if k==i-1 and tpos-15 >= l+81 and cornerclip then
  281.                         gui.text(8,i*8+50,"CC","#FF0000")
  282.                     end
  283.                     if j==i-1 and tpos-15 >= l+33 and walljump then
  284.                         gui.text(8,i*8+50,"WJ","#FF0000")
  285.                     end
  286.                     gui.text(24,i*8+50,string.format("%d.%02x",(tpos-tpos%16)/16,(tpos%16)*16))    
  287.                 end
  288.             end
  289.  
  290.             if xspeed<(-32) and xpos+8>r/16 then
  291.                 local calpos=allpos
  292.                 while calpos>r do
  293.                     calpos=calpos+xspeed
  294.                 end
  295.                 calpos=calpos+xspeed
  296.                 for i = 0,4 do
  297.                     local tpos=calpos-(4-i)*xspeed
  298.                     if tpos >= r then
  299.                         j=i
  300.                     end
  301.                     if tpos >= r-32 then
  302.                         k=i
  303.                     end
  304.                     if k==i-1 and tpos <= r-81 and cornerclip then
  305.                         gui.text(8,i*8+50,"CC","#FF0000")
  306.                     elseif j==i-1 and tpos <= r-33 and walljump then
  307.                         gui.text(8,i*8+50,"WJ","#FF0000")
  308.                     end
  309.                     gui.text(24,i*8+50,string.format("%d.%02x",(tpos-tpos%16)/16,(tpos%16)*16))
  310.                 end
  311.             end
  312.         end
  313.     end
  314. end
  315.  
  316. gui.register(function()
  317. carry()
  318. main(slot)
  319. end)
Add Comment
Please, Sign In to add comment