[abandoned] [Mod] Override [override] (v0.2)

Post Reply
User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

[abandoned] [Mod] Override [override] (v0.2)

by AntumDeluge » Post

this mod is abandoned, for removing/replacing entities, nodes, & items at server start see cleaner

Override Mod

Description:

A mod to simplify overriding craft items. Single or multiple items can be overridden with another pre-registered item using override.replaceItems. Single or multiple items can be overridden with a newly created item using override.overrideItems.

Supported object types: (overriding other types of objects may be supported in the future)

Global functions:
  • override.replaceItems (items, target)
    • Unregisters items & set names as aliases for another existing item.
    • items: List of item names to be overridden (can be string for single item override).
    • target: Item name of aliases' target.
  • override.overrideItems (name, def)
    • Unregisters craft items & registers names as aliases for new item.
    • name: Name of new item.
    • def: Item definition (see: core.register_craftitem) with additional overrides field (list of item names to be overridden or string for single item override).
Examples:

To override multiple items with an item that is already registered, say default:diamond for example, call:

Code: Select all

override.replaceItems({"mod1:diamond", "mod2:diamond", ...}, "default:diamond")
To override multiple items with a newly created one, call:

Code: Select all

override.overrideItems("modname:item", {
    overrides = {"mod1:item", "mod2:item", ...},
    description = "New item",
    wield_image = "modname_item.png",
    ...
}
Pre-existing items can be overridden using a file named overrides.txt in the world path. Each new line in the file represents a call to overrides.replaceItems. The formatting is as follows:

Code: Select all

alias1,alias2,...;target
In the example above, each existing item (alias1, alias2, etc.) will be unregistered & re-added as an alias of target.

Licensing: Requirements:
  • Depends: none
Links:
Releases:
Last edited by AntumDeluge on Thu May 27, 2021 05:24, edited 10 times in total.

User avatar
Desour
Member
Posts: 1473
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [Mod] Override [0.1] [override]

by Desour » Post

There's a minetest.override_item(name, redefinition) function (https://github.com/minetest/minetest/bl ... .txt#L2247).
You shouldn't only look at the dev wiki.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
Linuxdirk
Member
Posts: 3219
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Override [0.1] [override]

by Linuxdirk » Post

DS-minetest wrote:You shouldn't only look at the dev wiki.
It even is in the dev wiki.

http://dev.minetest.net/minetest.override_item

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

Re: [Mod] Override [0.1] [override]

by AntumDeluge » Post

I believe this mod is a little different though, because it allows overriding multiple items at once & redefines them as aliases. Perhaps the semantics between override & redefine are confusing? I would consider the functionality of minetest.override_item to be more like redefining. Though, override works for that too.

Overriding multiple items as aliases of another is useful when there are multiple mods that use similar items. I'll try to think of a good example. At the moment I can only think of default:diamond & gems:diamond. I believe this mod makes it easy to unify similar items into one.

If the item that you want to use already exists, say default:diamond, just call:

Code: Select all

override.replaceItems({"mod1:diamond", "mod2:diamond", ...}, "default:diamond")
If you want to create a new item to override others, call:

Code: Select all

override.overrideItems("modname:diamond", {
    overrides = {"default:diamond", "gems:diamond",},
    description = "New diamond item",
    wield_image = "modname_diamond.png",
    ...
}
Also, I want to try to make this mod capable of overriding other object types as well.

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] Override [0.1] [override]

by azekill_DIABLO » Post

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

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

Re: [Mod] Override [0.1] [override]

by AntumDeluge » Post

azekill_DIABLO wrote:alias?
So, if you call:

Code: Select all

override.replaceItems("gems:diamond", "default:diamond")
gems:diamond is first unregistered with:

Code: Select all

core.unregister_item("gems:diamond")
Then, it is re-added as an alias of default:diamond using:

Code: Select all

core.register_alias("gems:diamond", "default:diamond")
The same goes for multiple items:

Code: Select all

override.replaceItems({"mod1:diamond", "mod2:diamond",}, "default:diamond")
Each of mod1:diamond & mod2:diamond is first unregistered, then re-added as aliases of default:diamond.

So, in this mod, you're not just redefining an item. You are replacing it with either an existing or new one.

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] Override [0.1] [override]

by rubenwardy » Post

override.replaceItems("gems:diamond", "default:diamond")

Could be done with

minetest.register_alias_force("gems: diamond", "default:diamond")

Nice mod anyway, to allow doing this with lists
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

Re: [Mod] Override [0.1] [override]

by AntumDeluge » Post

rubenwardy wrote:override.replaceItems("gems:diamond", "default:diamond")

Could be done with

minetest.register_alias_force("gems: diamond", "default:diamond")
I had forgotten about force.

User avatar
Wuzzy
Member
Posts: 4804
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Override [0.1] [override]

by Wuzzy » Post

This mod seems pointless. It's just a wrapper mod which doesn't add any new functionality.

If you think the syntax of current Lua API is lacking, just fix Minetest.

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

Re: [Mod] Override [0.1] [override]

by AntumDeluge » Post

I would prefer this functionality to be in the Minetest core, but I'm not a very good C++ coder. I may put in a feature request though.


--- Edit ---

Now can read from overrides.txt in world path:

override @ Git commit 35ab53c
Last edited by AntumDeluge on Wed Aug 30, 2017 18:08, edited 1 time in total.

User avatar
AntumDeluge
Member
Posts: 213
Joined: Sun Aug 07, 2016 05:42
GitHub: AntumDeluge
IRC: AntumDeluge
Contact:

Re: [Mod] Override [0.2] [override]

by AntumDeluge » Post

UPDATES:

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] Override [0.2] [override]

by azekill_DIABLO » Post

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

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests