Page 2 of 3
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 10:33 am
by Aazlan
Finally...
Just in case someone else wanted to insert varied color gems in eye sockets:
Code: Select all
cloneObject{
name = "green_eye_right",
baseObject = "eye_socket_right",
onInsertItem = function(green_gem)
print("Green Gem Inserted Right")
return true
end,
}
Obviously place this in your "../mod_assets/scripts/objects.lua" and replace green and/or right with your needs.
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 11:32 am
by Shadowfied
Can anyone explain how to use the Door:setOpenedBy(key) script?
Do you just put this in a script entity? How do you specify which door is gonna be opened by this item?
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 12:04 pm
by antti
Shadowfied wrote:Can anyone explain how to use the Door:setOpenedBy(key) script?
Do you just put this in a script entity? How do you specify which door is gonna be opened by this item?
Yeah, add a script entity and refer to the door with its ID. For example, if you would want to open a with the ID of dungeon_door_wooden_locked_1 with an iron key, you could add the following line to a script entity:
Code: Select all
dungeon_door_wooden_locked_1:setOpenedBy("iron_key")
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 12:16 pm
by Shadowfied
antti wrote:Shadowfied wrote:Can anyone explain how to use the Door:setOpenedBy(key) script?
Do you just put this in a script entity? How do you specify which door is gonna be opened by this item?
Yeah, add a script entity and refer to the door with its ID. For example, if you would want to open a with the ID of dungeon_door_wooden_locked_1 with an iron key, you could add the following line to a script entity:
Code: Select all
dungeon_door_wooden_locked_1:setOpenedBy("iron_key")
Oh, so I had it correct already. Just had to be an iron key. Is there a way to make it work with other keys?
Thanks.
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 12:29 pm
by antti
Shadowfied wrote:antti wrote:Shadowfied wrote:Can anyone explain how to use the Door:setOpenedBy(key) script?
Do you just put this in a script entity? How do you specify which door is gonna be opened by this item?
Yeah, add a script entity and refer to the door with its ID. For example, if you would want to open a with the ID of dungeon_door_wooden_locked_1 with an iron key, you could add the following line to a script entity:
Code: Select all
dungeon_door_wooden_locked_1:setOpenedBy("iron_key")
Oh, so I had it correct already. Just had to be an iron key. Is there a way to make it work with other keys?
Thanks.
Any key should work
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 12:43 pm
by Shadowfied
The brass key didn't.
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 12:49 pm
by Montis
What he means is that you can swap out the yellow part below to any key object that exists, afterwards it should work with that kind of key.
dungeon_door_wooden_locked_1:setOpenedBy("iron_key")
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 12:50 pm
by resonansER
antti wrote:Yeah, add a script entity and refer to the door with its ID. For example, if you would want to open a with the ID of dungeon_door_wooden_locked_1 with an iron key, you could add the following line to a script entity:
Code: Select all
dungeon_door_wooden_locked_1:setOpenedBy("iron_key")
Any key should work
WHERE put this code? In which file?
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 12:59 pm
by Komag
You just add a script "lua" to your map, anywhere, with that line in it, that's all. Then it will work
I wrote it more detailed here:
viewtopic.php?f=14&t=3099
Re: I'm stumped... help!
Posted: Fri Sep 14, 2012 12:59 pm
by Montis
resonansER wrote:antti wrote:Yeah,
add a script entity and refer to the door with its ID. For example, if you would want to open a with the ID of dungeon_door_wooden_locked_1 with an iron key, you could add the following line to a script entity:
Code: Select all
dungeon_door_wooden_locked_1:setOpenedBy("iron_key")
Any key should work
WHERE put this code? In which file?
See also highlight.