Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

158 Neutral

About mrDIMAS

  • Rank

Personal Information

  • Industry Role
  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Yeah, I hate global variables and will punish script writers if they want to use them. Every function used by quest will accept "self" argument, and user can do anything with it. As I said above, using globals in my project is forbidden. I warn users about it in docs for scripts.
  2. I've figured out how to do what I want: luaL_dofile(L, "script.lua"); // now we have 'init', 'update' etc in global table // create new quest-table lua_newtable(L); // copy needed functions into quest table lua_pushstring(L, "init"); lua_getglobal(L, "init"); lua_settable(L, -3); lua_pushstring(L, "update"); lua_getglobal(L, "update"); lua_settable(L, -3); lua_setglobal(L, "QuestN"); // there we have to generate unique quest id Further improvement: check if we have needed functions after script execution. Also we have to check if function does not exist in a script. To do this we have to do something like this lua_pushnil(L); lua_setglobal("init"); lua_pushnil(L); lua_setglobal("update"); luaL_dofile(L, "script.lua"); lua_getglobal(L, "init"); if(lua_isnil(L, 1)) throw exception("..."); lua_pop(L, 1); lua_getglobal(L, "update"); if(lua_isnil(L, 1)) throw exception("..."); lua_pop(L, 1); ...
  3. Thank you, guys! This approach is fine too. This is for quests in my game. Quest needs only to have few basic functions which I wanted to place in file and populate quest-table with it. I wanted to create quest instances on C++ side. But as I see this is not a good way of doing this.
  4. Hello everyone! I need to fill lua table with functions from script file like this: function init() end function update() end I need to create table on stack and fill it with this functions from specified file. How can I do this?
  5. Hi! I wrote object pool. This is single-header library for fast object allocation. All objects inside of the pool placed in a contiguous memory block to be cache-friendly. Detailed description is in repository. https://github.com/mrDIMAS/SmartPool Here is some examples: class Foo { private: int fooBar; public: Foo() {} Foo(int foobar) : fooBar(foobar) {} }; ... Pool<Foo> pool(1024); // make pool with default capacity of 1024 objects Handle<Foo> bar = pool.Spawn(); // spawn object with default constructor Handle<Foo> baz = pool.Spawn(42); // spawn object with any args // do something // return object to pool pool.Return(bar); pool.Return(baz); Results of tests are in attached files. Please, criticize it and give me some feedback.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!