Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to check if player is in the given region #6

Open
OnsenManju opened this issue Nov 12, 2016 · 4 comments
Open

Failed to check if player is in the given region #6

OnsenManju opened this issue Nov 12, 2016 · 4 comments

Comments

@OnsenManju
Copy link

(Sorry to bother you again)
Reported here: https://tshock.co/xf/index.php?threads/keychangerssc.2528/page-4#post-47250

Tried debugging.
key_change

https://github.com/Enerdy/KeyChanger/blob/master/KeyChanger.cs#L246
Though I don't know much about TShock API, I think it would be better to use TileX,TileY for InArea() rather than raw coordinates(X,Y)...?
--> if (!region.InArea(args.Player.TileX, args.Player.TileY))

@AxisKriel
Copy link
Owner

This was me trying to do coordinates as my first project in TShock plugin development. God bless who even knows the difference between X/Y and TileX/Y when they begin with our lackluster documentation.

X and Y are the "real" coordinates used by the game. TileX and TileY are basically X/Y divided by 16 seeing as Terraria tiles are 16x16 pixels in size.

I believe TShock regions use TileX and TileY for storing coordinates (seeing as it would be silly to store ridiculously big numbers) so InArea probably should use that.

@OnsenManju
Copy link
Author

Thanks for the detailed explanation! Now I got it.
https://github.com/NyxStudios/TShock/blob/master/TShockAPI/TSPlayer.cs#L545-L559

@AxisKriel
Copy link
Owner

803e777

@OnsenManju
Copy link
Author

It worked as intended on the latest TShock 4.3.22, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants