Modular System

  • LittleProgramming
    23rd Nov 2019 Member 0 Permalink

    So, as of right now, TPT wouldn't need any changes. However, in the next updates, I think elements should be made in separate .LUA files which are modules. Basically, each category would have its own module. At first it might be hard to code in the system, but after that, coding new elements would be a breeze.

  • LBPHacker
    23rd Nov 2019 Developer 1 Permalink

    Coding new elements is already a breeze, and you can organise your elements into modules just fine. (Also, TPT doesn't use LUA, it uses Lua.)

  • LittleProgramming
    23rd Nov 2019 Member 0 Permalink

    On my computer, all file extensions are CAPITALIZED. The main TPT engine uses C++, but maybe the team could code some final bits and pieces then switch to Lua with modules.

  • LBPHacker
    23rd Nov 2019 Developer 0 Permalink

    That makes no sense at all >_>

  • LittleProgramming
    23rd Nov 2019 Member 0 Permalink

    Let me simplify.

     

    I said .LUA because of my computer showing every single file extension as ALL CAPS.

     

    The Powder Toy is coded in C++ (probably the most popular coding language), but you can make mods for it in Lua.

     

    The development team could maybe add some extra Lua functions to the kernal...

     

    ..then make the modules.

  • jacob1
    23rd Nov 2019 Developer 1 Permalink
    We would much rather have the freedom to code elements in c++. There are many elements that just aren't possible to replicate in Lua.

    In addition, Lua elements are very slow. You've probably noticed this. We don't want to decrease performance by 90% just to move the elements to Lua.


    I am open to using Lua to embed other things into the game, though. The script manager and multiplayer script are both in Lua, and are much easier to code in Lua than in c++. In this instance, we could embed the scripts into the game. But we aren't going to use Lua for performance-intensive stuff like elements.
  • LittleProgramming
    23rd Nov 2019 Member 0 Permalink

    Understood.

  • jacob1
    23rd Nov 2019 Developer 0 Permalink
    As another tangent, we do have one script embedded into the game now. It's this one:
    https://github.com/The-Powder-Toy/The-Powder-Toy/blob/master/src/lua/luascripts/eventcompat.lua

    It reimplements functions like tpt.register_step and tpt.register_keypress, which were removed in 94.0. It was much easier to handle this backwards compatibility in Lua than to try to keep the old api functions in the game and working the same way.