RemoveItem() in Game Lab

Hi all,

I’m looking for an answer on whether removeItem() works in Game Lab or not.

It is clearly listed in the Game Lab documentation, which you can see [here] at the bottom in the Tips section. (Code.org Tool Documentation)

It works fine in App Lab. However, when used in Game Lab, removeItem turns green as unknown blocks typically do.

Here’s a link where I was trying to use it.

It should choose a random color from the array whenever the mouse goes up, and then it should remove that color from the array so that the next click cannot repeat the same color.

Thanks for any help.

I’ve passed this on to code.org. guessing there is a documentation error because those functions are AppLab functions to the best of my knowledge.

Mike

Hey @david.vance

To follow-up from what Mike said - thanks for bringing this up. In looking into it, this highlighted some work we can do on our end to make the documentation clearer and more functional, and we’ve got some plans to improve the Game Lab documentation to help address the confusion you noticed. Here’s what I can say for now:

For right now, appendItem(), removeItem(), and insertItem() will not work in Game Lab - it’s a mistake on our end that this line appears in our Game Lab documentation and soon it will be removed. For your project, I’d recommend looking into the native javascript functions that work with arrays, specifically push(), pop(), and splice(). Behind the scenes, App Lab actually uses these methods for appendItem() and the other array methods, so using these digs a little deeper into how javascript works which is pretty cool.

When you use these functions in your code, they will still turn up as green blocks as if Game Lab doesn’t recognize them. But, they will still work correctly when you run your project. I’d recommend making a new temporary project just to play around with these functions and use text mode, then switch back to this project once you’ve figured out how you want to use these blocks to solve your problem.

Longer term: we’re looking into updating Game Lab so our array blocks could work here too, but I don’t have an ETA. Since these blocks aren’t part of our Game Lab curriculum, they won’t be prioritized as high as other updates that more directly impact the curriculum.

Cheers,
Dan - Code.org Curriculum Writer

1 Like

Splice will do exactly what I needed. Thanks.