Dont store the amount. It is changing while offline. Buildtime can be negative !
On item 'time' get
set buildtime to max(0 , (ItemValue - awaytime))
set amount to (buildtime) - (round(buildtime/10) *10)
i set those you are said. "build time" is perfect but "amount" has problem.
when build time is (last number < 5) :
94 ,844 ,54, 1014 : "amount"= 4
23 , 2543 , 3 , 83 : "amount"= 3
when build time is (last number >= 5) :
99 , 1059, 729 : "amount"= -1
597, 67 , 337 , 4597 : "amount"= -3
when build time is (last number = 0) :
"amount"= 0