Created
May 12, 2020 20:35
-
-
Save foxicode/44ec9c3b9c08e28bc0ce89692f247384 to your computer and use it in GitHub Desktop.
Sample Lua script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local circle1 = 1 | |
| local circle2 = 2 | |
| local circle3 = 3 | |
| local time = 0.0 | |
| local step = 0 | |
| function tick(delta) | |
| time = time + delta | |
| if (time >= 1000) then | |
| time = time - 1000 | |
| loopStep() | |
| end | |
| end | |
| function loopStep() | |
| if step == 0 then | |
| updateProperty(circle1, 'color', '#50ff0000') | |
| updateProperty(circle2, 'color', '#ffffff00') | |
| updateProperty(circle3, 'color', '#5000ff00') | |
| elseif step == 1 then | |
| updateProperty(circle1, 'color', '#50ff0000') | |
| updateProperty(circle2, 'color', '#50ffff00') | |
| updateProperty(circle3, 'color', '#ff00ff00') | |
| elseif step == 2 then | |
| updateProperty(circle1, 'color', '#ffff0000') | |
| updateProperty(circle2, 'color', '#50ffff00') | |
| updateProperty(circle3, 'color', '#5000ff00') | |
| end | |
| step = (step + 1) % 3 | |
| end | |
| function start(width, height) | |
| local circleRadius = height / 10 | |
| addWidget('Circle', | |
| circle1, | |
| width / 2, | |
| circleRadius * 2, | |
| circleRadius, | |
| '#ffff0000') | |
| addWidget('Circle', | |
| circle2, | |
| width / 2, | |
| circleRadius * 5, | |
| circleRadius, | |
| '#50ffff00') | |
| addWidget('Circle', | |
| circle3, | |
| width / 2, | |
| circleRadius * 8, | |
| circleRadius, | |
| '#5000ff00') | |
| end | |
| return start, tick |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment