Skip to main content

Placing slabs on top of each other with Python

Comments

17 comments

  • Peter Januarius

    Surely somebody knows how to do this?

    0
  • Danny Support
    Beacon of Knowledge Bug Zapper Support

    Hey there! 

    What is the end goal? 

    Is it possible to replace the two slabs with the full version of the block in the places it requires?

    0
  • Peter Januarius

    There is always a workaround! That is not the question.

    What I'm saying is that you should be able to place a slab on top of another slab with code if you can do it with the interface - which you can.

    Also - no, I can't "replace the two slabs with the block" because I want to offset the slab by 1 in both X and Z axes

    So is this a bug ?

    0
  • Dominick Support
    Bug Zapper Support

    From what I understand and what you described this is not a bug. Depending on the orientation of the block and if it is full sized or half sized, will create this space between them that you are referring to.

    0
  • Peter Januarius

    Thanks although that makes no sense then. How is it that with the interface you can place them on top of each other but with the code you can't ?

    0
  • Danny Support
    Beacon of Knowledge Bug Zapper Support

    Hey Peter,

    We may need a screenshot to dig deeper. Even without code there will be a gap if the slabs are offset by a half block. 

    Could you attach the code as well and we can test on our end?

    Thanks!

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    Hi, Peter Januarius - Which Python are you using? MakeCode or Azure Notebook? Do you mind sharing the specific code?
    It's curious that you mention slabs. We had a hard time getting the code to put a slab in the Agent's inventory in Azure Notebook this week.

    You could try using agent.inspect("down") to determine the metadata of the doubled slabs. Place them in the world and then detect the data, and then display it. That should be enlightening. =]

    It is also fair to say that there will always be things you can do in the world which cannot be done in code, and things you can do in chat which cannot be done in the world or code, and things you can do in Python, but not in MakeCode, and so on. It would be a crazy Venn Diagram!

    0
  • Peter Januarius

    Hi Debbie / Danny

    Using Makecode.

    The code to build the roof is:

    #Roof
        blocks.fill(182, positions.add(start_pos, pos(-1,5,1)),  positions.add(start_pos, pos(8,5,-11)), FillOperation.REPLACE)
        blocks.fill(182, positions.add(start_pos, pos(0,5,0)),  positions.add(start_pos, pos(6,6.5,-9)), FillOperation.REPLACE)

    I'm attaching a few images to illustrate the issue and show the block I am using (red sandstone slab)   

     

    This is me facing North (see my cool compass on the ground?) with a red sandstone slab in front of me. The agent is also there. issuing the agent.inspect(AgentInspection.BLOCK, FORWARD) just returns 0. Am I doing something wrong?

    This is just an image of all my code

    this is an image of the house I am trying to build in code. It clearly shows the air gap.

    This is the inventory showing the slab

     

    It is also worth pointing out that the whole architecture of running functions by callback is not great. You always have to comply with the (num, num, num) parameter list. Once you try to call a hiearchy of functions, you get hopelessly lost and it seems impossible to do. Hence my build_house() function - I'm having to do everything in one function rather than break them up into discrete units as per good design.

    I hope I'm doing something wrong here and it isn't by design you made it this way ?? !

    Anyway, looking forward to your reply

    0
  • Peter Januarius

    Hi,

    My post has been pending for 4 days?

    Many thanks

     

    Pete..

    0
  • Dominick Support
    Bug Zapper Support

    Thank you for pinging us about that. Our system did not show your first post in the system to approve it. Both posts are now approved. 

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star
    Okay, this is what I get. When I place slabs with Python, they are 182 blocks. There are spaces in between.

    Then I go back and manually place blocks in between them.. I used the agent and got the block id of the combined blocks. They are block 181.

    So I placed block 181 They look like full blocks. Not slabs. I hope that's what you want. Good luck!

    blocks.fill(181, pos(0, 0, 0), pos(5, 3, 5), FillOperation.REPLACE)
    0
  • Peter Januarius

    Not exactly but I can work around it

     

    My question on the design of your python API is still outstanding though.

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    Sorry, where is that? Could you please link?

    0
  • Peter Januarius

    This is from my previous post...

    It is also worth pointing out that the whole architecture of running functions by callback is not great. You always have to comply with the (num, num, num) parameter list. Once you try to call a hiearchy of functions, you get hopelessly lost and it seems impossible to do. Hence my build_house() function - I'm having to do everything in one function rather than break them up into discrete units as per good design.

    I hope I'm doing something wrong here and it isn't by design you made it this way ?? !

    Anyway, looking forward to your reply

    0
  • Peter Januarius

    I worked out how to do the roof with slabs properly.

    I created a first slab (half-height) layer.

    I then created a hole in the middle of this slab leaving a 1 unit border on the outside

    I then place a RED_SANDSTONE block in the hole. That did the trick.

    I could then place another slab on the top

    No manual effort necessary.

     

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    That's great! I'm glad I could help. Would you be willing to share the code? I'd love to see how you did it.

    It sounds like you used the slab (182) for a border around the edge, then used the full block (181) for the main roof, and then a slab (182) for the center decorative feature.

    Looks great! My students are done now with their houses and roofs in their Python CS classes. It's fun to see all of the creative things in MC:EE.

    I'm not sure I understand your concern about good design. If you prefer to use separate procedures to create the roof and the house, that's no problem.

    0
  • Bailey Kilroy

    Hey, I've run into this problem too. Is there a way to place a top slab using the agent, or can it only be done using the /fill command?

    0

Please sign in to leave a comment.