# Introduction

## Gimhook v0.0.1

A desktop app and modloader for Gimkit.

## How do I install Gimhook?

Check out the [installation](/installation/mac) section for information on installing depending on your OS.

## How do I make a mod?

While it is technically possible to [write a Gimhook mod manually](/creating-mods/gimhook-documentation), the recommended way to do it is via the work-in-progress Gimhook SDK.

Read the [SDK documentation](/creating-mods/sdk-documentation) for more information.

## Is this allowed on Gimkit?

The simplified answer is **yes, as long as you don't use it to cheat or otherwise do anything potentially problematic.**

Special thanks to Josh Feinsilber and Jeff Osborn for answering this question!

## How does this work?

In modern JavaScript, there are modules that can be defined and later imported.

Here's an example of a CommonJS module which we'll give the filename `add.js`:

```javascript
module.exports = (a, b) => {return a + b};
```

..and here's an example of a module that uses it:

```javascript
const add = require('./add');

console.log(add(2, 2)); // 4
```

However, modern web apps don't just use modules directly in the browser - They use a bundler to implement `require()` and bundle all of the dependencies they need into a single JavaScript file.

Gimhook works by hooking onto the parcel's implementation of `require()` (which Gimkit uses) and intercepting the imported modules to replace them with something else, allowing Gimkit to turn modules into global variables and inject modifications into the Gimkit web client.

Think of it as replacing the add function with something entirely different when it tries to use it. ;)

Also, keep in mind that this is all done client-side, so it doesn't touch anything on Gimkit's servers. **Your mods only are only on your client unless you share them and someone else installs it on their client.**

As for the desktop app part... that's just done with Electron.


# Mac

### How to Install Gimhook

Gimhook desktop is the way you will run your mods, but it has several things that you need to download for it to work. Install all of the items listed below:

&#x20;<https://nodejs.org/en/download>&#x20;

<https://git-scm.com/downloads>&#x20;

