What about short aliases?

User avatar
LNJ
Member
 
Posts: 200
Joined: Tue Sep 23, 2014 16:02
GitHub: LNJ2
IRC: LNJ2GO
In-game: LNJ

What about short aliases?

by LNJ » Tue Jun 09, 2015 17:00

What about short aliases?
Like for doors:door_wood an alias door_wood!

I had the idea that you create a setting in the minetest.conf and just when this setting is activatet the mods register their aliases.

Then it would be much easier to work with /give or /giveme!
There are already some aliases in the default-mod for old maps. Why not do more of them?

What do you think about it?
My Minetest Modding Tutorials (German) | Minetest TNG - My survival subgame! (OUTDATED... :() | #ComeToTheDuckSide - we have privacy! | diaspora* - The free and decentralized alternative to facebook and twitter!
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: What about short aliases?

by Krock » Tue Jun 09, 2015 18:22

Aliases are good until there are node name conflicts.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: What about short aliases?

by rubenwardy » Tue Jun 09, 2015 18:23

Here's a mod to do it (untested):

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local added = {}
for name, value in pairs(minetest.registered_item) do
   local nodeparts = string.split(name, ":")
   if #nodeparts == 2 then
      local item = nodeparts[2]
      if not added[item] then
         minetest.register_alias(name, item)
         added[item] = true
      end
   end
end


I don't recommend that this is included by default.
If there is a 'item' conflict (from mod:item, for example foo:bar and pub:bar would conflict), then the item with a lower value mod name alphabetically would be used.

To install, make a folder called "short_aliases" in a mods folder, create a file called "init.lua" in there
with that code as its content (use Notepad++, Wordpad, Gedit, Kate, Atom, etc - a plaintext editor)
 

User avatar
jbb
Member
 
Posts: 72
Joined: Tue Dec 09, 2014 17:16
GitHub: JBBgameich
IRC: JBB
In-game: JBB

Re: What about short aliases?

by jbb » Wed Jun 10, 2015 18:39

I think this is a great idea.
If avery mod will add a short alias, you could use /give better without knowing the item string of every block.
I think this could be added in the new Minetest 0.5.
Minetest runs better on Linux. So I'm using Linux.
 

User avatar
LNJ
Member
 
Posts: 200
Joined: Tue Sep 23, 2014 16:02
GitHub: LNJ2
IRC: LNJ2GO
In-game: LNJ

Re: What about short aliases?

by LNJ » Fri Aug 21, 2015 17:14

jbb wrote:I think this is a great idea.
If avery mod will add a short alias, you could use /give better without knowing the item string of every block.
I think this could be added in the new Minetest 0.5.


I think it would be better if just the mods from minetest_game use short aliases for now.
So there wouldn't be any compatibily problems.
My Minetest Modding Tutorials (German) | Minetest TNG - My survival subgame! (OUTDATED... :() | #ComeToTheDuckSide - we have privacy! | diaspora* - The free and decentralized alternative to facebook and twitter!
 

User avatar
SegFault22
Member
 
Posts: 870
Joined: Mon May 21, 2012 03:17

Re: What about short aliases?

by SegFault22 » Sun Aug 23, 2015 07:33

Aliases do not have to be registered within the mod which adds the item that the alias references; the alias registering code can be contained within a separate mod. Server owners could simply include one "aliases" mod which registers all of the aliases for all mods' items, so that conflicts are taken care of by default.

You could even make a mod which iterates through a table, using the strings in each row of each line for the parameters passed to the minetest.register_alias() function - instead of writing out the same function call once for each alias, only one function call needs to be existing in the mod file, which is put to work for each entry in the table. This has the result of decreasing the file size (by a fractional amount) when a large number of aliases need to be registered - it also makes the list a lot easier for the human to read, and easier for other mods to modify via table.insert() and other table modifying functions.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
aliases = {
{"default:stick_pine","stick_pine"},
{"default:stick_jungle","stick_jungle"},
{"pub:bar","bar"},
{"foo:bar","foobar"},
}
for _, row in ipairs(aliases) do
    local itemid = row[1]
    local alias = row[2]
    minetest.register_alias(alias,itemid)
end

However, the server owner would have to make each entry in the list, instead of simply having the alias registry entries done by each individual mod for its own items - also, the list would have to be updated every time a mod (for which an alias is registered) is removed, and every time a new mod is added for which the server owner desires aliases. But, it gets rid of the alias conflict problem, which results from independent mods creating aliases with the same name.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: What about short aliases?

by rubenwardy » Sun Aug 23, 2015 07:38

Automagick:

rubenwardy wrote:Here's a mod to do it (untested):

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local added = {}
for name, value in pairs(minetest.registered_item) do
   local nodeparts = string.split(name, ":")
   if #nodeparts == 2 then
      local item = nodeparts[2]
      if not added[item] then
         minetest.register_alias(name, item)
         added[item] = true
      end
   end
end
 


Return to Minetest General

Who is online

Users browsing this forum: Bing [Bot] and 13 guests

cron