SHARE
TWEET

Updated Keybinding script for Carf

Drykul Mar 23rd, 2020 372 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Special Keybinds v1.3.1
  2. #----------#
  3. #Features: A way to use almost any key on your keyboard to toggle switches,
  4. #           add to variables, or call scenes! Doesn't that sound just neat!
  5. #
  6. #Usage:   Press the set up keybind!
  7. #        
  8. #Customization: Add to the KI_KEYBINDS hash as needed!
  9. #                Details below!
  10. #
  11. #----------#
  12. #-- Script by: V.M of D.T
  13. #
  14. #- Questions or comments can be:
  15. #    given by email: sumptuaryspade@live.ca
  16. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  17. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  18. #
  19. #--- Free to use in any project, commercial or non-commercial, with credit given
  20. # - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
  21.  
  22. #This is where you set up your keybinds. It goes either:
  23. # Key symbol => [:scene, scene_name],
  24. # Key Symbol => [:var, var_id, amount],
  25. # Key Symbol => [:switch, switch_id],
  26. # Key Symbol => [:script, "script call"],
  27. #
  28. # Key Symbols are the names of the key, from A-Z, N0-N9, or many of the
  29. # named keys! They are listed as symbols below for semi-easy reference!
  30. #
  31. #Adding and removing keybinds while in game with simple script calls:
  32. #  $ki_keybinds.delete(symbol)
  33. #  $ki_keybinds[symbol] = [keybind setup (see above)]
  34. #Symbol is any Key Symbol as listed under Input below
  35.                   #~:N4 => [:script, "$game_party.gain_gold(1000)"],
  36.                   #~:W => [:script, "$game_player.move_by_int(8)",nil,1],
  37.                   #~:A => [:script, "$game_player.move_by_int(4)",nil,1],
  38.                   #~:S => [:script, "$game_player.move_by_int(2)",nil,1],
  39.                   #~:D => [:script, "$game_player.move_by_int(6)",nil,1],
  40.  $ki_keybinds = {  
  41.                   :N1 => [:switch, 100],
  42.                   :N2 => [:switch, 63],
  43.                   :N3 => [:switch, 89],
  44.                   :N4 => [:switch, 17],
  45.                   :N5 => [:switch, 00],
  46.                   :N6 => [:switch, 00],
  47.                   :N7 => [:switch, 00],
  48.                   :N8 => [:switch, 00],
  49.                   :N9 => [:switch, 93],
  50.                   :N0 => [:script, "$game_temp.reserve_common_event(1)"],
  51.                   :F5 => [:script, "$game_temp.reserve_common_event(2)"],
  52.                   :F6 => [:switch, 45],
  53.                   :F7 => [:switch, 49],
  54.                   :F8 => [:script, "$game_temp.reserve_common_event(3)"],
  55.                   :F4 => [:switch, 88],
  56.                   :F3 => [:var, 22, +1],
  57.                   :F2 => [:var, 23, -1],
  58. # Key Symbol => [:var, var_id, amount],
  59.  
  60.                 }
  61. module Keyboard_Input
  62.  
  63.   ASKS = Win32API.new 'user32', 'GetAsyncKeyState', ['p'], 'i'
  64.  
  65.   INPUT = { :backspace => 0x08, :tab => 0x09, :enter => 0x0D, :shift => 0x10,
  66.             :ctrl => 0x11, :alt => 0x12, :pause => 0x13, :caps => 0x14,
  67.             :escape => 0x1B, :space => 0x20, :pageup => 0x21, :pagedown => 0x22,
  68.             :end => 0x23, :home => 0x24, :left => 0x25, :up => 0x26,
  69.             :right => 0x27, :down => 0x28, :print => 0x2C, :insert => 0x2D,
  70.             :delete => 0x2E,
  71.            
  72.             :N0 => 0x30, :N1 => 0x31, :N2 => 0x32, :N3 => 0x33,
  73.             :N4 => 0x34, :N5 => 0x35, :N6 => 0x36, :N7 => 0x37, :N8 => 0x38,
  74.             :N9 => 0x39,
  75.            
  76.             :A => 0x41, :B => 0x42, :C => 0x43, :D => 0x44, :E => 0x45, :F => 0x46,
  77.             :G => 0x47, :H => 0x48, :I => 0x49, :J => 0x4A, :K => 0x4B, :L => 0x4C,
  78.             :M => 0x4D, :N => 0x4E, :O => 0x4F, :P => 0x50, :Q => 0x51, :R => 0x52,
  79.             :S => 0x53, :T => 0x54, :U => 0x55, :V => 0x56, :W => 0x57, :X => 0x58,
  80.             :Y => 0x59, :Z => 0x5A,
  81.            
  82.             :F1 => 0x70, :F2 => 0x71, :F3 => 0x72,
  83.             :F4 => 0x73, :F5 => 0x74, :F6 => 0x75, :F7 => 0x76, :F8 => 0x77,
  84.             :F9 => 0x78, :F10 => 0x79, :F11 => 0x7A, :F12 => 0x7B,
  85.            
  86.             :num => 0x90,
  87.             :scroll => 0x91, :lshift => 0xA0, :rshift => 0xA1, :lctrl => 0xA2,
  88.             :rctrl => 0xA3, :lalt => 0xA4, :ralt => 0xA5, :colon => 0xBa,
  89.             :plus => 0xBB, :comma => 0xBC, :minus => 0xBD, :period => 0xBE,
  90.             :slash => 0xBF, :tilde => 0xC0, :lbrace => 0xDB, :backslash => 0xDC,
  91.             :rbrace => 0xDD, :quote => 0xDE  }
  92.            
  93.   def self.press?(symbol, delay = 30)
  94.     return unless @delay == 0 or @delay.nil?
  95.     return false if ASKS.call(INPUT[symbol]) == 0
  96.     @delay = delay
  97.     return true
  98.   end
  99.   def self.update
  100.     return if @delay == 0
  101.     @delay -= 1 unless @delay.nil?
  102.   end
  103. end
  104.  
  105. class Scene_Base  
  106.   alias cekb_update update
  107.   def update
  108.     cekb_update
  109.     cekb_input_update
  110.     Keyboard_Input.update
  111.   end
  112.   def cekb_input_update
  113.     $ki_keybinds.each {|key, value|
  114.       next unless Keyboard_Input.press?(key, value[3] ? value[3] : 30)
  115.       next unless self.is_a?(Scene_Map)
  116.       SceneManager.call(value[1]) if value[0] == :scene
  117.       $game_variables[value[1]] += value[2] if value[0] == :var
  118.       if value[0] == :switch
  119.         id = value[1]
  120.         switch = $game_switches[value[1]]
  121.         switch == false ? $game_switches[id] = true : $game_switches[id] = false
  122.       end
  123.       eval(value[1]) if value[0] == :script
  124.     }
  125.   end
  126. end
  127.  
  128. class Game_Player
  129.   def move_by_int(dir)
  130.     return if !movable? || $game_map.interpreter.running?
  131.     move_straight(dir) if dir > 0
  132.   end
  133. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top