Page 1 of 1

[Mod] MultiHome [multihome]

Posted: Sat May 13, 2017 02:32
by octacian
MultiHome [multihome]
Image
GitHub: octacian/multihome
Download: Master (latest, stable)

Warning: MultiHome uses important features currently only available in development builds of Minetest. In order to get MultiHome working properly, you'll need to build your own version of Minetest newer than this commit (January 26th, 2017).

MultiHome is a Minetest mod allowing players to set multiple homes rather than just one home through Minetest Game's sethome mod. MultiHome supports limiting the max number of homes per-player (default: 5) and has two compatibility layers to allow working with sethome. The chatcommands made available by MultiHome depend on the compatibility mode chosen, as shown below.

Note: If MultiHome is set to no compatibility mode, the multihome privilege is required to use MultiHome features, otherwise the home privilege from sethome is used.

Compatibility

MultiHome provides exactly two compatibility modes allowing the mod to work with homes previously created with the sethome mod. If no compatibility mode is set, the setting defaults to none and the default set of chatcommands is used. The compatibility mode can be set with multihome.compatiblity in minetest.conf, valid values being none, deprecate, and override.

The first two compatibility modes use the same chatcommand (/multihome) as documented below, however, deprecate overrides chatcommands from sethome causing them to display a message stating that they are deprecated and /multihome should be used instead. Note: If a compatibility mode is set and the sethome mod is not found, compatibility is automatically set to none.

When attempting to vist a home using any compatibility mode, if the player does not specify a home to teleport to and they only have one home, the player will be automatically teleported to that home.

Compatibility: None/Deprecate

Both the none and deprecate compatibility modes use the same chatcommand, however deprecate adds deprecation messages as mentioned above. The best way to learn how to use this /multihome chatcommand is to use the in-game help, /help multihome, however, an overview of the usage can be found below.

/multihome <action> <home name> | <set, del (delete), go, list> <home name (not required with list)>

Compatibility: Override

The override compatibility mode does not use one single chatcommand, but rather overrides the chatcommands used by sethome for use by MultiHome and registers two extras (see below).

/home <home name>: Teleport to the home specified
/sethome <home name>: Set the position of the home specified
/delhome <home name>: Delete the home specified
/listhomes: List player's homes

Importing Homes

MultiHome supports imported homes from sethome in both the deprecate and override compatibility options. Importing can be enabled by setting multihome.import = true in minetest.conf. This will cause MultiHome to automatically import homes created by sethome in the player attributes whenever a player with a home joins. MultiHome will also import homes from the `homes` file in the world directory, however, as they are imported they cannot be removed from the file but instead set an attribute on the player indicating that any old homes have already been imported and should not be overwritten. These homes will be named default in MultiHome and will be removed from the player attributes after they have been imported.

Re: [Mod] MultiHome [multihome]

Posted: Sat May 13, 2017 21:13
by GreenXenith
Yessss!

Re: [Mod] MultiHome [multihome]

Posted: Sat May 13, 2017 21:21
by Chibi ghost
cool nice idea before I got the teleport mod I was always loosing houses
and every now and then the teleporter bugs out and looses a location so to set a spare home location is ideal

Re: [Mod] MultiHome [multihome]

Posted: Sun May 14, 2017 02:21
by ExeterDad
I'm very pleased with this one my friend :)
Especially since it's using player attributes so if and when it's time to cull out old players... the data goes with them when player files are removed.
However.. I seem to remember mention on Github that deletion of player attributes caused issues at this time. Did that get worked out and I haven't noticed?

Edit: Also MTG's newest /home also imports the homes from the homes flatfile and moves them into player attributes. Eventually the homes file will become empty. So homes that have already moved, will be missed.

Edited Edit: Okay looking closer you DO grab the homes from attributes for import, but not from the flatfile that might not of been imported yet with new MTG. Maybe include those if they exist?

Re: [Mod] MultiHome [multihome]

Posted: Sun May 14, 2017 11:23
by azekill_DIABLO
+1, needed on servers!

Re: [Mod] MultiHome [multihome]

Posted: Sun May 14, 2017 13:52
by octacian
ExeterDad wrote:However.. I seem to remember mention on Github that deletion of player attributes caused issues at this time. Did that get worked out and I haven't noticed?
I was never aware that this was a problem, however, I can say that it definitely isn't at this point as everything works fine for me.
ExeterDad wrote: Edited Edit: Okay looking closer you DO grab the homes from attributes for import, but not from the flatfile that might not of been imported yet with new MTG. Maybe include those if they exist?
Just pushed an update that includes positions from the flat file. The one downfall is that I cannot easily remove the old homes from the flat file, so instead I just set another attribute on the player indicating that homes have already been imported and should not be imported again. Interestingly enough though, MTG's sethome doesn't actually import items from the file to attributes and then remove them from the file, it just reads old ones from the file and only stores new ones in attributes.

Re: [Mod] MultiHome [multihome]

