Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/script_engine/src/lib/script_engine/lunartest.lua @ 7821

Last change on this file since 7821 was 7821, checked in by snellen, 18 years ago

should compile now

File size: 555 bytes
Line 
1 function printf(...) io.write(string.format(unpack(arg))) end
2
3function Account:show()
4  printf("Account balance = $%0.02f\n", self:balance())
5end
6
7a = Account(100)
8b = Account:new(30)
9
10print('a =', a)
11print('b =', b)
12print('metatable =', getmetatable(a))
13print('Account =', Account)
14table.foreach(Account, print)
15
16a:show() a:deposit(50.30) a:show() a:withdraw(25.10) a:show()
17
18parent = {}
19
20function parent:rob(amount)
21  amount = amount or self:balance()
22  self:withdraw(amount)
23  return amount
24end
25
26getmetatable(Account).__index = parent
27
28debug.debug()
Note: See TracBrowser for help on using the repository browser.