Page 1 of 2

[Mod] locks [locks]

PostPosted: Wed Nov 07, 2012 00:59
by Sokomine
Update: (Version 1.20) Added support for pipeworks. Shared locked chests and furnaces can now connect to tubes - just like normal chests and furnaces.

Update: Made minor change to make it runnable with newer versions of Minetest and added shared locked furnaces.

This is how the modified locked xdoors2 look. It also shows a list of available commands:
Image

This mod adds functionality to lock and share objects that have been adopted to this mod. The owner (=the one who placed the object) can grant other players usage of the object. Thus, the object may be shared by several players while beeing inaccessible to others.

Sample usage of a shared locked chest:
Image

A modified chest, sign (both from the default game) and doors2 (a mod from xyz) come with the mod as sample objects. Other objects for which this mod might be of intrest could be protector, furnances, teleporters, batteries (technic) or whatever you need.

The chest is most likely the most useful object: If you want to give something to a player who isn't online or roams around elsewhere, you can just put it into a shared locked chest and add the player as one of those allowed to use that chest. He can then pick the stuff up whenever he's close to the chest.

Locked doors seem quite popular as well, though I have mixed feelings about them. They where one of the reasons this mod was created in the first place; still, placing locked doors requires to think about it. It is not that good if there are too many locked doors (multiplayer servers are there so that other people can have a look at your house!), so use with care.

Another way of granting access to a shared locked object is by setting a password with the /set command. If none is set then no one can gain access that way. If a password is set and someone types it in, that player gets access to the object. Thus you can create simple puzzles if you like.

Other ways of getting acces to such objects are the diglocks priv (anyone who has that priv can do the same things with the object as the original owner) and the openlocks priv (acts as if the player has been added by the owner as a legitimate user).

I'm working on a mod called "playergroups" that allows the player to create groups of playernames so that he/she can e.g. create a group "friends" and then do "/add :friends" on each shared locked object instead of typing all the names in for every object. That mod works to a degree, but there's no guarantee. The playergroups mod has not been tested extensively.

The textures (lock, key, keychain, door with lock) have been provided by Addi. Please consult textures/licence.txt.

Download: https://github.com/Sokomine/locks/zipball/master
Browse code: https://github.com/Sokomine/locks
Version: 1.20 Added support for pipeworks
1.16 Pressing ESC in newer MT versions aborts input again (as in older versions)
1.1 first Version
Licence: GPLv3
Supports: * Pipeworks
TODO: Add textures for shared locked signs, chests and furnaces. Help wanted!

In order to use your own shared locked objects, you do need a key:
Image

The keychain is necessary to acces shared locked objects of other players. May also be used for your own objects instead of a key. One keychain is enough for all shared locked objects you encounter:
Image

The lock is a craftitem used to craft shared locked objects:
Image

Shared locked chest:
Image

Shared locked sign:
Image

Shared locked xdoor2:
Image

Shared locked furnace:
Image

The mod can be seen in action on King Arthurs Land.

PostPosted: Wed Nov 07, 2012 01:37
by InfinityProject
Very Nice! +1

PostPosted: Wed Nov 07, 2012 02:09
by Josh
Cool! +2

PostPosted: Wed Nov 07, 2012 04:22
by Aqua
Nice work=D

PostPosted: Wed Nov 07, 2012 10:47
by Topywo
The shared chest can be very usefull, good work! The textures are also looking good!

PostPosted: Wed Nov 07, 2012 13:22
by rubenwardy
Awesome!

I have been waiting for ages to get a shared locked chest.

I thought about doing this a while ago, but i have no idea how FormSpec works

Can you make this mod into a mod pack, so server owners can chose which parts to add?
IE: Shared Locked boxes but not locked doors

PostPosted: Wed Nov 07, 2012 13:29
by webdesigner97
Sounds very cool! :D

PostPosted: Wed Nov 07, 2012 14:57
by Sokomine
Removing unwanted shared locked objects is quite easy: Just delete or comment out those lines at the end of init.lua that you don't want:
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
dofile(minetest.get_modpath("locks").."/shared_locked_chest.lua");
dofile(minetest.get_modpath("locks").."/shared_locked_sign_wall.lua");
dofile(minetest.get_modpath("locks").."/shared_locked_xdoors2.lua");

After that you can (but don't have to) delete the corresponding file as well, i.e. shared_locked_xdoors2.lua.

FormSpecs are quite useful. It is even possible to change them during the lifetime of the object. Unfortionately there is no way to react to a player right-clicking and to change the menu at that time. Thus I went for a simple FormSpec input line for the handling of the locks.

PostPosted: Wed Nov 07, 2012 19:55
by Dragonop
THIS could be added to the main game +5

PostPosted: Thu Nov 08, 2012 14:23
by addi
Topywo wrote:[...]The textures are also looking good!

thanks :-)
the textures was made by me XD

PostPosted: Thu Nov 08, 2012 16:03
by mauvebic
Locked doors are only useful if you incorporate node protection around them, but only the ones that use can_dig(). Protection mods that user after_place or on placenode, people have time to fly through before the nodes reappear.

Ideally, you could have protection built-in so that when player places a locked door, it has the effect of protecting the whole dwelling? save the server admins the trouble of setting up small zones :-)

PostPosted: Thu Nov 08, 2012 19:10
by Sokomine
Right, without some sort of node protection the doors can be digged around and are more or less symbolic. Using them as tools to define protected areas is something I don't want - because that would lead to too many locked doors and inaccessible buildings. But the idea might be extended to another node - a node that can be placed as easily as a protector node and help define a larger area as protected.

