1

Make Code Arcade Arrays(?) Uncaught e.findIdx is not a function


I am working on a Microsoft Make Code Arcade Game in VS code using the Microsoft MakeCode Arcade Extension. While attempting to make enemies spawn automatically via a for loop, I ran into an error.
VS Code error msg:

    Uncaught e.findIdx is not a function
       at lvl1 (main.ts:105:1)
       at inline (main.ts:54:57)
       at runButtonEvents (pxt_modules/game/controllerbutton.ts:237:9)
       at inline (pxt_modules/game/controllerbutton.ts:266:45)
       at inline (pxt_modules/base/eventcontext.ts:32:59)

Make Code Arcade Website error msg:

    e.findIdx is not a function
      at lvl1 (line 118)
      at inline (line 57)
      at inline (line 6)

I believe this is caused by the array I was trying to use to create the variables for the sprites. But I do not know for sure.
Section of code Causing the problem:

    let enemys: any = []
    let enemyNumber: number
    for (let i: number = 0; i < 3; i++) {
        // enemy setup
        enemyNumber = i
        enemys[enemyNumber] = sprites.create(assets.image`Basic Enemy`, SpriteKind.Enemy)
        enemys[enemyNumber].vx = -30
    
        // enemy movment setup
        game.onUpdateInterval(200, function () { // evry 0.2 sec          
            if (enemys[enemyNumber].vx == 30) {  // if the player is traveling right
                if (!    (tiles.tileAtLocationIsWall(enemys[enemyNumber].tilemapLocation().getNeighboringLocation(CollisionDirection.Right).getNeighboringLocation(CollisionDirection.Bottom)))) { // if the tile to the below and to the right of the sprite is not a wall
                    enemys[enemyNumber].vx = -30 // make the sprite turn the other direction
                }
            } else {
                if (!        (tiles.tileAtLocationIsWall(enemys[enemyNumber].tilemapLocation().getNeighboringLocation(CollisionDi    rection.Left).getNeighboringLocation(CollisionDirection.Bottom)))) { // if the tile to the below and     to the right of the sprite is not a wall
                    enemys[enemyNumber].vx = 30 // make the sprite turn the other direction
                }
            }
        })
    }
    
    tiles.placeOnTile(enemys[1], tiles.getTileLocation(10, 14))
    tiles.placeOnTile(enemys[2], tiles.getTileLocation(20, 14))
    tiles.placeOnTile(enemys[3], tiles.getTileLocation(29, 11))

The git-hub repo can be found here. The Branch I am working on is called Code-(Colton) and can be found here. The error is caused in main.ts
I tried to comment out lines 115-135, but the error persisted. This may mean that something is a pre-defined asset, but I am verry lost. I do not know what the error message is telling me.
This title and content for this question was made by "Comrade Bacon" at this link: https://stackoverflow.com/questions/77385867/make-code-arcade-arrays-uncaught-e-findidx-is-not-a-function. Contributions on stackoverflow.com are made under this license.

Javascript Windows Web

2 Answers

  • 0

    While you use xproj/project.json concept, you need to use .NET Core CLI tools like dotnet build, dotnet publish.
    MSBuild has been supporting starting from .NET Core 1.0 Preview 3 and one of the main requirement is a project migration to csproj format. See Announcing .NET Core Tools MSBuild “alpha”.
    This title and content for this question was made by "Set" at this link: https://stackoverflow.com/questions/41755564/continuously-deploy-asp-net-core-application-using-powershell-script-in-teamcity/41760213#41760213. Contributions on stackoverflow.com are made under this license.

  • 0

    While you use xproj/project.json concept, you need to use .NET Core CLI tools like dotnet build, dotnet publish.
    MSBuild has been supporting starting from .NET Core 1.0 Preview 3 and one of the main requirement is a project migration to csproj format. See Announcing .NET Core Tools MSBuild “alpha”.
    The content for this answer was made by "Set" at this link: https://stackoverflow.com/questions/41755564/continuously-deploy-asp-net-core-application-using-powershell-script-in-teamcity/41760213#41760213. Contributions on stackoverflow.com are made under this license.

Give your answer

Be sure to answer with an explanation on why your solution works.

Don't see an answer for your question?
Ask here

Search tags used in this post