• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 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,853
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,853
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