#script api form

1 messages · Page 1 of 1 (latest)

tropic granite
#

So i have a script api form that has buttons how do i get another script api form to activate when a button is clicked

tropic granite
#
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)
    }
})```
unkempt marsh
#

yhh

#

so you press a button it opens a new form off butons?

tropic granite
#

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

unkempt marsh
#

oh

true grotto
# tropic granite i want it to yes idk how to associate it to another form tho
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)
    }
})
tropic granite
#

Is that suppose to replace my current form or add onto it

true grotto
#

you said you wanted a button to lead to another form right?

tropic granite
#

Yes

true grotto
#

this is it

tropic granite
#

Thats the new form

#

But the new form was supposed to be a message form

true grotto
#

you can change it to the one you want

#

for anotherform

tropic granite
#

It says in the script api that player is declared but never read

true grotto
#

because I forgot to add anotherform.show(player)

tropic granite
#

where does that go

true grotto
#

look at the form thing to help you

tropic granite
#

Huh

true grotto
#
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)
tropic granite
#

So thats supposed to be anotherform.player instead

true grotto
#

yes for anotherplayer

tropic granite
#

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

true grotto
tropic granite
#

I got it to open first after switching all players to wntities but wont open second

true grotto
#

did you add form . show in second

tropic granite
#
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)
    }
})```
true grotto
#

nope you didn't

tropic granite
#
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)
    }
})```
true grotto
tropic granite
#

i dont see that did you mean anotherform.show(entity

#

??

true grotto
tropic granite
#

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)

tropic granite
#

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

tropic granite
#

I assume i need to make a switch data.selection for each button then

true grotto
#

no

#

you just need to add a new case under the switch statement

worn fiberBOT
#
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1146907061360279592 message).
You can either send the script in code block highlighted in JS format:

​`​`​`js
world.sendMessage("Hello World");
​`​`​`

Or Send an attachment end in .js to debug the file.

peak sundial
#
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)
    }
})```
worn fiberBOT
#
Debug Result

There is an error in this [code](#1146907061360279592 message):

<repl>.js:17:17 - error TS2339: Property 'show' does not exist on type '(entity: any) => void'.

17     anotherform.show(entity)
                   ~~~~

tropic granite
#

First off how do i use that debugger