Talk:API GetUnitSpeed

Hey guys, I figured this out and just put the solution in the article coz I figured at least they'd have the info that way. Feel free to put the page into standard WoWWiki format. =) - Hillie (talk) 22:57, 21 November 2008 (UTC)

Thanks for the info. I'll set it up to use the API template once I figure it out. I just put this here to make it known that it exists since I added it to my mod. --Zefler (talk) 14:14, 24 November 2008 (UTC)

I noticed that sometimes while flying on a gryphon or when teleporting or something like that, that it returns 0,0 as your location. It stays that way indefinitely it seems until I open and close the map.. I am using CT_MapMod so it might be something CT_MapMod is doing but opening and closing the map seems to fix it. is it something with the function itself or is it something i'm not doing I wonder... - Hillie (talk) 14:24, 24 November 2008 (UTC)

Sounds like a call to SetMapToCurrentZone is required after a zone change for this API to return a value then. Similar to other location type calls. Opening your map and closing it calls SetMapToCurrentZone automatically. I'll test this tonight and will update. Thanks. --Zefler (talk) 17:20, 26 November 2008 (UTC)

k I was actually confused when I wrote this. I meant GetPlayerMapPosition.. but yeah, I just saw that in the API page. You have to call SetMapToCurrentZone. Sorry for the confusion - Hillie (talk) 20:41, 27 November 2008 (UTC)

Format as float to fix rounding issues
If the speed is formatted as float, it rounds instead of truncating, which makes the 420% display as 420% instead of 419%.

/script print(string.format("Current speed: %.0f%%", 100 * GetUnitSpeed("player") / 7))

I am also generally inclined to multiply before dividing, although it doesn't really matter here.