Skip to content

BlxCode/Bloxd.io-API

 
 

Repository files navigation

Readme

Note

This is not the official documentation and is not edited or run by any of Bloxd.io's Devs, this is ment to be an additional resource to the official documentation.

Warning

This repository may contain out-of-date or incorrect information at times, but the maintaners will try to keep this as up-to-date and correct as they can.

Tip

Find information that you think should be added or changed? Create a pull request!

You can run JavaScript when right clicking code blocks and press to code boards. This is only available to owners of worlds lobbies. The JavaScript can interact with the Bloxd.io game api.

Please use Bloxd.io's official discord server to report any issues you come across or features you'd like to see added. Please create a pull request if you notice incorrect, or missing information in this version of the documenation.

Code Blocks

  • World owners can find these by searching in the creative menu
  • No need to add press to code, this text is only needed for code boards, and will automatically be removed
  • If you want to run code without opening the code editor, you can trigger the code block by right clicking an adjacent press to code board instead
  • Code Blocks can not use callbacks cause Code Blocks only run when pressed

World Code

  • World owners can access the World code editor by pressing F8 or by clicking the World Code button in the Code Block editor
  • Like Code Blocks there is no need to add press to code
  • Unlike Code Blocks, World Code can contain callbacks and will run the code inside of a callback when the callback is triggered
  • There is no way to trigger a Code Block or sign from World Code

Boards

  • You can begin a board with press to code to run javascript when you right click it.
  • Normally you can't edit a code board after placing it, but you can currently work around this by putting a space before press to code.
  • Boards only allow for a small amount of text, we recommend you use Code Blocks instead, or you can work around this by using multiple boards

Notes

  • Global variable myId stores the player ID of who is running the code, it can not be used in World code.
  • Global variable thisPos stores the position of the currently executing code block or press to code board, it can not be used in World code.
  • You can use api.log or console.log for printing and debugging (they do the same thing).
  • You can use Date.now() instead of api.now() if you prefer, both return the time in milliseconds.
  • Comments like /* comment */ and // comment work.
  • World Code and Code Blocks are limited to 16,000 charecters including spaces and returns. The code editor is 80 charecters wide.
  • The JavaScript var variable can be called from World Code, Code Blocks, and Boards, regardless of which ones it is defined in. (Note though that if it is placed in a Code Block or Board that it must be executed before the variable can be used.)

Note

The official documentation will say that // comments will not work, but that is incorrect as they now work.

About this repository

This was created because the original documentation was not well explained or organized and lacked information that many people agreed would be helpful. So here it is, it's not perfect, but it contains more information then the original documentation. There may from time to time be errors in the documenation and it may lack newer information. That's why it's highly recomended that if you notice that there's missing information or that there's an error somewhere that you create a pull request. Also if you think that you have information that may be helpful to new coder that you create a pull request to add it here under the Information header. You will find that most of the files here are not formated the same as the original documentation, this is on purpose so that it's easier to search through for the information you want.

Information

Note

This section needs information, please create a pull request if you have information for this section.

FAQ

Q: What is the playerId in functions and callbacks?
A: It is field that contains the Id of a player. In Code Blocks and Press to Code signs it can contain the varible myId which will return the Id of the player that activated the code. In World Code though myId doesn't work cause code gets activated by callbacks. So instead in the playerId field in the callback we can place somthing like pId and that will define pId as the playerId of the player that triggered that callback. So we would can then place pId in to the playerId field in functions in that callback.

Q: Where can I use callbacks?
A: You can only use callbacks in World Code cause Code Blocks and Press to Code signs only get activated when a player presses them.

Q: What is the difference between World Code and Code Blocks?
A: World Code runs all the time and when a callback in World Code get triggered it runs the code in that callback. Code Blocks though only get triggered when a player presses them or a sign next to them gets triggered. But World Code is limited to 16,000 characters (including spaces) and you can only have one World Code for each world. But even though Code Blocks are also limited to 16,000 characters as well, you can have an unlimited amount of them.

About

A more fleshed out version of the original API documentation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published