Skip to main content

Placing Items through code

Comments

4 comments

  • Ernie Support
    Support

    Would this be what you are referring to?:
    Here is an excerpt from the Python reference guide:

    0
  • René Lehmann

    That's exactly what I'm trying to do (I'm in Makecode though).

    Does this work for you? On my end, this doesn't work in Makecode and neither in the Notebook environment.
    I also tried to set the language to US english (thinking that it might be a problem with "cake") but without success.

    The code gets underlined and I'm getting an error ("minecraft.core.minecraft_error.MinecraftError: Syntax error: Unexpected "spawnitem": at ">>spawnitem<< cake ~3 ~" (Code: 0x80000000)").

    The same happens when I try to execute the example in the reference guide. Most other things work though (for example world.set does work).

    I'm not able to post images here (I tried jpeg, png and different sizes, but I always get the error "You can only upload images (jpeg, gif or png). Image uploads are limited to 2 MB." even though my image is only 29KB in size...).

     

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    I think the problem (as I imagine it in my head =] if you will) is that items don't rest in a world spot, the way blocks do. Items attach onto something, or hover over something temporarily. So they don't "place," exactly. So although you can use the Makecode block to place, and sneak the item parameter in there, it is treating it as a block, and throws an error. (You get one of those pesky whispers: oops, trying to use an item as a block.)

    I can't find any way in current Makecode (although it is always updating and there's even an update today!) to do anything better than what you are doing, giving to agent and dropping. Another alternative would be to spawn a dispenser or something, but that would be more steps, I'm thinking. 

     

    0
  • René Lehmann

    Thanks Debbie for your answer,

    it would, of course, be nice to have all the possibilities in MakeCode that are also available in Python notebooks, but on the other hand, it's not that bad. I always tell my students that the ability of finding new, alternative approaches and thinking outside the box is also part of a problem-solving skill.

    0

Please sign in to leave a comment.