Just fixed the braces... at least i think i did
But even this doesn't work
function carriedItem()
{
if ( Player.getCarriedItem()==502)
{
print("test");
}
}
Just fixed the braces... at least i think i did
But even this doesn't work
function carriedItem()
{
if ( Player.getCarriedItem()==502)
{
print("test");
}
}
Your not even calling the function...
function useItem(x,y,z,itemId,blockId,side){
if(itemId==502){
print("test");
}
}
function modTick() {
if (getCarriedItem()==502) {
aimbutton();
}
else{
aimGUI.dismiss();
}
}
Keep getting the error:
Error occurred in script: testing.js
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "dismiss" of undefined (testing.js#235)
at org.mozilla.javascript.ScriptRuntime.constructError(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.constructError(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.typeError(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.typeError2(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.undefCallError(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
at script.modTick(testing.js:235)
at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at net.zhuoweizhang.mcpelauncher.ScriptManager.callScriptMethod(ScriptManager.java:214)
at net.zhuoweizhang.mcpelauncher.ScriptManager.tickCallback(ScriptManager.java:278)
at dalvik.system.NativeStart.run(Native Method)
How do i fix this?
Fixed that, now this poped up
Error occurred in script: testing.js
org.mozilla.javascript.WrappedException: Wrapped android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. (testing.js#235)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(Unknown Source)
at org.mozilla.javascript.NativeJavaMethod.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
at script.modTick(testing.js:235)
at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at net.zhuoweizhang.mcpelauncher.ScriptManager.callScriptMethod(ScriptManager.java:214)
at net.zhuoweizhang.mcpelauncher.ScriptManager.tickCallback(ScriptManager.java:278)
at dalvik.system.NativeStart.run(Native Method)
Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4746)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:4084)
at android.view.ViewRootImpl.die(ViewRootImpl.java:4071)
at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:336)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:286)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
at android.widget.PopupWindow.dismiss(PopupWindow.java:1270)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
... 11 more
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
But even this doesn't work
function carriedItem()
{
if ( Player.getCarriedItem()==502)
{
print("test");
}
}
Your not even calling the function...
function useItem(x,y,z,itemId,blockId,side){ if(itemId==502){ print("test"); } }Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
function modTick() { if (getCarriedItem==502) { print ("test") } }This should work.
Game dev and Minecraft modder.
Twitter: @jv110br_
Game dev and Minecraft modder.
Twitter: @jv110br_
Correction:
function modTick() { if(getCarriedItem()==502) { print("test") } }But, there's no item at ID 502. You added one?
Game dev and Minecraft modder.
Twitter: @jv110br_
Updated the code to
function modTick() { if (getCarriedItem()==502) { aimbutton(); } else{ aimGUI.dismiss(); } }Keep getting the error:
Error occurred in script: testing.js
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "dismiss" of undefined (testing.js#235)
at org.mozilla.javascript.ScriptRuntime.constructError(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.constructError(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.typeError(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.typeError2(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.undefCallError(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
at script.modTick(testing.js:235)
at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at net.zhuoweizhang.mcpelauncher.ScriptManager.callScriptMethod(ScriptManager.java:214)
at net.zhuoweizhang.mcpelauncher.ScriptManager.tickCallback(ScriptManager.java:278)
at dalvik.system.NativeStart.run(Native Method)
How do i fix this?
Game dev and Minecraft modder.
Twitter: @jv110br_
function aimbutton() { var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); ctx.runOnUiThread(new java.lang.Runnable({ run: function() { try{ aimGUI= new android.widget.PopupWindow(); var vlayout = new android.widget.RelativeLayout(ctx); var vbutton = new android.widget.Button(ctx); vbutton.setText("+"); vbutton.setTextSize(23); //button.setWidth(75); //button.setHeight(75); vbutton.setOnClickListener(new android.view.View.OnClickListener({ onClick: function(viewarg) { } })); vlayout.addView(vbutton); aimGUI.setContentView(vlayout); aimGUI.setWidth(80); aimGUI.setHeight(80); aimGUI.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT)); aimGUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.CENTER| android.view.Gravity.CENTER,0,0); }catch(err){ print("Error: "+err); } } })); }Oops i think it's saying aimGUI is undefinedTry putting the aimGUI variable at the start of the script
Game dev and Minecraft modder.
Twitter: @jv110br_
Error occurred in script: testing.js
org.mozilla.javascript.WrappedException: Wrapped android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. (testing.js#235)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(Unknown Source)
at org.mozilla.javascript.NativeJavaMethod.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
at script.modTick(testing.js:235)
at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at net.zhuoweizhang.mcpelauncher.ScriptManager.callScriptMethod(ScriptManager.java:214)
at net.zhuoweizhang.mcpelauncher.ScriptManager.tickCallback(ScriptManager.java:278)
at dalvik.system.NativeStart.run(Native Method)
Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4746)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:4084)
at android.view.ViewRootImpl.die(ViewRootImpl.java:4071)
at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:336)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:286)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
at android.widget.PopupWindow.dismiss(PopupWindow.java:1270)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
... 11 more
Game dev and Minecraft modder.
Twitter: @jv110br_