Skip to content

Blobs Modding

To see the Github Repo Page, click here!

Blobs can be modded with either JSON or lua, through their respective "main" folders. The documentations will teach you how to edit the game via these methods.

JSON Modding

In the "mods" folder, where your Blobs.exe file resides, you will find "main.json". This is used for modifiying the game's basic behaviours without any special logic. It can be used along side main.lua, though main.lua always overrides settings applied by main.json, so be aware.

There are three class types you can modify as of now:

- player
- bots
- world

You modify them like this:

main.json
1
2
3
4
5
6
7
8
{
    "enabled" : true,
    "main" : {
        "e1" : ["player", "walkspeed", "10"],
        "e2" : ["bots", "amount", "10"],
        "e3" : ["world", "realm", "1"]
    }
}
NOTE: It doesn't have to be "e1", it can be anything you desire.

This is called the editing property.

You may see that in e1, after "player" it says "walkspeed": this is called the change property. It tells the parser what to change about the editing property.

The change property varies by editing property. For the player class, there is:

- max_blob_size (integer)
- max_blob_size_can_change (string ["true"/"false"])
- blob_size (integer) (to be set after max_blob_size)
- walkspeed (int)
- name (string)
- color (string (hex))
- shift_buff (int) (controls the buff you get after holding shift to sprint)

For the bots class, it is:

- max_blob_size (integer)
- blob_size (integer) (to be set after max_blob_size)
- walkspeed (int)
- name (string)
- color (string (hex))

For the world class, it is:

- realm (int, from 0 - 1)
- music (string (relative path))

After walkspeed in e1, you can see 10. This is the controller property. It tells the parser the value to set change property to in the game's memory.

Lua Modding

Now, onto Lua Modding.

Lua Modding is more complicated as not only is it the younger of the two systems, but it also has more functions. First, I recommend you learn lua before reading on, as well as optionally getting the lua compiler for your system. Now that you are ready, let's begin!

Task Library

The task library is a small library of general tasks. Currently, it contains two functions:

- task.sleep(x : integer)
- task.spawn(x : function)

The first function, task.sleep(x), pauses the current thread for x seconds before resuming. Note: this pauses the current frame you are on if called in the main game loop.

The other function, task.spawn(x), creates a new thread in which it runs x (a function) in. This is useful for creating asynchronous-like functions.

Game Library

The game library is responsible for all game related functions and sub-libraries. The game library features the following functions:

- game.time()
- game.isPaused()
- game.pause()
- game.spawn_food(x : integer)

The first function, game.time(), returns the time in seconds since the start of the game.

The second function, game.isPaused(), returns whether if the game is paused or not. This is useful for checking if the game is a menu screen, for instance.

The third function, game.pause(), toggles the game pause mechanic. The last function, game.spawn_food(x), spawns x amount of food on the map.

Input Library

The input library is responsible for all input related functions in the game library. It is a sub-library of game, accessed via game.input

There are several functions in the library:

- game.input.keyPressed(x : integer)
- game.input.keyHeld(x : integer)
- game.input.keyReleased(x : integer)
- game.input.keyFree(x : integer)

The first function, game.input.keyPressed(x : integer), returns whether or not the key (x) has been pressed. The second function, game.input.keyHeld(x : integer), returns whether or not the key (x) has been held. The third function, game.input.keyReleased(x : integer), returns the opposite of keyPressed(). The final function, game.input.keyFree(x : integer), returns whether or not the key is up (the opposite of keyDown()).

World Library

The world library is responsible for all world related functions. It is an independent library.

  • SetDefaultPlayerColor and SetDefaultBotColor set the color of the player/bots, accepting four color values (r, g, b, a).
  • SetPlayerSize and SetBotSize set the size of the player/bots, accepting one integer value (x).
  • SetPlayerMaxSize and SetBotMaxSize set the max size of the player/bots, accepting one integer value (x). This should be called before Set(Player/Bot)Size(x).
  • SetPlayerName sets the name of the player, accepting one string value (s).
  • SetDefaultBotName sets the name of the bots, accepting one string value (s).

  • GetDefaultPlayerColor and GetDefaultBotColor get the color of the player/bots, sending four color values (r, g, b, a).

  • GetPlayerSize and GetBotSize set the size of the player/bots, sending one integer value (x).
  • GetPlayerMaxSize and GetBotMaxSize get the max size of the player/bots, sending one integer value (x).
  • GetPlayerName gets the name of the player, sending back one string value (s).
  • GetDefaultBotName gets the name of the bots, sending back one string value (s).

As of current, these are the built in Libraries in the Lua Modding language for Blobs.

Events

Events are very useful for doing functions when something happens. They are built into the Lua Modding engine. They are callbacks, and are used as below:

main.lua
1
2
3
    function OnPreload()
        print("Preloaded!")
    end

There are just a few events callbacks as of right now:

- function OnPreload() // OnPreload() is called as soon as the game loads.
- function OnLoad() // OnLoad() is called when the game finishes initialising all the variables and OnUpdate() is first called.
- function OnUpdate(dt) // OnUpdate is called on every frame and sends back dt, which representing Delta Time.
- function OnConsume(consumer_id, consumed_id) // OnConsume is called when any blob is consumed, consumerid can be -2 for food, -1 for player or 0 and above for the id of an AI. The same applies for consumedid.
- function OnSplit() // OnSplit is called when a player blob splits. This mechanic is currently under work.