Hey guys, would someone please show me how to add GUI, and have it execute code when tapped?
also, why wont this work?
function useItem(x,y,z,itemId,blockId,side)
{
if (itemId==280)
{
function bl_removeEntity(ent)
{
bl_removeEntity(64);
}
}
}
function attackHook(attacker, victim)
{
//Your Code Here
}
function modTick()
{
//Your Code Here
}
it's supposed to remove all dropped items when the stick is tapped ( i want it so when a GUI button is pressed it removes them).
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //A variable for the MCPE activity session
var GUI = null; //A variable for the button
function newLevel() { //When you start a world
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
try {
GUI = new android.widget.PopupWindow(); //The button becomes real as an android window
var layout = new android.widget.RelativeLayout(ctx); //Variable for the layout (can be Linear instead of relative)
var button = new android.widget.Button(ctx); //A variable for the ACTUAL button we see
button.setText("Remove"); //The text which will be on the button
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg) { //Perform a function when the button is pressed
//Insert the code of what will happen when the button is pressed
}
}));
layout.addView(button); //Adds a button the our chosen layout
GUI.setContentView(layout);
GUI.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Width of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Height of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT)); //Specifies whether the button is transparent or not.
GUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0); //Specify where the button will be on the screen. In this case it will be in the bottom right corner
}catch(problem){
print("The button can't be shown because " + problem); //Tells us the problem if the button cannot be displayed
}
}}));
}
function leaveGame() { //If we are exiting a world
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //The variable for the MCPE session
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
if(GUI != null) { //If the button is on the screen
GUI.dismiss(); //Dismiss the button
GUI = null; //Reset the button
}
}}));
}
//Your code
You should never have a function that you will not use so in this case remove function attackHook and function modTick
Rollback Post to RevisionRollBack
Make sure you follow me on twitter! @DarkDiaMiner IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //A variable for the MCPE activity session
var GUI = null; //A variable for the button
function newLevel() { //When you start a world
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
try {
GUI = new android.widget.PopupWindow(); //The button becomes real as an android window
var layout = new android.widget.RelativeLayout(ctx); //Variable for the layout (can be Linear instead of relative)
var button = new android.widget.Button(ctx); //A variable for the ACTUAL button we see
button.setText("Remove"); //The text which will be on the button
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg) { //Perform a function when the button is pressed
//Insert the code of what will happen when the button is pressed
}
}));
layout.addView(button); //Adds a button the our chosen layout
GUI.setContentView(layout);
GUI.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Width of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Height of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT)); //Specifies whether the button is transparent or not.
buttonWindow.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0); //Specify where the button will be on the screen. In this case it will be in the bottom right corner
}catch(problem){
print("The button can't be shown because " + problem); //Tells us the problem if the button cannot be displayed
}
}}));
}
function leaveGame() { //If we are exiting a world
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //The variable for the MCPE session
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
if(GUI != null) { //If the button is on the screen
GUI.dismiss(); //Dismiss the button
GUI = null; //Reset the button
}
}}));
}
//Your code
THANKS A TON! U r a lifesaver! Do u kno how to remove dropped items?
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //A variable for the MCPE activity session
var GUI = null; //A variable for the button
function newLevel() { //When you start a world
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
try {
GUI = new android.widget.PopupWindow(); //The button becomes real as an android window
var layout = new android.widget.RelativeLayout(ctx); //Variable for the layout (can be Linear instead of relative)
var button = new android.widget.Button(ctx); //A variable for the ACTUAL button we see
button.setText("Remove"); //The text which will be on the button
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg) { //Perform a function when the button is pressed
//Insert the code of what will happen when the button is pressed
}
}));
layout.addView(button); //Adds a button the our chosen layout
GUI.setContentView(layout);
GUI.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Width of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Height of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT)); //Specifies whether the button is transparent or not.
buttonWindow.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0); //Specify where the button will be on the screen. In this case it will be in the bottom right corner
}catch(problem){
print("The button can't be shown because " + problem); //Tells us the problem if the button cannot be displayed
}
}}));
}
function leaveGame() { //If we are exiting a world
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //The variable for the MCPE session
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
if(GUI != null) { //If the button is on the screen
GUI.dismiss(); //Dismiss the button
GUI = null; //Reset the button
}
}}));
}
//Your code
i tried it. it doesnt work... The button can't be shown because Button window is not defined.
Sorry about that, I just accidentally used an undefined variable. I just updated my post with the GUI script. If you want to know how to remove all dropped item entities, I suggest you ask 500ISE on the BlockLauncher thread. It might not even be possible....
Sorry about that, I just accidentally used an undefined variable. I just updated my post with the GUI script. If you want to know how to remove all dropped item entities, I suggest you ask 500ISE on the BlockLauncher thread. It might not even be possible....
You can remove them. MrARM did in his too many items mod. I need it for my NukePE mod to kill lag.
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //A variable for the MCPE activity session
var GUI = null; //A variable for the button
function newLevel() { //When you start a world
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
try {
GUI = new android.widget.PopupWindow(); //The button becomes real as an android window
var layout = new android.widget.RelativeLayout(ctx); //Variable for the layout (can be Linear instead of relative)
var button = new android.widget.Button(ctx); //A variable for the ACTUAL button we see
button.setText("Remove"); //The text which will be on the button
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg) { //Perform a function when the button is pressed
//Insert the code of what will happen when the button is pressed
}
}));
layout.addView(button); //Adds a button the our chosen layout
GUI.setContentView(layout);
GUI.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Width of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Height of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT)); //Specifies whether the button is transparent or not.
GUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0); //Specify where the button will be on the screen. In this case it will be in the bottom right corner
}catch(problem){
print("The button can't be shown because " + problem); //Tells us the problem if the button cannot be displayed
}
}}));
}
function leaveGame() { //If we are exiting a world
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //The variable for the MCPE session
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
if(GUI != null) { //If the button is on the screen
GUI.dismiss(); //Dismiss the button
GUI = null; //Reset the button
}
}}));
}
//Your code
I tried it, but there is no GUI. no error, but no GUI.
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //A variable for the MCPE activity session
var GUI = null; //A variable for the button
function newLevel() { //When you start a world
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
try {
GUI = new android.widget.PopupWindow(); //The button becomes real as an android window
var layout = new android.widget.RelativeLayout(ctx); //Variable for the layout (can be Linear instead of relative)
var button = new android.widget.Button(ctx); //A variable for the ACTUAL button we see
button.setText("Remove"); //The text which will be on the button
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg) { //Perform a function when the button is pressed
//Insert the code of what will happen when the button is pressed
}
}));
layout.addView(button); //Adds a button the our chosen layout
GUI.setContentView(layout);
GUI.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Width of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Height of the button. We didn't specify the amount of pixels, so don't worry.
GUI.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT)); //Specifies whether the button is transparent or not.
GUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0); //Specify where the button will be on the screen. In this case it will be in the bottom right corner
}catch(problem){
print("The button can't be shown because " + problem); //Tells us the problem if the button cannot be displayed
}
}}));
}
function leaveGame() { //If we are exiting a world
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //The variable for the MCPE session
ctx.runOnUiThread(new java.lang.Runnable({ run: function() {
if(GUI != null) { //If the button is on the screen
GUI.dismiss(); //Dismiss the button
GUI = null; //Reset the button
}
}}));
}
//Your code
You can change RIGHT to LEFT and you can change BOTTOM to TOP. At the end, the first number (0) indicates how many pixels you want the button to be moved vertically and in the opposite direction. The second number (0) indicates how many pixels you want the button to be moves horizontally in the opposite direction. E.g. If the position is RIGHT,BOTTOM and the numbers are (100,120), the button would be 100 pixels away from the right side and 120 pixels away from the bottom.
You can change RIGHT to LEFT and you can change BOTTOM to TOP. At the end, the first number (0) indicates how many pixels you want the button to be moved vertically and in the opposite direction. The second number (0) indicates how many pixels you want the button to be moves horizontally in the opposite direction. E.g. If the position is RIGHT,BOTTOM and the numbers are (100,120), the button would be 100 pixels away from the right side and 120 pixels away from the bottom.
also, why wont this work?
function useItem(x,y,z,itemId,blockId,side) { if (itemId==280) { function bl_removeEntity(ent) { bl_removeEntity(64); } } } function attackHook(attacker, victim) { //Your Code Here } function modTick() { //Your Code Here }it's supposed to remove all dropped items when the stick is tapped ( i want it so when a GUI button is pressed it removes them).
Please help.
Thanks!
~MattdaveMatt
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //A variable for the MCPE activity session var GUI = null; //A variable for the button function newLevel() { //When you start a world ctx.runOnUiThread(new java.lang.Runnable({ run: function() { try { GUI = new android.widget.PopupWindow(); //The button becomes real as an android window var layout = new android.widget.RelativeLayout(ctx); //Variable for the layout (can be Linear instead of relative) var button = new android.widget.Button(ctx); //A variable for the ACTUAL button we see button.setText("Remove"); //The text which will be on the button button.setOnClickListener(new android.view.View.OnClickListener({ onClick: function(viewarg) { //Perform a function when the button is pressed //Insert the code of what will happen when the button is pressed } })); layout.addView(button); //Adds a button the our chosen layout GUI.setContentView(layout); GUI.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Width of the button. We didn't specify the amount of pixels, so don't worry. GUI.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); //Height of the button. We didn't specify the amount of pixels, so don't worry. GUI.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT)); //Specifies whether the button is transparent or not. GUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0); //Specify where the button will be on the screen. In this case it will be in the bottom right corner }catch(problem){ print("The button can't be shown because " + problem); //Tells us the problem if the button cannot be displayed } }})); } function leaveGame() { //If we are exiting a world var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); //The variable for the MCPE session ctx.runOnUiThread(new java.lang.Runnable({ run: function() { if(GUI != null) { //If the button is on the screen GUI.dismiss(); //Dismiss the button GUI = null; //Reset the button } }})); } //Your codeWant 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]
IF I post a mod download it and give me a +1 if you appreciate.
Make sure you give me a suggestion at my WIP topic darkPE
Make sure you click on that +1 button if I help you! ---------------->
Thanks, will do!
THANKS A TON! U r a lifesaver! Do u kno how to remove dropped items?
i tried it. it doesnt work... The button can't be shown because Button window is not defined.
what to do?
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]
You can remove them. MrARM did in his too many items mod. I need it for my NukePE mod to kill lag.
I tried it, but there is no GUI. no error, but no GUI.
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]
how do i change its position?
You can change RIGHT to LEFT and you can change BOTTOM to TOP. At the end, the first number (0) indicates how many pixels you want the button to be moved vertically and in the opposite direction. The second number (0) indicates how many pixels you want the button to be moves horizontally in the opposite direction. E.g. If the position is RIGHT,BOTTOM and the numbers are (100,120), the button would be 100 pixels away from the right side and 120 pixels away from the bottom.
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]
Thanks!
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]
How do I make a /help command? I want to add one to my MattPE, a helper mod. Thanks!