• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Get your art tools and paintbrushes ready and enter Hive's 34th Texturing Contest: Void! Click here to enter!

[Lua] Do some natives that returns integer now returns real?

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,930
Hello, this question is because when I use the function tostring in an integer value that I get from functions like GetItemCharges or GetHeroLevel it appears with decimals, why? This didn't happen before. I know I can solve it by using the functions I2S or math.floor, but that is too much of a pain.
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,930
You may want to hook the problem functions to solve the issue so you don't have to repeat the fix everywhere.

Lua:
local oldGetItemCharges = GetItemCharges
GetItemCharges = function(whichItem)
     return math.floor(oldGetItemCharges(whichItem))
end

There's also this library by Bribe [Lua] - Hook
It might work, but is strange why is happening this now.
 
Status
Not open for further replies.
Top