My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Wiki pages

Monkeyspeak is a Dragonspeak-like interpreter written in Java. Monkeyspeak aims to be a cross-platform scripting solution that will be able to run on JavaME, Android (Dalvik), Windows, MacOSX, Linux (Ubuntu, Debian, Fedora, etc). It has no dependencies except for the SUN JDK.

Notice: This project is on hold due to having no personal time to work on it. If you want to contribute let me know. Or roll your own and I will link to it as an alternative.

Monkeyspeak is compiled under SUN JDK 1.6 it is not tested with any other JDK.

Short Example

Defining a Cause: (0:0) When the program starts,

	Monkeyspeak.addHandler(new TriggerHandler(0, 0) {
		@Override
		public boolean handle(Script s, Trigger t) {
		    return true;
		}
		
	    });

Defining the Effects: (5:0) set variable %test to {Hello World}. (5:1) print {%test} to the console.

	Monkeyspeak.addHandler(new TriggerHandler(5, 0) {

		@Override
		public boolean handle(Script s, Trigger t) {
		    // Set variables
		    String testRef = t.getVariableRef("%test");
		    Variable test = s.createVariable(testRef, t.getStringByIndex(0));
		    return true;
		}
	    });

	Monkeyspeak.addHandler(new TriggerHandler(5, 1) {

		@Override
		public boolean handle(Script s, Trigger t) {
		    String str = t.getStringByIndex(0);
		    str = s.getFormattedString(str);
		    System.out.println(str);
		    return true;
		}
	    });

Loading example Monkeyspeak code and executing 0:0

	try{
	Script script = Monkeyspeak.loadString("chunk", 
	    "0:0 When the program starts," +
	    "5:0 set variable %test to {Hello World}." +
	    "5:1 print {%test} to the console.");
	
	script.executeCause(0);
	
	}catch(Exception e){
	    e.printStackTrace(System.err);
	}

The line "script.executeCause(0);" will find the block starting with 0:0 and execute it.

Change the 0 to a 9, so instead of "script.executeCause(0);" it would look like "script.executeCause(9);", and you get 0:9 as the target instead of 0:0.

Replacing "script.executeCause(0);" with "script.execute();" will run through every block and every trigger running each TriggerHandler. This is a very costly and less effective way but it is available if it is necessary.

Powered by Google Project Hosting