Hey everyone,
New here and new to LoG and the Dungeon Editor. I've kinda gone headfirst into the editor as I liked the capabilities and how intuitive it is to create maps.
Having messed with the LoG 1 editor, I thought I'd buy LoG 2 and get the updated editor and assets. Done and so far, it is pretty neat.
Some things are a little different from the LoG 1 editor, a little less intuitive, IMHO. One thing I am having trouble with is how do you assign a key, or at least a key type, to a chest? I made a connector from the brass key to the chest and assigned Chest Locked = true. With this, it does not open though.
Sorry for the relatively easy question, but I can't seem to figure this out.
Thanks all and great job Almost Human!
How do you assign a key to a chest?
Re: How do you assign a key to a chest?
Right from the basic game design you can't.
Chests get opened by lockpicks and nothing else. It's also not a certain lockpick - everyone works on every chest.
You can change the look of the lockpicks by changing the icon (and also the name if you want) - but that's all.
I'm pretty sure you can make some tweaks to get chests opended by other keys, but this must be a bit tricky and I can't help with that.
Chests get opened by lockpicks and nothing else. It's also not a certain lockpick - everyone works on every chest.
You can change the look of the lockpicks by changing the icon (and also the name if you want) - but that's all.
I'm pretty sure you can make some tweaks to get chests opended by other keys, but this must be a bit tricky and I can't help with that.
Re: How do you assign a key to a chest?
This solution requires a bit of scripting, but works well enough:
Place a chest on the map, and disable the 'clickable' component. Enable the 'lock' component (do not enable the 'locked' checkbox inside the 'chest' component.)
place a lock in front of the chest and disable the 'model' component. Assign whichever key you like.
Place a script entity, and paste the following code into it, replacing any object names with your own:
Assign a connecter from the lock to the script, and you have a working chest lock. ![Smile :)](./images/smilies/icon_e_smile.gif)
Place a chest on the map, and disable the 'clickable' component. Enable the 'lock' component (do not enable the 'locked' checkbox inside the 'chest' component.)
place a lock in front of the chest and disable the 'model' component. Assign whichever key you like.
Place a script entity, and paste the following code into it, replacing any object names with your own:
Code: Select all
lock_1:setWorldPositionY(-0.75) --lowers the lock so it is level with the chest's lock
function unlockChest()
chest_1.lock:disable() --disables the lock model on the chest
chest_1.clickable:enable() --allows the player to open the chest by clicking
lock_1.clickable:disable() --prevents the lock from getting in the way when players are opening the chest
end
![Smile :)](./images/smilies/icon_e_smile.gif)
Grey Island mod(WIP): http://www.grimrock.net/forum/viewtopic ... 99#p123699
- The_Morlock
- Posts: 12
- Joined: Sun Jun 02, 2024 6:15 am
Re: How do you assign a key to a chest?
Thank yoy very much, this worked quite well with some tinkering on my part.ratman wrote: ↑Sun Jun 02, 2024 5:08 pm This solution requires a bit of scripting, but works well enough:
Place a chest on the map, and disable the 'clickable' component. Enable the 'lock' component (do not enable the 'locked' checkbox inside the 'chest' component.)
place a lock in front of the chest and disable the 'model' component. Assign whichever key you like.
Place a script entity, and paste the following code into it, replacing any object names with your own:
Assign a connecter from the lock to the script, and you have a working chest lock.Code: Select all
lock_1:setWorldPositionY(-0.75) --lowers the lock so it is level with the chest's lock function unlockChest() chest_1.lock:disable() --disables the lock model on the chest chest_1.clickable:enable() --allows the player to open the chest by clicking lock_1.clickable:disable() --prevents the lock from getting in the way when players are opening the chest end
![]()
Chest Name: brasschest1 (no connector)
Lock Name: brasschest_lock1 (connects to brasschest_scriptentity1)
Key Name: brasschest_key1 (no connector)
Script Name: brasschest_scriptentity1
brasschest_scriptentity1 Script:
Code: Select all
brasschestlock_1:setWorldPositionY(-0.75) --lowers the lock so it is level with the chest's lock
function unlockChest()
brasschest1.lock:disable() --disables the lock model on the chest
brasschest1.clickable:enable() --allows the player to open the chest by clicking
brasschest_lock1.clickable:disable() --prevents the lock from getting in the way when players are opening the chest
end
- DaggorathMaster
- Posts: 41
- Joined: Thu Sep 08, 2022 7:29 pm
Re: How do you assign a key to a chest?
For the active "clickable" component (brasschest1.clickable):
Have the onClick hook call a script function* which checks the id of the mouse item (the mouse item is what you are clicking with).
(Anything in <> brackets is whatever you name(d) it).
I would also go with naming the key after the chest, with _key at the end.
So, for example, felldurs_brass_chest and felldurs_brass_chest_key
Then, if you want to do this on more than one chest, it is simple to reuse the script:
(Editing just the one line with "getMouseItem"):
*Having def files do little or nothing but call an embedded ("normal") script file saves some headaches - with reloading and debugging.
Have the onClick hook call a script function* which checks the id of the mouse item (the mouse item is what you are clicking with).
(Anything in <> brackets is whatever you name(d) it).
Code: Select all
function <try_open_chest> (clickable)
if getMouseItem().go.id == <desired_id> then
<open_chest> (clickable.go) -- Or whatever your function is to open it, and what argument(s) you call it with.
else
<fail_to_open_chest> (clickable.go) -- Optional function for failing to unlock it, may just play the sad no unlock sound.
end
end
So, for example, felldurs_brass_chest and felldurs_brass_chest_key
Then, if you want to do this on more than one chest, it is simple to reuse the script:
(Editing just the one line with "getMouseItem"):
Code: Select all
if getMouseItem().go.id:find (clickable.go.id) then
...