# API Reference, part 4 of 5

Part 4 of 5 of [API Reference](https://bloxd.io/docs/api-reference.md). It covers progressBarUpdate to setCurrencyAmount. [llms.txt](https://bloxd.io/docs/llms.txt) lists every part.

## progressBarUpdate
Update the progress bar in the bottom right corner.

Can be queued.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| toFraction | `number` | The fraction of the progress bar you want to be filled up. |
| toDuration | `number` | The time it takes for the bar to reach the given toFraction in ms. If this is too low and you queue multiple updates, this toFraction could be skipped. Treat 200ms as a minimum. |

## queueCrosshairText
Schedule text to be displayed in the crosshair.

This text will be removed after the duration.

Stacking queued texts will schedule them to be displayed one after the other.

NOTE: Overriding the crosshairText client option may cause queued texts to be displayed incorrectly.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` | The ID of the player to display the text to. |
| text | `string \| CustomTextStyling` | The text to display. |
| duration | `number` | The duration of the text in milliseconds. |



### Returns:
`QueuedCommandId`

 

The ID of the queued command.

## queueMiddleTextLower
Schedule small text to be displayed in the middle of the screen (middleTextLower).

This text will be removed after the duration.

Stacking queued texts will schedule them to be displayed one after the other.

NOTE: Overriding the middleTextLower client option may cause queued texts to be displayed incorrectly.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` | The ID of the player to display the text to. |
| text | `string \| CustomTextStyling` | The text to display. |
| duration | `number` | The duration of the text in milliseconds. |



### Returns:
`QueuedCommandId`

 

The ID of the queued command.

## queueMiddleTextUpper
Schedule large text to be displayed in the middle of the screen (middleTextUpper).

This text will be removed after the duration.

Stacking queued texts will schedule them to be displayed one after the other.

NOTE: Overriding the middleTextUpper client option may cause queued texts to be displayed incorrectly.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` | The ID of the player to display the text to. |
| text | `string \| CustomTextStyling` | The text to display. |
| duration | `number` | The duration of the text in milliseconds. |



### Returns:
`QueuedCommandId`

 

The ID of the queued command.

## raycastForBlock
Raycast for a block in the world.

Given a position and a direction, find the first block that the "ray" hits.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| fromPos | `number[]` |  |
| dirVec | `number[]` |  |



### Returns:
`BlockRaycastResult`

## removeAppliedSkin
Remove gamemode-applied skin from a player

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |

## removeEffect
Remove an effect from a lifeform.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| lifeformId | `LifeformId` |  |
| name | `string` |  |

## removeFollowingEntityFromPlayer
Remove following entity from an entity

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `EntityId` |  |
| entityEId | `EntityId` |  |

## removeFromQueue
Remove a queued command from the queue.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| id | `QueuedCommandId` | The ID of the queued command to remove. |

## removeItemCraftingRecipes
Removes crafting recipes

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| itemName | `PNull<string>` | Removes all crafting recipes for the given player if null, otherwise removes the crafting recipes for the given item. |

## removeItemName
Remove an amount of item from a player's inventory

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| itemName | `ItemName` |  |
| amount | `number` |  |

## removeItemNameFromStandardChest
Remove an amount of item from a standardChest inventory

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| chestPos | `number[]` |  |
| itemName | `ItemName` |  |
| amount | `number` |  |
| playerId | `PlayerId` | The player who is interacting with the chest. |

## removeMiddleScreenBar
If there is any current middle screen bar running, this will hide it

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |

## resetCanChangeBlock
Remove any previous can/cant change block settings for a player at a specific co-ordinate

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| x | `number` |  |
| y | `number` |  |
| z | `number` |  |

## resetCanChangeBlockRect
Remove any previous can/cant change block rect settings for a player

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| pos1 | `number[]` |  |
| pos2 | `number[]` |  |

## resetCanChangeBlockType
Remove any previous can/cant change block type settings for a player

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| blockName | `BlockName` |  |

## resetCanPickUpItem
Reset a player's ability to pick up an item. itemId returned by createItemDrop

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| itemId | `EntityId` |  |

## resetItemCraftingRecipes
Reset the crafting recipes for a given back to its original bloxd state

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| itemName | `PNull<string>` | Resets all crafting recipes for the given player if null, otherwise resets the crafting recipes for the given item. |

## resetShopItemForPlayer
Delete a specific player's overrides for a shop item.

Like other methods, it doesn't matter whether the overrides were created

using createShopItemForPlayer or by using updateShopItemForPlayer instead.

This method does nothing if the overrides don't exist or are defined internally by the engine.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` | The player to reset the item for |
| categoryKey | `ShopCategoryKey` | The key of the category containing the item |
| itemKey | `ShopItemKey` | The unique key for the item |

## scalePlayerMeshNodes
Set an entity's meshScaling setting by 3d vector. Model node scaling is applied to lifeforms;

for mesh entities, this setting affects nametag placement and interaction reach, not the model's nodes.

State from prior calls to this api is lost so if you want to have multiple nodes scaled, pass in all the scales at once.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `EntityId` |  |
| nodeScales | `EntityMeshScalingMap` |  |

## sendFlyingMiddleMessage
Send a flying middle message to a specific player

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` | Id of the player |
| message | `string \| CustomTextStyling` | The text contained within the message. Can be either a string or use `Custom Text Styling`. |
| distanceFromAction | `number` | The distance from the action that has caused this message to be displayed, this value will be used to determine how the message flies across the screen. |
| lifetimeMs | `number` | How long the message will be visible in milliseconds. Defaults to 1000ms. |

## sendHitmarker
Show a hitmarker on the player's screen (the X-shaped crosshair flash indicating a successful hit).

Useful for custom weapons or things that need visual hit feedback.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` | The player to show the hitmarker to |
| isCrit | `boolean` | If true, shows an enhanced critical-hit hitmarker with a longer, more dramatic animation |
| directionVector | `PNull<number[]>` | Optional [x, y, z] direction vector. When provided, the hitmarker appears at the projected screen position of that direction rather than at the centre of the screen. Same flow as mobile melee attacks where the tap point differs from screen centre. |

## sendMessage
Send a message to a specific player

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` | Id of the player |
| message | `string \| CustomTextStyling` | The text contained within the message. Can use `Custom Text Styling`. |
| style | ` { fontWeight?: number \| string; color?: string } ` | An optional style argument. Can contain values for fontWeight and color of the message. style is ignored if message uses custom text styling (i.e. is not a string). |

## sendOverShopInfo
Show a message over the shop in the same place that a shop item's onBoughtMessage is shown.

Displays for a couple seconds before disappearing

Use case is to show a dynamic message when player buys an item

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| info | `string \| CustomTextStyling` |  |

## sendTopRightHelper


### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| icon | `string` | Can be any icon from font-awesome. |
| text | `string` | The text to send. |
| opts | ` { duration?: number width?: number height?: number color?: string iconSizeMult?: number textAndIconColor?: string fontSize?: string } ` | Can include keys duration, width, height, color, iconSizeMult.  Default opts: { duration: 8, // seconds width: 400px, height: 100px, color: 'rgb(102, 102, 102)', // must be rgb in this format (hex not supported), iconSizeMult: 5, textAndIconColor: "white", // can be any colour supported by css (e.g. hex, rgb), fontSize: '17px', } |

## setAuraLevel
Set the aura level for a player - shortcut for setTotalAura(level * auraPerLevel)

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| level | `number` |  |

## setBlock
Set a block. Valid names are any block name, including 'Air'



This function is optimised for setting broad swathes of blocks. For example, if you have a 50x50x50 area you need to turn to air, it will run performantly if you call this in double nested loops.



IF you're only changing a few blocks, you want this to be super snappy for players, AND you're calling this outside of your _tick function, you can use api.setOptimisations(false).



If you want the optimisations for large quantities of blocks later on, then call api.setOptimisations(true) when you're done.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| x | `number \| number[]` | Can be an array |
| y | `number \| BlockName` | Should be blockname if first param is array |
| z | `number` |  |
| blockName | `BlockName` |  |

## setBlockData
Store data about a block in a performant manner. Data is cleared when block changes.

E.g. chest

Works well with blocks marked tickable (e.g. wheat)

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| x | `number` |  |
| y | `number` |  |
| z | `number` |  |
| data | `object` |  |

## setBlockRect
Helper function that sets all blocks in a rectangle to a specific block.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| pos1 | `number[]` | array [x, y, z] |
| pos2 | `number[]` | array [x, y, z] |
| blockName | `BlockName` |  |

## setBlockWalls
Create walls by providing two opposite corners of the cuboid

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| pos1 | `number[]` | array [x, y, z] |
| pos2 | `number[]` | array [x, y, z] |
| blockName | `BlockName` |  |
| hasFloor | `boolean` |  |
| hasCeiling | `boolean` |  |

## setCallbackValueFallback
Set a default value to be returned by your callback code if it throws an error.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| cbName | `UserCallbacks` | The name of the callback to set the default value for. |
| value | `any` | The default value to return. |

## setCameraDirection
Set the direction the player is looking.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| direction | `number[]` | a vector of the direction to look, format [x, y, z] |

## setCameraZoom
Set camera zoom for a player

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| zoom | `number` |  |

## setCanChangeBlock
Let a player change a block at a specific co-ordinate. Useful when client option canChange is false.

Overrides blockRect and blockType settings, so also useful when you have disallowed changing of a block type with setCantChangeBlockType.

Using this on 1000s of blocks will cause lag - if that is needed, find a way to use setCanChangeBlockType.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| x | `number` |  |
| y | `number` |  |
| z | `number` |  |

## setCanChangeBlockRect
Make it so a player can Change blocks within two points. Coordinates are inclusive. E.g. if [0, 0, 0] is pos1

and [1, 1, 1] is pos2 then the 8 blocks contained within low and high will be able to be broken.

Overrides setCantChangeBlockType

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| pos1 | `number[]` | Arg as [x, y, z] |
| pos2 | `number[]` | Arg as [x, y, z] |

## setCanChangeBlockType
Lets a player Change a block type. Valid names are any block name, including 'Air'

Less priority than cant change block pos/can change block rect

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| blockName | `BlockName` |  |

## setCantChangeBlock
Prevents a player from changing a block at a specific co-ordinate. Useful when client option canChange is true.

Overrides blockRect and blockType settings, so also useful when you have allowed changing of a block type with setCantChangeBlockType.

Using this on 1000s of blocks will cause lag - if that is needed, find a way to use setCantChangeBlockType.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| x | `number` |  |
| y | `number` |  |
| z | `number` |  |

## setCantChangeBlockRect
Make it so a player cant Change blocks within two points. Coordinates are inclusive. E.g. if [0, 0, 0] is pos1

and [1, 1, 1] is pos2 then the 8 blocks contained within pos1 and pos2 won't be able to be broken.

Overrides setCanChangeBlockType

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| pos1 | `number[]` | Arg as [x, y, z] |
| pos2 | `number[]` | Arg as [x, y, z] |

## setCantChangeBlockType
Stops a player from changing a block type. Valid names are any block name, including 'Air'

Less priority than can change block pos/can change block rect

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| blockName | `BlockName` |  |

## setCantPickUpItem
Prevent a player from picking up an item. itemId returned by createItemDrop

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| itemId | `EntityId` |  |

## setChunkAsSchematic
Replace a world chunk with a chunk from a project schematic, including air and block data.

Both positions are block coordinates selecting their containing 32-block chunk.

Add schematics in the Code Editor. Missing paths or source chunks throw an error.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| schematicPath | `string` | Project-relative path, including .bloxdschem. |
| srcCoords | `[number, number, number]` | Block coordinates in the schematic's chunk grid (including selection padding). |
| destCoords | `[number, number, number]` | Block coordinates in the world. Existing blocks are replaced without break drops. |

## setClientOption
Modify a client option at runtime and send to the client if it changed

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| option | `PassedOption` | The name of the option |
| value | `ClientOptions[PassedOption]` | The new value of the option |

## setClientOptions
Modify client options at runtime

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| optionsObj | `Partial<ClientOptions>` | An object which contains key value pairs of new settings. E.g {canChange: true, speedMultiplier: false} |

## setClientOptionToDefault
Sets a client option to its default value. This will be the value stored in your game's defaultClientOptions, otherwise Bloxd's default.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| option | `ClientOption` |  |

## setCurrency
Dynamically define a currency for a player and show it on the HUD.

Amounts will persist between sessions if `persistent` is set to true.

Persistent currencies count towards db length limits.



Example usage:

```js
api.setCurrency(myId, "myCurrency", { amount: 100, icon: "coins", iconColour: "blue", persistent: true })
```

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| currencyId | `string` |  |
| info | `UgcCurrencyInfo` |  |

## setCurrencyAmount
Set the amount of a currency a player has. For persistent currencies, amount/subtext count towards db length limits.

### Parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| playerId | `PlayerId` |  |
| currencyId | `string` |  |
| amount | `number` |  |
| subtext | `string \| CustomTextStyling` |  |
