Page 1 of 1

Idea : Damaged Door (Scripting)

Posted: Wed Sep 19, 2012 7:33 pm
by Xzalander
I'm scripting this at the moment, but I figured a neat little idea.

'You're walking along and you see a portcullis or door stuck going up and down in its arch. Pressing a button elsewhere in the map overrides the mechanism and forces it open.'

Im sure this could be scripted very easily; the method I have in my head at the moment is a Timer that places and removes a torch from a torchholder hidden away in a 1x1 room on the map. A script then checks this Torchholder and raises or lowers the door accordingly (See Combination Torch Lock). A button then disables the script and permanently opens the door.

Why do this via a Torch Timer rather than a timer? Because then you could have several doors running off the same timer, but deactivate individual torches/doors.

Example

TimerA -> TorchTimer 1 = Door 1
-> Torch Timer 2 = Door 2
-> Torch Timer 3 = Door 3

If you disable the timer, you unlock all three doors. Where as if you disable the individual script to say only Torch 1, then torches 2 and 3 are still broken and still in time.


Although having written all that I'm sure there is a much much simpler way :geek: Either way the idea is there, use a timer to cause a door or two to 'break' and be stuck opening or closing.

Re: Idea : Damaged Door (Scripting)

Posted: Wed Sep 19, 2012 7:53 pm
by Montis
Try using counters instead of a torch, should be a bit simpler. But I like the general idea :)

Question to the devs: since there's a way to addConnector(), is there also a way to remove them? That could circumvent the need to go through a counter or script.

Re: Idea : Damaged Door (Scripting)

Posted: Wed Sep 19, 2012 9:24 pm
by Komag
apparently the exact same command ends up removing the connection!
EDIT - it doesn't actually work

I have a plate that triggers this script:

Code: Select all

function buttonconnect()
	spawn("wall_button", 3, 11, 22, 1, "MyWallbutton1")
	MyWallbutton1:addConnector("toggle", "spawndoor", "toggle")
end
I added another button nearby that triggers this script:

Code: Select all

function buttonbreak()
	MyWallbutton1:addConnector("toggle", "spawndoor", "toggle")
	print("button broken")
end
(so long as I trigger the plate before pressing the break button I'm good!)
So I step on the plate, button gets created and links to the door, button works. I press the break button (get console print "button broken"), now go back to the spawned button and it doesn't work. (But if I press the break button again then the spawned button will work again)

Re: Idea : Damaged Door (Scripting)

Posted: Wed Sep 19, 2012 9:25 pm
by petri
Montis wrote:Question to the devs: since there's a way to addConnector(), is there also a way to remove them?
Nope... not at the moment at least. I'm not sure how general purpose feature that would be.

Re: Idea : Damaged Door (Scripting)

Posted: Wed Sep 19, 2012 9:34 pm
by Komag
After some more testing I think maybe that's a one time happy coincidence of adding toggles that counter each other on every even pair (just a guess really)
on a separate test of a different connection already existing in the map, doing an addConnector of the same details did not break the connection

Re: Idea : Damaged Door (Scripting)

Posted: Fri Sep 28, 2012 7:16 pm
by Komag
just revisiting this issue...

First off, the door open/shut/broken thing is still best done with a simple timer, one for each door if you have three of them you want to set up (no need to set up three odd torch rooms).

Second, I found that if you add another connection but the opposite action, it will "counter" or negate the first action, thus effectively breaking the connection. Not sure how useful this really is, and it may act buggy or not work in various setups, but...

If you have an existing pressure plate linked to a timer with activate -> activate, then elsewhere you trigger a script in which you add a new connector from the plate to the timer with activate -> deactivate, then the plate will no longer trigger the timer.

But this would be much better accomplished some other way, counters or something, because creating new connections that negate others just leads to messes and problems I would think!