Skip to content

Instantly share code, notes, and snippets.

@pfirsich
Last active July 16, 2018 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfirsich/14c5367af65f11c3c27220291896b4ff to your computer and use it in GitHub Desktop.
Save pfirsich/14c5367af65f11c3c27220291896b4ff to your computer and use it in GitHub Desktop.
Documentation for Controll Config Scripts in Spectacular Shatter Buddies (http://shatterbuddies.net/)

Control Config Scripts (*.sbcs)

Notes

For syntax highlighting you can usually use JavaScript or C syntax highlighting.

The configs you find in the save directory in control_configs will be overwritten every time you restart the game. If you want to make a custom control script, you need to create a copy with a different name.

Sadly if there is a syntax error in these scripts, the script will be parsed up until that error without notifying you, so that you will have only partially working controls!

General Syntax

A config script consists of a series of assignment, where the left hand side of the assignment is a "slot" that represents a certain input in the game, for example jump or dodge.

For example:

jump = gp.leftshoulder
attackX = deadzone(gp.rightx, 0.25)

Slots

All inputs fall into two cateogries. "Binary" inputs which are either down or not down (usually some kind of button) and "analog" inputs, which can have a value inside a range (usually 0 to 1 or -1 to 1).

The slots you may assign are the following:

  • moveX, moveY, attackX, attackY: (analog) Inputs that provide the movement input directions and the attack input directions (left and right stick respectively)
  • jump, dodge, shorthop, grab, taunt: (binary) Self-explanatory.
  • light, heavy, special: (binary) Light, heavy and special attack.
  • attack, lightModifier, heavyModifier, specialModifier: (binary) The attack input does nothing on it's own, but may be combined with the modifiers to generate attack inputs of certain types.

Note

The attack slot and the modifiers have precedence over the other attack slots and usually they are double binded to one of the attack slots to make the button do something when no modifier is pressed. For example with attack being bound to the right stick, if you wanted the right stick to do light attacks if no modifier is presssed, you would do:

light = or(gp.a, attack)

So when you press attack and no modifier, the attack slot will do nothing on it's own, but the light slot will result in a light attack. But if you have a modifier pressed the corresponding attack will be generated instead.

Inputs

Gamepad Config Scripts

All of the gamepad inputs are inside the gp module so that you can access them by writing (example): gp.leftx or gp.x or gp.triggerleft.

The available binary inputs are: https://love2d.org/wiki/GamepadButton

The available analog inputs are: https://love2d.org/wiki/GamepadAxis

Keyboard Config Scripts

All keyboard inputs are binary inputs and they all reside in the kb module.

The available inputs are: https://love2d.org/wiki/KeyConstant

Example: kb.w, kb.lctrl, kb.space

Functions

  • toanalog(binary positive, binary negative): Returns an analog input as a combination of two binary inputs. The first (positive) being the input that if pressed alone will make the returned analog input return 1. The second, if pressed alone, will make the returned analog input return -1. If both are pressed 0 is returned.
  • deadzone(analog input, number deadzoneval): Returns an analog input that returns 0 instead of values smaller than deadzoneval in magnitude and the original value otherwise.
  • thresh(analog input, number threshval): Returns a binary input that will be not pressed if the value of input is smaller than threshval and pressed if it is greater.
  • or(binary arg1, binary arg2, ...): Returns a binary input that is pressed when one of the argument binary inputs argN is pressed and is not pressed when none of the arguments are.
  • and(binary arg1, binary arg2, ...): Returns a binary input that is pressed when all of the argument inputs argN are pressed and it is not pressed if any of them are not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment