Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8711 in orxonox.OLD for trunk/src/lib/script_engine


Ignore:
Timestamp:
Jun 22, 2006, 1:09:20 PM (18 years ago)
Author:
bensch
Message:

merged the script_engine back here

Location:
trunk/src/lib/script_engine
Files:
1 deleted
9 edited

Legend:

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

    r8408 r8711  
    1616                script_manager.cc \
    1717                script_class.cc \
    18                 script_method.cc \
    19                 \
    20                 account.cc \
    21                 object.cc
    22 
    23 
     18                script_method.cc
     19               
    2420AM_CPPFLAGS= @LUA_INCLUDES@
    2521
  • trunk/src/lib/script_engine/lunartest2.lua

    r8408 r8711  
    2222
    2323function main(arg)
    24   io.write("hello i am main!")
     24  io.write("hello i am main!\n")
    2525  -- use parameter
    2626  io.write("main received ", arg)
    2727  io.write(" as parameter\n")
    2828
    29  o = Object()
    30   o:printName()
     29 
    3130  --call member of an inserted object
    3231  Obj:printName()
    3332
    3433  --create object of a registered type
    35   --o = Object()
    36   --o:printName()
     34  o = Object()
     35  o:printName()
    3736
    3837  --take returnvalue from c
  • trunk/src/lib/script_engine/script.cc

    r8408 r8711  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
     3
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11### File Specific:
     12   main-programmer: Silvan Nellen
     13   co-programmer: Benjamin Grauer
     14*/
     15
    116#include "script.h"
    217#include "script_class.h"
    318#include "luaincl.h"
    419
     20#include "util/loading/resource_manager.h"
    521
    622#include "loading/load_param.h"
     
    5874 {
    5975
     76   std::string filedest(ResourceManager::getInstance()->getDataDir());
     77   filedest += "scripts/" + filename;
     78   
    6079   if(currentFile.length() != 0)
    6180   {
     
    6483    }
    6584
    66    int error = luaL_loadfile (luaState, filename.c_str());
     85   int error = luaL_loadfile (luaState, filedest.c_str());
    6786
    6887   if(error == 0)
    6988   {
     89     
    7090     error = lua_pcall(luaState, 0, 0, 0);
    7191
     
    192212 bool Script::pushParam(int param, std::string& toFunction)
    193213 {
    194    if(currentFunction.compare(toFunction) == 0)
     214   if(currentFunction == toFunction)
    195215   {
    196216     lua_pushnumber(luaState, (lua_Number) param);
    197217     argumentCount++;
    198     return true;
     218     return true;
    199219   }
    200220   else
     
    267287       returnCount--;
    268288     }
     289     else
     290       printf("ERROR: Form %s : trying to retreive non bolean value",this->currentFile.c_str());
    269291   }
    270292   return returnValue;
     
    313335 }
    314336
     337 bool Script::registerStandartClasses()
     338 {
     339   bool success = false;
     340   
     341   //success = this->registerClass(std::string("Vector"));
     342   
     343   return success;
     344 }
     345 
     346 
     347 bool Script::registerClass( const std::string& className)
     348 {
     349   BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);
     350   //printf("The script class for %s is at %p \n",className.c_str(),scriptClass);
     351   WorldObject tmpObj;
     352   if (scriptClass != NULL)
     353   {
     354     tmpObj.type = className;
     355     if( !classIsRegistered(className) )
     356     {
     357       static_cast<ScriptClass*>(scriptClass)->registerClass(this);
     358       tmpObj.name = "";
     359       registeredObjects.push_back(tmpObj);
     360       return true;
     361     }
     362   }
     363   return false;
     364 
     365 }
    315366
    316367 bool Script::classIsRegistered(const std::string& type)
  • trunk/src/lib/script_engine/script.h

    r8408 r8711  
     1/*!
     2 * @file scrip.h
     3 *  wrapper for a lua_State
     4 */
     5
    16#ifndef _SCRIPT_H
    27#define _SCRIPT_H
     
    5863
    5964    int  reportError(int error);                      //!< Get errormessage from the lua stack and print it.
     65    bool registerStandartClasses();                   //!< Register all the classes that the script might need
     66    bool registerClass(const std::string& className); //!< Register a class but dont add any instances
    6067    bool classIsRegistered(const std::string& type);  //!< Checks wheter the class "type" has already been registered with the script
    6168    bool objectIsAdded(const std::string& name);      //!< Checks wheter the object "name" has already been added to the script
  • trunk/src/lib/script_engine/script_class.cc

    r8408 r8711  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
  • trunk/src/lib/script_engine/script_manager.cc

    r8408 r8711  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
     3
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11### File Specific:
     12   main-programmer: Silvan Nellen
     13   co-programmer: Benjamin Grauer
     14*/
     15
     16
    117#include <string>
    218#include <list>
  • trunk/src/lib/script_engine/script_manager.h

    r8271 r8711  
     1/*!
     2 * @file scrip_manager.h
     3 *  manages the scripts
     4 */
     5
    16#ifndef _SCRIPT_MANAGER_H
    27#define _SCRIPT_MANAGER_H
  • trunk/src/lib/script_engine/script_method.cc

    r8413 r8711  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
  • trunk/src/lib/script_engine/script_method.h

    r8413 r8711  
    11/*!
    2  * @file script_class.h
     2 * @file script_method.h
    33 * @brief Definition of ...
    44*/
Note: See TracChangeset for help on using the changeset viewer.