• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

151 Neutral

About Davaris1

  • Rank
  1. Python 3.3.2 Embedding

    I made a modification to the start of the CallPlugIn function         //PyObject* pluginModule = PyImport_Import(name);     PyObject* pluginModule = PyImport_ImportModule(PLUGIN_NAME);     It got me further into the function, but the result string is null.     const char* resultStr = PyBytes_AsString(resultObj);       Edit: I tried this code and it got the right result.     char *cstrret;     PyArg_Parse(resultObj, "s", &cstrret);     I used this tutorial:   https://www6.software.ibm.com/developerworks/education/l-pythonscript/l-pythonscript-ltr.pdf   Its the only one I've found that works.  
  2. I am following this turorial and am not getting anywhere, with the code that was provided. I am running Python 3.3.2.   It returns null on   PyObject* pluginModule = PyImport_Import(name);     static const char* PLUGIN_NAME = "shout_filter"; String<> CallPlugIn(const String<>& ln) {     PyObject* name = PyBytes_FromString(PLUGIN_NAME);     PyObject* pluginModule = PyImport_Import(name);     Py_DECREF(name);     if (!pluginModule)     {         PyErr_Print();         return "Error importing module";     }     PyObject* filterFunc = PyObject_GetAttrString(pluginModule, "filterFunc");     Py_DECREF(pluginModule);     if (!filterFunc)     {         PyErr_Print();         return "Error retrieving 'filterFunc'";     }     PyObject* args = Py_BuildValue("(s)", ln);     if (!args)     {         PyErr_Print();         Py_DECREF(filterFunc);         return "Error building args tuple";     }     PyObject* resultObj = PyObject_CallObject(filterFunc, args);     Py_DECREF(filterFunc);     Py_DECREF(args);     if (!resultObj)     {         PyErr_Print();         return "Error invoking 'filterFunc'";     }     const char* resultStr = PyBytes_AsString(resultObj);     if (!resultStr)     {         PyErr_Print();         Py_DECREF(resultObj);         return "Error converting result to C string";     }     String<> result = resultStr;     Py_DECREF(resultObj);     return result; } int RunThatPythonScript() {     Py_Initialize();     PyObject* sysPath = PySys_GetObject((char*)"path");     PyObject* curDir = PyBytes_FromString(".");     PyList_Append(sysPath, curDir);     Py_DECREF(curDir);     String<> input = "Do Something With This Text";     CallPlugIn(input);     Py_Finalize();     return 0; }     I was getting the same issue with the official version demo:   http://docs.python.org/3/extending/embedding.html#embedding-python-in-c   Any suggestions?
  3. Video Game Architecture

    [quote name='flodihn' timestamp='1333317755' post='4927297'] [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3]I think it is pretty clear I am referring to the green arrows as an sort of abstraction thing, and not the grey boxes that is the lists and maps etc.[/size][/font][/color] [/quote] Okay, I see you don't understand the diagram at all. If it is a library like Utility Library, or Math Library, that can be used anywhere and don't rely on anything else, the arrows don't point anywhere, they end just outside their yellow box. Arrows that extend from one yellow box to another, mean those boxes rely on them. For instance Job Manager needs System Utilities. If you don't understand something, its better to ask how it works, than to say there is something wrong with it. Edit: I see Eric L. explained it above, better than I did.
  4. Video Game Architecture

    [quote name='flodihn' timestamp='1333314926' post='4927276'] I was not talking about the lists, arrays, strings etc. I was talking about the three arrows that point from the Utility Class and points to the System Managers. So my point is still valid. [/quote] From your block comment, you started out by demonstrating, you don't know what Lists, Arrays, Maps, Strings, Hash Tables, Smart Links, Reference Tables, Graphs and Trees are, or how and where they are used. I am not going to explain them to you, you need to take a basic programming class for that. This is stuff [u]everyone[/u] knows. I don't mean to be rude, but its pretty its obvious you haven't the faintest clue, what you are talking about. I am not suprised you don't understand this diagram.
  5. Video Game Architecture

    [quote name='flodihn' timestamp='1333300720' post='4927215'][list] [*]Looking at top left corner, the "Utility Library", it has 3 green arrows to something called "System Managers", what this means is not as I said not defined, so I have to "guess" it means some sort of abstraction, that[u] things in the "Utility Library" access "stuff" in "System Managers"[/u], probably in a very nested way that they could not draw it. [/list] [/quote] You really don't know what Lists, Arrays, Maps, Strings, Hash Tables, Smart Links, Reference Tables, Graphs and Trees are??? This is basic 101 stuff, all programmers know.
  6. exceptions in agelscript

    Just curious WitchLord, as you are going to add exceptions, what is your opinion of design by contract in AngelScript? For some reason C++ never introduced it, only Digital Mars has it for C++ as far as I know. [url="http://www.digitalmars.com/ctg/contract.html"]http://www.digitalma...g/contract.html[/url]
  7. I want an object to behave like this in AngelScript, but am unable to get it to work. [code] // AngelScript Code: ZedScriptW p(ptrToZedEntityID1); ZedScriptW s(ptrToZedEntityID2); [/code] This part seems to work. [code] // C++ r = engine->RegisterObjectType("ZedScriptW", sizeof(ZedScriptW), asOBJ_VALUE|asOBJ_APP_CLASS|asOBJ_APP_CLASS_CONSTRUCTOR|asOBJ_APP_CLASS_DESTRUCTOR); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("ZedScriptW", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ZedScriptW_Constructor), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("ZedScriptW", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(ZedScriptW_Destructor), asCALL_CDECL_OBJLAST); assert( r >= 0 ); [/code] However I can't figure out how to create a constructor that accepts multiple parameters. This is my attempt [code] // C++ r = engine->RegisterObjectBehaviour("ZedScriptW", asBEHAVE_CONSTRUCT, "void f(ZedEntityID @)", asFUNCTIONPR(ZedScriptW_Constructor_ZedEntityID, (ZedScriptW*, ZedEntityID*), void), asCALL_CDECL_OBJLAST); assert( r >= 0 ); [/code] This is the code for the constructor that takes a parameter. The function is called when I run it, but ownerID points to garbage. [code] // C++ void ZedScriptW_Constructor_ZedEntityID(ZedScriptW *memory, ZedEntityID *ownerID) { new(memory) ZedScriptW(); if (ownerID) memory->SetComponent(ownerID->GetOwner()); } [/code] Can anyone help? Edit: I think I have figured it out while writing this post. asCALL_CDECL_OBJLAST is the hint. So I have swapped the params around. [code]r = engine->RegisterObjectBehaviour("ZedScriptW", asBEHAVE_CONSTRUCT, "void f(ZedEntityID @)", asFUNCTIONPR(ZedScriptW_Constructor_ZedEntityID, ( ZedEntityID*, ZedScriptW*), void), asCALL_CDECL_OBJLAST); assert( r >= 0 void ZedScriptW_Constructor_ZedEntityID(ZedEntityID *ownerID, ZedScriptW *memory)[/code] Hopefully all of the above is correct. If not please let me know.
  8. AngelScript 2.21.2 released

    Thank you.
  9. Compatibility Issues with C4 Engine [Solved]

    I got AngelScript working with the C4 Engine, even when using the standard string class. I found these instructions in the C4 forums. [quote]If you use any standard headers, then you need to disable the C4FASTBUILD option. #define C4FASTBUILD 0[/quote] [quote] When new/delete are interfering with compilation: The only way that this would happen is if that external library is using the new operator in its header files. That being the case, you need to include any headers associated with that library before any C4 headers for each translation unit.[/quote] Just to be safe, I include all standard header files before the C4 files and it compiles.
  10. Assertion Error in scriptmgr.cpp

    Hi WitchLord, I was just testing your demo game and got an assertion of r = -10 at line 59 and line 87, in scriptmgr.cpp. I downloaded the tarball from here: [url="http://angelscript.svn.sourceforge.net/viewvc/angelscript/trunk/"]http://angelscript.s...elscript/trunk/[/url] It works fine when I use scriptstdstring.h, but when I use my version of it, those functions do not register. Edit: I have found my mistake. In my version of scriptstdstring.cpp I used "String" instead of "string".
  11. Thanks for your answers. They were very helpful.
  12. What the best way to go about this? I have some code from an old tutorial and they are loading all the files into one module and then calling function names from that module. [quote] // Load weapons script file if (LoadScript( pScriptEngine, "common.as", MAIN_MODULE ) < 0) { pScriptEngine->Release(); cout << "Failed to load script file." << endl; Pause(); return -1; } // Load weapons script file if (LoadScript( pScriptEngine, "weapons.as", MAIN_MODULE ) < 0) { pScriptEngine->Release(); cout << "Failed to load script file." << endl; Pause(); return -1; } // Load main script file that runs in synch with the game loop if (LoadScript( pScriptEngine, "main.as", MAIN_MODULE ) < 0) { pScriptEngine->Release(); cout << "Failed to load script file." << endl; Pause(); return -1; }[/quote] So is it better to create an additional module for each creature in a game, or should I have only 1 module and have unique "main functions", based on each creature's name? Creature1Main() { } Creature2Main() { } etc.
  13. RegisterObjectType returns asINVALID_NAME

    Thanks for replying so quickly. I just did what you said and it works. This is a very nice system!
  14. I'm trying to get my first script working using the C4 String class. Unfortunately it is hitting an assert and is returning asINVALID_NAME here: r = engine->RegisterObjectType("String<>", sizeof(String<>), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK); Assert( r >= 0 ); I have replaced string with String<> all through scriptstdstring.cpp, so I am not sure what I should do. Any suggestions?
  15. Compatibility Issues with C4 Engine [Solved]

    [quote name='WitchLord' timestamp='1315537023' post='4859330'] If C4 is using its own string class and you plan to expose C4's functionality to the script then it is probably better to rewrite the desired add-ons to use this class instead of std::string. This is exactly why angelscript doesn't have a built-in string type, so the application can pick and choose the best implementation. [/quote] Thanks for your help.
  • Advertisement