QtScript’ing In Your Face

I’m currently developing In Your Face, a free software 3d basketball game. I have reached the moment to create an scripting interface to be able to script cool AI’s.

After having a look at LuaBind and Boost::Python I’ve decided to go with QtScript. I’m quite happy with it, but I’m facing an issue that I’m having problems to figure out. I’ll probably send it to Qt Interest, but I’ll try to explain it here too to see if I get an answer.

I have a whole hierarchy of classes that I want to export. The base class is Action::Base, and there are plenty of other actions, like Action::MoveTo or Action::Shoot.

I’m (almost) already able to do stuff like this from JavaScript:

function enter() {
  var teamPlay = new TeamPlay();
  var al = new ActionList();
  var mta = new MoveToAction(0,10);
  al.append(mta);
  teamPlay.insert(0,al);
  state.setTeamPlay(teamPlay);
  state.setChanged();
}

Everything works fine except the “append” call. “append” takes a pointer to the abstract class Action::Base. If I invoke it with a MoveToAction object, I get an “incompatible types” error. I have tried adding a toAction() method to MoveToAction which returned a QScriptValue-wrapped Action::Base *, but I’m still getting the same error.

Anyone has a QtScript example where something like this is done?

One Response to “QtScript’ing In Your Face”

  1. Lisa from Canada Says:

    love the foocast! you guys rock! also helps me practice mi Espanol,
    porque mi español es tan horrible ahora. Me siento como me he olvidado que todo me enseñaron en universidad.

    besos,
    Lisa

Leave a Reply