Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Scripletter v1.02 by Zetu
- #===============================================================================
- module Z
- INPUT_LETTERS = [
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
- 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z'
- ]
- INPUT_NUMBERS = [
- '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
- ]
- SHIFT_NUM = {
- 1 => '!', 2 => '@', 3 => '#', 4 => '$', 5 => '%',
- 6 => '^', 7 => '&', 8 => '*', 9 => '(', 0 => ')'
- }
- end
- class Scriptletter
- attr_accessor :active
- attr_reader :text
- attr_reader :width
- def initialize(x, y, width)
- @window = Script_Input_Window.new(x, y, width)
- @width = width
- @text = ""
- @active = true
- end
- def height
- return 56
- end
- def clear
- @text = ""
- @window.text = @text
- end
- def add_key(value)
- Sound.play_decision
- @text += value
- @window.text = @text
- end
- def remove_key
- Sound.play_cancel
- @text = @text.chop
- @window.text = @text
- end
- def update
- return unless @active
- JetInput.update
- check_key_input_letters
- check_key_input_numbers
- check_special
- @window.refresh
- end
- def check_key_input_letters
- for key in Z::INPUT_LETTERS
- if eval("JetInput.trigger?(JetInput::#{key})")
- if JetInput.shift_state
- add_key(key.upcase)
- else
- add_key(key.downcase)
- end
- return
- end
- end
- end
- def check_key_input_numbers
- for key in Z::INPUT_NUMBERS
- if eval("JetInput.trigger?(JetInput::NUM_#{key})")
- if JetInput.press?(JetInput::SHIFT)
- add_key(Z::SHIFT_NUM[eval(key)])
- else
- add_key(key)
- end
- return
- end
- end
- end
- def check_special
- if JetInput.trigger?(JetInput::BACK) or JetInput.trigger?(JetInput::DELETE)
- remove_key
- elsif JetInput.trigger?(JetInput::SPACE)
- add_key(" ")
- end
- end
- def dispose
- @window.dispose
- @window = nil
- end
- end
- class Script_Input_Window < Window_Base
- attr_accessor :text
- def initialize(x, y, width)
- super(x, y, width, 56)
- @text = ""
- end
- def refresh
- self.contents.clear
- text = "@> #{@text}"
- text += "|" if (Graphics.frame_count % Graphics.frame_rate) > 40 if active
- self.contents.draw_text(0, 0, self.contents.width, WLH, text)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement