From 3cdee540fcc2da22b4c11aea910f433039583252 Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Tue, 12 Jul 2022 03:12:04 +0300 Subject: [PATCH] Added examples: standard library and scripts --- examples/componentTest.ht | 10 +++++++++ examples/simulateTest.ht | 42 ++++++++++++++++++++++++++++++++++++++ examples/standard.lcsproj | Bin 0 -> 8291 bytes 3 files changed, 52 insertions(+) create mode 100644 examples/componentTest.ht create mode 100644 examples/simulateTest.ht create mode 100644 examples/standard.lcsproj diff --git a/examples/componentTest.ht b/examples/componentTest.ht new file mode 100644 index 0000000..865eaee --- /dev/null +++ b/examples/componentTest.ht @@ -0,0 +1,10 @@ +fun simulate(inputs) -> Map { + final result = Map() + if (inputs['A'] && inputs['B']) { + result['OUT'] = true + } else { + result['OUT'] = false + } + return result +} + diff --git a/examples/simulateTest.ht b/examples/simulateTest.ht new file mode 100644 index 0000000..c033d62 --- /dev/null +++ b/examples/simulateTest.ht @@ -0,0 +1,42 @@ +var inputsValue = 0 + +fun onLoad { + snackBar("Script loaded", "Start", start) +} + +fun getFunctions { + return ["start", "random"] +} + +fun start { + inputsValue = 0 + simSetPartiallySimulating(false) + simRestart() + tick() +} + +fun tick { + final inputs = getInputs() + final inputsLength = inputs.length + + simSetInputsBinary(inputsValue) + inputsValue += 1 + + if (inputsValue >= Math.pow(2, inputsLength)) { + inputsValue = 0 + snackBar("Finished going through all possible values", "Restart", () { + start() + }) + } + else { + setTimeout(1000, tick) + } +} + +fun random { + final inputs = getInputs() + final inputsLength = inputs.length + + simSetInputsBinary(Math.randomInt(Math.pow(2, inputsLength))) +} + diff --git a/examples/standard.lcsproj b/examples/standard.lcsproj new file mode 100644 index 0000000000000000000000000000000000000000..fe4cc3ded616202ba6535b2138de757da6a3f5d7 GIT binary patch literal 8291 zcmcIpc{o&U|F%PwY$GN|sbAP_;{T-^MppYydpQtF`kok+V1-^_LHcemW#Q`T?TIltiYFueS$-?r#oj`v>}K{aYA6Y7_F_ z_?V5X{QMy=81j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