Trying to learn geck scripting.

Post » Sun Aug 08, 2010 3:28 pm

So I'm trying to script an airlock using 2 gear doors.
So far I'm at a lose on how to link the 2 doors or the 3 control panels to the script.

Here's my code I'm trying to use.
scn GearDoor900Control ;By Guardian9978int lock1int lock2begin onActivate   if VGearDoor9000isactivated == 0      set VGearDoor9000isactivated to 1 ;Global Variable      Activate   endifend;    0 = none (not a door) ;    1 = open ;    2 = opening ;    3 = closed ;    4 = closingbegin Gamemode   If VGearDoor9000isactivated == 1      if lock1 == 0         if VGearDoor9001.GetOpenState == 1            VGearDoor9001.SetOpenState 4            set VGearDoor90001Open to 0 ;Global Variable         elseif VGearDoor9001.GetOpenState == 3            set VGearDoor90001Open to 1 ;Global Variable         endif         if VGearDoor9002.GetOpenState == 1            VGearDoor9002.SetOpenState 4            set VGearDoor90002Open to 0 ;Global Variable         elseif VGearDoor9002.GetOpenState == 3            set VGearDoor90002Open to 1 ;Global Variable         endif      endif      if lock2 == 0         if VGearDoor9001.GetOpenState == 3            if VGearDoor9002.GetOpenState == 3               set lock2 to 1               if VGearDoor90001Open == 1                  VGearDoor9001.SetOpenState 2                  set VGearDoor9000isactivated to 0 ;Global Variable               endif               if VGearDoor90002Open == 1                  VGearDoor9002.SetOpenState 2                  set VGearDoor9000isactivated to 0 ;Global Variable               endif            endif         endif      endif   endifend

User avatar
Pumpkin
 
Posts: 3440
Joined: Sun Jun 25, 2006 10:23 am

Post » Sun Aug 08, 2010 10:04 pm

Hey, I may be back later to help in more detail, but beforehand. Why do you need 3 control panels? Why not just 1? I assume you want one outside on either side and one inside? Why not just have one inside of it, and make it so you can only enter from the side your on. So it's always open to you.
User avatar
kirsty joanne hines
 
Posts: 3361
Joined: Fri Aug 18, 2006 10:06 am

Post » Sun Aug 08, 2010 2:47 pm

Hey, I may be back later to help in more detail, but beforehand. Why do you need 3 control panels? Why not just 1? I assume you want one outside on either side and one inside? Why not just have one inside of it, and make it so you can only enter from the side your on. So it's always open to you.

That's actually a good point but I still need to know how to link the 2 doors and the 1 control panel to the script.
User avatar
Angelina Mayo
 
Posts: 3427
Joined: Wed Jan 24, 2007 4:58 am

Post » Sun Aug 08, 2010 9:25 pm

Alright, so let's set up a script to have a room. It has two door's to enter/exit it, and one control panel in the middle. We will label the doors Door1 and Door2. When you first enter the base, you MUST enter through Door1, and once you are inside passed the airlock, you would then HAVE TO enter the airlock via Door2, alright?

So, in this case, we would want the airlock to start off by default, accesible to the player, outside. So, make your room with your two door and one button/panel the player can activate. Now, you could add some cool gas spray timed effects to this, but the way yours is set up above, it would be instant. One door opens and the other closes. I am going to make there be a 5 seconds delay, since if one is closing and the other opens, it's no longer air tight. Set Door1 to Open By Default. Leave Door2 closed. In the activate parent tab's of both doors, check the 'parent activate only' box, so the player cannot activate the doors by looking at them. Next give each door and the control panel a unique ref ID, for this example script they will be called Door1Ref, Door2Ref, and ControlRef. Replace these in the script with whatever you call yours. Alright, here is the script. It will detect which door is open, close the open one, then 5 seconds later, open the other one. It will also be unactivatable, while the airlock process is going.

