Skip to content

Commit b30aed5

Browse files
committed
added: rounding variable values to 1 decimal place
1 parent e2dac7a commit b30aed5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ export class WingInstance extends InstanceBase<WingConfig> implements InstanceBa
216216
})
217217

218218
this.variableHandler.on('update-variable', (variable, value) => {
219-
this.setVariableValues({ [variable]: value })
219+
let rounded = Math.round((value + Number.EPSILON) * 10) / 10
220+
if (Number.isInteger(value)) {
221+
rounded = Math.round(value)
222+
}
223+
this.setVariableValues({ [variable]: rounded })
220224
})
221225

222226
this.variableHandler.on('send', (cmd: string, arg?: number | string) => {

0 commit comments

Comments
 (0)