Python coding problem with coordinates, how do I exclude y position?
I put starts "*" at where I have the problem, I need the agent to get only the x and z cords and exclude or ignore the y cords. but I don't know how to do that.
does anyone know how I can exclude the y cords?
hopefully someone can help me in this small community!
thank you,
much apricated
P.S. scroll down to see the code i marked the location of the code with a bunch of starts
also y is the starting pos
and x is the end of the wall/ ending pos
def on_chat():
agent.teleport_to_player()
agent.move(LEFT, 2)
y = agent.get_position()
agent.set_slot(1)
agent.set_assist(PLACE_ON_MOVE, True)
agent.set_assist(DESTROY_OBSTACLES, True)
agent.set_item(POLISHED_ANDESITE, 5, 1)
agent.move(FORWARD, 1)
agent.set_item(AIR,1 , 1)
agent.move(RIGHT,1)
agent.set_item(POLISHED_ANDESITE,1,1)
agent.move(RIGHT,1)
for i in range(2):
agent.set_item(STONE,1,1)
agent.move(FORWARD,4)
agent.move(LEFT,1)
agent.set_item(POLISHED_ANDESITE,1,1)
agent.move(FORWARD,1)
agent.set_item(AIR,1,1)
agent.move(RIGHT,1)
agent.set_item(POLISHED_ANDESITE,1,1)
agent.move(RIGHT,1)
x = agent.get_position() *******************************************************
agent.teleport((y), WEST)
agent.move(UP,1)
agent.set_item(POLISHED_ANDESITE, 5, 1)
agent.move(FORWARD, 1)
agent.set_item(AIR,1 , 1)
agent.move(RIGHT,1)
agent.set_item(POLISHED_ANDESITE,1,1)
agent.move(RIGHT,1)
for i in range(3):
agent.set_item(STONE,1,1)
agent.move(FORWARD,4)
agent.move(LEFT,1)
agent.set_item(POLISHED_ANDESITE,1,1)
agent.move(FORWARD,1)
agent.set_item(AIR,1,1)
agent.move(RIGHT,1)
agent.set_item(POLISHED_ANDESITE,1,1)
agent.move(RIGHT,1)
if x == y:
for s in range(1):
agent.teleport((y), WEST)
agent.move(UP,1)
y = agent.get_position()
for p in range(1):
agent.set_item(POLISHED_ANDESITE, 5, 1)
agent.move(FORWARD, 1)
agent.set_item(AIR,1 , 1)
agent.move(RIGHT,1)
agent.set_item(POLISHED_ANDESITE,1,1)
agent.move(RIGHT,1)
player.on_chat("wall", on_chat)
0
-
Hi billy motric!
Thanks for being the first to post in our new Coding in Minecraft forum! I'm going to relay some info from my dev team, let me know if you still have questions.
Use x = agent.get_position().getValue(Axis.X)
In python on MakeCode. You can also use the block code mode to get just the x and the z and convert to python code. If converting isn't an option, then use the text in the first line.
y and z are very similar. just change for which one you want
agent_postion = world(x, 0, 0) if you need to use those values
When your code gets to the line
if x == y:
You will need to change something about how the variable y is defined, as that's a Position whereas x is a number.0
Please sign in to leave a comment.
Comments
1 comment