Simply press the blue "View Raw" button to download it.
Now, let's get started.
*Please keep in mind that this uses Java (not JavaScript) to implement, so please try to keep up
var buttonWindow = null; //A window we haven't yet made
function newLevel() { //As soon as the world loads
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
//A variable we'll use later to add the button to the current MCPE activity
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
//This will allow our button to run on the current UI thread of MCPE
try { //Try to create our button
buttonWindow = new android.widget.PopupWindow();
//Make our variable a usable window
var layout = new android.widget.RelativeLayout(activity);
//A layout to put into our window
var button = new android.widget.Button(activity);
//A button to put in our layout
button.setText("Press Me!");
//Write some text upon our button
button.setOnClickListener(new android.view.View.OnClickListener({
//When we press our button
onClick: function(viewarg) { //This lets our button run something
//The function() comes from activity.runOnUiThread()
Level.explode(Player.getX(), Player.getY(), Player.getZ(), 3.0);
clientMessage("This is our button!");
}
}));
layout.addView(button);//Add our button to our layout
buttonWindow.setContentView(layout);//Add our layout to our window
buttonWindow.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
//Make our window the same size as the button within
buttonWindow.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
//The outline of our button's(The window) color
buttonWindow.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0);
//The location of our button on the screen, BOTTOM RIGHT
//The 0, 0 is the margin size, use this to push it around along those locations
}catch(problem){
print("Button could not be displayed: " + problem); //Print our error if we failed to make the button
}
}}));
}
function leaveGame() { //Get rid of it when we leave the world
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
if(buttonWindow != null) { //If our window still exists
buttonWindow.dismiss(); //Remove it from the screen
buttonwindow = null; //Reset it
}
}}));
}
Great! Now here it is uncommented:
var buttonWindow = null;
function newLevel() {
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
try{
buttonWindow = new android.widget.PopupWindow();
var layout = new android.widget.RelativeLayout(activity);
var button = new android.widget.Button(activity);
button.setText("Press Me!");
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg) {
Level.explode(Player.getX(), Player.getY(), Player.getZ(), 3.0);
clientMessage("This is our button!");
}
}));
layout.addView(button);
buttonWindow.setContentView(layout);
buttonWindow.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
buttonWindow.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0);
}catch(problem){
print("Button could not be displayed: " + problem);
}
}}));
}
function leaveGame() {
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
if(buttonWindow != null) {
buttonWindow.dismiss();
buttonwindow = null;
}
}}));
}
I apologize for any hard to read text, it's MCForum's fault
There were some errors that I had to fix. But just little ones.
For example:
activity.runOnUiThread(new java.lang.Runnable(){
//The function body should be outside of the parameters as this causes GUI to not show up sometimes.
});
There were some errors that I had to fix. But just little ones.
For example:
activity.runOnUiThread(new java.lang.Runnable(){
//The function body should be outside of the parameters as this causes GUI to not show up sometimes.
});
Hm... That's not how I do it and it works fine..Thanks though!
Rollback Post to RevisionRollBack
Back to modding! Follow me on Twitter @byteandahalf
There were some errors that I had to fix. But just little ones.
For example:
activity.runOnUiThread(new java.lang.Runnable(){
//The function body should be outside of the parameters as this causes GUI to not show up sometimes.
});
Show me what you did because it works for me. Show me your whole code.
Rollback Post to RevisionRollBack
Back to modding! Follow me on Twitter @byteandahalf
This is not java; this is still javascript, just that it uses android and java methods like android.view.View.OnClickListener.
It still uses var not type.
In ADT (android developer tools) it tells me to do
Button//skipped the imports
Button button=new Button(context);
button.setOnClickListener(new OnClickListener(){
@Override public void onClick(){}
});
Can I do the same in here?
The {} is behind not inside the ()
Btw I saw 'import' bolded in Notepad++. Is import usable?
Rollback Post to RevisionRollBack
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
buttonWindow.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0);
Ctx
Can u explain which lines throw exceptions?
Rollback Post to RevisionRollBack
I can be found on Freenode IRC channels #pocketmine, #ModPEScripts, #LegendOfMCPE, #pmplugins or #BeaconMine.
I am a PocketMine-MP plugin developer. I hate it when people think that I love stupid admin positions. Being an admin is nothing compared to being a plugin developer.
I am also a main developer of BlockServer, a work-in-progress MCPE server software. You are welcome to download it, but it so far onlly spawns you in the upther (above the world). You can chat, though.
I do not own this server but I just love to put this banner here:
Simply press the blue "View Raw" button to download it.
Now, let's get started.
*Please keep in mind that this uses Java (not JavaScript) to implement, so please try to keep up
var buttonWindow = null; //A window we haven't yet made
function newLevel() { //As soon as the world loads
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
//A variable we'll use later to add the button to the current MCPE activity
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
//This will allow our button to run on the current UI thread of MCPE
try { //Try to create our button
buttonWindow = new android.widget.PopupWindow();
//Make our variable a usable window
var layout = new android.widget.RelativeLayout(activity);
//A layout to put into our window
var button = new android.widget.Button(activity);
//A button to put in our layout
button.setText("Press Me!");
//Write some text upon our button
button.setOnClickListener(new android.view.View.OnClickListener({
//When we press our button
onClick: function(viewarg) { //This lets our button run something
//The function() comes from activity.runOnUiThread()
Level.explode(Player.getX(), Player.getY(), Player.getZ(), 3.0);
clientMessage("This is our button!");
}
}));
layout.addView(button);//Add our button to our layout
buttonWindow.setContentView(layout);//Add our layout to our window
buttonWindow.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
//Make our window the same size as the button within
buttonWindow.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
//The outline of our button's(The window) color
buttonWindow.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0);
//The location of our button on the screen, BOTTOM RIGHT
//The 0, 0 is the margin size, use this to push it around along those locations
}catch(problem){
print("Button could not be displayed: " + problem); //Print our error if we failed to make the button
}
}}));
}
function leaveGame() { //Get rid of it when we leave the world
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
if(buttonWindow != null) { //If our window still exists
buttonWindow.dismiss(); //Remove it from the screen
buttonwindow = null; //Reset it
}
}}));
}
Great! Now here it is uncommented:
var buttonWindow = null;
function newLevel() {
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
try{
buttonWindow = new android.widget.PopupWindow();
var layout = new android.widget.RelativeLayout(activity);
var button = new android.widget.Button(activity);
button.setText("Press Me!");
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg) {
Level.explode(Player.getX(), Player.getY(), Player.getZ(), 3.0);
clientMessage("This is our button!");
}
}));
layout.addView(button);
buttonWindow.setContentView(layout);
buttonWindow.setWidth(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setHeight(android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonWindow.setBackgroundDrawable(new
android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
buttonWindow.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM, 0, 0);
}catch(problem){
print("Button could not be displayed: " + problem);
}
}}));
}
function leaveGame() {
var activity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
activity.runOnUiThread(new java.lang.Runnable({ run: function() {
if(buttonWindow != null) {
buttonWindow.dismiss();
buttonwindow = null;
}
}}));
}
I apologize for any hard to read text, it's MCForum's fault
First, you will need the newest 1.5.2 beta 1 for BlockLauncher.
You can get it here:
https://github.com/z...elease-beta.apk
Simply press the blue "View Raw" button to download it.
Now, let's get started.
*Please keep in mind that this uses Java (not JavaScript) to implement, so please try to keep up
Great! Now here it is uncommented:
I apologize for any hard to read text, it's MCForum's fault
Back to modding! Follow me on Twitter @byteandahalf
Smart:very
Sexy:true
|
|
V
lol!
Back to modding! Follow me on Twitter @byteandahalf
Back to modding! Follow me on Twitter @byteandahalf
Back to modding! Follow me on Twitter @byteandahalf
Link Removed
Link Removed
Back to modding! Follow me on Twitter @byteandahalf
There were some errors that I had to fix. But just little ones.
For example:
Link Removed
Link Removed
Back to modding! Follow me on Twitter @byteandahalf
Back to modding! Follow me on Twitter @byteandahalf
Check out my game! It's an open-world, sandbox text adventure.
Follow @hexdro_
Hexdro © 2012-2015
+1 for both of you
This is not java; this is still javascript, just that it uses android and java methods like android.view.View.OnClickListener.
It still uses var not type.
P.S. or or else?
2. Porting MCPC functions to MCPE by ModPE 3. PocketMine Plugin: PocketMine ModPE! 4. PocketMine Servers: Capture Nether Reactor 5. Chunk Claimers (like factions as a mini-game)
Can I do the same in here?
The {} is behind not inside the ()
Btw I saw 'import' bolded in Notepad++. Is import usable?
Ctx
Can u explain which lines throw exceptions?
Link Removed
Link Removed
still: "reference error: "ctx" is not defined"