#home system

1 messages · Page 1 of 1 (latest)

cloud kelp
#

I'll help you with one note:

Don't recreate new post that already being create

#

Do you have your form?

muted rapids
#

no

cloud kelp
#
const homeForm = new ActionFormData()
  .title("Home")
  .body("Select one")
  .button("Create")
  .button("Teleport")
  .button("Home")
#

Can a player have more than one home?

muted rapids
#

Yes

cloud kelp
#
function createHome(player) {
  const createForm = new ModalFormData()
    .title("Create Home")
    .textField("Home Name")

  createForm.show(player).then(r => {
    if (r.canceled) return;

    player.addTag(`HOME:${r.formValues[0]}:${Object.values(player.location).join(" ")}`)
    player.sendMessage(`Successfully create home "${r.formValues[0]}"`)
  })
}
#
function teleportHome(player) {
  const tags = player.getTags().map(tag => tag.startsWith("HOME:"))
  const teleportForm = new ActionFormData()
    .title("Teleport Home")
    .body("Select one to teleport")

  for (const tag of tags) {
    const [_, name, loc] = tag.split(":")
    teleportForm.button(`Home: ${name}\n${loc}`)
  }

  teleportForm.show(player).then(r => {
    if (r.canceled) return;

    const [_, name, loc] = tags[r.selection]
    player.teleport(new Vector(...loc.split(" "), player.dimension, player.rotation.x, player.rotation.y, true))
    player.sendMessage("Successfully teleport to ${name}")
  })
}
#
function deleteHome(player) {
  const tags = player.getTags().map(tag => tag.startsWith("HOME:"))
  const deleteForm = new ActionFormData()
    .title("Delete Home")
    .body("Select one to delete")

  for (const tag of tags) {
    const [_, name, loc] = tag.split(":")
    teleportForm.button(`Home: ${name}\n${loc}`)
  }

  deleteForm.show(player).then(r => {
    if (r.canceled) return;

    player.removeTag(tags[r.selection])
    player.sendMessage("Successfully delete home")
  })
}
#

Done

muted rapids
#

good part I understood

#

I will test here

muted rapids
#

it didn't open, I put it in another menu to open the 3 and it didn't

cloud kelp
#

Show your code

muted rapids
cloud kelp
#

Hmmm you run exgui(player), not exgui4

muted rapids
#

exist

#

there

cloud kelp
#

I know

#

But you still run exgui, not exgui4

world.events.beforeItemUse.subscribe(eventData => {
    
let player = eventData.source
let item = eventData.item
    if (item.typeId == "m:carteira") {

// This one
exgui(player)
}
})
#

Try change to exgui4

muted rapids
#

In exgui there is a "home" button that goes to exgui4

cloud kelp
#

Oh

muted rapids
cloud kelp
#

Does anythiny except exgui4 works?

limpid roseBOT
#
Debug Result

