• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games.
    Don't forget to come back September 21st to vote for your favorites!
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
[v12+] Set the Controls Screen (now supporting gamepad)

Resource [v12+] Set the Controls Screen (now supporting gamepad) 1.2.8

hello, I just wanna ask how can I add this to the options menu? (where you select the text's speed or change your text dialog graphics)
You have this method:
I didn't found a cleaner way. My workaround:

On my script, comment/remove the

Code:
Expand Collapse Copy
MenuHandlers.add(:pause_menu, :controls, {
  "name"      => _INTL("Controls"),
  "order"     => 75,
  "effect"    => proc { |menu|
    pbPlayDecisionSE
    open_set_controls_ui(menu)
    next false
  }
})

On UI_Options script section:

Change 'return @options.length + 1' to 'return @options.length + 2'.

Change 'optionname = (index == @options.length) ? _INTL("Close") : @options[index].name' to

Code:
Expand Collapse Copy
    optionname = case index
      when @options.length+1; _INTL("Close")
      when @options.length;   _INTL("Controls")
      else; @options[index].name
    end

Change 'return if index == @options.length' to 'return if index >= @options.length'.

Change 'description = _INTL("Close the screen.")' to

Code:
Expand Collapse Copy
      if @sprites["option"].index==@options.length
        description = _INTL("Set the Controls.")
      else
        description = _INTL("Close the screen.")
      end

Change 'break if @sprites["option"].index == @options.length' to

Code:
Expand Collapse Copy
          break if @sprites["option"].index == @options.length+1
          open_set_controls_ui if @sprites["option"].index == @options.length
.
Or you could instal my plugin and set the configuration to add this script in the options menu to true. Be aware that my plugin also changes the appearance of the options and set control menus and that you'll still need this plugin installed for it to work. I only added the steps mentioned by FL to add the option in my script.
 
Is there any way to make the plugin open in the options instead of the pause menu in version v21.1? I tried to make the adjustments I saw in the discussions but they didn't work
 
Is there any way to make the plugin open in the options instead of the pause menu in version v21.1? I tried to make the adjustments I saw in the discussions but they didn't work
My Options Screen and Language Options plugins have those adjustments added and they both have a v21+ version. Try to see if any of them work for you. The Language Options only adds the adjustments, I think, so it may be easier for you to compare what is wrong.
 
My Options Screen and Language Options plugins have those adjustments added and they both have a v21+ version. Try to see if any of them work for you. The Language Options only adds the adjustments, I think, so it may be easier for you to compare what is wrong.
Thank you very much, I just added your options plugin and it worked correctly,

I use the quick save and delta speed up plugin, which use aux1 and aux2, I'm trying to make the control script recognize the changes, but it's causing conflict, if I put it to change, even though I don't change it in the game, the plugins stop working. work. I'm studying and examining what I can do, but that's just an additional thing, it's not even important hahahah

Edit: I found what it was, in the control script there was already a Q and a W being used, these two come as AUX1 and AUX2 as standard, but they were being used to scroll up and I hadn't noticed XD
 
Last edited:
Hi not regarding your Plugin but regarding controls, do you know if there is a way to check via script new keybinds mapped via the F1 standard functionality in Essentials 21.1? By standard the Action key is the Z let's say I change that to the letter Q, is there a way via script to get that Q is the keybind for Input::ACTION?
 
Hi not regarding your Plugin but regarding controls, do you know if there is a way to check via script new keybinds mapped via the F1 standard functionality in Essentials 21.1? By standard the Action key is the Z let's say I change that to the letter Q, is there a way via script to get that Q is the keybind for Input::ACTION?
There is no way in current Essentials MKXP-Z (the player) as far as I know.
 
The more recent versions of MKXP-Z allow for polling the scroll wheel with Input.scroll_v, could you add support for binding it?
 
Hey, thanks a lot for this, it works perfectly and I've successfully added a couple of extra AUX inputs. I have a couple of questions though. First, how could I change it so instead of the controls scene showing each array of buttons as text, it shows their icons? I've got some fancy controller/keyboard icons and I'd like to replace the text with them. I know you can use <icon = XXX> but I think it is not as easy as that (maybe it is?).
Also, I'd like to limit the player to only bind two keyboard keys and one gamepad key. MAX_KEYS_PER_ACTION limits the whole number of bindings, but I cannot limit keys and gamepad separatedly. Is there any way to achieve this, or is it too complex to bother?
 
Hey, thanks a lot for this, it works perfectly and I've successfully added a couple of extra AUX inputs. I have a couple of questions though. First, how could I change it so instead of the controls scene showing each array of buttons as text, it shows their icons? I've got some fancy controller/keyboard icons and I'd like to replace the text with them. I know you can use <icon = XXX> but I think it is not as easy as that (maybe it is?).
Also, I'd like to limit the player to only bind two keyboard keys and one gamepad key. MAX_KEYS_PER_ACTION limits the whole number of bindings, but I cannot limit keys and gamepad separatedly. Is there any way to achieve this, or is it too complex to bother?
I tested the below code:

1. Have icons instead of text for keys

Before line super(x,y,width,height) add
Ruby:
Expand Collapse Copy
      @image_hash = {
        "Space" => AnimatedBitmap.new("Graphics/Icons/bagPocket1"),
        "Enter" => AnimatedBitmap.new("Graphics/Icons/bagPocket2"),
        # Add the remaining icons here

        "None" => AnimatedBitmap.new("Graphics/Icons/bagPocket3"),
        "?" => AnimatedBitmap.new("Graphics/Icons/bagPocket4"), # This isn't the question mark key, but undefined icon
      }
Before line def itemCount add
Ruby:
Expand Collapse Copy
    def dispose
      for k in @image_hash.keys
        @image_hash[k].dispose
      end
      super
    end

Change
Ruby:
Expand Collapse Copy
      value = @action_handler[index].keys_text
      xpos = width+rect.x
      width = rect.width*14/20
      pbDrawShadowText(
        self.contents,xpos,rect.y,width,rect.height,
        value,@sel_base_color,@sel_shadow_color
      )
      self.contents.draw_text(xpos,rect.y,width,rect.height,value)
to
Ruby:
Expand Collapse Copy
            interval = 8
      current_x = width+rect.x
      y = rect.y + 10
      for control in @action_handler[index].control_array
        animatedBitmap = @image_hash[control.key_name] || @image_hash["?"]
        pbCopyBitmap(self.contents, animatedBitmap.bitmap, current_x, y)
        current_x += interval + animatedBitmap.width
      end


2. Have separate limits for keyboard keys and buttons

Before line 'def key_array' add
Ruby:
Expand Collapse Copy
    def keyboard_key_count
      return @control_array.count{|c| c.key_code!=0 && ActionData.keyboard_key?(c.key_code)}
    end

    def gamepad_button_count
      return @control_array.count{|c| c.key_code!=0 && !ActionData.keyboard_key?(c.key_code)}
    end

    def self.keyboard_key?(key_code)
      return key_code < Input::GAMEPAD_OFFSET
    end

Change lines
Ruby:
Expand Collapse Copy
        @action_handler.clear_keys_with_input(new_input)
        @action_handler.set_key(new_input, @index, @reading_key_index)
to
Ruby:
Expand Collapse Copy
      keyboard_limit = 2
      button_limit = 1
      keyboard_count = @action_handler[@index].keyboard_key_count
      button_count = @action_handler[@index].gamepad_button_count
      if new_input>0
        if @action_handler[@index].size > @reading_key_index
          keyboard_count-=1 if ActionData.keyboard_key?(@action_handler[@index].control_array[@reading_key_index].key_code)
          button_count-=1 if !ActionData.keyboard_key?(@action_handler[@index].control_array[@reading_key_index].key_code)
        end
        keyboard_count+=1 if ActionData.keyboard_key?(new_input)
        button_count+=1 if !ActionData.keyboard_key?(new_input)
      end
      if keyboard_count > keyboard_limit
        pbMessage(_INTL("You can't add more than {1} keyboard keys to an action!",keyboard_limit))
      elsif button_count > button_limit
        pbMessage(_INTL("You can't add more than {1} gamepad buttons to an action!",button_limit))
      else
        @action_handler.clear_keys_with_input(new_input)
        @action_handler.set_key(new_input, @index, @reading_key_index)
      end
 
I tested the below code:

1. Have icons instead of text for keys

Before line super(x,y,width,height) add
Ruby:
Expand Collapse Copy
      @image_hash = {
        "Space" => AnimatedBitmap.new("Graphics/Icons/bagPocket1"),
        "Enter" => AnimatedBitmap.new("Graphics/Icons/bagPocket2"),
        # Add the remaining icons here

        "None" => AnimatedBitmap.new("Graphics/Icons/bagPocket3"),
        "?" => AnimatedBitmap.new("Graphics/Icons/bagPocket4"), # This isn't the question mark key, but undefined icon
      }
Before line def itemCount add
Ruby:
Expand Collapse Copy
    def dispose
      for k in @image_hash.keys
        @image_hash[k].dispose
      end
      super
    end

Change
Ruby:
Expand Collapse Copy
      value = @action_handler[index].keys_text
      xpos = width+rect.x
      width = rect.width*14/20
      pbDrawShadowText(
        self.contents,xpos,rect.y,width,rect.height,
        value,@sel_base_color,@sel_shadow_color
      )
      self.contents.draw_text(xpos,rect.y,width,rect.height,value)
to
Ruby:
Expand Collapse Copy
            interval = 8
      current_x = width+rect.x
      y = rect.y + 10
      for control in @action_handler[index].control_array
        animatedBitmap = @image_hash[control.key_name] || @image_hash["?"]
        pbCopyBitmap(self.contents, animatedBitmap.bitmap, current_x, y)
        current_x += interval + animatedBitmap.width
      end


2. Have separate limits for keyboard keys and buttons

Before line 'def key_array' add
Ruby:
Expand Collapse Copy
    def keyboard_key_count
      return @control_array.count{|c| c.key_code!=0 && ActionData.keyboard_key?(c.key_code)}
    end

    def gamepad_button_count
      return @control_array.count{|c| c.key_code!=0 && !ActionData.keyboard_key?(c.key_code)}
    end

    def self.keyboard_key?(key_code)
      return key_code < Input::GAMEPAD_OFFSET
    end

Change lines
Ruby:
Expand Collapse Copy
        @action_handler.clear_keys_with_input(new_input)
        @action_handler.set_key(new_input, @index, @reading_key_index)
to
Ruby:
Expand Collapse Copy
      keyboard_limit = 2
      button_limit = 1
      keyboard_count = @action_handler[@index].keyboard_key_count
      button_count = @action_handler[@index].gamepad_button_count
      if new_input>0
        if @action_handler[@index].size > @reading_key_index
          keyboard_count-=1 if ActionData.keyboard_key?(@action_handler[@index].control_array[@reading_key_index].key_code)
          button_count-=1 if !ActionData.keyboard_key?(@action_handler[@index].control_array[@reading_key_index].key_code)
        end
        keyboard_count+=1 if ActionData.keyboard_key?(new_input)
        button_count+=1 if !ActionData.keyboard_key?(new_input)
      end
      if keyboard_count > keyboard_limit
        pbMessage(_INTL("You can't add more than {1} keyboard keys to an action!",keyboard_limit))
      elsif button_count > button_limit
        pbMessage(_INTL("You can't add more than {1} gamepad buttons to an action!",button_limit))
      else
        @action_handler.clear_keys_with_input(new_input)
        @action_handler.set_key(new_input, @index, @reading_key_index)
      end
Wow thank you so much for this, it is exactly what I wanted, it works great! Just a little detail, right now, by default, some controls have a single key and a single controller button (which is fine). When I add a second key, it shows after the controller button, and I want to always show keys together, then the button. How can I make this?
NKauRGW.png
mlkJ03m.png
 
Wow thank you so much for this, it is exactly what I wanted, it works great! Just a little detail, right now, by default, some controls have a single key and a single controller button (which is fine). When I add a second key, it shows after the controller button, and I want to always show keys together, then the button. How can I make this?
Good idea. I added into base script.

To add to your version, look at commit log.
 
Good idea. I added into base script.

To add to your version, look at commit log.
Thank you so much, it works perfectly! Sorry for being picky but since I'm creating an UI for this, I'd love to keep the 2 keys 1 button structure, and I was wondering if it'd be possible to fill the array with blanks when there are less inputs binded. Also, when you try to change or add any input, the action menu that opens up has no windowskin, how can I make it match its windowskin with the rest?

Edit: Nevermind I found that the windowskin problem was related to my modded pause menu, I've made it so you open the controls menu from the options and it is now fixed. I'd still love to have the ability to always have the icons in the correct positions though

FnSt8pZ.png


Vvnbv2U.png
 
Last edited:
Thank you so much, it works perfectly! Sorry for being picky but since I'm creating an UI for this, I'd love to keep the 2 keys 1 button structure, and I was wondering if it'd be possible to fill the array with blanks when there are less inputs binded.
Before line animatedBitmap = @image_hash[control.key_name] || @image_hash["?"] add line current_x = [current_x, width+rect.x + 80].max if SetControls::AUTO_SORT && control.key_code >= Input::GAMEPAD_OFFSET. I put the distance as 80, change if you wish so.
 
Before line animatedBitmap = @image_hash[control.key_name] || @image_hash["?"] add line current_x = [current_x, width+rect.x + 80].max if SetControls::AUTO_SORT && control.key_code >= Input::GAMEPAD_OFFSET. I put the distance as 80, change if you wish so.
Thank you so much! It is now nearly complete, thanks again, you're the best! ❤️
 
Sorry to bother again, but I think that because of all of these modifications, now SetControls.key_array("Cancel")[0] crashes the game, I tested it on a random NPC:

[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.8]

Script error in event 16 (coords 9,5), map 11 (Piso de Reynolds)
Exception: LocalJumpError
Message: no block given (yield)

***Full script:
SetControls.key_array("Cancel")[0]

Backtrace:
404:Set Controls:645:in `block in key_array'
404:Set Controls:644:in `each'
404:Set Controls:644:in `find_all'
404:Set Controls:644:in `key_array'
(eval):1:in `execute_script'
033:Interpreter:138:in `eval'
033:Interpreter:138:in `execute_script'
034:Interpreter_Commands:1177:in `command_355'
034:Interpreter_Commands:116:in `execute_command'
033:Interpreter:130:in `block in update'
 
Sorry to bother again, but I think that because of all of these modifications, now SetControls.key_array("Cancel")[0] crashes the game, I tested it on a random NPC:

[Pokémon Essentials version 21.1]
[v21.1 Hotfixes 1.0.8]

Script error in event 16 (coords 9,5), map 11 (Piso de Reynolds)
Exception: LocalJumpError
Message: no block given (yield)

***Full script:
SetControls.key_array("Cancel")[0]

Backtrace:
404:Set Controls:645:in `block in key_array'
404:Set Controls:644:in `each'
404:Set Controls:644:in `find_all'
404:Set Controls:644:in `key_array'
(eval):1:in `execute_script'
033:Interpreter:138:in `eval'
033:Interpreter:138:in `execute_script'
034:Interpreter_Commands:1177:in `command_355'
034:Interpreter_Commands:116:in `execute_command'
033:Interpreter:130:in `block in update'
This is an error in base script. I pushed a fix (just removed the word 'yield').
 
Back
Top