Floof Modding API Reference

Welcome, this page aims to make modding floof easier for you! Feel free to spin up a lobby and try this in a split screen as you go through!

Warning:

This API is subject to change at any time. Additionally, the API is not guaranteed to be stable and may result in broken rooms.

Warning:

Only the room owner can run these commands. If you are not the room owner, you will not be able to run these in the room.

Table of Contents

Introduction

In order to start modding you need to be able to access the developer console. If you don't know how to do this, google search "How do I open the developer tools on my browser?", replacing "my browser" with your browser. Once you have the developer console open, you can start running the code below.

Basic Game Structure

The game is made using JavaScript, and you will be interacting with the game's JavaScript in order to mod it. This guide expects you to have a basic overview of JavaScript, and if you don't, you can check out the MDN Web Docs for more in-depth information. The lobby runs in a Web Worker, which is a separate thread from the main thread. This means that you can't directly access the game's JavaScript from the console. Instead, you will be using a custom made socket API which sends commands to and from the main thread, which runs the client. This API is what you will be using to mod the game.

Important JavaScript Concepts

Promises are a way to handle asynchronous code in JavaScript. They are objects that represent the eventual completion or failure of an asynchronous operation and its resulting value. You can read more about them here.

Async/Await is a way to write asynchronous code that looks synchronous. It's a way to write promises in a more readable way. You can read more about them here.

Web Workers are a way to run JavaScript code in a separate thread from the main thread. This is useful for running code that may take a long time to run, as it won't block the main thread. You can read more about them here.

Broadcast Channel is a way to communicate between different windows or tabs, or in our case, the lobby Web Worker. You can read more about them here.

Websocket is a way to communicate between the client and the server. In our case, you will establish connection between a lobby server which routes packets between clients and lobbies. You can read more about them here.

Warning:

The rest of this guide will assume you have a basic understanding of JavaScript syntax, and the concepts above. If you don't, you may have a hard time understanding what the code and responses below do or mean. It is up to you to learn these concepts before continuing. We are not responsible for teaching basic JavaScript.

Synchronous Information

The synchronous information is the information that will be returned instantly. This information is stored in the client, and therefore has no need to return an asynchronous response.

Getting a Petal's Index

This function will return the index of the petal whose name you've provided. If the petal doesn't exist, it will return -1. You should use this index to pass to other functions that require a petal index, however recent support has been added that lets you directly pass the petal's name into it.

 

Getting a Mob's Index

This function will return the index of the mob whose name you've provided. If the mob doesn't exist, it will return -1. You should use this index to pass to other functions that require a mob index, however recent support has been added that lets you directly pass the mob's name into it.

 

Getting a Tier's Index

This function will return the index of the tier whose name you've provided. If the tier doesn't exist, it will return -1. You should use this index to pass to other functions that require a tier index, however recent support has been added that lets you directly pass the tier's name into it.

 

Next Available Indices

These two functions will return the next available petal and mob indices. This is useful for adding custom petals and mobs, as you can use these indices to prevent collisions between your custom petals and mobs and the preexisting ones. These numbers will always be different as new petals and mobs are added to the game.

 

Help

While this function doesn't do anything or have any arguments, it will open a new tab in your browser to this page.

 

Warning:

The rest of the functions are not synchronous and will return a promise. This means that you will need to use the .then() function to access the data. You can also use the async/await syntax to make the code look cleaner in a top-level async function. If you need more information on promises, you can check out the MDN Web Docs. More information on async/await can be found here.

The response will contain an "ok" field that will be true if the request was successful and false if it was rejected. The "message" field will contain a message that will help you understand why the request was rejected, or if it was successful. The "data" field will contain the data you requested if the request was successful. It may be in many different forms. Your responses wil allmost always look something like this:

 

Get Players

This function's response's data section will contain an array of all the players in the room.

 

The response will look like this:

 

Get Mobs

This function's response's data section will contain an array of all the mobs in the room.

 

The response will look like this:

 

Spawn Mob

This function will spawn a mob in the room. The response will contain the mob that was spawned. You must provide two arguments, the index and the rarity ID. They must both be valid numbers in the index and rarity ranges respectively. If you don't want to remember the index and rarity ID, you can use the Synchronous Functions to get them, or, with recent support, simply provide the mob's name and rarity name.

 

The response will look like this:

 

Spawn AI Flower

This function, much like the spawnMob function, spawns an AI Flower in the room. The response will contain the AI Flower that was spawned. There are two arguments that are required: the rarity of the AI Flower's petals, and the AI Flower's level.

 

The response will look like this:

 

Get Room Info

This function will return the room info. The response will contain the room info.

 

The response will look like this:

 

Set Room Info

This function will set the room info. The response will contain the room info. You must weather the room's sizing is dynamic or static. If the room is dynamic, the room will resize to fit the number of players, and the mob cap will be automatically adjusted as well. If the room is static, the room will not resize, and the mob cap will not be adjusted.

If the supplied first argument is "false" (static), then the second and third arguments are the room width and height respectively. The fourth argument is the mob cap, and the fifth argument is the wave to set (required, but doesn't work in gamemodes other than waves).

 

The response will look like this:

 

Get Petal Info

This function will return the petal info. The response will contain the petal info. Provide the petal's index or direct name to get the petal's info. The response will contain the PetalConfig object of the petal you requested if successful.

 

The response will look like this:

 

Add Custom Petal

This function will add a custom petal to the room. The response will contain the PetalConfig object of the petal you just created if successful. All arguments in the constructor are required. Because it's a new petal, you must provide a drawing object as described below. Additional information is provided as of use cases. In order to give good drawings, please read up on the HTML Canvas API

Here are the default parameters for the petal options:
 

 

The response will look like this:

 

Edit Petal

This function will edit a custom petal in the room. The response will contain the PetalConfig object of the petal you just edited if successful. You should use an existing petal config retrieved by either the creation of a custom petal, or the fetching of another existing petal. Only what you change will be applied.

 

The response will look like this:

 

Delete Petal

This function will delete a custom petal in the room. The response will tell you if you were successful or not.

 

Set Slot

This function will set the slot of a player. The response will contain the player that was modified. You must provide four arguments: clientID, slotID, index, rarity. The clientID is the ID of the player you want to modify. The slotID is the slot you want to modify. The index is the index of the petal you want to set. The rarity is the rarity of the petal you want to set. If you don't want to remember the index and rarity ID, you can use the Synchronous Functions to get them.

 

The response will look like this:

 

Set Slot Amount

This function will set the amount of slots a player has. The response will contain the player that was modified. You must provide two arguments: clientID, amount. The clientID is the ID of the player you want to modify. The amount is the amount of slots you want to set.

 

The response will look like this:

 

Quickly Setting Slots

Warning:

Because this is asynchronouse, we must first set the amount of slots, then set the slots. This is because if we don't wait for the first request to finish, the second requests may not be supported in their index bounds.