AxisKriel / KeyChanger

SBPlanet KeyChanger System: Enchanges special chest keys by their correspondent items
2 stars 9 forks source link

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

Open OnsenManju opened 7 years ago

OnsenManju commented 7 years ago

(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 commented 7 years ago

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 commented 7 years ago

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

AxisKriel commented 7 years ago

803e77709689e30f8e195a65a3e462366aa4a54b

OnsenManju commented 7 years ago

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