Hi there,
It’s been a long time…
My wife recently offered a “vector”, a little cute robot that i can program.
Sadly the only SDK available is in Python.
Here is a litle piece of code i want to do in Haxe
import anki_vector
def main():
args = anki_vector.util.parse_command_args()
with anki_vector.Robot(args.serial) as robot:
robot.behavior.say_text("haxe power")
if __name__ == "__main__":
main()
And this is my miserable attempt
class Main {
static public function main():Void {
trace("Hello World");
var robot = new Robot();
}
}
@:pythonImport("anki_vector")
@:native("anki_vector.Robot")
extern class Robot {
public function new();
}
My problem is that the generated code doesn’t import the anki_vector as i want.
This might work: (I assumed serial was a boolean, might not be)
class Main {
static public function main():Void {
var robot = AnkiVector.Robot(false);
robot.behavior.say_text("haxe power");
}
}
@:pythonImport("anki_vector")
@:native("anki_vector")
extern class AnkiVector {
public static function Robot(serial:Bool):Robot;
}
extern class Robot {
public var behavior:Behavior;
}
extern class Behavior {
public function say_text(msg:String):Void;
}
Note that in python the with probably calls some dispose function or something at the end of the block that’s not done here.