#home dimension teleport

1 messages · Page 1 of 1 (latest)

ripe anchor
#

Like I have the home system so if the person is in another dimension it will not teleport him to this other dimension how do I make him teleport to the dimension where he is home

solid raptor
#

save the dimension along with the home data

#

then tp to the dimension

ripe anchor
#

This I know, I want to know how

#

?

solid raptor
#

learn js and how to use the scripting api like MANY have already suggested

#

you keep asking every single possible question in here

ripe anchor
#

This no longer has anything to do with js

#

And yes with the components of mine

ripe anchor
sly bison
#

@ripe anchorhttps://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/entity#teleport

ripe anchor
#

It doesn't say how to get the dimension that the player is

ripe anchor
#

there simple thing bro

ripe anchor
#

I was testing to see if it would

#
player.addTag(`HOME:${r.formValues[0]}: ${Object.values(player.location).map(Math.floor).join(" ")} :${dim}`)
#
const Dimension = r[4]

player.teleport({x, y, z}, Dimension)
#

I tried in other ways the "player.teleport"

#

what's wrong?

granite hearth
#

Dimension is a class that is instantiated. You need to get it from the world class

ripe anchor
#

like this?

ripe anchor
#

?

granite hearth
#

U didn't send anything

ripe anchor
#

what is wrong?

#

I already spent 2 hours testing different things

granite hearth
#

Just get the dimension from the world instance then put that into the dimension parameter

ripe anchor
#

Did not help

granite hearth
#

Literally what I just said

var dimension = world.getDimension('overworld');
player.teleport(new Vec3(0,0,0), dimension);
ripe anchor
#

I did different

#

then I saved the result in the tag and then got it there

granite hearth
#

That's not the same as an instantiated dimension

ripe anchor
#

Hum?

#

but there I would only be getting overworld

granite hearth
#

Id is an id. Its not an object

ripe anchor
#

so how would I get the dimension that the person is for me to save in the tag and then get it?

ripe anchor
granite hearth
#

That's the thing. Use the id to get the dimension to then pass it into the method

ripe anchor
#

So is it right? Before "player.teleport"?

granite hearth
#

Yes

ripe anchor
#

vec3 have any import?

granite hearth
#

Mate. Just look at the docs. Everything you need to know is right there

ripe anchor
#

I tested and it wasn't a friend

granite hearth
#

Once u learn how to use the docs. Just looking at a method will give you all the information you need. Which class to import, What parameters to fill and the errors that are thrown, asynchronous operation etc..

ripe anchor
#

where do i learn?

#

but the focus here is another

granite hearth
#

I mean how much more direct can you not be

ripe anchor
#

I already read it there

#

?

#

I'm understanding nothing

#
function exgui5(player) {
  const dim = player.dimension.id
  const createForm = new ModalFormData()
    .title("§lCriar home")
    .textField("Nome da home:", "...")

  createForm.show(player).then(r => {
    if (r.canceled) return;
const [name] = r.formValues
if (name === "") {
 player.sendMessage("§cColoque o nome da home!")
return;
}
player.addTag(`HOME:${r.formValues[0]}: ${Object.values(player.location).map(Math.floor).join(" ")} ${dim}`)
 player.sendMessage(`§aHome criada com sucesso§f "${r.formValues[0]}"`)
  })
}
#
function exgui6(player) {
const tags = player.getTags().filter(tag => tag.startsWith("HOME:"))
if (tags.length === 0) {
  const gui8 = new ActionFormData()
gui8.title("§lTeleportar Home")
gui8.body("Voce nao possui home para teleportar!")
gui8.button("§lCriar Home");
        gui8.show(player).then(result => {
if(result.selection === 0){
                exgui5(player);
            }
        })
  return;
}
  const tp = new ActionFormData()
    .title("§lTeleportar Home")
    .body("Selecione uma home:")

 for (const tag of tags) {
    const loc = tag.split(":")
    const home = loc[1]
    const x = loc[2].split(" ")[1]
    const y = loc[2].split(" ")[2]
    const z = loc[2].split(" ")[3]
    tp.button(`§l${home}\n§2${x} ${y} ${z}`)

    }
    tp.show(player).then(result => {
    
    const r = tags[result.selection].split(":")
    const home = r[1]
    const x = r[2].split(" ")[1]
    const y = r[2].split(" ")[2]
    const z = r[2].split(" ")[3]
    const dimension =  world.getDimension(r[3])
    
           player.teleport(new Vec3(x,y,z), dimension);
           player.sendMessage("§aSucesso ao se teleportar na home§f " + home)
           player.runCommandAsync(`playsound random.orb @s`)
       
    })
}
raven rockBOT
#
Stable/Experimental/Beta

Stable: This means the current, publicly supported version of Minecraft. Everyone plays Stable by default.

Experimental: Experimental can be turned on per-world. If you want to use Experimental things in your addons you (and everyone who uses your addon) will need to turn on Experimental in their world.

Beta: Beta is the most extreme "cutting edge" Minecraft. Beta is opt-in, meaning you need to install it separately. It will replace your stable Minecraft unless you use a version switcher. Beta players cannot play with stable players, and visa-versa.

Marketplace: Marketplace work cannot contain beta or experimental features.

Sometimes we say exp instead of experimental

ripe anchor
#

I still don't know where it went wrong

granite hearth
#

The type of variable

#

Also you got basically a lot of things wrong there

ripe anchor
granite hearth
#

Do you even know what you are trying to put in. Trace the code because it starts at the very point you start putting variables into the constants

ripe anchor
#

Yes

granite hearth
#

Ill explain in the simplest terms. Your putting a string into an integer for the method and your also putting a string into the dimension parameter

#

Integer is not string

ripe anchor
granite hearth
#
    const r = tags[result.selection].split(":")
    const home = r[1]
    const x = r[2].split(" ")[1]
    const y = r[2].split(" ")[2]
    const z = r[2].split(" ")[3]
    const dimension = r[3]
    
           player.teleport(new Vector3(x,y,z), dimension);
``` all of this is wrong
ripe anchor
#

exactly what?

#

because when I hadn't tried to put it to teleport in the right dimension it was working

granite hearth
#

All of it

#

EVERY SINGLE LINE

#

Is wrong

ripe anchor
#

You didn't understand the question

#

Can you give a simple to understand explanation?

granite hearth
#

I told you way before. Your putting a variable that is typeof string into a method that takes no string parameters

#

Meaning you need to convert your variables

#

For starters. Change

const dimension = r[3]

to

const dimension = world.getDimension(r[3])
ripe anchor
#

I didn't know this one

ripe anchor
#

but there I was only getting the one from the normal world

#

puts falter

granite hearth
#

Exactly. So you change that example to match your code

#

I'm never gonna give full blown code. Only from examples

ripe anchor
#

at the time I only understood the code and didn't try to change it

ripe anchor
#

do you have any more errors?

granite hearth
#

At this point just wrap that entire function in try catch and log the error to console to debug it

ripe anchor
#

?

tawdry pebbleBOT
#
Debug Result

There are 2 errors in this [code](#1093629549054541894 message):

<repl>.js:10:17 - error TS2552: Cannot find name 'exgui5'. Did you mean 'exgui6'?

10                 exgui5(player);
                   ~~~~~~

  <repl>.js:1:10
    1 function exgui6(player) {
               ~~~~~~
    'exgui6' is declared here.
<repl>.js:37:32 - error TS2304: Cannot find name 'Vec3'.

37            player.teleport(new Vec3(x,y,z), dimension);
                                  ~~~~

ripe anchor
#

it didn't work