Jump to content
Banjo

How do you get the player's co-ordinates?

Recommended Posts

Posted (edited)

Simple question, related to my other thread but since nothing showed up in searches I thought it would be better to ask in a new one so others can find it for help if they want to do the same...

 

EDIT: SOLVED!

 

I figured it out, but for those who are wanting to know how, here's the code from Robomat's awesome Co-Ordinates Viewer mod...

 

        local absX = player:getX();
        local absY = player:getY();


        local cellX = absX / 300;
        local cellY = absY / 300;
        local locX = absX % 300;
        local locY = absY % 300;

 

absX and absY are "absolute" co-ordinates (where in the whole game world you are)

 

cellX, cellY, locX and locY are "relative" co-ordinates (current cell and location within it, as used in start spawns)

 

Edited by Banjo

Share this post


Link to post
Share on other sites

player:getX() is float, and it may be 1234.5

(absX / 300) is float too! Not integer.

So I think there is a mistake...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...