I'm trying to script an alcove to open a door when a specific item is inserted.
I've found tons of example scripts on this forum, but none of them work. I am a complete scripting novice. I know I need to swap out the names of the door, alcove, and items with my own names, but beyond that I can't understand what I'm doing wrong.
http://www.grimrock.net/modding_log1/ho ... ve-puzzle/ The script I found here crashes the editor.
Scripting an alcove puzzle
- Zo Kath Ra
- Posts: 931
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Scripting an alcove puzzle
Board index < Legend of Grimrock 2 < Mod Creation
http://www.grimrock.net/modding_log1/ho ... ve-puzzle/
Do you want to make a script for Grimrock 1 or 2 ?
http://www.grimrock.net/modding_log1/ho ... ve-puzzle/
Do you want to make a script for Grimrock 1 or 2 ?
-
- Posts: 3
- Joined: Wed May 27, 2020 4:35 pm
Re: Scripting an alcove puzzle
Grimrock 2.
Re: Scripting an alcove puzzle
Connect the alcove to this script; adjust the door id, and the item name to suit.
Welcome to the forum.
Code: Select all
function checkItem(surface, item)
if item.go.name == "rock" then --target item name
local door = findEntity('dungeon_door_wooden_1') --target door id
if door then
door.door:open()
end
end
end
- Zo Kath Ra
- Posts: 931
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Scripting an alcove puzzle
In LoG 2, it's simpler:
Code: Select all
function itemPuzzle(caller, item)
if item.go.name == "pitroot_bread" then
playSound("level_up")
end
end
"item" contains the inserted object's Item component.
".go" references the component's game object.
(LoG 1 didn't have components)
To learn more about the differences between LoG 1 and LoG 2 scripting, I'd recomend the LoG 2 modding guide:
http://www.grimrock.net/modding/
-
- Posts: 3
- Joined: Wed May 27, 2020 4:35 pm
Re: Scripting an alcove puzzle
Thank you both!