Phoenix1291

StylusInputDisplay.lua

Jun 10th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. -- Gives a cross hair UI for the stylus for DS games
  2.  
  3. local upColor = 'white'
  4. local downColor = 'green'
  5. local dotColor = 'red'
  6.  
  7. function Draw(x, y, maxX, maxY, isDown)
  8.     color = upColor
  9.     if isDown then
  10.         color = downColor
  11.     end
  12.  
  13.     gui.drawLine(0, y, maxX, y, color)
  14.     gui.drawLine(x, 0, x, maxY, color)
  15.  
  16.     if isDown then
  17.         gui.drawPixel(x, y, dotColor)
  18.     end
  19. end
  20.  
  21. while true do
  22.     if emu.getsystemid() ~= "NDS" then
  23.         console.log('This script is for Nintendo DS only')
  24.         break
  25.     end
  26.    
  27.     local btns = joypad.get()
  28.    
  29.     if movie.mode() == "PLAY" and emu.framecount() > 0 then
  30.         btns = movie.getinput(emu.framecount() - 1)
  31.     end
  32.  
  33.     local x = btns['TouchX']
  34.     local y = btns['TouchY']
  35.     local isDown = btns['Touch']
  36.  
  37.     -- A bit of a hack to ensure it is not drawing while mouse moving
  38.     -- on the top screen
  39.     if y == 0 then
  40.         x = 0
  41.     end
  42.  
  43.     pts = client.transformPoint(x, y)
  44.     local tx = pts["x"];
  45.     local ty = pts["y"];
  46. gui.DrawNew("native")
  47.     Draw(tx, ty, 10000, 10000, isDown)
  48.  
  49.     emu.frameadvance()
  50. end
Add Comment
Please, Sign In to add comment