• sp3ctr4l@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    60
    arrow-down
    2
    ·
    edit-2
    3 hours ago

    … Ok, that is legitimately impressive, from a technical standpoint.

    Lua is a high level, not exactly very ‘fast’, very performant language. It is designed to be very, very human readable, and coding noob friendly.

    Getting a 3D physics engine to work … in lua… is not something I would have thought possible.

    Usually you need to use a much lower level language to … actually do that.

    EDIT:

    A few other commenters have now pointed out that this is actually using LuaJIT… which passes Lua code to a C compiler, quickly translates and then compiles in C, and then runs in C.

    So, that makes much more sense, its functionally running in C, a lower level, compiled code language.

    Still impressive nonetheless!

    • gamer@lemm.ee
      link
      fedilink
      English
      arrow-up
      4
      ·
      2 hours ago

      Imma be the guy and drop an ackshually

      • Nothing about Lua would make it difficult to implement a physics engine in it compared to other languages
      • The hardest part would be integrating with Morrowind’s systems. If the engine doesn’t expose e.g. collision geometry to scripts in an efficient way, then you’ll run into some real challenges
      • Even without LuaJIT, there’s no reason to expect performance so bad you can’t implement realtime rigid body physics. Interpreted Lua is fast, but even if it wasn’t, a 60 fps performance target for physics is not tough to achieve at all
      • Zahille7@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 hours ago

        Project Zombie and GMod both use Lua scripts. GMod is also one of the best physics sandboxes imo, and has like the most mods on the workshop ever.

        • Leuthil@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          1 hour ago

          The physics in GMod isn’t implemented in Lua though. It was already part of the Source engine.

          Unless GMod isn’t referring to Garry’s Mod.

    • everyonesconnected@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      8
      ·
      6 hours ago

      So from what I can read, the Morrowind Script Extender uses LuaJIT instead of regular lua, which does tracing just-in-time compilation. Meaning, and I’m just paraphrasing wikipeda here, it compiles frequently executed sequeneces of operations into machine code.

      • sp3ctr4l@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        4 hours ago

        Now, that is a very relevant detail!

        I did not know LuaJIT was even a thing.

        Still probably not as performant as … C++ or Rust or something, that is totally precompiled… but that would explain how this is even possible, a 3D Lua based physics engine.

        Yeah, looks like LuaJIT passes a bunch of the Lua code into C, just good ole C, and then dynamically compiles it, then runs the ‘translated’ C code.

        That makes a lot more sense lol.

      • sp3ctr4l@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        6 hours ago

        I haven’t benchmarked anything in a while, so it is possible Lua is more performant now than it once was… but in my (out of date) experience, python is faster than Lua, and nearly every language that is actually compiled is… one or two or three orders of magnitude faster.

        Though it is also worth mentioning that Lua is fairly simple to plug in to some kind of database language, which can result in reasonably good performance in situations involving say… dynamically spawning or unspawning tons of inventory style minor items, or containers with them.

        Lua has been fast enough to handle a simple 2D physics engine… but this is the first time I am hearing of it handling 3D.

    • datavoid@lemmy.ml
      cake
      link
      fedilink
      English
      arrow-up
      28
      arrow-down
      1
      ·
      14 hours ago

      It is designed to be very, very human readable, and coding noob friendly

      As someone who can’t wrap my head around lua syntax, I will have to assume I simply have too much coding experience

      • gradual@lemmings.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        5 hours ago

        Yeah, I remember using LUA back in the day for gmod.

        Hands down one of the shittiest languages I ever touched, right down there with PHP.

        Really puts into perspective how stupid developers can be when deciding the tools that they use.

      • sp3ctr4l@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        2
        ·
        6 hours ago

        I know what you mean lol, but Lua is very noob friendly… it goes fairly far out of its way to make many common functions and data types as compatible with each other as possible… so thats another way it is generally more slow, but also more forgiving, won’t just totally error out and be frustrating to a beginner coder.