[mod]Lua Entities Overrider [WIP][entity_override]

Post Reply
User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

[mod]Lua Entities Overrider [WIP][entity_override]

by taikedz » Post

Github: https://github.com/taikedz-mt/entity_override
Download: https://github.com/taikedz-mt/entity_ov ... master.zip
License: LGPLv3

Demo video: https://www.youtube.com/watch?v=36VhUWrMjQY

Minetest: Lua Entity Override

Override behaviour of Lua entities.

Why this mod?

This mod is intended to provide a small framework to redefine Lua entities without touching the original mods' Lua files directly - instead, the properties are changed at runtime, during load.

This goes some ways to reduce technical debt - a state where every update to the original or supporting code causes you to need to maintain/reapply your changes.

This way, you can keep up to date with regularly changing mods without having to untangle merge conflicts from your customizations.

Its main use will be to override mob behaviours, but can be used for any entity in the minetest.registered_entities list.

How to use this mod
  • Create a new mod for your customizations
    Add a dependency on this mod, as well as the mods you want to override
    Create your Lua files using the simple API structure
Example

Code: Select all

local demofunction = function(self,clicker)
        minetest.chat_send_player(clicker:get_player_name(),"You right-clicked a "..self.name)
        return true
end

local genrewrite = {
        type="npc",
        hp_max = {
                check=function(oldval) return oldval < 30 end,
                value=30, --  new value to assign, if above check of the old value returned true
        },
        on_rightclick = {
                fchain_type = "before",
                fchain_func = demofunction
        }
}

override:rewrite("dmobs:panda",genrewrite)
override:rewrite("dmobs:fox",genrewrite)

-- make a bigger, stronger orc whilst leaving the normal one alone

override.clone("dmobs:orc","mydmobs:orc")
override.rewrite("mydmobs:orc",{reach=4,armor=80,visual_size={ value={x=5,y=5} }})
To Do
  • * Allow some way of de-registering entities altogether
    * provide an ABM canceller
    * proof of concept code for overriding some mobs_redo functions (example of adding functionality without packaging a modified API file - e.g. as do NSSM or ESMOBS currently)
Last edited by taikedz on Sat Sep 15, 2018 12:02, edited 7 times in total.

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod][wip] Lua Override [override]

by taikedz » Post

An example of this being in use can be found here https://github.com/taikedz/vivarium/blo ... g/init.lua

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [mod][wip] Lua Override [override]

by azekill_DIABLO » Post

nice!
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
TheReaperKing
Member
Posts: 531
Joined: Sun Nov 22, 2015 21:36
Contact:

Re: [mod][wip] Lua Override [override]

by TheReaperKing » Post

This is super useful!! I have to take lava out for my students and this will make life much easier updating the minetest_game. I was wondering, is there a reason to use LGPL 3 instead of LGPL 2.1 like minetest uses? I'm not sure if it matters but it might make life easier for people if it shared the same license as minetest since I believe the main difference is that with the LGPL 3 you have to provide the install instructions.
Become A Real Life Superhero - http://SuperheroHill.com
Project Lead of the Doom 3 Mod Last Man Standing - http://Doom3Coop.com
Project Lead of Platinum Arts Sandbox Free 3D Game Maker - http://SandboxGameMaker.com
Youtube Channel - https://www.youtube.com/user/PlatinumArtsKids

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod][wip] Lua Override [override]

by taikedz » Post

TheReaperKing wrote:This is super useful!! I have to take lava out for my students and this will make life much easier updating the minetest_game.
Thanks - hope it makes life easier for you!
TheReaperKing wrote:I was wondering, is there a reason to use LGPL 3 instead of LGPL 2.1 like minetest uses? I'm not sure if it matters but it might make life easier for people if it shared the same license as minetest since I believe the main difference is that with the LGPL 3 you have to provide the install instructions.
TL;DR = it's actually more useful and clearer to distribute under LGPLv3 than LGPLv2.1, and no extra requirements or duties are asked of users or implementors.

Long story is:

There are no extra duties or burdens from LGPLv2.1 to LGPLv3 that I noticed, though v3 is, in my mind, lexically clearer. v2.1 refers to the licensed software as a "Library" (which can cause problems in later legal interpretations - would you call the full Minetest package a "Library", and if not can the license even be meaningfully applied), and adds some strange requirements (written offer of source code, etc) that don't really mesh with modding and application distribution.
LGPLv2.1 wrote:A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
Compare against
LGPLv3 wrote:“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
I am no lawyer, but in the way I interpret the text, the later version is more manageable and usable.

The section on installation instructions is conditional on its applicability, generally to perpetuate installation instructions in a re-distributed and modified form, and does not refer so much to an installation guide as it does to documenting the prerequisite requirements and expected environment:
LGPLv3 wrote:Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL
The corresponding GPL version states:
GPLv3_sec6 wrote:"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.

If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).

User avatar
TheReaperKing
Member
Posts: 531
Joined: Sun Nov 22, 2015 21:36
Contact:

Re: [mod][wip] Lua Override [override]

by TheReaperKing » Post

Thanks for that insight! Looks like you've definitely done your research :) Easier to read is definitely a good thing!
Become A Real Life Superhero - http://SuperheroHill.com
Project Lead of the Doom 3 Mod Last Man Standing - http://Doom3Coop.com
Project Lead of Platinum Arts Sandbox Free 3D Game Maker - http://SandboxGameMaker.com
Youtube Channel - https://www.youtube.com/user/PlatinumArtsKids

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [mod][wip] Lua Override [override]

by rubenwardy » Post

Really, as a library, it might be worth licensing this mod under a permissive license such as MIT. Making it copyleft stops permissive mods and subgames such as Pixture from using this. It's much more useful to have one shared library that everyone can use, rather than forcing permissive games to make their own version - given that the active code is 60 lines ish long, wouldn't be that hard.

Also, I feel like the mod name should have "entity" in it, like "lib_entity_overrider" or something like that, and the title should contain entity too.

Assuming that you don't want to change the mod name, this would be a better title:

Code: Select all

[Mod] LuaEntity Member Function Override [WIP] [override]
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod][wip] Lua Override [override]

by taikedz » Post

Thanks rubenwardy. I'll do a proper rename as per your suggestion once back on laptop.

As for LGPL, It doesn't force anyone to rewrite an implementation and can be linked to without making any licensing demands on someone else's larger body of work (aside from direct changes to my code) -- it is specifically designed to allow other people to even make proprietary apps whilst still using the LGPL'd code. I feel this is amply permissive, keeping to my choice of keeping my own code Free whilst still allowing anyone else to license the rest of their work as they please.....

User avatar
taikedz
Member
Posts: 698
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake
Location: Scotland, UK
Contact:

Re: [mod]Lua Entities Overrider [WIP][entity_override]

by taikedz » Post

Added table concatenation

Did a demo video https://www.youtube.com/watch?v=36VhUWrMjQY

Post Reply

Who is online

Users browsing this forum: No registered users and 54 guests