“Give a man a fish, he gets food for a day. Teach a man to fish, he gets food for the rest of his life” @Naum When on forums, properly format code using [code]
Your code here [/code]
“Give a man a fish, you feed him for a day, don’t teach a man to fish and you feed yourself. He’s a grown man. Fishing’s not that hard.” - Ron Swanson
Thanks to all who responded. I’m newbie. The purpose of the program is to write the coordinates of the robot’s movement into the cells of the array Coordinat. I wanted to use a variable Shag to change the cells of the array. But it looks like the variable doesn’t change and everything is written to the first cell. Now the code looks like this
vexcode_brain_precision = 0
Shag = 0
ShagNext = 0
PosX = 0
PosN = 0
PosY = 0
Coordinat = [[0 for y in range(100)] for x in range(2)]
def when_started1():
global Shag, ShagNext, PosX, PosN, PosY, Coordinat, vexcode_brain_precision
drivetrain.set_drive_velocity(100, PERCENT)
drivetrain.set_turn_velocity(100, PERCENT)
while True:
PosX = location.position(X, MM)
PosY = location.position(Y, MM)
if distance.get_distance(MM) > 250:
drivetrain.drive_for(FORWARD, 250, MM)
Coordinat[Shag][0] = PosX
Coordinat[Shag][1] = PosY
brain.print(Shag)
brain.print(",")
brain.print(Coordinat[Shag][0], precision=vexcode_brain_precision)
brain.print(",")
brain.print(Coordinat[Shag][1], precision=vexcode_brain_precision)
brain.print(",")
brain.new_line()
drivetrain.turn_for(RIGHT, 90, DEGREES)
else:
drivetrain.turn_for(LEFT, 90, DEGREES)
drivetrain.drive(FORWARD)
vr_thread(when_started1())