Posted: Sun May 14, 2017 17:59
by ExeterDad
octacian wrote:I was never aware that this was a problem, however, I can say that it definitely isn't at this point as everything works fine for me.
I can't quote were I "thought'" I read about that. I likely misunderstood. Thanks for confirming :)
octacian wrote:Interestingly enough though, MTG's sethome doesn't actually import items from the file to attributes and then remove them from the file, it just reads old ones from the file and only stores new ones in attributes.
Unless I'm reading it wrong, the code in this commit says it does remove the homes entry?
https://github.com/minetest/minetest_ga ... 74e8e88047
At or near "-- remove `name` from the old storage file"

Anyhow... looking forward to getting this mod into our server :)

Re: [Mod] MultiHome [multihome]

Posted: Mon May 15, 2017 05:05
by octacian
ExeterDad wrote:Unless I'm reading it wrong, the code in this commit says it does remove the homes entry?
Ah, you're right it does. However, after giving this some thought it is still impossible for me to delete entries from the homes file once I import them into MultiHome, only the original sethome mod can do that as writing to the file with MultiHome as well could cause major issues. At this point I wouldn't worry about it though, the issue will never present itself as a real gameplay-affecting issue, plus, there isn't really anything I can do.

Also, thanks to all for the positive feedback, it's really an encouragement!

Re: [Mod] MultiHome [multihome]

Posted: Tue May 16, 2017 07:24
by dawgdoc
I imagine I may be doing something wrong, but I am getting errors when this mod is enabled.

I first added multihome.compatibility = override to minetest.conf. When that generated errors I tried multihome.compatibility = deprecate, which caused a similar error. I placed the setting below the basic_privs line. The errors generated were :

Code: Select all

2017-05-16 01:18:05: WARNING[Main]: Mod name conflict detected: "farming"
2017-05-16 01:18:05: WARNING[Main]: Will not load: /usr/share/minetest/games/minetest_game/mods/farming
2017-05-16 01:18:05: WARNING[Main]: Overridden by: /home/dawgdoc/.minetest/mods/farming
2017-05-16 01:18:05: ERROR[Main]: The following mods could not be found: "3dmushrooms" "along_shore" "bushes" "bushes_classic" "cavestuff" "dryplants" "ferns" "flowers_plus" "junglegrass" "molehills" "nature_classic" "trunks" "vines" "woodsoils" "youngtrees"
2017-05-16 01:18:05: WARNING[Main]: NodeDefManager: Ignoring CONTENT_IGNORE redefinition
2017-05-16 01:18:05: ERROR[Main]: ModError: Failed to load and run script from /home/dawgdoc/.minetest/mods/multihome/init.lua:
2017-05-16 01:18:05: ERROR[Main]: /home/dawgdoc/.minetest/mods/multihome/init.lua:219: attempt to call field 'override_chatcommand' (a nil value)
2017-05-16 01:18:05: ERROR[Main]: stack traceback:
2017-05-16 01:18:05: ERROR[Main]: 	/home/dawgdoc/.minetest/mods/multihome/init.lua:219: in main chunk
2017-05-16 01:18:05: ERROR[Main]: Check debug.txt for details.


-------------
  Separator
-------------

2017-05-16 01:21:40: WARNING[Main]: Mod name conflict detected: "farming"
2017-05-16 01:21:40: WARNING[Main]: Will not load: /usr/share/minetest/games/minetest_game/mods/farming
2017-05-16 01:21:40: WARNING[Main]: Overridden by: /home/dawgdoc/.minetest/mods/farming
2017-05-16 01:21:40: ERROR[Main]: The following mods could not be found: "3dmushrooms" "along_shore" "bushes" "bushes_classic" "cavestuff" "dryplants" "ferns" "flowers_plus" "junglegrass" "molehills" "nature_classic" "trunks" "vines" "woodsoils" "youngtrees"
2017-05-16 01:21:40: WARNING[Main]: NodeDefManager: Ignoring CONTENT_IGNORE redefinition
2017-05-16 01:21:41: ERROR[Main]: ModError: Failed to load and run script from /home/dawgdoc/.minetest/mods/multihome/init.lua:
2017-05-16 01:21:41: ERROR[Main]: /home/dawgdoc/.minetest/mods/multihome/init.lua:208: attempt to call field 'override_chatcommand' (a nil value)
2017-05-16 01:21:41: ERROR[Main]: stack traceback:
2017-05-16 01:21:41: ERROR[Main]: 	/home/dawgdoc/.minetest/mods/multihome/init.lua:208: in main chunk
2017-05-16 01:21:41: ERROR[Main]: Check debug.txt for details.
Is the issue as simple as me placing multihome.compatibility at the wrong place in minetest.conf?

Re: [Mod] MultiHome [multihome]

