diff options
Diffstat (limited to 'scripts/common.lua')
-rw-r--r-- | scripts/common.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/common.lua b/scripts/common.lua new file mode 100644 index 0000000..d84d97d --- /dev/null +++ b/scripts/common.lua | |||
@@ -0,0 +1,21 @@ | |||
1 | function waitForTick() | ||
2 | return coroutine.yield() | ||
3 | end | ||
4 | |||
5 | function moveLeft(id, len, speed) | ||
6 | local remaining = len / speed | ||
7 | |||
8 | while (remaining > 0) do | ||
9 | id:ponderable().vel.x = -speed | ||
10 | remaining = remaining - waitForTick() | ||
11 | end | ||
12 | end | ||
13 | |||
14 | function moveRight(id, len, speed) | ||
15 | local remaining = len / speed | ||
16 | |||
17 | while (remaining > 0) do | ||
18 | id:ponderable().vel.x = speed | ||
19 | remaining = remaining - waitForTick() | ||
20 | end | ||
21 | end | ||