Page 1 of 2
[Mod-Assets] Keys in locks. (re-usable keys)
Posted: Wed May 27, 2015 3:59 am
by spectre900
So after a bit of fiddling I managed to convert my old mod to G2.
What this mod does is enable keys in custom dungeons to be visually put inside locks and then be taken out again without consuming the key. If you have ever played Dungeon Master 2 then you know what I mean.
How to install/use:
1) Extracts files into your mod folder.
2) Add this line to your "init.lua" file found in: mod_assets/scripts
Code: Select all
import "mod_assets/scripts/keys_in_locks.lua"
3) To make a key click sound add the following lines in a cript entity on your map and link your locks to it.
Code: Select all
function playLock()
playSound("key_lock")
end
--hints--
> B locks are used for wallsets with deeper "depth" to them such as the castle walls.
> The door locks fits best on dungeon doors and some mine doors.
> Use the lock_stone if you can't find a good surface to place your locks on.
--You may use and edit this mod in any way you like. crediting is not necessary but would be nice. --
Dropbox Download:
https://www.dropbox.com/s/p1n6qqbh6zsks ... 2.rar?dl=0
This mod for Grimrock 1:
viewtopic.php?f=14&t=6469
If you find any problems please report them to me.
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Wed May 27, 2015 4:31 am
by st1nger
very nice work, thanks alot.
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Wed May 27, 2015 7:43 am
by minmay
spectre900 wrote:3) To make a key click sound add the following lines in a cript entity on your map and link your locks to it.
Code: Select all
function playLock()
playSound("key_lock")
end
Why not just add this to the onInsertItem hook? Then you don't need an extra connector on every lock.
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Wed May 27, 2015 8:50 am
by Isaac
I like the look of it, but quite often the keys are used in the logic, and having one key fit multiple locks would cause havoc. The mod would certainly need to be designed with reusable keys in mind; (and a lot of unique keys).
The first area in my ORRR2 room, had three doors, but only one key, because it was a choice of which one to unlock; and it affected the way the room worked.
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Wed May 27, 2015 12:14 pm
by spectre900
minmay wrote:spectre900 wrote:3) To make a key click sound add the following lines in a cript entity on your map and link your locks to it.
Code: Select all
function playLock()
playSound("key_lock")
end
Why not just add this to the onInsertItem hook? Then you don't need an extra connector on every lock.
I did ask if that was possible in another thread but didn't get an answer for it, plus some may want it to "click" on both inserting and removing the key or just use a different sound altogether, or no sound.
Isaac wrote:I like the look of it, but quite often the keys are used in the logic, and having one key fit multiple locks would cause havoc. The mod would certainly need to be designed with reusable keys in mind; (and a lot of unique keys).
The first area in my ORRR2 room, had three doors, but only one key, because it was a choice of which one to unlock; and it affected the way the room worked.
There are ways to build around that, like requiring a key to stay inside to keep a door open so you can't take it with you or even requiring multiple keys to open the next section. Plus there are a lot of key variants in the game. (although not sure prison locks count anymore as they don't appear to have textures.)
Not sure if it's possible to force a key to stay in the lock, but that could be an option too for certain locks.
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Thu May 28, 2015 11:52 pm
by JohnWordsworth
Neat - I like it. I get the impression that it would be a good idea to either use this for the entirety of your mod or not at all, because mixing up mechanics for things is only going to confuse players. BUT, with that said, I always thought it a bit weird that keys were "consumed" and, while this likely means having a wider set of different keys, I like the extra realism this gives.
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Fri May 29, 2015 10:20 am
by Eleven Warrior
+ 1 to john _ This is cool thxs
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Wed Jun 10, 2015 10:38 pm
by spectre900
New version is out. it fixes the issue with the lock_stone and stops that rather annoying message to pop up all the time.
Just download again and replace the "keys_in_locks.lua and make sure the lock_stone model file added to your models folder. (should not affect your dungeon when replacing the scripts.)
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Mon Dec 21, 2015 5:01 am
by Vandalar
I like a lot this mod assets. Most likely you already figured this out, but for those searching the forums, you can add this little function inside a script and attach it on the onRemoveItem hook. The key is actually removed and destroyed immediately, but another one is added immediately in the lock. So visually, it's like if the key is "stuck" in the lock.
In this example, I "re-added" the gold key for a golden lock. Simply change the name of the key for the associated key lock.
Code: Select all
function lockRemoveItem(self)
setMouseItem(nil)
self:addItem(spawn("gold_key").item)
end
Once again, great asset.
Cheers !
Vand
Re: [Mod-Assets] Keys in locks. (re-usable keys)
Posted: Mon Dec 21, 2015 5:26 am
by minmay
Vandalar wrote:I like a lot this mod assets. Most likely you already figured this out, but for those searching the forums, you can add this little function inside a script and attach it on the onRemoveItem hook. The key is actually removed and destroyed immediately, but another one is added immediately in the lock. So visually, it's like if the key is "stuck" in the lock.
In this example, I "re-added" the gold key for a golden lock. Simply change the name of the key for the associated key lock.
Code: Select all
function lockRemoveItem(self)
setMouseItem(nil)
self:addItem(spawn("gold_key").item)
end
Once again, great asset.
Cheers !
Vand
Uh, a MUCH better way to do this is to just disable the ItemComponent of the key after it's added to the lock. Your approach doesn't even retain the original object.