scn AirlockScriptShort AirlockState	;this is 0 by default, or the airlock is ready to be entered from the outsideShort Working	;also 0 bydefault, meaning the airlock is currently doing nothingFloat TimerBegin OnActivate	If AirlockState == 0 && Working == 0		Set Working to 1		Set Timer to 5		Door1Ref.Activate	ElseIf AirlockState == 1 && Working == 0		Set Working to 1		Set Timer to 5		Door2Ref.Activate	EndIfEndBegin GameMode	If Working == 1 || Working == 2		If Timer > 0			Set Timer to Timer - GetSecondsPassed		ElseIf AirlockState == 0			Set Working to 2			Door2Ref.Activate			Set Timer to 5			Set AirlockState to 1		ElseIf AirlockState == 1			Set Working to 2			Door1Ref.Activate			Set Timer to 5			Set AirlockState to 0		ElseIf Working == 2			Set Working to 0		EndIf	EndIfEnd


If Door 1 is open, is closes it and after 5 seconds opens Door 2. Then the switch cannot be activate for 5 more seconds, to allow Door 2 to fully open. Otherwise if 2 is open, 1 opens, then after 5 seconds its activatable. This script will work forever provided the airlock is the only way into the area past it. If the player goes through, exiting through door 2, then goes around another way and comes back to door 1 of the airlock, it will be closed and unaccesable from that side. I hope this helps, let me know if you need anything more help. :)

Gunmaster95
User avatar
Jynx Anthropic
 
Posts: 3352
Joined: Fri Sep 08, 2006 9:36 pm

Post » Sun Aug 08, 2010 6:07 pm

Alright, so let's set up a script to have a room. It has two door's to enter/exit it, and one control panel in the middle. We will label the doors Door1 and Door2. When you first enter the base, you MUST enter through Door1, and once you are inside passed the airlock, you would then HAVE TO enter the airlock via Door2, alright?

So, in this case, we would want the airlock to start off by default, accesible to the player, outside. So, make your room with your two door and one button/panel the player can activate. Now, you could add some cool gas spray timed effects to this, but the way yours is set up above, it would be instant. One door opens and the other closes. I am going to make there be a 5 seconds delay, since if one is closing and the other opens, it's no longer air tight. Set Door1 to Open By Default. Leave Door2 closed. In the activate parent tab's of both doors, check the 'parent activate only' box, so the player cannot activate the doors by looking at them. Next give each door and the control panel a unique ref ID, for this example script they will be called Door1Ref, Door2Ref, and ControlRef. Replace these in the script with whatever you call yours. Alright, here is the script. It will detect which door is open, close the open one, then 5 seconds later, open the other one. It will also be unactivatable, while the airlock process is going.

scn AirlockScriptShort AirlockState	;this is 0 by default, or the airlock is ready to be entered from the outsideShort Working	;also 0 bydefault, meaning the airlock is currently doing nothingFloat TimerBegin OnActivate	If AirlockState == 0 && Working == 0		Set Working to 1		Set Timer to 5		Door1Ref.Activate	ElseIf AirlockState == 1 && Working == 0		Set Working to 1		Set Timer to 5		Door2Ref.Activate	EndIfEndBegin GameMode	If Working == 1 || Working == 2		If Timer > 0			Set Timer to Timer - GetSecondsPassed		ElseIf AirlockState == 0			Set Working to 2			Door2Ref.Activate			Set Timer to 5			Set AirlockState to 1		ElseIf AirlockState == 1			Set Working to 2			Door1Ref.Activate			Set Timer to 5			Set AirlockState to 0		ElseIf Working == 2			Set Working to 0		EndIf	EndIfEnd


If Door 1 is open, is closes it and after 5 seconds opens Door 2. Then the switch cannot be activate for 5 more seconds, to allow Door 2 to fully open. Otherwise if 2 is open, 1 opens, then after 5 seconds its activatable. This script will work forever provided the airlock is the only way into the area past it. If the player goes through, exiting through door 2, then goes around another way and comes back to door 1 of the airlock, it will be closed and unaccesable from that side. I hope this helps, let me know if you need anything more help. :)

Gunmaster95



So I applied your code to an activator. I also renamed Door1REF and Door2REF to VGearDoor9001 and VGearDoor9002 since my door Reference Editor ID's were different.
I placed the Activator in the world. I then set the Activators active parent to the switch, saved, then loaded into game and the switch doesn't open or close any doors.
User avatar
Niisha
 
Posts: 3393
Joined: Fri Sep 15, 2006 2:54 am

Post » Sun Aug 08, 2010 9:03 pm

Ahh, I forgot one thing that would normally only affect appearance, but since your using a switch to activate the activator. (which is weird because you could just place this script on a unique switch) I need to place Activate in the onactivate blocks. :P Here is what it looks like with the Activate lines in it:

scn AirlockScript  Short AirlockState      ;this is 0 by default, or the airlock is ready to be entered from the outside Short Working   ;also 0 bydefault, meaning the airlock is currently doing nothing  Float Timer  Begin OnActivate         If AirlockState == 0 && Working == 0                 Set Working to 1                 Set Timer to 5                 Door1Ref.Activate 		Activate        ElseIf AirlockState == 1 && Working == 0                 Set Working to 1                 Set Timer to 5                 Door2Ref.Activate 		Activate        EndIf End  Begin GameMode         If Working == 1 || Working == 2                 If Timer > 0                         Set Timer to Timer - GetSecondsPassed                 ElseIf AirlockState == 0                         Set Working to 2                         Door2Ref.Activate                         Set Timer to 5                         Set AirlockState to 1                 ElseIf AirlockState == 1                         Set Working to 2                         Door1Ref.Activate                         Set Timer to 5                         Set AirlockState to 0                 ElseIf Working == 2                         Set Working to 0                 EndIf         EndIf End


Now the switch will actually look like its activating, and in your case cause the activator to trip. However, you should put the script on the switch itself, or the player will be able to activate the switch over and over, and while it will only actually do anything if the Working variable is 0, it will look weird if they change it back and forth. Also, if your doors are VGearDoor's and take like 20 seconds to open, set the timer's (both) from 5 seconds to something more like a few seconds more than it takes for them to fully open. So if they take 13 seconds to fully animate then set the timer to 15. 5 will be way to short and be weird.

Gunmaster95
User avatar
phillip crookes
 
Posts: 3420
Joined: Wed Jun 27, 2007 1:39 pm

Post » Sun Aug 08, 2010 9:21 pm

How do you create a unique switch?
User avatar
Anna Beattie
 
Posts: 3512
Joined: Sat Nov 11, 2006 4:59 am

Post » Sun Aug 08, 2010 6:29 pm

Just like how you create anything else in a unique editor ID. Open up the switches main window, where you can change the model, name, editor ID, and script. Then type in your own unique editor ID like MyAirlockSwitch01 and click OK. Now it will ask 'Do you wish to create a unique form?' Click yes, or it changes every single one in the game, which is bad. Now you have your own unique switch, which you can attach the script too so you don't need that second activator.
User avatar
Beulah Bell
 
Posts: 3372
Joined: Thu Nov 23, 2006 7:08 pm

Post » Sun Aug 08, 2010 8:16 pm

OK lets see if I can't get your help to figure out what I'm doing wrong.

Door1 ID: VGearDoor9001
Door2 ID: VGearDoor9002
Both doors have Persistent Reference enabled.
One door is open by default the other isn't.

The activator is the switch with the Airlock script attached.

Your script with door ids changed.
scn AirlockScriptShort AirlockState ;this is 0 by default, or the airlock is ready to be entered from the outsideShort Working ;also 0 bydefault, meaning the airlock is currently doing nothingFloat TimerBegin OnActivate        If AirlockState == 0 && Working == 0                Set Working to 1                Set Timer to 5                VGearDoor9001.Activate                Activate        ElseIf AirlockState == 1 && Working == 0                Set Working to 1                Set Timer to 5                VGearDoor9002.Activate                Activate        EndIfEndBegin GameMode        If Working == 1 || Working == 2                If Timer > 0                        Set Timer to Timer - GetSecondsPassed                ElseIf AirlockState == 0                        Set Working to 2                        VGearDoor9002.Activate                        Set Timer to 5                        Set AirlockState to 1                        Activate                ElseIf AirlockState == 1                        Set Working to 2                        VGearDoor9001.Activate                        Set Timer to 5                        Set AirlockState to 0                        Activate                ElseIf Working == 2                        Set Working to 0                EndIf        EndIfEnd


Every time I use the activator switch it doesn't activate any of the doors.
User avatar
Sylvia Luciani
 
Posts: 3380
Joined: Sun Feb 11, 2007 2:31 am

Post » Sun Aug 08, 2010 9:31 am

Door1 ID: VGearDoor9001
Door2 ID: VGearDoor9002


Are these the Editor ID's, or the Reference ID's? It must be the reference ID's. To give something a ref id, double click it to to open the properties window, then at the top in the very top box, type in what you want it to be. I recommend VGearDoor9001Ref and VGearDoor9002Ref. Then, in the script write that. If you use the editor ID, the game has no clue which reference of that object you mean, so it doesn't do anything.
User avatar
Scared humanity
 
Posts: 3470
Joined: Tue Oct 16, 2007 3:41 am

Post » Sun Aug 08, 2010 10:43 am

Sorry about that.

From the top to the bottom of the Reference window:
Reference Editor ID <-- both doors are this ID
Base Object
Encounter Zone
Then the Tabs...

If needed I can send my mod to you and you can see what I have done.
User avatar
Taylor Bakos
 
Posts: 3408
Joined: Mon Jan 15, 2007 12:05 am

Post » Sun Aug 08, 2010 10:14 pm

Yeah, you want those two things (the vgeardoor9001, etc) to be in the Reference Editor ID window, which you have. Then the only thing I can think of that you messed up was something with the switch. Did you make a unique base object (it used to be Ref ID, and Editor ID, but I guess in NV its Ref Editor ID, and Base Object.) for the switch? Also make sure you have the script attached. I can't tell you how many times I have gone to test something, and it fails and I can't figure out why, only to find that I did not pick the script. :P
User avatar
Kayleigh Williams
 
Posts: 3397
Joined: Wed Aug 23, 2006 10:41 am

Post » Sun Aug 08, 2010 9:53 pm

base object is the model file path that you want to use.

When I delete either gear door G.E.C.K. tells me there linked to the control panels script.
But when I delete the control panel it doesn't say it's linked to the 2 doors.
User avatar
Hearts
 
Posts: 3306
Joined: Sat Oct 20, 2007 1:26 am

Post » Sun Aug 08, 2010 10:28 pm

Base object is the object's name, as an object, no matter how many you place. Not the model file path at all.

That means they are correctly referenced. All it's saying is you are deleting a Reference that is used in a script, so the script will no longer function. The door, however, don't have a script on them, so it wont complain about the control panel or anything. Does it still not work?

EDIT: Try replacing Activate with SetOpenState 1, if they are supposed to open, and SetOpenState 0 if they should be closing. So it would look like this:

scn AirlockScript  Short AirlockState ;this is 0 by default, or the airlock is ready to be entered from the outside Short Working ;also 0 bydefault, meaning the airlock is currently doing nothing  Float Timer  Begin OnActivate         If AirlockState == 0 && Working == 0                 Set Working to 1                 Set Timer to 5                 VGearDoor9001.SetOpenState 0                Activate         ElseIf AirlockState == 1 && Working == 0                 Set Working to 1                 Set Timer to 5                 VGearDoor9002.SetOpenState 0                Activate         EndIf End  Begin GameMode         If Working == 1 || Working == 2                 If Timer > 0                         Set Timer to Timer - GetSecondsPassed                 ElseIf AirlockState == 0                         Set Working to 2                         VGearDoor9002.SetOpenState 1                        Set Timer to 5                         Set AirlockState to 1                         Activate                 ElseIf AirlockState == 1                         Set Working to 2                         VGearDoor9001.SetOpenState 1                         Set Timer to 5                         Set AirlockState to 0                         Activate                 ElseIf Working == 2                         Set Working to 0                 EndIf         EndIf End


Now instead of activating the door, which may not work, it simply tells them to animate and changes their state.
User avatar
Erich Lendermon
 
Posts: 3322
Joined: Sat Nov 03, 2007 4:20 pm

Post » Sun Aug 08, 2010 4:15 pm

Base object is the object's name, as an object, no matter how many you place. Not the model file path at all.

That means they are correctly referenced. All it's saying is you are deleting a Reference that is used in a script, so the script will no longer function. The door, however, don't have a script on them, so it wont complain about the control panel or anything. Does it still not work?

EDIT: Try replacing Activate with SetOpenState 1, if they are supposed to open, and SetOpenState 0 if they should be closing. So it would look like this:

scn AirlockScript  Short AirlockState ;this is 0 by default, or the airlock is ready to be entered from the outside Short Working ;also 0 bydefault, meaning the airlock is currently doing nothing  Float Timer  Begin OnActivate         If AirlockState == 0 && Working == 0                 Set Working to 1                 Set Timer to 5                 VGearDoor9001.SetOpenState 0                Activate         ElseIf AirlockState == 1 && Working == 0                 Set Working to 1                 Set Timer to 5                 VGearDoor9002.SetOpenState 0                Activate         EndIf End  Begin GameMode         If Working == 1 || Working == 2                 If Timer > 0                         Set Timer to Timer - GetSecondsPassed                 ElseIf AirlockState == 0                         Set Working to 2                         VGearDoor9002.SetOpenState 1                        Set Timer to 5                         Set AirlockState to 1                         Activate                 ElseIf AirlockState == 1                         Set Working to 2                         VGearDoor9001.SetOpenState 1                         Set Timer to 5                         Set AirlockState to 0                         Activate                 ElseIf Working == 2                         Set Working to 0                 EndIf         EndIf End


Now instead of activating the door, which may not work, it simply tells them to animate and changes their state.


That changed worked. Thank You.
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm

Post » Sun Aug 08, 2010 7:22 pm

That changed worked. Thank You.

Ah, good! Simply adjust the timer's to the correct value so it doesnt do anything too fast, but also so the player isn't sitting there for 20 seconds waiting for something to happen. I think it didnt work before, because I thought an activate command in a script would overwrite the 'parent activate only' option, but I suppose not; and we need that so the player can't activate them. Glad I could help. :)

Gunmaster95
User avatar
Khamaji Taylor
 
Posts: 3437
Joined: Sun Jul 29, 2007 6:15 am

Post » Sun Aug 08, 2010 10:09 pm

Only had to make a slight change in your code to fix a new problem that showed up.

Begin GameMode         If Working == 1 || Working == 2                 If Timer > 0                         Set Timer to Timer - GetSecondsPassed                 ElseIf AirlockState == 0                         Set Working to 0                         VGearDoor9002.SetOpenState 1                        Set Timer to 5                         Set AirlockState to 1                         Activate                 ElseIf AirlockState == 1                         Set Working to 0                        VGearDoor9001.SetOpenState 1                         Set Timer to 5                         Set AirlockState to 0                         Activate                 EndIf         EndIf End


without that change after the door opened the other door would open as well.
User avatar
Kelvin Diaz
 
Posts: 3214
Joined: Mon May 14, 2007 5:16 pm

Post » Sun Aug 08, 2010 9:54 am

Only had to make a slight change in your code to fix a new problem that showed up.

Begin GameMode         If Working == 1 || Working == 2                 If Timer > 0                         Set Timer to Timer - GetSecondsPassed                 ElseIf AirlockState == 0                         Set Working to 0                         VGearDoor9002.SetOpenState 1                        Set Timer to 5                         Set AirlockState to 1                         Activate                 ElseIf AirlockState == 1                         Set Working to 0                        VGearDoor9001.SetOpenState 1                         Set Timer to 5                         Set AirlockState to 0                         Activate                 EndIf         EndIf End


without that change after the door opened the other door would open as well.


Ah, silly me :facepalm: this is because it looks and trips the first one. But you need the ending set working to 0 block or the switch can be activated again the instant the second door start's opening. It would instantly snap open and begin to close, and look bad. I fixed the code by adding back in the second part, but under a different section so it doesnt interfere with the top part. Sorry. xP

Begin GameMode	If Working == 1		If Timer > 0			Set Timer to Timer - GetSecondsPassed		ElseIf AirlockState == 0			Set Working to 2			VGearDoor9002.SetOpenState 1			Set Timer to 5			Set AirlockState to 1			Activate                	ElseIf AirlockState == 1                       		Set Working to 2                        		VGearDoor9001.SetOpenState 1                        		Set Timer to 5                       		Set AirlockState to 0                        		Activate		EndIf	ElseIf Working == 2		If Timer > 0			Set Timer to Timer - GetSecondsPassed		Else			Set Working to 0		EndIf	EndIfEnd


Sorry about the weird indentation... It looks fine when I click 'edit' post, and I cannot seem to fix it. :P So just indent it properly in your script so it's easier to read.
User avatar
Irmacuba
 
Posts: 3531
Joined: Sat Mar 31, 2007 2:54 am

Post » Sun Aug 08, 2010 9:15 pm

I fixed my problem and this is what I ended up with.

I also removed all the timers and replaced them with door states so I wont have to time when things open and close.

Global Variables:
V900working
V900airlockstate

The code is here:
scn AirlockScriptBegin OnActivate        If V900working == 0                V900BunkerDoor1Block.Enable                Set V900working to 1                playgroup Forward 1                Activate        EndIfEndBegin GameMode        If V900working == 1                If VBlastDoor1Ref.GetOpenState == 1                        playgroup Left 1                        VBlastDoor1Ref.SetOpenState 0                Endif                If VBlastDoor1Ref.GetOpenState == 3                        If V900airlockstate == 0                                VGD9001Ref.SetOpenState 0                        Endif                        If V900airlockstate == 1                                VGD9002Ref.SetOpenState 0                        Endif                        Set V900working to 2                Endif        Endif        If V900working == 2                If VGD9001Ref.GetOpenState == 3                        V900Door1LS.playgroup Forward 1                        V900Door1L.playgroup Forward 1                Else                        V900Door1LS.playgroup Left 1                        V900Door1L.playgroup Left 1                Endif                If VGD9002Ref.GetOpenState == 3                        V900Door2LS.playgroup Forward 1                        V900Door2L.playgroup Forward 1                Else                        V900Door2LS.playgroup Left 1                        V900Door2L.playgroup Left 1                Endif                If V900airlockstate == 0                        If VGD9001Ref.GetOpenState == 3                                VGD9002Ref.SetOpenState 1                        Endif                        If VGD9002Ref.GetOpenState == 1                                Set V900airlockstate to 1                                Set V900working to 3                        Endif                Elseif V900airlockstate == 1                        If VGD9002Ref.GetOpenState == 3                                VGD9001Ref.SetOpenState 1                        Endif                        If VGD9001Ref.GetOpenState == 1                                Set V900airlockstate to 0                                Set V900working to 3                        Endif                Endif        Endif        If V900working == 3                If isAnimPlaying == 0                        playgroup SpecialIdle 0                Endif                VBlastDoor1Ref.SetOpenState 1                V900BunkerDoor1Block.Disable                V900Door1LS.playgroup Backward 0                V900Door2LS.playgroup Backward 0                V900Door1L.playgroup Backward 0                V900Door2L.playgroup Backward 0                Set V900working to 0        EndifEnd

User avatar
Emma Pennington
 
Posts: 3346
Joined: Tue Oct 17, 2006 8:41 am


Return to Fallout: New Vegas