Spawn Button / Lever connected to Door

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
djoldgames
Posts: 107
Joined: Fri Mar 23, 2012 11:28 pm
Contact:

Spawn Button / Lever connected to Door

Post by djoldgames »

Is there any way how to connect my spawned Button or Lever (in the script ewntity) with the door?
I am missing some hook on Button entity like "onActivate = function(self)......"

I need spawn some buttons "on-the-fly" in my script entity (after activate pressure plate) and these must be active - connected to doors.
- Or eventually How to I remove entity (button/lever) created by editor
- Or eventually How to I hide entity (button/lever) created by editor
- Or eventually How to I move entity (to wall) or change its facing

Code: Select all

-- first: clone new custom button in the objects.lua
cloneObject{
       name = "Custom_wall_button",
       baseObject = "wall_button",
       -- need the onActivate hook
}

-- next in the lua script entity
function ActivatePressurePlate()
       spawn("Custom_wall_button", 1, 10, 21, 2, "MyWallbutton1")
       -- is there any way to connect MyWallbutton1 to the door?
end
Thanks for answer.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Spawn Button / Lever connected to Door

Post by petri »

You can use the addConnector() method to connect the button to the door. There was an example script somewhere on the forum.
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: Spawn Button / Lever connected to Door

Post by Montis »

petri wrote:You can use the addConnector() method to connect the button to the door. There was an example script somewhere on the forum.
Is this method described somewhere in the documentation? I can't seem to find it.
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
djoldgames
Posts: 107
Joined: Fri Mar 23, 2012 11:28 pm
Contact:

Re: Spawn Button / Lever connected to Door

Post by djoldgames »

petri wrote:You can use the addConnector() method to connect the button to the door. There was an example script somewhere on the forum.
Thank you for the tip. BTW addConnector() example script isn't anywhere on the forum, only in this thread ;-)
I do some try/catch in the editor and this is the right code:

addConnector(Event, Target, Toggle)
-- all parameters must be strings

Code: Select all

function ActivatePressurePlate()
       spawn("Custom_wall_button", 1, 10, 21, 2, "MyWallbutton1")
       MyWallbutton1:addConnector("toggle","dungeon_door_metal_6","toggle")
end
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Spawn Button / Lever connected to Door

Post by Komag »

This is very nice! I've added it to the script repository :)

does it have to be a custom (newly cloned) wall button?

EDIT - no, it can just be "wall_button" that is spawned
Finished Dungeons - complete mods to play
Post Reply