Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7975 in orxonox.OLD for branches/script_engine


Ignore:
Timestamp:
May 30, 2006, 11:52:41 AM (19 years ago)
Author:
snellen
Message:

works finally

Location:
branches/script_engine/src/lib/script_engine
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/script_engine/Makefile.am

    r7962 r7975  
    1010bin_PROGRAMS = account
    1111account_SOURCES = \
    12                 account.cc
     12                account.cc\
     13                Script.cc
     14
    1315
    1416
     
    1921
    2022noinst_HEADERS = \
    21                 lunar.h
     23                lunar.h\
     24                Script.h
  • branches/script_engine/src/lib/script_engine/account.cc

    r7962 r7975  
    3535        static Lunar<Object>::RegType methods[];
    3636
    37         Object(lua_State* L) { }
     37        Object(lua_State* L) {callCount = 0; }
    3838        ~Object() { printf("deleted Object (%p)\n", this); }
    3939
    40         int printName(lua_State* L){std::cout<<"Hi i'm object!"<<std::endl; return 0;}
     40        int printName(lua_State* L)
     41        {
     42          printf("Hi i'm object %p ! This is the %i. call.\n",this,callCount);
     43          callCount ++;
     44          return 0;
     45        }
     46
     47
     48      private:
     49        int callCount;
     50
    4151    };
    4252
     
    6171      Lunar<Account>::Register(L);
    6272      Lunar<Object>::Register(L);
    63       Object obj(L);
    64       Lunar<Object>::insertObject(L,&obj,"Object",false);
    6573
    66 
    67 
     74      Object* obj= new Object(L);
     75      Lunar<Object>::insertObject(L,obj,"Obj",false);
     76      //delete obj;
    6877
    6978      if(argc>1) lua_dofile(L, argv[1]);
  • branches/script_engine/src/lib/script_engine/lunar.h

    r7963 r7975  
    118118        int objectRef = push(L, obj, gc);
    119119
    120         lua_pushliteral(L, "Object" );
     120        lua_pushlstring(L, name.c_str(), name.size());
    121121        lua_pushvalue(L, objectRef );
    122122        lua_settable(L, LUA_GLOBALSINDEX );
  • branches/script_engine/src/lib/script_engine/lunartest.lua

    r7962 r7975  
    55end
    66
    7 --o = Object()
    8 Object:printName()
     7o = Object()
     8o:printName()
     9
     10Obj:printName()
    911
    1012a = Account(100)
Note: See TracChangeset for help on using the changeset viewer.