I have been scripting Minecraft PE with Rhino, I have been existing libraries from both Java and android and I thought to myself why not make my own classes and script those now I made a android class...
Android class
package com.latch.to.modpe;
public class MainActivity extends android.app.Activity
{
private android.widget.Toast t;
public void printToast()
{
t = new android.widget.Toast(getApplicationContext());
t.makeText(getApplicationContext(), "Hello Minecraft from my java file", android.widget.Toast.LENGTH_LONG);
}
}
And my JS File
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
var myClassFromFile = com.latch.to.modpe
function newLevel()
{
ctx.runOnUiThread(new java.lang.Ruable() {
run: function()
{
try
{
myClassFromFile.printToast();
}
catch(error)
{
clientMessage(error);
}
}
});
}
But when I ran it it gave me the error
Caot call property printToast in object [JavaPackage com.latch.to.modpe]. It is not a function it is an object.
