kingtitan Posted March 11, 2012 Share Posted March 11, 2012 Hello all. I am not a scripter, if I was I would gladly do this on my own. However, I need to add "auto-close" functionality to an existing activator in game (cgate01). Here is the script attached to the door at present: scn RFWHallPortcullis01SCRIPT ; activated by linked child ; activates optionally linked parent after 1 sec delay short init short open short next short busy float timer ref mySelf ref myParent begin onActivate if isActionRef player == 1 if open == 0 message " This gate is opened elsewhere." endif elseif isActionRef mySelf == 0 && busy == 0 if open == 0 playgroup forward 0 set open to 1 enableLinkedPathPoints else playgroup backward 0 set open to 0 disableLinkedPathPoints endif set next to 1 set timer to 1 set busy to 1 endif end begin gameMode if init == 0 ; set up ref vars set mySelf to getSelf set myParent to getParentRef ; prepare linked pathsgrid points disableLinkedPathPoints set init to 1 endif ; daisy-chain activation if next == 1 && timer <=0 set next to 0 myParent.activate mySelf 1 endif if timer > 0 set timer to timer - getSecondsPassed endif if isAnimPlaying == 0 && busy == 1 set busy to 0 endif end begin onReset reset3DState set open to 0 set busy to 0 set next to 0 disableLinkedPathPoints end All I would like is for this script to close automatically after 4 seconds (vanilla default time)! Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted March 11, 2012 Share Posted March 11, 2012 (edited) Hmm, how about something like "set next to 2" and "set timer to 3" (1 sec has already passed) inside the "daisy-chain" if-block and below it putting something like if next == 2 && timer <= 0 set next to 0 mySelf.activate endif Maybe you could store the activating entity from within the OnActivate block via "GetActionRef" and then add it at the end of this "activate" call, so you always know who or what activated the chain, but I don't know if it's really needed either. I don't know. I couldn't give it too much thought, yet, and I can't say I've ever scripted a door opening mechanism such as this... but something along that line would be my first attempt for the auto-closing. Maybe it helps. Edited March 11, 2012 by DrakeTheDragon Link to comment Share on other sites More sharing options...
kingtitan Posted March 12, 2012 Author Share Posted March 12, 2012 I was actually hoping someone could just post the entire code instead of pieces of it? I know that sounds very lazy, but being completely honest, I know absolutely nothing about scripts except where to copy and paste them. If someone could do that for me I would be very grateful. Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted March 13, 2012 Share Posted March 13, 2012 (edited) I was actually hoping someone could just post the entire code instead of pieces of it? I know that sounds very lazy, but being completely honest, I know absolutely nothing about scripts except where to copy and paste them. If someone could do that for me I would be very grateful.Oh, sure. I was just a little short on time last time. Here you go, your code plus my changes/additions added in: scn RFWHallPortcullis01SCRIPT ; activated by linked child ; activates optionally linked parent after 1 sec delay short init short open short next short busy float timer ref mySelf ref myParent ref myActivator ;who activated me begin onActivate set myActivator to getActionRef ;store who activated me if isActionRef player == 1 if open == 0 message " This gate is opened elsewhere." endif elseif isActionRef mySelf == 0 && busy == 0 if open == 0 playgroup forward 0 set open to 1 enableLinkedPathPoints else playgroup backward 0 set open to 0 disableLinkedPathPoints endif set next to 1 set timer to 1 set busy to 1 endif end begin gameMode if init == 0 ; set up ref vars set mySelf to getSelf set myParent to getParentRef ; prepare linked pathsgrid points disableLinkedPathPoints set init to 1 endif ; daisy-chain activation if next == 1 && timer <=0 set next to 2 set timer to 3 ;wait 3 more seconds, 1 already passed, makes 4 in total myParent.activate mySelf 1 endif if next == 2 && timer <= 0 set next to 0 mySelf.activate myActivator ;daisy-chain who first activated this over into next call endif if timer > 0 set timer to timer - getSecondsPassed endif if isAnimPlaying == 0 && busy == 1 set busy to 0 endif end begin onReset reset3DState set open to 0 set busy to 0 set next to 0 disableLinkedPathPoints end That should do the trick. I hope it works. Edited March 13, 2012 by DrakeTheDragon Link to comment Share on other sites More sharing options...
kingtitan Posted March 13, 2012 Author Share Posted March 13, 2012 Many thanks Drake, I really appreciate it. Sorry if I came across as rude earlier! I just have an extreme lack of understanding in scripting! Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted March 13, 2012 Share Posted March 13, 2012 No need to be sorry. You're not even the pinnacle of the ice berg, as they say, compared to others I was already helping out. And those were never causing a problem either.If one prefers a readily-compiled complete script over a bunch of randomly unsorted additions, modifications and edits, provided out-of-context by your's truly, that's totally fine.It's politely asking for something else than what was initially given, nothing rude at all. :thumbsup: ...I just hope it works, as I can't test it myself. Link to comment Share on other sites More sharing options...
kingtitan Posted March 13, 2012 Author Share Posted March 13, 2012 Well thank you, I'm glad I didn't offend. I try to be as curteous as possible, but I fear that sometimes I come across more rudely than intended! But, if no harm taken no harm done right?Anyway, I will definently test it out when I get the time and gladly report my findings. Link to comment Share on other sites More sharing options...
Recommended Posts