#script api form
1 messages · Page 1 of 1 (latest)
ActionForm?
import { ActionFormData } from '@minecraft/server-ui';
world.afterEvents.itemUse.subscribe((event) => {
if (event.itemStack.typeId == "rpg:stats") {
const entity = event.source
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
form.show(entity)
}
})```
i want it to yes idk how to associate it to another form tho
the others are just message forms tho
dont need it to open another action form but where is that if put in
oh
import { world, system } from '@minecraft/server';
import { ActionFormData } from '@minecraft/server-ui';
const form = (player)=>{
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
form.show(player).then(data=>{
switch (data.selection){
case 1:
anotherform(player)
break;
}
})
}
const anotherform =(player)=>{
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
}
world.afterEvents.itemUse.subscribe((event) => {
if (event.itemStack.typeId == "rpg:stats") {
const entity = event.source
form(entity)
}
})
Is that suppose to replace my current form or add onto it
you said you wanted a button to lead to another form right?
Yes
this is it
because I forgot to add anotherform.show(player)
where does that go
look at the form thing to help you
Huh
const form = (player)=>{
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
form.show(player).then(data=>{
switch (data.selection){
case 1:
anotherform(player)
break;
}
})
}
form.show(player)
So thats supposed to be anotherform.player instead
yes for anotherplayer
Im still confused
I think i got it
Testing now
Pulled an error says entity is not defined
1 sec
Nope not working to open it initially
it's from the event.source thing
I got it to open first after switching all players to wntities but wont open second
did you add form . show in second
import { ActionFormData } from '@minecraft/server-ui';
const form = (entity) => {
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
form.show(entity).then(data => {
switch (data.selection) {
case 1:
anotherform(entity)
break;
}
})
}
const anotherform = (entity) => {
anotherform.show(entity)
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
}
world.afterEvents.itemUse.subscribe((event) => {
if (event.itemStack.typeId == "rpg:stats") {
const entity = event.source
form(entity)
}
})```
nope you didn't
import { ActionFormData } from '@minecraft/server-ui';
const form = (entity) => {
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
form.show(entity).then(data => {
switch (data.selection) {
case 1:
anotherform(entity)
break;
}
})
}
const anotherform = (entity) => {
anotherform.show(entity)
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
form.show(entity)
}
world.afterEvents.itemUse.subscribe((event) => {
if (event.itemStack.typeId == "rpg:stats") {
const entity = event.source
form(entity)
}
})```
remove anotherform.show(player)
just do this
i want it so when you use the iten rpg:stats it opens up a menue displaying buttons with each stat that when clicked opens a skill guide
i was asking if you ment anotherform.show(entities) because there is no anotherform.show(players)
just remove it
Ok so its mapped to the second button now
Im assuming case 0 will map to first if mc slot numbering is anything to go by
yes
I assume i need to make a switch data.selection for each button then
import { world, system } from '@minecraft/server';
import { ActionFormData } from '@minecraft/server-ui';
const form = (entity) => {
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
form.show(entity).then(data => {
switch (data.selection) {
case 1:
anotherform(entity)
break;
}
})
}
const anotherform = (entity) => {
anotherform.show(entity)
const form = new ActionFormData()
form.button(`attack: ${world.scoreboard.getObjective('attack').getScore(entity.scoreboardIdentity)}`)
form.button("test 2")
form.show(entity)
}
world.afterEvents.itemUse.subscribe((event) => {
if (event.itemStack.typeId == "rpg:stats") {
const entity = event.source
form(entity)
}
})```
There is an error in this [code](#1146907061360279592 message):
[36m<repl>.js[0m:[33m17[0m:[33m17[0m - [31merror[0m[30m TS2339: [0mProperty 'show' does not exist on type '(entity: any) => void'.
[7m17[0m anotherform.show(entity)
[7m [0m [31m ~~~~[0m
First off how do i use that debugger