| 1 |
ball = { |
| 2 |
xpos = 60, |
| 3 |
ypos = 60, |
| 4 |
|
| 5 |
-- without the colon syntax, must mention self argument explicitly |
| 6 |
move = function(self, newx, newy) |
| 7 |
self.xpos = newx |
| 8 |
self.ypos = newy |
| 9 |
end |
| 10 |
} |
| 11 |
|
| 12 |
-- using the colon, ball is passed as self automatically |
| 13 |
ball:move(100, 120) |
| 14 |
|
| 15 |
-- using the dot, must pass self explicitly |
| 16 |
ball.move(ball, 100, 120) |
| 17 |
|
| 18 |
-- From https://pico-8.fandom.com/wiki/Lua |
| 19 |
|