0 Favourites

Download new Custom Keys Plugin here

This forum is currently in read-only mode.
  • hi all

    I've created a Custom Controls plugin you can use for your games. To begin with, I will state that unfortunately, this does not work with built-in behaviors, but only for your own control and movement.

    Now on to the good news...

      Features:
    • Set up to 100 different controls for up to 10 players (total of 1000 controls)
    • Allow players to change keys at runtime
    • Save keys to a file and load them to individual players
    • Saves key config files not easily readable in a text editor

    Now, before you try to use it, please read the tutorial below.

    download the plugin here

    Download an example exe here

    • click the text of the control setting you want to modify (i.e. Left Mouse Button)
    • if you change the controls after clicking Save, clicking Load instantaneously loads your saved keys and sets them.

    Download the example cap here

    (saved in .99)

    (the tutorial below will help you to understand what you're looking at)

    first I will list the actions and expressions, and then explain how they are all used.

      Actions:
    • New Control (makes a new control for your game, such as "jump", or "move right". creates the control for all players)
    • Set Key (sets a key to your control)
    • Save Key Config (saves a key config to a file)
    • Load Key Config (loads a key config from a file)
    • Change Display String (allows you to change the default text to represent keys, like "F-12" instead of "F12", so you can decide what the player sees on your key config menu
      Expressions:
    • Get Control (Let's you check if the player is pressing one of their set controls)
    • Get Control String (Returns a string with the name of the key set to a certain control, like "Tab", or "Left mouse button")

    on to the tutorial:

    first unrar the plugins into construct's plugin directory. one will go directly into \plugins, the other will go into \plugins\runtime

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/1ChooseObjects.PNG">

    1.when you open your construct project. add both the Custom Keys Object and the Mouse/Keyboard Object

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/2AddControls.PNG">

    2.At start of layout, add any controls you want in your game using the AddControl action in Custom Keys

    3.In your game, you make your control editor menu. Decide when you want the player to press the key he is customizing.

    Now this part might seem a little weird, but don't let it confuse you. you do the same exact thing every time, and after the next step, it all becomes very intuitive.

    Add a System Condition : For, and set it up as displayed below; just set the "end" number to 89. I will explain the reasoning for this in the next step

    (I know some screenshots show 1 to 89, but it should be 0 - 89, you leave the 0 alone. Will retake screenshots later)

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/whatitwilllooklike1.png">

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/Capture.PNG">

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/3AddSystemForLoop.PNG">

    4.Next you add a subevent, Mouse/Keyboard : On Key Pressed,

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/whatitwilllooklike2.png">

    instead of choosing a key from the list:

    right click the word key just above the list of choices and select use expression.

    for the expression, simply type loopindex

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/4OnKeyPressed.PNG">

    the reason you are doing this is because the system:for loop is having the mouse/keyboard function check whether the player pressed any of the 90 possible keys.

    loopindex is the current key it's checking

    5.Now you can set the keys by adding the CustomControls : Set Key action:

    • choose one of the controls you added in the start of layout,
    • choose a player to set it to,
    • and always type loopindex for the key to set to. remember, loopindex is the key that you actually pressed.

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/5SetControls.PNG">

    it will be easy to read in the event sheet which key was set and when:

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/whatitwilllooklike3.png">

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/6OnCustomKeyPressed.PNG">

    6.Now for the fun part - where you're making the character move with your new controls.

    You add a mouse/keyboard : "On key pressed", or "key is down" condition,

    but instead of choosing a key from the drop down list.

    Right click the word key just above the list of choices and select use expression. Now double click the custom keys icon to bring up the expression list:

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/7OnCustomKeyPressed.PNG">

    7.The first parameter is the name of the control, the second parameter is the player number. So the condition in the screenshot above would trigger anytime player 1 pressed the "jump" key

    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/8GetControlString.PNG">

    8.You may have noticed in step 6, there is another expression for Custom Keys --- Get Control String. This is to show the player what key they have set.

    ControlString(name of control, player number) [/code:1ji99rbx]
    If player 1 would have set [b]jump[/b] to be the [b]Left mouse button[/b], then the action in the screenshot above would set [b]Text[/b] to [b]"Left mouse button"[/b].  
    
    But what if you wanted the text to say [b]"Mouse1"[/b], or [b]"LEFT MOUSE BUTTON"[/b], or [b]"lft ms btn"[/b]?
    fortunately there is an action for that as well:
    
    [b]change display string[/b]
    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/9ChangeDisplayString.PNG">
    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/10ChangeDisplayString.PNG">
    9.[b]Change display string[/b] allows you to override the default string output for keys you get from the [b]Get Control String[/b] expression.  First choose the key you want to override the string for, and then, input whatever string you wish.
    
    <img src="http://dl.getdropbox.com/u/1013446/New%20Folder/11SaveKeyConfig.PNG">
    10.And last, but certainly not least, there are the [b]SaveKeyConfig[/b], and [b]LoadKeyConfig[/b] actions.
    Simply select a filename, and which player you want to save the keys from, or load the keys to.  You can choose whatever file extension you wish, and the saved file is purposefully not easily readable in a text file.  The start directory is the directory your game exe is in.  
    
    If you want to save a default key configuration, make your cap with your own key configuration menu.  Make the cap save to [b]"default.keys"[/b] (for instance),  then set the keys and save the cap, then change the cap so it no longer saves to [b]"default.keys"[/b], and make it load those keys whenever a user clicks a Set to Default button , and save new key configs to [b]"user.keys"[/b](or whatever).  You can also setup several preset control schemes this way by saving several files [b]"Control Scheme A"[/b], [b]"WSAD walk"[/b], etc.
    
    Have fun, please feel free to ask questions, and make suggestions.  This plugin is free to use for whatever purposes you wish.  I hope you find it useful
  • Wow thats a lot for your first plug.

  • uber useful

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • You are free to download and play with it

    especially the exe, since it's no trouble to test out

    but this plugin will soon be obselete,

    I am making a version without as much awkwardness, that also let's you save and use xbox360 controls,

    the xbox360 pad support is not the part I'm making, david just made a new xbox360 plugin, I'm just making it so you can save the controls

  • Congratulations on making your first plugin

  • thanks!

    this is not THE plugin btw, if you're wondering

    that's still a whiles away

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)