Robot is not moving

Hello,

I have written a Python script as follows, but the program-subprogram is not working, and the coordinates are not being printed.

Could you please help me resolve this issue?

Thank you.


Test.vcmx (92.5 KB)

Hello,

The .vcmx does not have the components included, please tick the following option from “Save As” in the file backstage:
image

In general though, I believe your code might be wrong and as far as I understand, the OnPosition event should not be used like that. Please modify it like this:

image

br,
Lefa

Thank you for your response.

I followed your instructions, but it still doesn’t work.

Is “foo” the name of the function? I wrote it as follows, but it doesn’t work.

Test_Moving.vcmx (67.2 KB)

Here’s the thing, let’s talk more carefully about why your OnPosition doesn’t take effect, it’s because simply OnPosition doesn’t point to a defined event, that is, when you use it directly:

def OnPosition(*n):
  pass

That is, when you use: def OnPosition(*n): pass directly, it’s actually the equivalent of “def function()” for VC, it’s no different, it won’t take effect until you call it, so in general if you’re going to use OnPosition as an event, what you need is what Lefa said. “Event carrier. Event = function”.
Let’s go back to the other question of why your program won’t do the run, there’s actually another reason, I looked at the fact that you’re using the module vcHelpers.Robot2, and when you use this module, in the VC’s opinion, in order for strange bugs not to happen, he’ll give run access to your python script and turn off the robot actuator’s enablement, which That’s the biggest reason it’s not allowed, you can add something like the following to your script to make sure the robot executor can run.

exe = comp.findBehaviour('Executor')
exe.IsEnabled = True