Need help? Ask us anything! [CLOSED] [12/21/2020 - 1/8/2021]

Can you help me? Please! Two days ago i get my Meowbit. And it is disconnecting when copying UF2 files. And i’m just can’t get any game on it:/

2 Likes

Hmmm… Make sure you are using the cable that was with the meowbit! Plug it in and turn it on!
Then take the uf2 file and drag it over!
If that does not work then try other games! If that also does not work then open the editor for the game, next to the big download buton press the 3 Dots, press select hardware, press meowbit, then press the 3 buttons again after it loaded and press pair device! Follow the instructions and pair it! Then a symbol should appear next to the big download button to indicate that you are connected, press download and wait!
If that does not work as well either the USB slot is damaged or the meowbit broken (which does not make much sense because you just got it) I am not a professional but I hope this helps! If it does not ask @mmoskal!

2 Likes

How hard would it be to make a RNG extension so you can have multiple RNGs as objects and you can set a seed?

@UnsignedArduino we actually have this in the JavaScript

// 123 is the seed
const myRandom = new Math.FastRandom(123);

const randomInteger1 = myRandom.next() // could be any integer between 1 and 65535
const randomInteger2 = myRandom.randomRange(0, 10)
const randomBoolean1 = myRandom.percentChance(50)
const randomBoolean2 =  myRandom.randomBool()
const randomFruit = myRandom.pickRandom(["apple", "orange", "blueberry"])
myRandom.reset() // resets the state back to the starting seed

Ironically, this is actually slower than using the regular random APIs despite the name (but still very, very fast)

1 Like

Nice!

This is what I currently have so far after fiddling around in the MakeCode playground:

//% blockNamespace=Random color="#FF8000"
class FastRandomBlocks {
    _rng: FastRandom

    constructor(seed: number) {
        this._rng = new Math.FastRandom(seed)
    }

    /**
     * Return the next number between 1 and 65535
     */
    //% block="%Random(rng) get next number"
    nextNumber() {
        return this._rng.Next()
    }

    /**
     * Returns a random number between two numbers
     * @param minimum The minimum number, ex: 1
     * @param maximum The maximum number, ex: 10
     */
    //% block="%Random(rng) get a random number between $minimum| and $maximum"
    //% inlineInputMode=inline
    randomRange(minimum: number, maximum: number) {
        return this._rng.randomRange(minimum, maximum)
    }

    /**
     * Returns a boolean based on the percent passed in
     * @param percent The percentage of the time the boolean returned will be true.
     */
    //% block="%Random(rng) get a random boolean with %percent| percent chance"
    percentChance(percent: number) {
        return this._rng.percentChance(percent)
    }

    /**
     * Returns a boolean with a 50% chance of being true
     */
    //% block="%Random(rng) 50/50 chance"
    randomBoolean() {
        return this._rng.randomBool()
    }

    /**
     * Pick a random element from the array passed in
     * @param elements The array to choose from, ex: ["apples", "oranges", "pears"]
     */
    //% block="%Random(rng) choose a random element from %elements"
    //% elements.shadow="lists_create_with"
    randomElement(elements: Array) {
        return this._rng.pickRandom(elements)
    }

    /**
     * Reset the RNG
     */
    //% block="Reset %Random(rng)"
    resetRNG() {
        this._rng.reset()
    }
}


//% color="#FF8000"
namespace Random {
    /**
     * Create a RNG object
     * @param seed The seed for the RNG, ex: 1234
     */
    //% block="create RNG || with seed $seed"
    //% blockSetVariable=rng
    //% expandableArgumentMode="toggle"
    export function createRNG(seed: number = 0): FastRandomBlocks {
        return new FastRandomBlocks(seed);
    }
}

For some reason, the simulator inside the playground never finishes loading, so I can’t test it. But are there any big no noes that stand out to you? (And should I create a new thread for this?)

Thank you wery much!!!

1 Like

Did it work?

1 Like

Chill question for the next Help Desk stream:

What consoles do you currently own? What consoles have you owned in the past? Playing any “old” games still?

2 Likes

@UnsignedArduino few things:

  1. You can test packages in the regular editor. Just switch to javascript, create a new file, paste your code into that file, return to blocks. Any blocks defined in any file that isn’t main.ts will show up in the toolbox
  2. On line 3, it should be Math.FastRandom
  3. For the randomElement function, you need to define it like this:
  randomElement(elements: any[]): any {
      return this._rng.pickRandom(elements)
  } 
  1. Instead of using % in your block definitions, use $. You can change all instances of %Random(rng) to be $this and then set the default variable name by adding another line like this:
   //% block="$this 50/50 chance"
   //% this.defl=rng
   randomBoolean() {
       return this._rng.randomBool()
   }

The reasons for using $ instead of % are kinda tough to explain, but just know that you are much less likely to accidentally break your extension in the future when changing code if you use $

  1. It’s usually recommended to add a //% blockId="extensionname_functionname" to your functions but totally optional
1 Like

@jacob_c haha i love that question! might take me more than one stream though…

1 Like

Yes!!! :slight_smile:

1 Like

Nice! How did it work though? What did you do so that it worked?

Hello! Is there any way I can use Python to make extensions for makecode arcade? I think that currently, makecode arcade only supports TS/JS to make extensions, but I am not very familiar with either, though I am working on learning them. I have a little bit more experience with python.

1 Like

I’m was copying the empty UF2 files :man_facepalming:

2 Likes

Oh… Well that explains a lot! Glad that I could help you!

We’ll be answering questions today on stream at 1PM PST! Tune in live if you want, but don’t worry if you can’t – we’ll post the video with links after :slight_smile:

2 Likes
  • What is your favorite/easiest thing to draw in Arcade? Hardest?
  • And when will you add flipping and rotating in the official image editor?
  • When is the next release coming? (Several weeks? Months? I’m just wondering)
2 Likes

And also, @system has a cake emoji - is today the forum anniversary?

1 Like

It automatically updates, the editor will say Download complete - reloading or something like that.

1 Like

THANKS EVERYBODY for your questions! The stream is posted here! Arcade Advanced Stream #180 - Help Desk!

2 Likes