Jump to content

Get Position of an entity


StormLight
 Share

Recommended Posts

function spawnmob(loc: location, entity: entity type):
    spawn {_entity} at {_loc}

on death:
    if victim is pig:
        if victim's name is "&kWorld Border":

command /pig:
    trigger:
        spawnmob(location of player, pig)    
        set name of last spawned entity to "&kWorld Border"
        set {_entity} to last spawned entity
        set {variable._x} to x-position of {_entity}
        set {variable._z} to z-position of {_entity}
        send "%{variable._x}%" to player
        send "%{variable._z}%" to player

every 1 seconds in world "world":
    set {variable._x} to x-position of {_entity}
    set {variable._z} to z-position of {_entity}
    make console execute command "worldborder center %{variable._x}% %{variable._z}%"			
			

So basically, I am trying to get the world border to follow a pig. I did get the base off of AgentGamerPro's Skript. 

I have done quite a bit of editing, but I need to know how to get the coords of the pig after it has moved. Right now, it just gets the coordinates of where it spawned at. Any help would be greatly appreciated!

Link to comment
Share on other sites

Hello @StormLight!

1. I'm glad you took inspiration from the skript i made, really makes me happy 😄

2. I don't know whats wrong with this skript... here is the main stuff in my skript:

 

function spawnmob(loc: location, entity: entity type):
	spawn {_entity} at {_loc}

command /pig:
	permission: pig
	permission message: Hey, you can't use this command!
	trigger:
		spawnmob(location of player, pig)	
		set name of last spawned entity to "World Border"
		set {entity} to last spawned entity

every tick in world "world": # will be laggy, suggest 5 ticks for better performance
	set {x} to x-position of {entity}
	set {z} to z-position of {entity}
	make console execute command "worldborder center %{x}% %{z}%"

hopefully this helps, again, i don't know what's wrong with your skript... maybe it's the different variables? although keep in mind with this skript i sent it dosent save the entity, so you have to do /pig again when the server restarts.

Edited by AgentGamerPro

 

 

image.png.bc433d6489d70ad831075fe76809b993.png

Lifestealed | Minecraft Servers

[VIP] 12/26/20 - 10/27/2021
[PRO] 12/27/21 - Present

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share



×
×
  • Create New...