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
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} }})
- * 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)