Posted: Tue May 16, 2017 23:11
by octacian
dawgdoc wrote:I first added multihome.compatibility = override to minetest.conf. When that generated errors I tried multihome.compatibility = deprecate, which caused a similar error. I placed the setting below the basic_privs line.
This is caused by the fact that you do not have a development build of Minetest, as 0.4.15 stable is missing two important features used by this my (player attributes and chatcommand override APIs). In order to get MultiHome working correctly, you'll need to build a new development version of Minetest with this commit or newer (simply doing git pull as in the linked guide will work fine).

BTW, placement in minetest.conf doesn't matter at all for anything, just so that you know :D (well, so long as you don't redefine the same thing later, but that's pretty obvious)

Re: [Mod] MultiHome [multihome]

Posted: Wed May 17, 2017 01:28
by dawgdoc
octacian wrote:
dawgdoc wrote:I first added multihome.compatibility = override to minetest.conf. When that generated errors I tried multihome.compatibility = deprecate, which caused a similar error. I placed the setting below the basic_privs line.
This is caused by the fact that you do not have a development build of Minetest, as 0.4.14 stable is missing two important features used by this my (player attributes and chatcommand override APIs). In order to get MultiHome working correctly, you'll need to build a new development version of Minetest with this commit or newer (simply doing git pull as in the linked guide will work fine).

BTW, placement in minetest.conf doesn't matter at all for anything, just so that you know :D (well, so long as you don't redefine the same thing later, but that's pretty obvious)
I realized today, while away from the house, that I hadn't mentioned my MT version nor the OS of my computer. Thank you for replying in spite of that. (LinuxMint 18.1 based on Ubuntu Xenail, and MT 0.4.15 from the stable PPA). I really must have been sleepy while reading the first post to not catch that a -dev build was needed and to think that it and the readme said to add the line to minetest.conf. Thank you, again, for the reply.

Re: [Mod] MultiHome [multihome]

Posted: Fri Jan 26, 2018 12:56
by BBmine
Totes adding this to our LAN server :D

Re: [Mod] MultiHome [multihome]

Posted: Wed Feb 06, 2019 01:33
by aristotle
I have been using your mod in override mode and it just feels so natural. Thank you so much! :D

Re: [Mod] MultiHome [multihome]

Posted: Thu Feb 14, 2019 10:54
by aristotle
I am on MT 04.17.1 and when I set the multihome.max setting in minetest.conf to have up to 10 homes an error has occurred.

After line 5

Code: Select all

local max    = minetest.setting_get("multihome.max") or 5
I solved it by just adding a quick fix

Code: Select all

max = tonumber(max)

Re: [Mod] MultiHome [multihome]

Posted: Sat Aug 31, 2019 02:50
by Nathan.S
Looks like you have a spelling error in the readme file. multihome.compatiblity should probably be multihome.compatibility

Re: [Mod] MultiHome [multihome]

Posted: Fri Oct 18, 2019 17:00
by Walker
Bug ^^

Code: Select all

2019-10-18 18:46:05: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'multihome' in callback on_chat_message(): .../sda3/Minetest/server4/.minetest/mods/multihome/init.lua:65: attempt to compare string with number
2019-10-18 18:46:05: ERROR[Main]: stack traceback:
2019-10-18 18:46:05: ERROR[Main]: 	.../sda3/Minetest/server4/.minetest/mods/multihome/init.lua:65: in function 'func'
2019-10-18 18:46:05: ERROR[Main]: 	...test/bin/../share/minetest/builtin/game/chatcommands.lua:30: in function <...test/bin/../share/minetest/builtin/game/chatcommands.lua:9>
2019-10-18 18:46:05: ERROR[Main]: 	...minetest/bin/../share/minetest/builtin/game/register.lua:419: in function <...minetest/bin/../share/minetest/builtin/game/register.lua:399>
Codesegment:

Code: Select all

...
64	-- if home doesn't already exist (i.e. a new home is being created), check for space
65	if not homes[name] and count_homes(homes) >= max then
66		return false, "Too many homes. Remove one with /multihome del <name> or /delhome <name>"
67	end
...

Re: [Mod] MultiHome [multihome]

Posted: Sun Feb 07, 2021 00:36
by srutzky
Hello. I ran into the same error that @aristotle and @Walker ran into (comparing string and number) when setting multihome.max in minetest.conf. I went to the source repo to make the change only to find that it had already been done (even if not in the ideal spot). I also found that a settingtypes.txt file had been added so that the options could be configured via the "All Settings" GUI (something else I had been considering doing, so that's awesome), and one or two other minor improvements. Would it be possible to please publish / package up the changes so that they are available via ContentDB? (although, it does appear that the mod.conf file is missing a few details that are in the version I installed via ContentDB)

In the mean time, I did just submit a PR to improve the error handling / messaging, and I moved the tonumber() fix for the "setting max in minetest.conf" error to the ideal location (i.e. the source of setting the max variable) so that any other use of that variable in the future does not potentially run into that same error:

https://github.com/octacian/multihome/pull/6

Thanks and take care,
Solomon...