Forum

Notifications
Clear all

MCPE/Bedrock Scoreboard API (ScoreAPI)

McBedrock
(@mcbedrock1)
Illustrious Member Admin

Scoreboard API (ScoreAPI)

 

This behavior pack extends the capabilities of the scoreboard command. You can perform calculations over coordinates, player’s level and game mode. The behavior pack uses smart algorithms, so there is high performance

 

Documentation

First you need to declare objectives x, y, z, ry, rx, level, mode and temp. This is easy to do by entering the command /function scoreapi_init. What are these objectives for?

  • x, y, z — the main coordinates of the player
  • ry, rx — the coordinates of the player’s head rotation. ry — horizontal rotation, from –180 to 180. rx — vertical rotation, from –90 to 90.
  • level — the player’s level
  • mode — the player’s gamemode
  • temp — a temporary objective used in some functions. Changing its value will not have any effect

The syntax of the functions

Functions starting with save_ save the values of the player’s properties to the objectives. For example, function save_level saves the player’s level to the level objective.

Functions starting with set_ set the player’s properties by taking values from objectives.

Functions starting with tp_ teleport the entity using objectives x, y, z, or ry, rx. For example, function tp_x teleports the entity to the x objective. tp_xyz teleports the entity to the x, y, z objectives. “” in the function name means ~ (relative). So tp_-xy means “tp ~x y“, tp_-x-y-z means “tp ~x ~y ~z“, etc.

Functions

There are 65 functions (8 private, 3 system and 51 usable. Usable functions:

  • scoreapi_init — initiates objectives x, y, z, ry, rx, level, mode and temp
  • scoreapi_remove — removes objectives
  • scoreapi_help — outputs information about the functions
  • save_? — saves ? to the objectives. Examples: save_xy (saves x and y coordinates), save_rx (saves rx coordinate), save_mode (saves gamemode)
  • save_all — saves all the coordinates (x, y, z, ry, rx). This function does not save the level and gamemode!
  • tp_? — teleports the entity to ? coordinates. Examples: tp_xz (teleports to x and z), tp_x-yz (teleports to x, ~y and z), tp_-ry (teleports to ~ry)
  • tp_all — teleports the entity to all the coordinates (x, y, z, ry and rx)
  • set_mode — sets the player’s gamemode
  • set_level — sets the player’s level
  • add_levels — adds levels to the player’s level (supports negative values)
  • remove_levels — removes levels from the player’s level (supports negative values)
  • clear_level — sets the player’s level to 0
  • look_xyz — turns the entity to the x, y, z coordinates

Practice

Let’s practice! First, call the scoreapi_init function to add the necessary objectives. Let’s say you want to teleport to the x –35 coordinate. Do /scoreboard players set @s x -35. Then call the tp_x function. Congratulations! You are at the x 35 coordinate!

You have to save your coordinates (including your head rotation). Do /function save_all to save all the coordinates. Done! Now you can view your coordinates by entering /scoreboard players list @s. If you just want to save coordinates without turning, call save_xyz.

You have to teleport 10 blocks up. Do /scoreboard players set @s y 10. Then call the tp_-y function. “-” means ~ (relative).

You have to set your level to a random value from 15 to 35. Do /scoreboard players random @s level 15 35. Then call the set_level function. To save your current level to the level objective, do /function save_level.

Notes

  • When setting the player level, the sound is not played; this was done on purpose. To fix this, do /playsound random.levelup @s ~ ~ ~ 0.75 1
  • I recommend disabling the sendcommandfeedback gamerule before using functions starting with tp_
  • Maximum values: x, z, ry, rz  16777216, y  4096, level  24791, mode  2.
  • You can use my addon in your own projects and edit the functions for your purposes

 

Thank you for using my addon! If you find any bug or error in the text, write in the comments.

 
Changelog
  • Fixed thesave_rxfunction
  • Improved documentation
  • Fixed other minor bugs

creator: coolomet

Downloads

Quote
Topic starter Posted : 24/08/2020 11:53 pm
Share: