Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

started writing wrapper class

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