PostPosted: Thu Nov 08, 2012 19:52
by fgr
mauvebic wrote:....., it has the effect of protecting the whole dwelling? save the server admins the trouble of setting up small zones :-)


ummmm .... well, how you want to figure out how large the protected area / building / zone should be if you have neighbor?

PostPosted: Mon Dec 31, 2012 17:13
by clarksallador
not working...again its from the lua

PostPosted: Mon Dec 31, 2012 18:14
by Sokomine
Can you be more specific? Just a "not working" doesn't help much. What does not work as expected? Which version are you running?

PostPosted: Mon Dec 31, 2012 19:26
by EnryStar
Nice ! And whith fournaces ?

PostPosted: Mon Dec 31, 2012 20:17
by Sokomine
Furnances can be adapted in a similar way. Might make sense to include them. I'll have a look at the code of furnances.

PostPosted: Tue Jan 01, 2013 01:05
by clarksallador
C:\Users\user\Downloads\minetest=0.4.3-win32\bin\..\games\minetest_game\mods\Sokomine-locks-4d336b5\init.lua
this also im using 0.4.3

PostPosted: Tue Jan 01, 2013 13:29
by Topywo
clarksallador wrote:C:\Users\user\Downloads\minetest=0.4.3-win32\bin\..\games\minetest_game\mods\Sokomine-locks-4d336b5\init.lua
this also im using 0.4.3


Try:

C:\Users\user\Downloads\minetest=0.4.3-win32\bin\..\games\minetest_game\mods\locks\init.lua

Works for most mods with a name/version number/master in the foldername.

If it doesn't work, consider upgrading/installing the latest minetest version. But you still need to rename those kind of folders.

PostPosted: Tue Jan 01, 2013 15:58
by Sokomine
Ah, yes, sorry. All mods from github do carry a version number. Some people work around this by turning their mods into a modpack. But other mods will need renaming anyway. For my local singleplayer game, I do have a directory with a lot of mods and symlink those I want to have for the current game to the appropriate folder.

PostPosted: Thu Mar 28, 2013 16:45
by sfan5-bot
[EE] No License found


Please fix these Mistakes and report this post, a moderator will delete it
If you believe I have made a Mistake contact sfan5

PostPosted: Wed Jul 10, 2013 20:51
by Sokomine
Fixed a minor bug that caused the mod not to run with some recent versions.

Added shared locked furnaces.

Textures for the shared locked objects (sign, chest, furnace - maybe similar to the door?) are welcome!

License added. Re-added images after they where lost due to the disappearance of zimg.eu.

PostPosted: Thu Jul 11, 2013 02:28
by Inocudom
Does this work with homedecor's doors?

PostPosted: Thu Jul 11, 2013 03:52
by Sokomine
No, it only works with the doors it comes with - the ones shown in the first screenshot. The mod is built so that adapting it to new objects is pretty easy. The doors from homedecor could be adopted if homedecor where to depend on the locks mod (not very likely) or if new versions of them with support for the locks mod where created. The doors need some technical changes to support the lock-functionality (i.e. adding a configuration line in a formspec, checking if they're allowed to be opened etc.)

PostPosted: Fri Jul 12, 2013 02:28
by addi
Here a short instruction how to add a optional dependence on this mod and execute your own functions if it is installed.

you must only change 2 things

first:
add locks? to depends.txt
depends.txt
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
default
locks?

!important dont forgett the ? after the locks

it makes a optional dependence to the locks mod. if it is installed it is loading first.

the next step is:
add this function to init.lua (or somewhere other)
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
if locks then
local MODPATH = minetest.get_modpath(minetest.get_modname());
dofile(MODPATH.."/shared_locked.lua")
end


!important you must check if the locks api is registered! only to check with minetest.get_modpath("locks") will crash the server if you forgett to add the locks? into depends.txt

step 3:

create the file shared_locked.lua
and register the nodes in it and using the locks api

PostPosted: Sun Dec 15, 2013 13:52
by addi
due the new feature of minetest 0.4.8 the text of the shared locked signs dose change if the formspec is canceled with the ESC key.
it dose also happen to the other shared locked stuff

PostPosted: Tue Dec 17, 2013 02:10
by Sokomine
Thanks for the bug report. I've fixed it and uploaded a new version to github. Aborting input ought to work now as before.

PostPosted: Sat Jan 11, 2014 02:25
by Sokomine
Upon request, I've added support for pipeworks. Tubes from that mod can be used with the shared locked chest and furnace like with a normal chest and furnace (i.e. tubes can connect to them). There's also a command
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
/pipeworks

which you can enter into the command window of shared locked chests/furnaces to toggle output to tubes on or off. Right now this does not work because pipeworks epects another return value than what the MT documentation says, so watch out for new versions of pipeworks.

PostPosted: Sat Jan 11, 2014 06:59
by Nore
Sokomine wrote:Upon request, I've added support for pipeworks. Tubes from that mod can be used with the shared locked chest and furnace like with a normal chest and furnace (i.e. tubes can connect to them). There's also a command
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
/pipeworks

which you can enter into the command window of shared locked chests/furnaces to toggle output to tubes on or off. Right now this does not work because pipeworks epects another return value than what the MT documentation says, so watch out for new versions of pipeworks.

Done ;)

PostPosted: Sat Jan 18, 2014 17:41
by Achilles
WOW, i really like this mod. Thanks for doing it.
Can you only use keys to open shared locked doors, chests and etc, or can you also:
1) set a password/passwords
2) Add a clients name to the shared locked door/chest so that he/she can open it.