Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/script_engine/src/lib/script_engine/account.cc @ 8397

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

fixed out the T::ClassName

File size: 1.4 KB
Line 
1
2
3
4#include <iostream>
5
6#include "luaincl.h"
7#include "base_object.h"
8#include "lunar.h"
9
10#include "script_class.h"
11
12
13 class Account : public BaseObject {
14      lua_Number m_balance;
15   public:
16    // static const char className[];
17     static Lunar<Account>::RegType methods[];
18
19     Account(lua_State *L)      { m_balance = luaL_checknumber(L, 1); }
20     Account(double balance=0)    : m_balance(balance) { this->setClassID(CL_ACCOUNT, "Account"); }
21
22     void deposit (float value) { m_balance += value; };
23     void withdraw(float value) { m_balance -= value; };
24     float balance() { return m_balance; };
25
26     int deposit (lua_State *L) { m_balance += luaL_checknumber(L, 1); return 0; }
27     int withdraw(lua_State *L) { m_balance -= luaL_checknumber(L, 1); return 0; }
28     int balance (lua_State *L) { lua_pushnumber(L, m_balance); return 1; }
29     ~Account() { printf("deleted Account (%p)\n", this); }
30 };
31
32 //const char Account::className[] = "Account";
33
34 Lunar<Account>::RegType Account::methods[] = {
35   {"deposit", new ExecutorLua1<Account, float>(&Account::deposit)},
36   {"withdraw", new ExecutorLua1<Account, float>(&Account::withdraw)},
37   {"balance", new ExecutorLua0ret<Account, float>(&Account::balance)},
38   {0,NULL}
39 };
40
41tScriptClass<Account> global_ACCOUNT_ScriptableClass("Account", CL_ACCOUNT, NULL);
42
43
44//CREATE_SCRIPTABLE_CLASS(Account, CL_ACCOUNT, NULL);
Note: See TracBrowser for help on using the repository browser.