There are 6 errors in this [code](#1091911274914381865 message):

main.js:1:26 - error TS2307: Cannot find module 'functions.js' or its corresponding type declarations.

1 import { getScore } from "functions.js";
                           ~~~~~~~~~~~~~~
main.js:125:43 - error TS2731: Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'.

125             `scoreboard players set @s "${property}" ${value}`
                                              ~~~~~~~~
main.js:157:10 - error TS2339: Property 'scores' does not exist on type 'Player'.

157   target.scores["money"] += amount;
             ~~~~~~
main.js:185:6 - error TS2554: Expected 2-3 arguments, but got 1.

185     .textField("Home Name")
         ~~~~~~~~~~~~~~~~~~~~~~

  @minecraft/server-ui.d.ts:235:30
    235     textField(label: string, placeholderText: string, defaultValue?: string): ModalFormData;
                                     ~~~~~~~~~~~~~~~~~~~~~~~
    An argument for 'placeholderText' was not provided.
main.js:210:25 - error TS2304: Cannot find name 'Vector'.

210     player.teleport(new Vector(...loc.split(" "), player.dimension, player.rotation.x, player.rotation.y, true))
                            ~~~~~~
main.js:223:5 - error TS2552: Cannot find name 'teleportForm'. Did you mean 'teleportHome'?

223     teleportForm.button(`Home: ${name}\n${loc}`)
        ~~~~~~~~~~~~

  main.js:195:10
    195 function teleportHome(player) {
                 ~~~~~~~~~~~~
    'teleportHome' is declared here.

muted rapids
cloud kelp
#

Does the main home form open?

muted rapids
#

Yes

cloud kelp
#

Okay, I know the issue

muted rapids
#

Oh

cloud kelp
#

On createForm, there's textField, add another string as a description

#

.textField("Home Name", "Name")

muted rapids
#

I was already testing calm down there

cloud kelp
#

Okay

muted rapids
#

the one to create home opened

cloud kelp
#

You can add these on teleportForm and deleteForm under const tags

if (tags.length === 0) {
  new MessageFormData()
    .title("Error")
    .body("You don't have any home! Create new one")
    .button1("Ok")
    .button2("Cancel")
    .show(player)
    .then()
  return;
}
muted rapids
#

when I tested it I created a home

#

It was not

cloud kelp
#

Try change with this

player.addTag(`HOME:${r.formValues[0]}:${Object.values(player.location).map(Math.floor).join(" ")}`)
muted rapids
cloud kelp
#

I think when you input the name, you use your alphabet

#

Like maybe é doesn't accepted on tag

muted rapids
#

Example

#

I was creating home "ja"

cloud kelp
#

Is it works?

muted rapids
#

No

cloud kelp
#

Weird

#

When you create home, does it show the message say Successfully?

muted rapids
#

Yes

cloud kelp
#

Huh

#
const [name] = r.formValues
player.addTag(`HOME:${name}:${Object.values(player.location).map(Math.floor).join(" ")}`)
muted rapids
#

it was not

cloud kelp
#

Very weird

muted rapids
#
const tags = player.getTags().filter(tag => tag.startsWith("HOME:"))
#

menu opens but does not teleport

muted rapids
#

does anyone know what's wrong?

muted rapids
#

give up ?

#

@cloud kelp

cloud kelp
#

I'm sorry, I have something to do rn

#
player.teleport(new Vector(...loc.split(" ")), player.dimension, player.rotation.x, player.rotation.y, true)
```There's missing `)` there, so maybe try it
muted rapids
#

it was not

muted rapids
#
const tags = player.getTags().filter(tag => tag.startsWith("HOME:"))
  const teleportForm = new ActionFormData()
    .title("Teleport Home")
    .body("Select one to teleport")

  for (const tag of tags) {
    const [_, name, loc] = tag.split(":")
    teleportForm.button(`Home: ${name}\n${loc}`)
  }

  teleportForm.show(player).then(r => {
    if (r.canceled) return;

    const [_, name, loc] = tags[r.selection]
player.teleport(new Vector(...loc.split(" ")), player.dimension, player.rotation.x, player.rotation.y, true)
    player.sendMessage("Successfully teleport to ${name}")
  })
}
proper locustBOT
#
ScriptAPI - Debug Bot

Here have a test bot dedicated towards debuging script-api code blocks within discord by yourself.

Usage
1. Make sure to use JS Code Block formating
`

console.warn("like this")

2. ` Long press Code Block message

3. Click Apps from the menu

4. Select Debug (Preview) for beta and Debug (Stable) for stable

5. Pog! you should be seeing all the issues, if any

limpid roseBOT
#
Debug Result

There are 9 errors in this [code](#1091911274914381865 message):

<repl>.js:1:14 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

1 const tags = player.getTags().filter(tag => tag.startsWith("HOME:"))
               ~~~~~~

  @minecraft/server.d.ts:3318:15
    3318         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.
<repl>.js:11:21 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

11   teleportForm.show(player).then(r => {
                       ~~~~~~

  @minecraft/server.d.ts:3318:15
    3318         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.
<repl>.js:15:1 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

15 player.teleport(new Vector(...loc.split(" ")), player.dimension, player.rotation.x, player.rotation.y, true)
   ~~~~~~

  @minecraft/server.d.ts:3318:15
    3318         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.
<repl>.js:15:28 - error TS2556: A spread argument must either have a tuple type or be passed to a rest parameter.

15 player.teleport(new Vector(...loc.split(" ")), player.dimension, player.rotation.x, player.rotation.y, true)
                              ~~~~~~~~~~~~~~~~~
<repl>.js:15:48 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

15 player.teleport(new Vector(...loc.split(" ")), player.dimension, player.rotation.x, player.rotation.y, true)
                                                  ~~~~~~

  @minecraft/server.d.ts:3318:15
    3318         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.
<repl>.js:15:66 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

15 player.teleport(new Vector(...loc.split(" ")), player.dimension, player.rotation.x, player.rotation.y, true)
                                                                    ~~~~~~

  @minecraft/server.d.ts:3318:15
    3318         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.
<repl>.js:15:85 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

15 player.teleport(new Vector(...loc.split(" ")), player.dimension, player.rotation.x, player.rotation.y, true)
                                                                                       ~~~~~~

  @minecraft/server.d.ts:3318:15
    3318         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.
<repl>.js:16:5 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

16     player.sendMessage("Successfully teleport to ${name}")
       ~~~~~~

  @minecraft/server.d.ts:3318:15
    3318         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.
low kelp
#

@muted rapids

muted rapids
#

everything seems right

muted rapids
#

does anyone know what's wrong?

cloud kelp
#

@muted rapids Btw, did you import Vector?

#
import { Vector } from "@minecraft/server"
muted rapids
#

ha, I was wondering what this vector would be

muted rapids
rough quarry
#

did it work?

#

it work for me if i use runCommandAsync to teleport

muted rapids
muted rapids
#

?

rough quarry
#

do tags[r.selection].split(" ")

rough quarry
#

i did it like this```js
for (const tag of tags) {
const loc = tag.split(" ")
const home = loc[0].split(":")[1]
const x = loc[1]
const y = loc[2]
const z = loc[3]
tp.button(§a${home} \n§b ${x} ${y} ${z})
}
tp.show(player).then(result => {

       const r = tags[result.selection].split(" ")
       const home = r[0].split(":")[1]
       const x = r[1]
       const y = r[2]
       const z = r[3]
       player.runCommandAsync(`tp @s ${x} ${y} ${z}`)
       player.tell(`§aSuccessfully teleported to §b${home}!`)
       player.runCommandAsync(`playsound random.orb @s`)
    
})
muted rapids
#

@rough quarry

#

there was a space in the code there, it worked

muted rapids
#

thanks @rough quarry @cloud kelp

muted rapids
#

Thanks to that I learned other things I didn't know

muted rapids
#

like I want to put a switch that when activated the home is public that is general can teleport