+ Reply to Thread
Results 1 to 7 of 7

Thread: LUA defined entities

  1. #1
    Wirererer Pangamini's Avatar
    Join Date
    Feb 2009
    Location
    Slovakia
    Posts
    358

    Question LUA defined entities

    (This is not LUA for GMOD)

    I am working on a game. I have hit the problem, maybe those more experienced in lua might know what i need. So what's going on:

    I have implemented LUA in my c++ project. It works well.
    I want to have entities that are created and controlled by lua code. What i have got now is that when lua code is loaded and executed, c++ functions that define the main properties of the entity are called. For now these contain functions like "addProp", "addWeld", "addHinge", "makeMotor" and so on. In the c++ there is an object for every type of entity created, which holds these parameters (called EntDef for example)
    then there are LUA functions called every game tick to control the entity. And here's the problem: i made the compiled chunk shared for all entities of one type (means one chunk per EntDef), which works well for definition and creating. Problem is that lua function "Tick" also shares all the lua globals with other entities.
    One (and only one i could imagine clearly) solution would be to create separate chunk for every entity created; only problem there is the amount of lua code to compile and store in memory - everything is compiled for every one. Would this be too expensive?

    If you have any idea what i am talking about, feel free to help me xD

  2. #2
    Not a bot itsbth's Avatar
    Join Date
    Feb 2007
    Location
    Norway
    Posts
    1,173

    Default Re: LUA defined entities

    Lua Lua Lua Lua Lua Lua (not LUA).

    See how GMod does it.
    Or if you want to make it simple, just pass a table.

  3. #3
    Wirererer Pangamini's Avatar
    Join Date
    Feb 2009
    Location
    Slovakia
    Posts
    358

    Default Re: LUA defined entities

    "see how GMod does it"

    Can you send me the source codes?

    Another thing - attempts to call "setmetatable" results in error (global setmetatable nil) any ideas? It's built-in function.
    Yeah this is the thing that bothers me the most now.

    --LOL i had to implement default basic lua function by myself xD looks crappy but works :-P
    Last edited by Pangamini; 02-18-2010 at 04:47 PM.

  4. #4
    ◕␣◕ McLovin's Avatar
    Join Date
    Sep 2008
    Location
    Batman, Turkey
    Posts
    2,346
    Blog Entries
    3

    Default Re: LUA defined entities

    Use gamemonkey, then you don't have to emulate classes or any of that BS.
    Anticept - HP you are terrible at trolling. Always have been. Leave it up to the pros like Jat.
    Black Phoenix - Actually cunt goes into bullshit. Bullshit does not fit in cunt.
    Drunkie - Logically, Jat Goodwin must be a fist pumping guido.

  5. #5
    Wirererer Pangamini's Avatar
    Join Date
    Feb 2009
    Location
    Slovakia
    Posts
    358

    Default Re: LUA defined entities

    I have no idea what is that gamemonkey, but i have already solved this using metatables

  6. #6
    ◕␣◕ McLovin's Avatar
    Join Date
    Sep 2008
    Location
    Batman, Turkey
    Posts
    2,346
    Blog Entries
    3

    Default Re: LUA defined entities

    GameMonkey Script

    Real classes! Dealing with an object oriented language is usually a better solution, especially in games.
    Anticept - HP you are terrible at trolling. Always have been. Leave it up to the pros like Jat.
    Black Phoenix - Actually cunt goes into bullshit. Bullshit does not fit in cunt.
    Drunkie - Logically, Jat Goodwin must be a fist pumping guido.

  7. #7
    Wirererer Pangamini's Avatar
    Join Date
    Feb 2009
    Location
    Slovakia
    Posts
    358

    Default Re: LUA defined entities

    It's how you understand lua metatables. If you get them, it can be even more powerful than classes. It's freedom :-P

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots