Jump to content

Script sanity check, multiple door handler for airlock


Recommended Posts

I haven't tried this yet and can't for a few hours (since I'm not actually *at* my PC with CK/FO4 on it), but here's the deal.

 

Imagine a short room with two submarine bulkhead doors. There's a button at each door outside, and one button in the middle. The outside buttons use the same script, and another script runs the inside button. If this works as-is, fantastic... also always looking for improvements/recommendations, and I will be sticking a translation for water level and a teleport command into a second version of the inside button script later.

 

Behavior-wise, this is an airlock, and only one door should be open at a time.

 

Outside button script: used near and far for the door descriptions since this gets used locally for both external buttons

Scriptname M1V201AirlockIntScript extends ObjectReference

ObjectReference Property ALNearDoor auto
ObjectReference Property ALFarDoor auto

Event OnActivate(ObjectReference AkActionRef)
	int ALNDState = ALNearDoor.GetOpenState()
	int ALFDState = ALFarDoor.GetOpenState()

	if (ALFDState == 3)
		if (ALNDState == 3)
			ALNearDoor.setOpen(true)
		else
			ALFarDoor.SetOpen(false)
			debug.notification("Airlock is already open")
			ALNearDoor.setOpen(true)
		endif
	else
		ALFarDoor.SetOpen(false)
		ALNearDoor.SetOpen(true)
	endif
endevent

Inside button script: Door A is the 'inside' door and door B the 'outside'. Wanted to give a preference that in the case, somehow, that both doors were closed, door A opens on the first press, then it will toggle as usual. Also wanted to wait a short time during the 'toggle' with both doors closed, because that's what airlocks would seem to do.

Scriptname M1V201AirlockIntDoorInsideButton extends ObjectReference

ObjectReference Property ALDoorA auto
ObjectReference Property ALDoorB auto

Event OnActivate(ObjectReference AkActionRef)
	int ALDAState = ALDoorA.GetOpenState()
	int ALDBState = ALDoorB.GetOpenState()

	if (ALDAState == 3)
		if (ALDBState == 3)
			ALDoorA.setOpen(true)
		else
			ALDoorB.SetOpen(false)
			utility.wait(5.0)
			ALDoorB.setOpen(true)
		endif
	else
		ALDoorA.SetOpen(false)
		utility.wait(5.0)
		ALDoorB.SetOpen(true)
	endif
endevent

So... have I done anything spectacularly stupid? Also, I want to make these bulkhead doors accessible only by the button, is that a matter of locking them inaccessible, and do I toggle the inaccessible flag on the main edit tab as well or not?

 

Going to have further work later when I have the external door placed as teleport target, which should always be open after teleporting but I think I've got a handle on that (setting it open with event onLoad , right? Script is added to the door object itself?)

Link to comment
Share on other sites

Ok, now that I had time to test it there was an error in door selection in the inside button code, and the outside button code (thanks to using near/far) didn't even need a single if statement, I just simplified it down to "close the far door, wait 5 seconds, open the near door". At that outside button there's never a reason to want to close the door you're standing in front of, that's for someone else on the other side to call for, and the interior button does the closing when you're in transit.

 

Suppose I answered my own question...

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...