Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/script_engine/lunartest2.lua @ 8290

Last change on this file since 8290 was 8271, checked in by bensch, 19 years ago

merge

File size: 1.0 KB
RevLine 
[8046]1function printf(...) io.write(string.format(unpack(arg))) end
2
3function Account:show()
4  printf("Account balance = $%0.02f\n", self:balance())
5end
6
7parent = {}
8
9function parent:rob(amount)
10  amount = amount or self:balance()
11  self:withdraw(amount)
12  return amount
13end
14
15getmetatable(Account).__index = parent
16
[8271]17
18function test()
19io.write("Hi i'm test\n")
20end
21
22
[8046]23function main(arg)
[8271]24  -- use parameter
[8046]25  io.write("main received ", arg)
26  io.write(" as parameter\n")
[8271]27
28  --call member of an inserted object
[8046]29  Obj:printName()
[8271]30
31  --create object of a registered type
32  o = Object()
33  o:printName()
34
35  --take returnvalue from c
36  callCount = Obj:getCallCount()
37  io.write("callCount is now ",callCount)
38  io.write("\n")
39
40  --pass parameters to a c++ method
41  Obj:takeParam(3)
42
43  --print object information
[8046]44  print('a =', a)
45  print('b =', b)
46  print('metatable =', getmetatable(a))
47  print('Account =', Account)
48  table.foreach(Account, print)
49
50  a:show() a:deposit(50.30) a:show() a:withdraw(25.10) a:show()
51  Obj:printName()
[8058]52
[8271]53  return 2,false,2.72
54
[8046]55  --debug.debug()
56end
Note: See TracBrowser for help on using the repository browser.