#Custom command registry not returning values for parameters

1 messages · Page 1 of 1 (latest)

smoky echo
#

Has anybody figured out how to get the custom command registry optional or mandatory parameters to actually return a value for example I created a custom enum using the command registry however I can't get it to return the selected enum value so for example my enum was a form enum which had three values possible form one form two and form three all strings in an array however when I tried to do an if statement for example say if form enum selection is form 1 then it would show the first form if it was form two it would show the second one. However this is not just a problem with custom enums other mandatory and optional parameters also do not return a value of what the player has either selected if it is a entity or player selector or typed if it is a string or integer parameter I don't know if I am missing something or maybe it's just not been added yet?
Sorry for the ramble

clear flame
#

provide the code you have?

smoky echo
# clear flame provide the code you have?

here ```js
import { CommandPermissionLevel, CustomCommandParamType, system, world } from "@minecraft/server";
import { ActionFormData, ModalFormData, MessageFormData } from "@minecraft/server-ui";

system.beforeEvents.startup.subscribe((data) => {
data.customCommandRegistry.registerEnum("custom:form", ["form1", "form2", "form3"])
data.customCommandRegistry.registerCommand({ name: "custom:newui", description: "opens a custom user interface", permissionLevel: CommandPermissionLevel.Admin, mandatoryParameters: [{ type: CustomCommandParamType.Enum, name: "custom:form" }] }, (data) => {
system.run(() => {
if ("custom:form" == "form1") {
testmenu.mainMenu(data.sourceEntity)

        }
    }
    )

})

})

class newUITest {
mainMenu(Player) {
const form = new ModalFormData()
.title("this is a test modal from")
.label("testing")
.textField("this is a test text field", "test", { tooltip: "this is a test tooltip" })
.slider("this is a test slider", 0, 1, { tooltip: "this is a test tooltip" })
.toggle("test toggle", { tooltip: "this is a test tooltip" })
.show(Player)
}
}
export const testmenu = new newUITest();

#

I know I only have one form in the code here but I tried making it only show up when you select form one inside the enum and it didn't work it is also not just a custom enum that doesn't seem to return value of selection it also seems to do the same thing with the player that is selected or the entity that is selected in both the player and entity selectors so just as an example if I wanted to make a custom command that only worked if for example the pig was selected in the entity selector I haven't found a way to add that into an if statement for it to check because as I already stated it doesn't seem to return the value that the player selected in the command

echo field
# smoky echo here ```js import { CommandPermissionLevel, CustomCommandParamType, system, worl...

here ```js
import { CommandPermissionLevel, CustomCommandParamType, system, world, CustomCommandStatus } from "@minecraft/server";
import { ActionFormData, ModalFormData, MessageFormData } from "@minecraft/server-ui";

system.beforeEvents.startup.subscribe((data) => {
data.customCommandRegistry.registerEnum("custom:form", ["form1", "form2", "form3"])
data.customCommandRegistry.registerCommand({ name: "custom:newui", description: "opens a custom user interface", permissionLevel: CommandPermissionLevel.Admin, mandatoryParameters: [{ type: CustomCommandParamType.Enum, name: "custom:form" }] }, (data) => {
system.run(() => {
if ("custom:form" == "form1") {
testmenu.mainMenu(data.sourceEntity)

        }
    }
    )

return { status: CustomCommandStatus.Success }
})

})

class newUITest {
mainMenu(Player) {
const form = new ModalFormData()
.title("this is a test modal from")
.label("testing")
.textField("this is a test text field", "test", { tooltip: "this is a test tooltip" })
.slider("this is a test slider", 0, 1, { tooltip: "this is a test tooltip" })
.toggle("test toggle", { tooltip: "this is a test tooltip" })
.show(Player)
}
}
export const testmenu = new newUITest();

smoky echo
#

And if so could you tell me how does the command success factor into it

echo field
#

try it

echo field
clear flame
smoky echo
clear flame
#

add an argument after data

#

it'll store the value of enum

#

that's how custom commands work

smoky echo