Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/script_engine/lunartest.lua @ 8184

Last change on this file since 8184 was 8061, checked in by bensch, 18 years ago

merged the scriptengine back to the trunk

File size: 629 bytes
RevLine 
[7821]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
[8044]7
[7975]8o = Object()
9o:printName()
[7962]10
[8021]11Obj:printName() --external added object
[7975]12
[7821]13a = Account(100)
14b = Account:new(30)
15
16print('a =', a)
17print('b =', b)
18print('metatable =', getmetatable(a))
19print('Account =', Account)
20table.foreach(Account, print)
21
22a:show() a:deposit(50.30) a:show() a:withdraw(25.10) a:show()
23
[8044]24
25
[7821]26parent = {}
[8044]27 function parent:rob(amount)
[7821]28  amount = amount or self:balance()
29  self:withdraw(amount)
30  return amount
31end
32
33getmetatable(Account).__index = parent
34
[7829]35--debug.debug()
Note: See TracBrowser for help on using the repository browser.