ask me any questions you have i will do my best to answer them.
@YuHayate I’m afraid that screenshot is a tad too small for me to read. Can you share a link to the code?
ah, this is a bug in arcade but there’s an easy workaround! you need to make sure a tilemap is defined before calling the “array of all ___ locations” block.
but it it already is
ah, i see… looks like there’s another issue in the for loop you posted the screenshot of. the bounds of our for loops are inclusive, meaning you want the max to be the length of the array minus 1 and not just the length.
or try using a for-of loop instead!
i works but the camera dosent move from zones
I don’t think I’ve EVER heard anyone else say tad in my entire life.
I like it though.
Isn’t the MakeCode built-in loop a foreach loop?
hello @richard it is me again, im making a automatique textur generator and im making en extention for it
any idea what im doing wrong?
Looks like there are a few errors in this code.
Let’s take a look at how functions are declared in TypeScript:
function functionName(arg1: Type1, arg2: Type2): ReturnType {
...
}
Note the order of the argument declarations here: all arguments should be declared with the name followed by a colon and the type. Here we have two arguments, arg1 of type Type1 and arg2 of type Type2. This function also returns a value of type ReturnType, which we list after the argument list. If we wanted to return nothing, we would set “void” as the return type instead.
Alright, with that in mind, let’s take a look at your code. I see a few issues:
- Your arguments are declared
type: name
instead ofname: type
. Try switching the order around! - Your function has a return type of void, but it returns a value on line 26. I think you can just remove that return statement on line 26
- You have an extra close curly brace on line 19 that you should delete
I hope that helps!
I see thank you very much
i seems that the “Image” type is not what it seams
this is what i get ------
this is what i want ----
do you have any more tips for me?
it’s the right type! you just need to add an annotation to set the “shadow block” for each argument. Something like this:
namespace custom {
/**
* TODO: describe your function here
* @param myImage describe parameter here
* @param myImage2 describe parameter here
*/
//% block="draw $myImage onto $myImage2"
//% myImage.shadow=screen_image_picker
//% myImage2.shadow=screen_image_picker
export function Print(myImage: Image, myImage2: Image): void {
for (let X = 0; X <= 16; X++) {
for (let Y = 0; Y <= 16; Y++) {
if (myImage.getPixel(X, Y) != 0) {
myImage2.setPixel(X, Y, myImage.getPixel(X, Y))
}
}
}
}
}
i see, thanck you