Guest TAJocelyn Posted October 31, 2009 Share Posted October 31, 2009 Here's a nice little script that can be used to control an object(xmarker) by several different switches that will all show the same animation. scn AATJGenericLightSwitch ;====================================================================; ;This is part of the repair lights script and can control multiple switches using the same;xmarker and linked refs.;This script controls the animation of the switch and turns on or off the normal;lights once power is restored by repairing its node.;Its xmarker acts as an on/off switch and is set as the linked reference of the switch;SetOpenstate 0=closed, 1=open;GetOpenState 0=not a door, 1=open, 2=is opening, 3=closed, 4=is closing ;====================================================================; ref LinkedRef ;this is the light switch on or off (xmarker)ref self ;this is the switch ref ;====================================================================; ;This section checks to make sure that the animation matches the xmarker state ;====================================================================; Begin OnLoad ;Start when enabled set self to GetSelf ;Get the refrence number of the switch if LinkedRef.GetDisabled == 1 ;xmarker is off self.SetOpenState 0 ;Switch is set to closed Red else self.SetOpenState 1 ;switch is set to open endif end ;====================================================================; ;This section handles the activation or use of the switch ;====================================================================; Begin onActivate ;Start when used set LinkedRef to GetLinkedRef ;This is an xmarker that is the on/off switch set self to GetSelf ;This is the switch being used if self.getOpenstate == 3 ;is switch is off? self.Activate ;then Green light and LinkedRef.enable ;Xmarker is enabled == lights On elseif self.getOpenstate == 1 ;is switch is on? self.Activate ;then Red light and LinkedRef.disable ;Xmarker off == lights Off endif end ;====================================================================; ;This section checks to see if the xmarker has been turned on by another switch and;sets its animation to match. This will be called by all switches ;====================================================================; Begin GameMode ;Runs always Set self to GetSelf ;the switch Set LinkedRef to GetLinkedRef ;the xmarker if LinkedRef.GetDisabled == 1 ;xmarker is off self.SetOpenState 0 ;Switch is set to closed Red else self.SetOpenState 1 ;switch is set to open endifend Link to comment Share on other sites More sharing options...
Guest TAJocelyn Posted October 31, 2009 Share Posted October 31, 2009 This is a basic repair script for a light switch(and lights). scn AATJGenericLightSwitchRepair ;========================================================================; ; With a repair skill of 10, 1 scrap, 1 abraxo cleaner, and a wrench, the player can; restore an areas lights after its power node has been repaired.; Use only one switch for repair as we want the player in the room; This script is placed on a dummy switch that is set to enable parent on our real switch, we can reuse this by ; enable to create random faults. ;========================================================================; ref LinkedRef ; The linked power noderef self ; The switchshort state ; 0 = Broken ; 1 = Fixed short active ; 0 = Not fixing ; 1 = fixing short button ; Message Choice (0 or 1) in this script ;========================================================================; begin onActivate set LinkedRef to GetLinkedRefset self to GetSelf if LinkedRef.GetDisabled == 0 ;Is its node repaired? if IsActionRef player == 1 ;Is it the player? if state == 0 && active == 0 if player.getAV repair >= 10 && player.getitemcount Spareparts > 1 &&player.GetItemCount Wrench01 == 1 && player.GetItemCount AbraxoCleaner >= 1 ;This is one line in the editor. ShowMessage AATJLightRepair ;Repair Option Avalible set active to 1 ;We are fixing else ShowMessage AATJLightSkill ;Item count too low endif endif else ;Do nothing its broke! endifelse showmessage AATJPowerNodeNotRepaired ;No powerendifend ;========================================================================; begin GameMode if active == 1 set active to 0 if state == 0 set button to getButtonPressed ;Message choice if button == 0 ;Repair Lights Player.removeitem FissionBattery 1 ;Remove Battery Player.removeitem SpareParts 1 ;Remove Scrap Player.removeitem AbraxoCleaner 1 ;Remove Cleaner Player.RewardXP 10 ;XP=Skill if aaTJVGDoorRoomFix.GetDisabled == 0 ;The room is clean ShowMessage AATJLightRepaired else ShowMessage AATJLightRepairedNasty endif self.Disable ;Enable fixed light switch set state to 1 elseif button == 1 ;Leave it alone ; do nothing endif endif endif end Link to comment Share on other sites More sharing options...
Guest TAJocelyn Posted October 31, 2009 Share Posted October 31, 2009 My generic light repair system;This consists of two consoles and two switches and one xmarker.The first consol uses my animated ruined consol type 4 or 6 and the following script: scn AATJGenericLargePowerNodeRepair ; This script repairs the broken power node so the switch can be repaired.; With a skill of 20 and 2 batteries, a wrench, the player can restore the power to the relay system.; Also, with no skill, a Paint Gun, and 1 Turpentine, the player can repaint the console.; This uses my type6 ruined vault version of the console.; Note this script is cut down from my original that allows repeated repairs. ;========================================================================; ref LinkedRef ;Used to set the state of the light switch (repair/no-repair).ref SelfRef ;The broken power node (disable parent), the good power node is set to be oppisite disable parentshort state ; 0 = Broken ; 1 = Fixed ; 2 = Not Painted short active ; 0 = Not Fixable ; 1 = Fixable short button ; Message Choice (0 or 1) in this script ;========================================================================; begin onActivate set LinkedRef to GetLinkedRefset SelfRef to GetSelf if IsActionRef player == 1 if state == 0 && active == 0 if player.getAV repair >= 20 && player.getitemcount FissionBattery >= 2 && Player.GetItemCount Wrench01 == 1;this is one line in the editor ShowMessage aaTJGenPowNodRepMsg ;Repair Option Available set active to 1 ;Fixable else ShowMessage aaTJGenLrgPowNodRepReq ;Failure show requirements endif elseif state == 1 && active == 0 ;only show if you have the materials. if Player.GetitemCount PaintGun == 1 && Player.GetItemCount Turpentine >= 1 ShowMessage aaTJGenPaiRepMsg ;Paint the node set active to 1 set state to 2 else ;Do nothing this just enables repair of switch endif endifendif end ;========================================================================; begin gameMode if active == 1 set active to 0 if state == 0 set button to getButtonPressed ;Message choice if button == 0 ;Repair Node Player.removeitem FissionBattery 2 ;Remove Battery Player.RewardXP 20 ;XP=Skill ShowMessage aaTJRepairSuccess SelfRef.PlayGroup Forward 1 set state to 1 LinkedRef.enable ;Enables the repairable switch elseif button == 1 ;Leave it alone ; do nothing endif elseif state == 2 set button to GetButtonPressed if button == 0 Player.removeitem Turpentine 1 SelfRef.disable ;Enables the new power node elseif button == 2 ;Do nothing endif endifendif End This ruined consol will allow the player to repair and then repaint it. When repaired the consol lights animate on. When it’s repainted it is replaced with a normal type4 or 6 consol with its lights animated. The real purpose of the consol is to allow the repair of the light switch and be a test object for the emergency power.The second consol has the following script attached: scn AATJGenericPowerNodeFixed ;=======================================; ;this script starts the animation for the node when;it is enabled. ;=======================================; ref LinkedRef ;So it will work on two nodes for doorsBegin OnLoad ;Start when enabled Set LinkedRef to GetLinkedRef ;The second node 2 per PlayGroup Forward 1 ;Play the animation Forward ImmediantlyLinkedRef.PlayGroup Forward 1 ;Play the animation on second node too end ;Only runs once unless disabled and re-enabled ;=======================================;; For new content ;=======================================; Begin OnActivate ; this is a catch-all Set LinkedRef to GetLinkedRef PlayGroup Forward 3 LinkedRef.PlayGroup Forward 3 ShowMessage AATJConsRepaired ; Just tell the player its working. End With either repaired, the first switch will now allow the player to repair it. The next script is placed on the first switch: scn AATJGenericLightSwitchRepair ;========================================================================; ; With a repair skill of 10, 1 scrap, 1 abraxo cleaner, and a wrench, the player can; restore an area light after its power node has been repaired.; Use only one switch for repair as we want the player in the room ;========================================================================; ref LinkedRef ; The linked power node ref self short state ; 0 = Broken ; 1 = Fixed short active ; 0 = Not fixing ; 1 = fixing short button ; Message Choice (0 or 1) in this script ;========================================================================; begin onActivate set LinkedRef to GetLinkedRefset self to GetSelf if LinkedRef.IsAnimPlaying Forward == 1|| LinkedRef.getdisabled == 1 ;Is its node repaired? if IsActionRef player == 1 if state == 0 && active == 0 if player.getAV repair >= 10 && player.getitemcount Spareparts > 1 && player.GetItemCount Wrench01 == 1 && player.GetItemCount AbraxoCleaner >= 1 ; this is one line in the editor. ShowMessage AATJLigRepair ;Repair Option Avalibleset active to 1elseShowMessage AATJLigSkill ;Item count too lowendif endifelse ;Do nothing its broke!endifelse showmessage AATJPowerNodeNotRepairedendifend ;========================================================================; begin GameMode if active == 1set active to 0 if state == 0 set button to getButtonPressed ;Message choice if button == 0 ;Repair Lights Player.removeitem FissionBattery 1 ;Remove Battery Player.removeitem SpareParts 1 ;Remove Scrap Player.removeitem AbraxoCleaner 1 ;Remove Cleaner Player.RewardXP 10 ;XP=Skill ;if aaTJVGDoorRoomFix.GetDisabled == 0 ;The room is clean ;ShowMessage AATJLightRepaired ;else ShowMessage AATJRepairSuccess ;endif self.Disable ;Enable fixed light switch set state to 1 elseif button == 1 ;Leave it alone ; do nothing endifendifendif end When the switch is repaired it disables itself which enables the normal switch. The normal switch has the following script attached: scn AATJGenericLightSwitch ;====================================================================; ;SetOpenstate 0=closed, 1=open;GetOpenState 0=not a door, 1=open, 2=is opening, 3=closed, 4=is closing ;====================================================================; ref LinkedRef ;this is the light switch on or off (xmarker)ref self ;this is the switch ref ;====================================================================; ;This section checks to make sure that the animation matches the xmarker state ;====================================================================; Begin OnLoad ;Start when enabled set self to GetSelf ;Get the refrence number of the switch if LinkedRef.GetDisabled == 1 ;xmarker is off self.SetOpenState 0 ;Switch is set to closed Redelse self.SetOpenState 1 ;switch is set to openendif end ;====================================================================; ;This section handles the activation or use of the switch ;====================================================================; Begin onActivate ;Start when used set LinkedRef to GetLinkedRef ;This is an xmarker that is the on/off switchset self to GetSelf ;This is the switch being used if self.getOpenstate == 3 ;Switch off self.Activate ;Green light LinkedRef.enable ;Xmarker on == lights Onelseif self.getOpenstate == 1 ;Switch is on self.Activate ;Red light LinkedRef.disable ;Xmarker off == lights Offendif end ;====================================================================; ;This section checks to see if the xmarker has been turned on by another switch and;sets its animation to match. This will be called by all switches ;====================================================================; Begin GameMode ;Runs always Set self to GetSelf ;the switchSet LinkedRef to GetLinkedRef ;the xmarker if LinkedRef.GetDisabled == 1 ;xmarker is off self.SetOpenState 0 ;Switch is set to closed Redelse self.SetOpenState 1 ;switch is set to openendif end Now with this script running, the switch will mirror any other switch set as a linked reference to the xmarker. Link to comment Share on other sites More sharing options...
bfg10k17 Posted October 31, 2009 Share Posted October 31, 2009 I relly happy about this thing that you doing, 'cous maybe a modder could use it, but you started in a wrong place.This is the mod requests forum. Please move these posts to the right place.Make a new post Here, its a place for general talking about modding. Link to comment Share on other sites More sharing options...
Recommended Posts