Title as said: I am trying to convert Inch of mercury(inhg) into towards hectopascal(hpa) but the conversion factor is giving me offset values of whats is shown here.
Current conversion factor as shown by convertInhgToHpa
For another example: Standard Pressure should equal to
inhg 29.92 - hpa 1013
local WeatherValues = game:GetService("ReplicatedStorage").DynamicWeather.Scripts.DynamicWeather.WeatherValues
local Frame = script.Parent.Frame
local Foursplc
local Threesplc
local Twosplc
local Onesplc
local function convertInhgToHpa(Value)
local conversionFactor = 33.86389
local hpaValue = Value * conversionFactor
return hpaValue
end
-----------------------------------------------------------------------------------------------------------------------
repeat
task.wait(1)
local GetPressure = tostring(WeatherValues.AtmosphericPressure.Value)
local pressureInPsi = WeatherValues.AtmosphericPressure.Value
local pressureInHpa = convertInhgToHpa(pressureInPsi)
Foursplc = string.sub(GetPressure, 1,1)
Threesplc = string.sub(GetPressure, 2,2)
Twosplc = string.sub(GetPressure, 5,5)
Onesplc = string.sub(GetPressure, 6,6)
warn("Atmospheric Pressure: INHG["..Foursplc..""..Threesplc.."."..Twosplc..""..Onesplc.."] HPA["..math.round(pressureInHpa).."]")
until 1 == 0
Ok. I’m a bit confused on what’s going on with your repeat loop. First,
can be changed to until false or to a while loop.
Second, what is going on with all of this sub string stuff?
Try this
local WeatherValues = game:GetService("ReplicatedStorage").DynamicWeather.Scripts.DynamicWeather.WeatherValues
local Frame = script.Parent.Frame
local decimalPlaces = 2
local function convertInhgToHpa(Value)
local conversionFactor = 33.86389
local hpaValue = Value * conversionFactor
return hpaValue
end
--===========================================================================--
--===========================================================================--
while task.wait(1) do
local pressureInPsi = WeatherValues.AtmosphericPressure.Value
local pressureInHpa = convertInhgToHpa(pressureInPsi)
local roundedPressure = math.round(pressureInPsi * 10^decimalPlaces) / 10^decimalPlaces
warn("Atmospheric Pressure: INHG["..roundedPressure.."] HPA["..math.round(pressureInHpa).."]")
end
@ABizarre_Dummy’s solution will be great, just make sure that you don’t mix up your PSI and inHg readings. You used 2 variables (GetPressure and pressureInPsi) but you gave them both the inHg value.
local pressureInInHg = WeatherValues.AtmosphericPressure.Value
This somewhat gave me good results, Idk why I did that loop in the first place honestly. The strings were just something quickly thrown together. However, I am still having trouble with my conversionfactor issue still with converting the atmosphere pressure of inhg to hpa. I updated the value from:
--Before during posted factor
local conversionFactor = 33.86389
--After updating conversion factor
local conversionFactor = 33.8639