#Book Menu

1 messages · Page 1 of 1 (latest)

dreamy tinsel
#

you shoudve post this in script api not in json ui, btw
1 make sure to change the version in the manifest to theese

    {
        "module_name": "@minecraft/server",
        "version": "1.11.0-beta"
    },
    {
        "module_name": "@minecraft/server-gametest",
        "version": "1.0.0-beta"
    },
    {
        "module_name": "@minecraft/server-ui",
        "version": "1.2.0-beta"
    }

2 create script folder then create main.js

3 import in main.js this:

import { world, system, EquipmentSlot } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui"

4 when player clicks on item (copy that after imports)

world.afterEvents.itemUse.subscribe((eventData) => {
let player = eventData.source
let itemUse = eventData.itemStack.typeId
if (itemUse == "YOUR_NAMESPACE:YOUR_ITEM example: minecraft:compass") {
book(player); // book means open the book ui
}
});

5 book ui

function book(player) {// book is the name of the function make sure it mathes the opening
let mainForm = new ActionFormData()
.title("title")
.body("your text")
.button("button", "textures/ui/texture you want")
mainForm.show(player).then(result => {
if (result.selection === 0) { //if player select first button take him to tha page second
second(player);
}
})
}

then do the same and create another function changing the id the code is the same

function second(player) {// book is the name of the function make sure it mathes the opening
let mainForm = new ActionFormData()
.title("title")
.body("your text")
.button("button", "textures/ui/texture you want")
mainForm.show(player).then(result => {
if (result.selection === 0) { //if player select first button take him to tha page secondform
book(player);
}
})
}

hasty pollen
hasty pollen
hasty pollen
#

I remember last year I called another file to open the ui

#

like main.js call Book_ui.js for exemple and i put the ui script in Book_ui.js

dreamy tinsel
#

All the code should be in main.js

hasty pollen
# dreamy tinsel All in main.js
import { world, system, EquipmentSlot } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui"
world.afterEvents.itemUse.subscribe((eventData) => {
    let player = eventData.source
    let itemUse = eventData.itemStack.typeId
    if (itemUse == "ken:menu") {
        book(player); 
    }
});
function book(player) {// book is the name of the function make sure it mathes the opening 
    let mainForm = new ActionFormData()
        .title("Number1")
        .body("TestNumber1")
        .button("button", "textures/ui/menu")
    mainForm.show(player).then(result => {
        if (result.selection === 0) { //if player select first button take him to tha page second
            second(player);
        }
    })
};
function second(player) {// book is the name of the function make sure it mathes the opening 
    let mainForm = new ActionFormData()
        .title("Number2")
        .body("TestNumber2")
        .button("button", "textures/ui/menu")
    mainForm.show(player).then(result => {
        if (result.selection === 0) { //if player select first button take him to tha page secondform
            book(player);
        }
    })
}
#

I did that

dreamy tinsel
#

Does it work?

hasty pollen
#

I just have a problem I don't know if I should put " , " or " ; " after } for book function

#

or maybe nothing

hasty pollen
#

second(player;
}
})
}here

#
import { world, system, EquipmentSlot } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui"
world.afterEvents.itemUse.subscribe((eventData) => {
    let player = eventData.source
    let itemUse = eventData.itemStack.typeId
    if (itemUse == "ken:menu") {
        book(player); 
    }
});
function book(player) {// book is the name of the function make sure it mathes the opening 
    let mainForm = new ActionFormData()
        .title("Number1")
        .body("TestNumber1")
        .button("button", "textures/ui/menu")
    mainForm.show(player).then(result => {
        if (result.selection === 0) { //if player select first button take him to tha page second
            second(player);
        }
    })
} here
function second(player) {// book is the name of the function make sure it mathes the opening 
    let mainForm = new ActionFormData()
        .title("Number2")
        .body("TestNumber2")
        .button("button", "textures/ui/menu")
    mainForm.show(player).then(result => {
        if (result.selection === 0) { //if player select first button take him to tha page secondform
            book(player);
        }
    })
}
dreamy tinsel
hasty pollen
#

Yes i know log
Okay im going to try

dreamy tinsel
hasty pollen
#

