In-game scripting for advanced animations

  • I have seen a lot of people demanding ways to perform advanced things in the game, and I believe they are right to want that. And since LUA scripting is already supported in the game, I would suggest implementing this on the client side for constructions. I would support this on objects, and not blocks. The idea is this:

    • Each object could have two more properties : UID (null or none by default), and an axis. This axis could be selected via the mouse (i.e. the same way a light can be fixed on an object, etc.) and implementing this would only mean to display that axis when editing the object's properties (i.e. object edit mode)
    • Activating an object would run an associated LUA script on the client. Any update made the script would update any other users nearby. Object activation could be triggered by one of these event : action key (via keyboard), or proximity


    An example script could be



    Obviously, the limitation of the scripts should not affact objects outside a certain range (i.e. retrieving an object that is too far away would fail, even if that object exists). and the object's original position should be able to reset in case a script mess up it's coordinates and position (i.e. obj:reset();). Also, an object UID can only be seen if the player can edit in the area where the object is placed.


    The possiblity with this can allow to make

    • Custom doors, windows, etc.
    • Teleporters, Elevators
    • Dynamic lighting
    • Trains and subways, buses
    • etc.


    Anyway, this is a draft idea. I don't know how to integrate this with the idea of power sources (for power lines, and other ideas that were discussed the forum regarding objects requiring an energy source to work), or how to move a group of objects at once.
    et me know what you think!

  • It's quite a very interesting idea, but there are several problems: The biggest problem is the fact, that all objects are (clientside) baked into one mesh per chunk. If you are going to change the object position via script now, the game would have to recalculate the whole mesh. If you want to do something like a "smooth" movement, this would require frequent transformations (i.e. recalculations of the mesh), and you will run quickly into performance issues.
    Doors for example are a special case in the game, since they do modify the vertexbuffer of the mesh directly (the vertexindex of the door inside the "big mesh" is stored, and when opening/closing a door, the accordings vertices are moved every tick to simulate "smooth movement"). Unfortunately this approach is not possible for modifications via Lua =/


    What we can offer instead: The creation of dynamic objects via Lua. You could move and rotate them with nearly no performance costs then. Only the object itself will have an impact on performance, but it would be no problem if there are not too many dynamic objects at the same location.
    And since dynamic lights are already supported by the game (when carrying a torch, flashlight etc.), we can also allow the creation of dynamic lightsources via Lua ;) But again, dynamic lights have a big impact on performance, so it's wise to use them with care.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!