#a little help with ActionForm uis
1 messages · Page 1 of 1 (latest)
import { world } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"
world.beforeEvents.chatSend.subscribe((event) => {
data.cancel = true;
const player = event.sender
const msg = event.message
if (msg == "!settings") {
event.cancel = true
Settings(player);
}
})
const playerList = mc.world.getPlayers();
if (playerList.length >= 1) {
const Settings = new mcui.ActionFormData()
.title("§7§lSettings")
.body("§7Message Color §8§l(Page 1)")
.button("§4Dark Red")
.button("§cRed")
.button("§6Orange")
.button("§gMineCoin Gold")
.button("§eYellow")
.button("§aLime")
.button("§2Green")
.button("§3Cyan")
.button("§bLight Blue")
.button("§9Blue")
.button("§5Magenta")
.button("§dPink")
.button("§8§lNext Page>");
const result = await form.show(playerList[0]);
if (result.canceled) {
player.sendMessage("§cYou exited out of the dialog. Note that if the chat window is up, dialogs are automatically canceled.");
return -1;
} else {
player.sendMessage("§aYour Message Color Is Now: ");
}
}
So how can i find the button they clicked
And how do i make it so if they clicked the last button (next page) it would show them another ui
ok
wait
function form(player) {
const buttons = ['red','orange','yellow']
const f = new ActionFormData()
f.title("title")
f.body("body")
for (const button of buttons) f.button(button)
f.button("Next Page")
f.show(player).then((result) => {
if (result.canceled) return player.sendMessage(`§cYou exited out of the dialog. Note that if the chat window is up, dialogs are automatically canceled.`);
if (result.selection > buttons.length - 1) return form2(player);
player.sendMessage(`§aYour Message Color Is Now: ${buttons[result.selection]}`);
})
}
function form2(player) {
const buttons = ['green','blue','purple']
const f = new ActionFormData()
f.title("title")
f.body("body")
for (const button of buttons) f.button(button)
f.button("Previous Page")
f.show(player).then((result) => {
if (result.canceled) return player.sendMessage(`§cYou exited out of the dialog. Note that if the chat window is up, dialogs are automatically canceled.`);
if (result.selection > buttons.length - 1) return form(player);
player.sendMessage(`§aYour Message Color Is Now: ${buttons[result.selection]}`);
})
}
system.run(() => {
for (const plr of world.getPlayers()) {form(plr)}
})```
i havent added the part in which it acutally changes the chat colours or does anything for each button
but its like ```js
if (result.selection == 0) /change colour to red as the first button is red/
if (result.selection == 1) /change colour to orange as the second button is orange/
...
or you could use switch()