Page 1 of 1

Dividing

Posted: Wednesday 01 July 2020 15:03
by Varazir
Hello,

I hade a script that worked when I created it ( some time ago ) isn't working now.
I found a workaround.

When I created the script the value I got when I used this was 1 ( if selector.level = 10 )

Code: Select all

selectedGroupNumber = selector.level/10
But now I get 1.0

Is that work as design or a bug ?


Workaround was to use 10, 20, 30 in the script rater then 1, 2, 3

TIA
Daniel

Re: Dividing  [Solved]

Posted: Wednesday 01 July 2020 15:40
by waaren
Varazir wrote: Wednesday 01 July 2020 15:03 When I created the script the value I got when I used this was 1 ( if selector.level = 10 )

Code: Select all

selectedGroupNumber = selector.level/10
But now I get 1.0
Is that work as design or a bug ?
This is because of the change to Lua 5.3 in domoticz V4.11439. In Lua 5.3 a division of two integers result in a float.
If you need it to be an integer you can use

Code: Select all

math.floor( selector.level / 10 )

Re: Dividing

Posted: Wednesday 01 July 2020 15:57
by Varazir
Thanks then I know it was a change caused it. Well as I said I made it work without division.