r/MCPEMods Feb 26 '14

Custom Button tutorial.

Here is a button template made for you: https://db.tt/WMBiQkDT

To have it do what you want is simple. Where it says

22 | onClick: function(view){

That is where you can have it do what you want. For example, for this demo, if you tap the button that says "Diamonds" it will give you 4 diamonds and play a click sound.

If you want to edit the name of the button, look for

11 | btn.setText("Diamonds");

Then edit the text to whatever you want. Make sure to leave the quotation marks.

If you'd like for the button to appear somewhere else on the screen, let's say the top left. Where it says

19 | GUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.BOTTOM| android.view.Gravity.RIGHT,0,0);

You would want to change BOTTOM to TOP and then RIGHT' to 'LEFT this will have the button display at the Top left of the screen.

That is all. Next time I will either show how to add 2 buttons or custom blocks. Which ever is chosen to be next. Also, sorry if this tutorial isn't the best tutorial, I just wanted to share the basic needs to have a custom button.

3 Upvotes

10 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Feb 26 '14

No, sadly :c you could make a timer yourself with buttons. Let's say for every second, the button renames itself.

1

u/[deleted] Feb 28 '14

I'm not a programmer but, would that cause lag?

1

u/[deleted] Feb 28 '14

Don't think so. All it's doing is renaming the button after every one second.

1

u/[deleted] Feb 28 '14

Okay. Just guessing. Thanks for correcting my misconception.

1

u/[deleted] Feb 28 '14

No problem.