darkus37 Posted March 23, 2015 Share Posted March 23, 2015 Hi, I'm really hoping someone can help me out with scripting for my mod. Scripting and I don't get along very well - I think I have a mental block against it or something - but I've managed to cobble together some scripts together using other scripts. If anyone would like to help me out part or full time - please, please do so. In the meantime, I've been trying to add some timers to an existing script. The script is attached to an invisible door. This door is connected to another invisible door in another cell and also has a Linked Ref to an X-Marker Heading. Here is that script: scn HARESTeleporterAirlockScriptRef TeleportRefShort TeleCompanionShort ButtonShort DoOnceFloat Timer1Float Timer2Short State1Short State2Begin OnActivate if IsActionRef player == 1 ShowMessage HARESTeleAirlockMsg set DoOnce to 1 endifendBegin GameModeIf DoOnce == 1 Set Button to GetButtonPressed If Button == -1 Return ElseIf Button == 0 ; Go To Teleporter Control Room Set TeleportRef to HARESTeleporterCell01.GetLinkedRef Set DoOnce to 1 ElseIf Button == 1 ; Go To Teleporter Armory Set TeleportRef to HARESTeleporterCell02.GetLinkedRef Set DoOnce to 1 ElseIf Button == 2 ; Lock-Down Message ShowMessage HARESSecLockDownMsg Set DoOnce to 0 ElseIf Button == 3 ; Extend Airlock Bridge Set DoOnce to 10 ElseIf Button == 4 ; Retract Airlock Bridge Set DoOnce to 20 ElseIf Button == 5 ; Cancel Set DoOnce to 0 EndIfEndIfIf DoOnce == 1 Player.MoveTo TeleportRef if (VNPCFollowers.bEDEHired) && (EDE1REF.Waiting != 1) EDE1REF.MoveTo TeleportRef EDE2REF.MoveTo TeleportRef EDE3REF.MoveTo TeleportRef EndIf if (VNPCFollowers.bBooneHired) && (CraigBooneREF.Waiting != 1) CraigBooneREF.MoveTo TeleportRef EndIf if (VNPCFollowers.ArcadeHired) && (ArcadeREF.Waiting != 1) ArcadeREF.MoveTo TeleportRef EndIf if (VNPCFollowers.bCassHired) && (RoseofSharonCassidyREF.Waiting != 1) RoseOfSharonCassidyREF.MoveTo TeleportRef EndIf if (VNPCFollowers.bVeronicaHired) && (VeronicaREF.Waiting != 1) VeronicaREF.MoveTo TeleportRef EndIf if (VNPCFollowers.bLilyHired) && (LilyREF.Waiting != 1) LilyREF.MoveTo TeleportRef EndIf if (VNPCFollowers.RaulHired) && (RaulREF.Waiting != 1) RaulREF.MoveTo TeleportRef EndIf if (VNPCFollowers.RexHired) && (RexREF.Waiting != 1) RexREF.MoveTo TeleportRef EndIf Set DoOnce to 0 PlaySound DRSEnclaveLargeOpen Autosave Set GameHour To GameHour + 1EndIfIf DoOnce == 10 ApplyImageSpaceModifier FadeToBlack4sISFX PlaySound DRSEnclaveLargeOpen Set Timer1 to 1.5 Set DoOnce to 0 Set State1 to 1EndIfIf State1 == 1 If Timer1 > 0 Set Timer1 to Timer1 - GetSecondsPassed Else HARESTeleExtendedTunnelsRef.enable Set State1 to 0 Set DoOnce to 0EndIfIf DoOnce == 20 ApplyImageSpaceModifier FadeToBlack4sISFX PlaySound DRSEnclaveLargeOpen Set Timer2 to 1.5 Set DoOnce to 0 Set State2 to 1EndIfIf State2 == 1 If Timer2 > 0 Set Timer2 to Timer2 - GetSecondsPassed Else HARESTeleExtendedTunnelsRef.disable Set State2 to 0 Set DoOnce to 0EndIfEndIfEnd I've been trying to save it, but the GECK (Script Extended) tells me that it can't - the exact message is: ************************************************************************SCRIPTS: Script 'HARESTeleporterAirlockScript', Line 87:Mismatched if/else/endif block starting on line 87. ************************************************************************ With a follow up message saying: ************************************************************************SCRIPTS: Script 'HARESTeleporterAirlockScript', Line 87:Mismatched if/then/else block.************************************************************************ Can someone please tell me what I did wrong, how to fix it, and if there are any other problems in the script? Link to comment Share on other sites More sharing options...
claustromaniac Posted March 23, 2015 Share Posted March 23, 2015 (edited) Hey darkus37,You're missing an endif before the end of the block. scn HARESTeleporterAirlockScript ref TeleportRef int TeleCompanion int Button int DoOnce float Timer1 float Timer2 int State1 int State2 Begin OnActivate if IsActionRef player == 1 ShowMessage HARESTeleAirlockMsg set DoOnce to 1 endif End Begin GameMode if DoOnce == 1 set Button to GetButtonPressed if Button == -1 Return elseif Button == 0 ; Go To Teleporter Control Room set TeleportRef to HARESTeleporterCell01.GetLinkedRef set DoOnce to 1 elseif Button == 1 ; Go To Teleporter Armory set TeleportRef to HARESTeleporterCell02.GetLinkedRef set DoOnce to 1 elseif Button == 2 ; Lock-Down Message ShowMessage HARESSecLockDownMsg set DoOnce to 0 elseif Button == 3 ; Extend Airlock Bridge set DoOnce to 10 elseif Button == 4 ; Retract Airlock Bridge set DoOnce to 20 elseif Button == 5 ; Cancel set DoOnce to 0 endif endif if DoOnce == 1 Player.MoveTo TeleportRef if (VNPCFollowers.bEDEHired) && (EDE1REF.Waiting != 1) EDE1REF.MoveTo TeleportRef EDE2REF.MoveTo TeleportRef EDE3REF.MoveTo TeleportRef endif if (VNPCFollowers.bBooneHired) && (CraigBooneREF.Waiting != 1) CraigBooneREF.MoveTo TeleportRef endif if (VNPCFollowers.ArcadeHired) && (ArcadeREF.Waiting != 1) ArcadeREF.MoveTo TeleportRef endif if (VNPCFollowers.bCassHired) && (RoseofSharonCassidyREF.Waiting != 1) RoseOfSharonCassidyREF.MoveTo TeleportRef endif if (VNPCFollowers.bVeronicaHired) && (VeronicaREF.Waiting != 1) VeronicaREF.MoveTo TeleportRef endif if (VNPCFollowers.bLilyHired) && (LilyREF.Waiting != 1) LilyREF.MoveTo TeleportRef endif if (VNPCFollowers.RaulHired) && (RaulREF.Waiting != 1) RaulREF.MoveTo TeleportRef endif if (VNPCFollowers.RexHired) && (RexREF.Waiting != 1) RexREF.MoveTo TeleportRef endif set DoOnce to 0 PlaySound DRSEnclaveLargeOpen Autosave set GameHour to GameHour + 1 endif if DoOnce == 10 ApplyImageSpaceModifier FadeToBlack4sISFX PlaySound DRSEnclaveLargeOpen set Timer1 to 1.5 set DoOnce to 0 set State1 to 1 endif if State1 == 1 if Timer1 > 0 set Timer1 to Timer1 - GetSecondsPassed else HARESTeleExtendedTunnelsRef.Enable set State1 to 0 set DoOnce to 0 endif if DoOnce == 20 ApplyImageSpaceModifier FadeToBlack4sISFX PlaySound DRSEnclaveLargeOpen set Timer2 to 1.5 set DoOnce to 0 set State2 to 1 endif if State2 == 1 if Timer2 > 0 set Timer2 to Timer2 - GetSecondsPassed else HARESTeleExtendedTunnelsRef.Disable set State2 to 0 set DoOnce to 0 endif endif endif End Edited March 24, 2015 by claustromaniac Link to comment Share on other sites More sharing options...
darkus37 Posted March 23, 2015 Author Share Posted March 23, 2015 Thanks very much claustromaniac! I also noticed you changed Short into Int - can you please tell me what the difference is? Link to comment Share on other sites More sharing options...
claustromaniac Posted March 23, 2015 Share Posted March 23, 2015 Thanks very much claustromaniac! I also noticed you changed Short into Int - can you please tell me what the difference is?You're welcome :smile: There's no difference actually. There should be, but in reality the engine treats shorts and longs as ints, and internally treats ints as floats, so you could say that it simply treats everything as floats :tongue: Source: http://geck.bethsoft.com/index.php?title=Int Link to comment Share on other sites More sharing options...
darkus37 Posted March 23, 2015 Author Share Posted March 23, 2015 Hi, sorry again - I've been having a bit of trouble with this script in-game (among others). My mod has a cell called "Teleporter Control Room" (000Teleporter2) which is linked to another cell called "Teleporter Armory" (000Teleporter1). The script works fine in the armory cell, but I'm having a lot of trouble with the other cell. Just about every script acts wonky in the Teleporter Control Room cell. For example: 1. Activating the door (with the above attached script), displays the correct location to go to, but does nothing - just exits the message box. Same thing when it's supposed to display the Security Lock-Down Message - just exits the message box.2. Trigger Areas become disabled for seemingly no reason and replacing them in-GECK seems to have no response. I have no idea why this happens or what's causing it. Any ideas? Link to comment Share on other sites More sharing options...
claustromaniac Posted March 24, 2015 Share Posted March 24, 2015 (edited) Oops.I messed up earlier, sorry. I didn't inspect the script in great detail and misplaced the missing endif by accident lol. :sweat:I've just finished inspecting it (in great detail this time) and not only I fixed it but I also cleaned it up, tidied it up, and optimized it for performance. It looks better than my room right now. Oh, and I added some comments to explain a couple of things, you can delete those if you want (they're quite intrusive). scn HARESTeleporterAirlockScript ref TeleportRef int TeleCompanion int Button int DoOnce ;----------------------------------------------------------------------------------- float Timer ; I removed both Timer1 and Timer2 and replaced them with this to ; simplify the script. ; I also removed both State1 and State2 for the same reason. ;----------------------------------------------------------------------------------- Begin OnActivate if IsActionRef player set DoOnce to 1 ShowMessage HARESTeleAirlockMsg endif End Begin GameMode ;----------------------------------------------------------------------------------- if DoOnce == 0 ; Little check to optimize this script for performance. Return ; nothing to do here, trim CPU usage. endif ;----------------------------------------------------------------------------------- if DoOnce == 1 set Button to GetButtonPressed if Button == -1 Return elseif Button == 0 ; Go To Teleporter Control Room set TeleportRef to HARESTeleporterCell01.GetLinkedRef elseif Button == 1 ; Go To Teleporter Armory set TeleportRef to HARESTeleporterCell02.GetLinkedRef elseif Button == 2 ; Lock-Down Message ShowMessage HARESSecLockDownMsg set DoOnce to 0 Return ; skip the rest of the script ;----------------------------------------------------------------------------------- elseif Button == 3 || Button == 4 ; Toggle Airlock Bridge set DoOnce to 10 ; As you can see, I simplified this part. ;----------------------------------------------------------------------------------- else ;Cancel set DoOnce to 0 Return ; skip the rest of the script endif endif ;----------------------------------------------------------------------------------- if DoOnce == 1 && TeleportRef != 0 ; check to ensure the variable stores ; something, otherwise the script could crash. ;----------------------------------------------------------------------------------- Player.MoveTo TeleportRef if (VNPCFollowers.bEDEHired) && (EDE1REF.Waiting != 1) EDE1REF.MoveTo TeleportRef EDE2REF.MoveTo TeleportRef EDE3REF.MoveTo TeleportRef endif if (VNPCFollowers.bBooneHired) && (CraigBooneREF.Waiting != 1) CraigBooneREF.MoveTo TeleportRef endif if (VNPCFollowers.ArcadeHired) && (ArcadeREF.Waiting != 1) ArcadeREF.MoveTo TeleportRef endif if (VNPCFollowers.bCassHired) && (RoseofSharonCassidyREF.Waiting != 1) RoseOfSharonCassidyREF.MoveTo TeleportRef endif if (VNPCFollowers.bVeronicaHired) && (VeronicaREF.Waiting != 1) VeronicaREF.MoveTo TeleportRef endif if (VNPCFollowers.bLilyHired) && (LilyREF.Waiting != 1) LilyREF.MoveTo TeleportRef endif if (VNPCFollowers.RaulHired) && (RaulREF.Waiting != 1) RaulREF.MoveTo TeleportRef endif if (VNPCFollowers.RexHired) && (RexREF.Waiting != 1) RexREF.MoveTo TeleportRef endif ;----------------------------------------------------------------------------------- set TeleportRef to 0 ;just wiping the variable after using it, otherwise the ;added security check above would fail in the future. ;----------------------------------------------------------------------------------- set DoOnce to 0 PlaySound DRSEnclaveLargeOpen Autosave set GameHour to GameHour + 1 endif if DoOnce == 10 ApplyImageSpaceModifier FadeToBlack4sISFX PlaySound DRSEnclaveLargeOpen set Timer to 1.5 set DoOnce to -1 endif if DoOnce == -1 if Timer > 0 set Timer to Timer - GetSecondsPassed else if HARESTeleExtendedTunnelsRef.GetDisabled HARESTeleExtendedTunnelsRef.Enable else HARESTeleExtendedTunnelsRef.Disable endif set DoOnce to 0 endif endif End Please let me know if it works well for you. Other than that, I can tell you that you should rename those cells that you mentioned because prefixing FormIDs with numbers is quite problematic by itself. The names don't matter as long as they don't start with numbers. Something like AAATeleporter1 or even A00Teleporter1 would be OK. If you used numeric prefixes in other FormIDs in your mod you should change those too. Edited March 24, 2015 by claustromaniac Link to comment Share on other sites More sharing options...
darkus37 Posted March 24, 2015 Author Share Posted March 24, 2015 Thanks very much, it works! I also want to thank you so much for telling me about the prefixes - I've been banging my head for so long with that problem and even decided to split the Teleporter cell in two just to get around it. I've renamed them and it works great. Now on to the next problem: The first script works - more or less - but the timing is off. Here it is: scn HARESTeleChamInvisDoor02ScriptShort ButtonShort DoOnceFloat TimerDoorShort StateBegin OnActivate PlayerIf AAAReactor == 0 ShowMessage AAATeleportNoPowerElseIf AAAReactor == 1 ShowMessage HARESTeleportHomeMsg02 Set DoOnce to 1EndIfEndBegin GameModeIf DoOnce == 1 Set Button to GetButtonPressed If Button == -1 Return ElseIf Button == 0 ; Open Teleporter Pod Chamber Door Set DoOnce to 10 ElseIf Button == 1 ; Display Security Lockdown Message ShowMessage HARESTeleportHomeMsg02 Set DoOnce to 0 ElseIf Button == 2 ; Cancel Set DoOnce to 0 EndIfEndIfIf DoOnce == 10 HARESTeleporterPodsDoorRef.SetOpenState 1 ApplyImageSpaceModifier FadeToBlack4sISFX PlaySound DRSEnclaveLargeOpen Set TimerDoor to 1.5 Set DoOnce to 0 Set State to 1EndIfIf State == 1 If TimerDoor > 0 Set TimerDoor to TimerDoor - GetSecondsPassed Else HARESTeleChamberBarrierRef.disable HARESTeleporterHomeSwitchRef.disable HARESTeleporterPodsDoorControlRef.disable Set State to 0 Set DoOnce to 0 EndIfEndIfEnd The second script also appears to work except for the open door/disable x-marker functions. Scn HARESTeleportHomeScriptShort ButtonShort DoOnceFloat TimerHomeFloat TimerDoorShort StateBegin OnActivate PlayerIf AAAReactor == 0 ShowMessage AAATeleportNoPowerElseIf AAAReactor == 1 ShowMessage HARESTeleportHomeMsg01 Set DoOnce to 1EndIfEndBegin GameModeIf DoOnce == 1 Set Button to GetButtonPressed If Button == -1 Return ElseIf Button == 0 ; teleport Field (must be preset) Set HARESTeleportControl.Destination to 10 Set DoOnce to 30 ElseIf Button == 1 ; teleport Mark (must be preset) Set HARESTeleportControl.Destination to 9 Set DoOnce to 30 ElseIf Button == 2 ; teleport to preset menu (must be discovered) ShowMessage HARESTeleportDevicePresetMsg01 Set DoOnce to 20 ElseIf Button == 3 ; Open Teleporter Pod Chamber Door Set DoOnce to 50 ElseIf Button == 4 ; leave it alone Set DoOnce to 0 EndIfEndIfIf DoOnce == 20 Set Button to GetButtonPressed If Button == -1 Return ElseIf Button == 0 ; camp mccarran Set HARESTeleportControl.Destination to 1 Set DoOnce to 30 ElseIf Button == 1 ; freeside Set HARESTeleportControl.Destination to 2 Set DoOnce to 30 ElseIf Button == 2 ; goodsprings Set HARESTeleportControl.Destination to 3 Set DoOnce to 30 ElseIf Button == 3 ; Hoover damn Set HARESTeleportControl.Destination to 4 Set DoOnce to 30 ElseIf Button == 4 ; jacobstown Set HARESTeleportControl.Destination to 5 Set DoOnce to 30 ElseIf Button == 5 ; new vegas strip Set HARESTeleportControl.Destination to 6 Set DoOnce to 30 ElseIf Button == 6 ; novac Set HARESTeleportControl.Destination to 7 Set DoOnce to 30 ElseIf Button == 7 ; leave it alone Set DoOnce to 0 EndIfEndIfIf DoOnce == 30 Player.MoveTo HARESMarkerHome HARESTeleportEffectsFX.Enable Set TimerHome to 4 Set DoOnce to 0EndIfIf ( TimerHome > 0 ) Set TimerHome to TimerHome - GetSecondsPassedElse EnablePlayerControls HARESTeleportEffectsFX.Disable Set DoOnce to 40EndIfIf DoOnce == 40 HARESTeleportControl.Activate HARESTeleportControl 1 Set DoOnce to 0EndIfIf DoOnce == 50 HARESTeleporterPodsDoorRef.SetOpenState 1 ApplyImageSpaceModifier FadeToBlack4sISFX PlaySound DRSEnclaveLargeOpen Set TimerDoor to 1.5 Set DoOnce to 0 Set State to 1EndIfIf State == 1 If TimerDoor > 0 Set TimerDoor to TimerDoor - GetSecondsPassed Else HARESTeleChamberBarrierRef.disable HARESTeleporterHomeSwitchRef.disable HARESTeleporterPodsDoorControlRef.disable Set State to 0 Set DoOnce to 0 EndIfEndIfEnd I was also wondering if there is a way to have a similar timed set of operations through a terminal option. I tried doing it without a timer and all I got was instant disabling/enabling of an x-marker and/or opening/closing of a door as well as the sound playing on a loop until I reloaded a previous save - or is it simpler to do it via a script attached to a switch? Link to comment Share on other sites More sharing options...
claustromaniac Posted March 24, 2015 Share Posted March 24, 2015 (edited) I have some stuff to do right now, but I'll take a good look at those scripts later today. As for the timed-set-of-operations-through-a-terminal-option thingy, I'm pretty sure it's easier than it sounds. You just need to make it change the variables of the scripts of the doors and such externally. I'll try to give you an example later. EDIT: Ok I took a good look and it seems you made very minor mistakes. I can't test the timing in the first script for obvious reasons but, if it works well otherwise, you should be able to test by just changing the value of the timer yourself. As for the second script, the one line that I suspect is causing you trouble is the following one: HARESTeleportControl.Activate HARESTeleportControl 1 That basically means that HARESTeleportControl activates itself, which is kinda weird. I changed it to: HARESTeleportControl.Activate PlayerREF 1 But that's mostly just a wild guess. If I was wrong there I'm sure you'll let me know. Now, regarding the terminal commands, I will try to explain what you can do with the following example. Let's suppose you wanted to open the so-called "Teleporter Pod Chamber Door" through a terminal option. You'd need to set up the terminal, then in the Item Result Script for that option you could simply add a script with the following line: set HARESTeleChamInvisDoor02REF.DoOnce to 10 Then, when you select that option in game the terminal sets the value of that variable to 10, and the already existing script in that door does the rest of the job. Let me know if that helps. Edited March 25, 2015 by claustromaniac Link to comment Share on other sites More sharing options...
darkus37 Posted March 25, 2015 Author Share Posted March 25, 2015 OK, I added the scripts in-game, and I've experienced a couple of problems. The first problem is with the ChamInvisDoor02Script - it seems to ignore the timer and just disables the x-marker right away before a really short fadetoblack. The problems really begin once I activate the HARESTeleportHomeScript - basically, once it's used, it bugs out all the other scripts like the Airlock and trigger areas, as well as the ChamInvisDoor02 script - none of them work. ************************************ I haven't checked out the terminal option just yet, but I'll give it a try a little later. However, while we are on the subject, what would a script like this looks like? For example, in the HARESTeleChamInvisDoor02Script, there is a section called 'Begin OnActivate' - I wouldn't need that, right? ************************************ I was also wondering about a set of operations. For example: 1. On script start - ApplyImageSpaceModifier FadeToBlack4sISFX; PlaySound DRSEnclaveLargeOpen.2. +1 seconds - disable an x-marker (DefaultRef).3. +3 seconds - PlaySound TRPPitchingMachineRunLPM.4. Script Ends. Link to comment Share on other sites More sharing options...
Recommended Posts