Makecode Arcade Mini Extentions/Functions

Hello! I’ve been experimenting with some of makecode arcade’s hidden functions, and I’ve made a list of mini extensions and functions for you to use!


Extentions:

Console Overlay

Screenshot 2023-05-14 at 10-39-22 Topics tagged extension

Description:

Using a built in but hidden feature, this extension displays the system console directly on the screen! It’s extremely helpful when you want to directly get values but don’t want to have to manually click on the console button.

Located in the console category

Blocks:

Note!

The console overlay only saves the messages while it’s on, meaning that previous messages in the console are not displayed.

Example

Output:

Info +

Screenshot 2023-05-14 at 12-55-06 Topics tagged extension

Description:

This extension expands the INFO category, giving you the ability to show/hide the stats, change the life image and customize the stat colors.

Located in the info category

Features:

  • Ability to customize the on-screen life, timer, and score displays.
  • Ability to turn those displays on/off

Blocks:

Screenshot 2023-05-14 at 02-01-44 Microsoft MakeCode Arcade

Display:

  • Turns the display on/off
  • Stats are automatically set to 0 if not previously set

Numbers

  • Returns the value of the property

Color

  • Sets color of the background/text/border

Set Life Image To Image

  • Sets the life icon
  • Recommended icon size: 8x8

Example:

Screenshot 2023-05-14 at 02-05-01 Microsoft MakeCode Arcade

Output:


Functions

String Functions:

Description

These functions are for more advanced uses of strings.


String to uppercase/lowercase

Uppercase:

helpers.stringToUpperCase("lowercase"): void

Lowercase:

helpers.stringToLowerCase("uppercase"): void

String is empty?

Checks if a string is empty, returns true if it is

helpers.stringEmpty("string"): boolean

Replace all

This function finds all instances of to replace in string and replaces them with replace with

helpers.stringReplaceAll("string", "to replace", "replace with"): string

Alternatively you can use stringReplace, but that only replaces the first instance of to replace


Slice

This function gets a substring in string from start to end

helpers.stringSlice("string", start, end): string

Another alternative is helpers.stringSubstr("string", start) , where it gets the letters from start to the end of string


Search Function:

Description:

These functions search for a specific thing by name. Returns null if nothing is found.


Search for song

helpers.getSongByName("mySong")

Search for tilemap

helpers.getTilemapByName("myTilemap")

Search for image

helpers.getImageByName("myImage")

Search for animation

helpers.getAnimationByName("myAnimation")

Search for tile

helpers.getTileByName("myTile")

Thank you to the makecode arcade team for implementing these functions, I’m just showing them to you.
More to come in the future!

6 Likes

This is super cool! I think I’ve found a glitch with the Info+ extension though. When I download the extension, my game won’t start, whether I’m actually using the extension blocks or not. The problem seems to be coming from a duplicate file that already exists in the game. I think if this file is removed in GitHub, the extension will work.

1 Like

Fixed! I deleted the file, but it gave me all sorts of errors so I restored it and it worked!

1 Like

Two More Functions!

1. Rotating An Image

This function rotates an image by degrees

image.rotated(degrees): Image

This is a MUCH better alternative to complicated workarounds.

2. Console Priority

This function adds a listener to the console, meaning that every time that something is logged in the console the code runs.

console.addListener((priority, text) => void): void

This code seems very complicated, so let me break it down for you.

  1. (priority, text)
    These are basically variables to use later on in the code, which means we shouldn’t edit them.

    priority is the type of message being sent. Makecode arcade has mainly usless console.log alternatives like console.warn, console.error, and console.debug. These are different types of console messages, but they only show up differently in the browser console, not the editor console. priority returns the type of message with the console priority type.

    text is the text of the message being sent.

  2. () => void
    void is just the script to run after the message is received. The best way to use it is by replacing it with:

    function() {
    }
    

Now that I’ve explained it, here’s how you can use it in your own code:

console.addListener((priority, text) => function() {
//code here
})

Now we can monitor the console using plain old JavaScript.

An example of how we can use this in our code is:

console.addListener((priority, text) => function() {
    if (text == "score+1" && priority == ConsolePriority.Log) {
        info.changeScoreBy(1)
    }
})

In this case, every time a message is logged the game checks if the message is score+1 and the message type is ConsolePriority.Log. If so, it changes the score by 1.
PS: YOU CAN REMOVE A LISTENER BY COPYING THE SCRIPT THEN REPLACING addListener WITH removeListener.

2 Likes

Now when I use the URL to download the extension, nothing shows up.

2 Likes

Hmm, it seems to be working for me. Here are the links though:

1 Like