idk cuz m'y minecraft infinite crash

#

i just ré download mc

hasty pollen
#

OOOH Okay i going to change inedex.js by main.js in my manifest and im going to re try

dreamy tinsel
hasty pollen
#

yeah yeah i change this

#

okay it's work !

#

im in game and i this the first interface and when i click and button i can open the seconde interface

hasty pollen
dreamy tinsel
# hasty pollen how can i put more button on same page

function book(player) {// book is the name of the function make sure it mathes the opening
let mainForm = new ActionFormData()
.title("Number1")
.body("TestNumber1")
.button("button", "textures/ui/menu") <===== thats a button just copy that line and paste under here
mainForm.show(player).then(result => {
if (result.selection === 0) { //if player select first button take him to tha page second <== that 2 lines are when
second(player); <==the button number N is pressed open a new ui
}
})
};

hasty pollen
#

function book(player) {
let mainForm = new ActionFormData()
.title("Number1")
.body("TestNumber1")
.button("button", "textures/ui/menu")
.button("button2", "textures/ui/menu")
.button("button3", "textures/ui/menu")
if (result.selection === 0) {
second(player);
}
})
};

#

like this

dreamy tinsel
# hasty pollen function book(player) { let mainForm = new ActionFormData() .title("...

function book(player) {// book is the name of the function make sure it mathes the opening
let mainForm = new ActionFormData()
.title("Number1")
.body("TestNumber1")
.button("button", "textures/ui/menu")
.button("button2", "textures/ui/menu2") <====== HERE PASTE A NEW BUTTON
if (result.selection === 0) { //if player select first button take him to tha page second
second(player);
}
if (result.selection === 1) { //that number is the position of button
second(player);
}
})
};

dreamy tinsel
hasty pollen
#

ok slection 1 too

#

ok right im going try put this in my cocd

#

code

dreamy tinsel
#

with more buttons it should look like this

hasty pollen
#
import { world, system, EquipmentSlot } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui"
world.afterEvents.itemUse.subscribe((eventData) => {
    let player = eventData.source
    let itemUse = eventData.itemStack.typeId
    if (itemUse == "ken:menu") {
        book(player); 
    }
});
function book(player) { 
    let mainForm = new ActionFormData()
        .title("§t§lLumeria Menu") 
        .body("Select category")
        .button("button1", "textures/ui/menu1")
        .button("button2", "textures/ui/menu2")
        .button("button3", "textures/ui/menu3")
        .button("button4", "textures/ui/menu4")
    mainForm.show(player).then(result => {
        if (result.selection === 0) {
            button1(player);
        }
        if (result.selection === 1) {
            button2(player);
        }
        if (result.selection === 2) {
            button3(player);
        }
        if (result.selection === 3) { 
            button4(player);
        }
    })
};
function button1(player) {
    let mainForm = new ActionFormData()
        .title("Number2")
        .body("TestNumber2")
        .button("button", "textures/ui/menu")
    mainForm.show(player).then(result => {
        if (result.selection === 0) {
        }
    })
}
#

i made this

#

so now i juste nedd copy function button1 and replace id by button2

#

just

#

i copy this

#
function button2(player) {
    let mainForm = new ActionFormData()
        .title("Number2")
        .body("TestNumber2")
        .button("button", "textures/ui/menu")
    mainForm.show(player).then(result => {
        if (result.selection === 0) {
        }
#

and i put under the first but vscode say me i have one error

#

i think i forgot , or ;

hasty pollen
#

it's okay

#

im going try in game

hasty pollen
#

so now you lnow how can i put commande when i click on button ?

dreamy tinsel
hasty pollen
hasty pollen
#

Ok right !!!!!!

dreamy tinsel
hasty pollen
#

Nice it work's

hasty pollen
#

@dreamy tinsel possible to make text zone and under put clickable button

gaunt lintel
#

#1067535382285135923

hasty pollen
#

Like :

Welcome to lumeria, confirm Rules to take start kit.
[Confirme]
hasty pollen
gaunt lintel
#

np

hasty pollen
#

sorry, I couldn't find the category #1067535382285135923 so I continued it here #1238526872954863637