roscopeco / deelang

A lightweight dynamic scripting language for Android
Other
28 stars 0 forks source link

How to use conditionals? #13

Closed jacksondus closed 8 years ago

jacksondus commented 8 years ago

In short, I need to do something like this:

if(game.hasGlobalFlag("how_to_do_this"){game.removeGlobalFlag("how_to_do_this")}

I am not sure how I would go about doing something like this in Deelang.

roscopeco commented 8 years ago

There is no conditional support in the language. The intention is that you have something like this on your self object:

public void test(Block block, Boolean bool) {
  if (bool) block.invoke;
  else getBinding().setErrorFlag();
}

which would allow you to then do (in Dee):

test(game.hasGlobalFlag("how_to_do_this")) {
  game.removeGlobalFlag("how_to_do_this"));
}

And supports the 'or' construct, e.g.

test(game.hasGlobalFlag("how_to_do_this")) {
  game.removeGlobalFlag("how_to_do_this"));
} or {
  game.addGlobalFlag("how_to_do_this"));
}
jacksondus commented 8 years ago

@roscopeco So the 'or' construct would be called by 'getBinding().setErrorFlag()'... Still considering the suitability for this in my project, along with several other languages. Is it possible to create new variables for things such as booleans and other primitives, or is it expected that all referenced variables are declared in Java?