After those have been installed, open the command prompt and navigate to a folder that is not in iCloud Drive. You can do this by typing `cd <folder path here` . Then, run the command `git clone` [`https://github.com/gimhook/gimhook.git`](https://github.com/gimhook/gimhook.git) . Now, type the following command: `bash ./scripts/build.sh/.`. Gimhook is now installed!

### How to Install a Mod

Open up Git Bash, and use `cd path_here` to get to the gimhook folder. Then, run the command `bash ./scripts/run.sh --debug-mode`. This will launch the Gimhook app, and you will be prompted to log in. Once you log in, you need the code for the mod you want to run. Visit the [GimForge mods](/gimforge-mods/enhanced-movement) section to see which mods are available for use. Once you copy a mod's code, go to the side of the screen, where there is a weird sidebar with a bunch of code-looking stuff. At the top, there are a few tabs. One of them is named console. Click on that. Then, click on the creative games button (left side of the screen). Now you have to be very fast for this step. Click on the creative map you want to load and then paste your code into the sidebar on the right as fast as possible. If you were fast enough, when the game loads, test your mod. Depending on which mod you installed, the mod should run correctly!


# Windows & Linux

### How to Install Gimhook

Downloading gimhook just got 3000% easier! First, download the release for your operating system from here: <https://github.com/gimhook/gimhook/releases/tag/0.0.1> Then, extract the zip file and look inside the extracted files for "gimhook.exe". If an error pops up, wait a minute and run it again!

### How to Install a Mod

First, you need a mod file. Visit the [GimForge mods](/gimforge-mods/enhanced-movement) section to find one. Download the mod file, and open the gimhook app. Click "Mods". In the mods menu, click install, and select the mod file you just downloaded! Then go back to the gimhook home page, and click "Join Game" or "Dashboard" to go to where you want to go!


# Gimhook Documentation

**NOTE: This page is about the creation of mods. If you want to learn more about the mods available on GimForge, visit the** [**mods**](/gimforge-mods/enhanced-movement) **section.**

### Documentation Pages

* [Gimhook API](/creating-mods/api)
* [Gimhook Hooks](/creating-mods/hooks)

### What Gimhook is and isn't

**What it is:**

* A modloader and desktop app for Gimkit
* A simple API for building Gimkit mods
* Designed for improving the Gimkit Creative map editor

**What it isn't:**

* Useful for cheating
* A tool for using custom assets in Gimkit Creative
* Built for non-2D gamemodes

### Why not custom assets?

There are 2 reasons, one being technical, and another being non-technical.

The first reason is that the modloader loads mods as javascript files, and doesn't have a way (other than base64 URLs, but that would destroy the file size of mods) to load any mod assets.

The second reason Josh himself has even told me (and I agree with) is that it could lead to seriously problematic assets being used. Team Fortress 2 has suffered from this problem already with its custom image features.


# Hooks

The hook types mentioned below can be used to hook into specific parts of the game with callback functions.

`internal` hooks are only meant to be used internally. **Do not use them.** They are only included here for reference.

All of these hooks can be used via `gimhook.addHook` - Look at the API documentation for more information.

### require

Module: `parcel`\
Type: `internal` Callback arguments: `string` (name)\
Callback output: `Module | undefined` (not sure if this the real type name)

`require()` hooks are used to intercept and modify javascript modules used within Gimkit.

Don't use this in your mods, this isn't meant for that.

### message

Module: `game`\
Type: `external` Callback arguments: `string` (message type), `any` (data)\
Callback output: `boolean | undefined` (if the function returns true, other handlers are skipped)

Used for intercepting colyseus messages. **Currently broken.**

### join

Module: `game`\
Type: `external` Callback arguments: N/A\
Callback output: N/A

Used to allow mods to handle joining a game with custom code.


# API

All APIs mentioned below are in the global scope.

If you need to use React, it's included in the global scope - You can just use the `React` variable anywhere.

**NOTE**: The Gimhook SDK currently isn't able to replace React imports in mods with a wrapper for the global variable. Please don't import it.

### gimhook.getHooks

Module: `core`\
Type: `Function`\
Input type: `string` (name)\
Output type: `string[]`

`gimhook.getHooks` is used to get all of the hook callbacks, given a hook name.

### gimhook.addHook

Module: `core`\
Type: `Function`\
Input type: `string` (name), `Function` (callback)\
Output type: N/A

`gimhook.addHook` is used to add a callback function to a hook, which is called whenever the hook is triggered.

See the documentation page on hooks for more information.

### gimhook.onJoin

Module: `core`\
Type: `Function`\
Input type: `Function` (callback)\
Output type: N/A

`gimhook.onJoin(handler)` is a synonym for `gimhook.addHook("join", handler)`.

### gimhook.game.isGameActive

Module: `game`\
Type: `boolean`\
Input type: N/A\
Output type: N/A

`gimhook.game.isGameActive` is used to determine when a game is currently active.

### gimhook.game.is2DGamemode

Module: `game`\
Type: `boolean`\
Input type: N/A\
Output type: N/A

`gimhook.game.is2DGamemode` is used to determine if the active gamemode (if any) is a 2D gamemode.

### gimhook.graphics.player.getPlayer

Module: `core`\
Type: `Function`\
Input type: N/A\
Output type: Player (I don't know the TypeScript type for it)

`gimhook.graphics.player.getPlayer` is used to get the currently active player.

### gimhook.graphics.player.getPosition

Module: `core`\
Type: `Function`\
Input type: N/A\
Output type: Position (I don't know the TypeScript type for it)

`gimhook.graphics.player.getPosition` is used to get the position of the currently active player.

### gimhook.graphics.player.setPosition

Module: `core`\
Type: `Function`\
Input type: `number` (x), `number` (y)\
Output type: N/A

`gimhook.graphics.player.setPosition` is used to set the position of the currently active player.

NOTE: No, you can't use this to teleport around the map and cheat. It is useless unless you're in the creative map editor.

### gimhook.graphics.camera.getCamera

Module: `core`\
Type: `Function`\
Input type: N/A\
Output type: Camera (I don't know the TypeScript type for it)

`gimhook.graphics.camera.getCamera` is used to get the currently active camera.

### gimhook.graphics.camera.getZoom

Module: `core`\
Type: `Function`\
Input type: N/A\
Output type: `number`

`gimhook.graphics.camera.getZoom` is used to get the zoom value of the currently active camera.

### gimhook.graphics.camera.setZoom

Module: `core`\
Type: `Function`\
Input type: `number` (zoom)\
Output type: N/A

`gimhook.graphics.camera.setZoom` is used to set the zoom value of the currently active camera.


# SDK Documentation

Coming soon!


# Enhanced Movement

This mod was created by @Coder\_Gage.

## Source Code (V1.0.0)

<details>

<summary><a href="https://cdn.discordapp.com/attachments/1119585136913162240/1119585137051582464/enhancedmovement.js">EnhancedMovement.js</a> (Click Link to Download)</summary>

```javascript
// gimhook: {"name":"Enhanced Movement","description":"A mod to easily move in bigger jumps around the map, and through walls.","version":"1.0.0","author":"Coder_Gage","license":"MIT"}
(() => {
    // src/index.ts
    gimhook.addHook("join", () => {
      console.log("Game joined!");
      console.log("Thanks for Using My Mod!")
      console.log("-Coder_Gage")
  
      x = 0
      y = 0
      xy = 0

      moveValue = 100

      window.addEventListener("keydown", function(event) {
        if(event.code == 'KeyA' && event.shiftKey) {
            if(x > 100) {
            gimhook.graphics.player.setPosition(x-moveValue, y)
            } else {
                console.log("To Far Left!")
            }
        }
        if(event.code == 'KeyD' && event.shiftKey) {
            if(x < 31900) {
            gimhook.graphics.player.setPosition(x+moveValue, y)
            } else {
                console.log("To Far Right!")
            }
        }
        if(event.code == 'KeyW' && event.shiftKey) {
            if(y < 31900) {
            gimhook.graphics.player.setPosition(x, y-moveValue)
            } else {
                console.log("To Far Up!")
            }
        }
        if(event.code == 'KeyS' && event.shiftKey) {
            if(y > 100) {
            gimhook.graphics.player.setPosition(x, y+moveValue)
            } else {
                console.log("To Far Down!")
            }
        }
        if(event.code == 'KeyR' && event.shiftKey) {
            gimhook.graphics.player.setPosition(16000, 16000)
        }
      });  

      setInterval(function getpos() {
        xy = gimhook.graphics.player.getPosition();
        x = xy['x'];
        y = xy['y'];
    }, 2)

    });
})();
```

</details>

## How to Use It

After installing the mod, hold the shift key while using `WASD` to move around in bigger jumps. View the [customizability ](#customizability)section to learn how you can customize this mod to your liking.

## Customizability

This mod has multiple customizable options.

{% tabs %}
{% tab title="moveValue" %}
This is a variable defined at the beginning of the code. Customize it to change how far you move each time you jump around. The default value is `100`, but you can change it to `250` if you want to move around in bigger jumps.
{% endtab %}

{% tab title="Keybinds" %}
Holding `shift` while using `WASD` activates the jumps. I recommend keeping the shift required but feel free to change `WASD` to other keys. You can use [this](https://www.toptal.com/developers/keycode)[ website](https://www.toptal.com/developers/keycode) to figure out each key value. For example, if you prefer to use the arrow keys to move around, you can change `KeyA` to `ArrowLeft`, and repeat for each key.
{% endtab %}
{% endtabs %}

## Changelog

<table><thead><tr><th>Version</th><th>Changes</th><th data-hidden></th></tr></thead><tbody><tr><td>v1.0.0</td><td>Created the actual mod with <code>WASD</code> "jumped" movement.</td><td></td></tr></tbody></table>


# ClickTP

This mod was created by @Blackhole927.

## Source Code (V1.0.0)

<details>

<summary><a href="https://cdn.discordapp.com/attachments/1119691421734154332/1119691421977432205/ClickTP.js">ClickTP.js</a> (Click Link to Download)</summary>

```javascript
// gimhook: {"name":"ClickTP","description":"A mod that lets you teleport to where you shift-click!","version":"1.0.0","author":"Blackhole927","license":"MIT"}
(() => {
  gimhook.addHook("join", () => {
      console.log("Game joined!")
      console.log("Test...")
      var w = 0
      var h = 0
      var clickTPon = false;
      onmousemove = function(e) {
          w = window.innerWidth
          h = window.innerHeight
          mouseX = e.clientX
          mouseY = e.clientY
          mouseX -= w/2
          mouseX = mouseX/(w)
          mouseY -= h/2
          mouseY = mouseY/h
          zoom = gimhook.graphics.camera.getZoom()
          zoom = 1/zoom
          mouseX *= zoom
          mouseY *= zoom
          mouseX *= 2
          mouseY *= 2

      }
      onmousedown = function(e) {
          if (e.shiftKey) {
              xy = gimhook.graphics.player.getPosition()
              xy["x"] += mouseX*(w/2)
              xy["y"] += mouseY*(h/2)
          }

          gimhook.graphics.player.setPosition(xy["x"], xy["y"])
      }
  });
})();
```

</details>

## How to Use It

After installing the mod, hold down `SHIFT` while clicking with your mouse. You will move in the direction of your mouse.

## Changelog

| Version | Changes                                        |
| ------- | ---------------------------------------------- |
| v1.0.0  | Added shift-click teleportation functionality. |


# Better Zoom

This mod was created by @Blackhole927.

## Source Code (V1.0.1)

<details>

<summary><a href="https://cdn.discordapp.com/attachments/1119691275474567219/1119691276040810606/BetterZoom.js">BetterZoom.js</a> (Click Link to Download)</summary>

```javascript
// gimhook: {"name":"BetterZoom","description":"A mod that lets you zoom out a bit more than usual...use the scroll wheel to zoom!","version":"1.0.1","author":"Blackhole927","license":"MIT"}
(() => {
  // src/index.ts
  gimhook.addHook("join", () => {
    tZoom = 1
    cZoom = gimhook.graphics.camera.getZoom()


    setInterval(function x() {
        cZoom = tZoom - (tZoom-cZoom)/1.25
        gimhook.graphics.camera.setZoom(cZoom)
    }, 0.25)

    window.addEventListener("wheel", function(e) {
        var dir = Math.sign(e.deltaY);
        if (dir == 1) {
            if (tZoom > 0.1) {
                tZoom -= 0.1
            }
        } else {
            tZoom += 0.1
        }
    });

    console.log("BetterZoom Mod Loaded");
  });
})();
```

</details>

**NOTE:** Older versions of mods are currently not available on this site. However, you can view them in the `usable-mods` channel of our discord.

## How to Use It

After installing the mod, scroll up or down on your mouse or trackpad to zoom in and out. View the [customizability](#customizability) section to see how you can customize this mod.

## Customizability

{% tabs %}
{% tab title="Zoom Amount" %}
Change `0.1` to a bigger or smaller number to change how much you zoom in or out. However, do **NOT** change the `0.1` located at `if (tZoom > 0.1)` .
{% endtab %}
{% endtabs %}

## Changelog

| Version | Changes                                                                                             |
| ------- | --------------------------------------------------------------------------------------------------- |
| v1.0.0  | Added basic zoom with number keys `1`, `2`, `3`, and `4` .                                          |
| v1.0.1  | Added scroll wheel functionality to zoom in and out using your scroll wheel instead of number keys. |


