#Detect first time on a new dimension

16 messages · Page 1 of 1 (latest)

thick cape
#

I want to create a script that detect if it is the first time a player enters the Ad Astra mod Moon, and since the mod's system teleports you to the equivalent x, z position on the moon i want to reposition the player to the position x = 0, z = 0 every time he enters the dimension. I have some other things i would like to add to this system but they're not the main topic of this post so i'll have them apart if anyone can help me :

  • I want to save the player's inventory if it is his first time on the dimension, and then give all the items back after some requirements are complete.

  • I want to generate a structure if it is the first time a player enters the dimension, for multiplayer reasons, i don't want multiple structures being generated, so only one structure at x = 0, z = 0 would be generated.

golden warrenBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

thick cape
#

Ok, i have a script with kjs adittions, but i have no idea why it doesn't work

#

i will send it in a moment if anyone can check it

#

ok.. maybe i've been an idiot...

#

i'll check somethin real quick and i'll post the script here if anyone else needs it

thick cape
#

no, didn't work

#

here's the script

#
  
// priority: 0

 console.info('Moon Scripts work')

CommonAddedEvents.playerChangeDimension(event => {
    event.server.tell(event.getNewWorldKey())
    let dimension = event.getNewWorldKey()
    let sdimension = dimension.slice(33, dimension.length-1)
    event.server.tell(dimension.slice(33, dimension.length-1))
    if (sdimension == "minecraft:the_nether"){
        event.server.tell('hello')
    }
});
#

also for some reason the 2nd server.tell event doesn't work

#

...

#

i had to convert the

event.getNewWorldKey()
#

to a string

#

why it wasn't a string before?

#

no idea.

#

The WORKING script :

CommonAddedEvents.playerChangeDimension(event => {
    let dimension = String(event.getNewWorldKey())
    if (dimension.slice(34, dimension.length-1) == "minecraft:the_nether"){
        event.server.tell('hello')
    }
});