Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Menus = [
- { // ID: 0
- Setting: {
- Width: 250,
- Height: 150,
- Pause: false,
- Texture: "minecraft:textures/gui/demo_background.png"
- },
- Childs: [
- {
- Type: 0, // Label
- Text: "First menu",
- PosX: 105,
- PosY: 10,
- Width: 40,
- Height: 16,
- Color: 0xFF0000 // Optional param
- },
- {
- Type: 1, // Button & TexturedButton
- Text: "Teleport Spawn",
- PosX: 95,
- PosY: 130,
- Width: 60, // Optional param
- Height: 15, // Optional param
- func: function(e){
- e.player.setPos(e.player.spawnPoint.pos);
- e.player.closeGui();
- }
- },
- {
- Type: 1,
- Text: "",
- PosX: 5,
- PosY: 5,
- Width: 20,
- Height: 20,
- Texture: "minecraft:textures/gui/widgets.png",
- TextureX: 0,
- TextureY: 106,
- HoverText: ["Join \"CNPC scripting\"", "Learn More Script!", "Click to link"],
- func: function(e){
- e.player.message("\"CNPC scripting\" Discord: https://discord.gg/2jZm88M");
- e.player.closeGui();
- }
- },
- {
- Type: 2, // TexturedRect
- Texture: "minecraft:textures/painting/paintings_kristoffer_zetterstrand.png",
- PosX: 20,
- PosY: 30,
- Width: 64,
- Height: 48,
- TextureX: 192,
- TextureY: 112
- }
- ]
- }
- ];
- function interact(e){
- if(e.type == 0 && e.player.mainhandItem.name == "minecraft:clock"){
- showMenu(e, 0);
- }
- }
- function showMenu(e, id){
- var Menu = Menus[0];
- var UI = e.API.createCustomGui(id, Menu.Setting.Width, Menu.Setting.Height, Menu.Setting.Pause);
- UI.setBackgroundTexture(Menu.Setting.Texture);
- var Childs = Menu.Childs;
- for(var i = 0; i < Childs.length; i++){
- switch(Childs[i].Type){
- case 0:
- var Child = UI.addLabel(i, Childs[i].Text, Childs[i].PosX, Childs[i].PosY, Childs[i].Width, Childs[i].Height, Childs[i].Color);
- break;
- case 1:
- if(Childs[i].Texture){
- UI.addTexturedButton(i, Childs[i].Text, Childs[i].PosX, Childs[i].PosY, Childs[i].Width, Childs[i].Height, Childs[i].Texture, Childs[i].TextureX, Childs[i].TextureY)
- }else{
- var Child = UI.addButton(i, Childs[i].Text, Childs[i].PosX, Childs[i].PosY, Childs[i].Width, Childs[i].Height);
- }
- break;
- case 2:
- var Child = UI.addTexturedRect(i, Childs[i].Texture, Childs[i].PosX, Childs[i].PosY, Childs[i].Width, Childs[i].Height, Childs[i].TextureX, Childs[i].TextureY);
- break;
- }
- if(Childs[i].HoverText) UI.getComponent(i).setHoverText(Childs[i].HoverText);
- }
- e.player.showCustomGui(UI);
- }
- function customGuiButton(e){
- var Child = Menus[e.gui.ID].Childs[e.buttonId];
- if(Child.func) Child.func(e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement