illyism Posted February 12, 2009 Share Posted February 12, 2009 Light switch script place this inside an activator. and link the light to a x-marker, using Enable Parenting. scn ValhallaLightSwitchScript ref myself ref light short toggle begin onactivate if myself == 0 set myself to this endif if light == 0 set light to myself.getlinkedref endif if toggle == 0 light.disable activate set toggle to 1 else light.enable set toggle to 0 activate endif end SpotLight script.I used the MegatonSpotlight01, and the FX beam light, and some lights, all connected to each other using Linked references, can also be done using Enable Parenting. (probably better.) It deactivates itself at day, and if you use Destruction Stages, it can be destroyed and disables lights. scn ValhallaSpotLightScript ; Spot light usage script ; Author: Illyism - www.project-valhalla.org ; If you use this script in your mod, please keep these lines intact ;!!-----Requires a FXBeam and a Light source linked to the object to work------!! short Toggle ;0= on; 1=off ref mySpotlight ref mySpotLightBeam ref mylight ref myspotter ref myspotter2 ref myspotter3 ref myspotter4 ref myspotter5 ref myspotter6 ref myspotter7 ref myspotter8 ref myspotter9 begin onactivate set myspotlight to this ;Spotlight static set mySpotLightBeam to myspotlight.getlinkedref ;FXBeam set mylight to myspotlightbeam.getlinkedref ;Light set mySpotter to mylight.getlinkedref ;spotlight light set myspotter2 to myspotter.getlinkedref ;Just in case 2 set myspotter3 to myspotter2.getlinkedref ;Just in case 3 set myspotter4 to myspotter3.getlinkedref ;Just in case 4 set myspotter5 to myspotter4.getlinkedref ;Just in case 5 set myspotter6 to myspotter5.getlinkedref ;Just in case 6 set myspotter7 to myspotter6.getlinkedref ;Just in case 7 set myspotter8 to myspotter7.getlinkedref ;Just in case 8 set myspotter9 to myspotter8.getlinkedref ;Just in case 9 ;Toggles if Toggle == 0 ;Set off Myspotlightbeam.disable mylight.disable myspotter.disable myspotter2.disable myspotter3.disable myspotter4.disable myspotter5.disable myspotter6.disable myspotter7.disable myspotter8.disable myspotter9.disable mylight.csize 1 set Toggle to 1 elseif Toggle == 1 ;Set on myspotlightbeam.enable mylight.enable myspotter.enable myspotter2.enable myspotter3.enable myspotter4.enable myspotter5.enable myspotter6.enable myspotter7.enable myspotter8.enable myspotter9.enable mylight.csize 2 set Toggle to 0 endif end begin OnDestructionStageChange set myspotlight to this ;Spotlight static set mySpotLightBeam to myspotlight.getlinkedref ;FXBeam set mylight to myspotlightbeam.getlinkedref ;Light set mySpotter to mylight.getlinkedref ;spotlight light set myspotter2 to myspotter.getlinkedref ;Just in case 2 set myspotter3 to myspotter2.getlinkedref ;Just in case 3 set myspotter4 to myspotter3.getlinkedref ;Just in case 4 set myspotter5 to myspotter4.getlinkedref ;Just in case 5 set myspotter6 to myspotter5.getlinkedref ;Just in case 6 set myspotter7 to myspotter6.getlinkedref ;Just in case 7 set myspotter8 to myspotter7.getlinkedref ;Just in case 8 set myspotter9 to myspotter8.getlinkedref ;Just in case 9 Mylight.disable Myspotlightbeam.disable myspotter.disable myspotter2.disable myspotter3.disable myspotter4.disable myspotter5.disable myspotter6.disable myspotter7.disable myspotter8.disable myspotter9.disable end begin gamemode if gamehour <= 18 && Gamehour >= 7 && Getdisabled == 0 Mylight.disable Myspotlightbeam.disable myspotter.disable myspotter2.disable myspotter3.disable myspotter4.disable myspotter5.disable myspotter6.disable myspotter7.disable myspotter8.disable myspotter9.disable endif end Link to comment Share on other sites More sharing options...
SpeedyB64 Posted February 12, 2009 Share Posted February 12, 2009 Here is an interesting one: A script to make a door that requires more than one switch to open. First you will need an X marker, give it a reference name like DoorSwitchMarkerRef place this marker at height (Z axis) 0 Script type: object scn 3SwitchDoorScript short used begin onactivate if DoorSwitchMarkerRef.getpos z == 0 DoorSwitchMarkerRef.setpos z, 10 set used to 1 elseif DoorSwitchMarkerRef.getpos z == 10 && used == 0 DoorSwitchMarkerRef.setpos z, 20 set used to 1 elseif DoorSwitchMarkerRef.getpos z == 20 && used == 0 DoorSwitchMarkerRef.setpos z, 30 set used to 1 DoorRef.SetOpenState 1 ;DoorRef is the reference name of your door endif end place this script on a switch and in the GECK you can place 3 of these switches and when they are all used it will open the door. If the switch is animated you can add a "playgroup forward 1" comand after each "setpos" line. you could also replace "setopenstate 1" with "unlock" to unlock the referenced door. This script is easily expanded for more switches. The script can also be modified to work more than once but thats much more complex. Link to comment Share on other sites More sharing options...
Riven1978 Posted February 13, 2009 Share Posted February 13, 2009 Ok now can some one sticky this, Please. This is too valuable a post to not be hehe, :thumbsup: Link to comment Share on other sites More sharing options...
sumoftwosins Posted February 13, 2009 Share Posted February 13, 2009 This is added to the list of links in the sticky post. Regardless, it is great that everyone is contributing. I've got a ton of scripts that I'll post from my mod once they are fully tested and optimized. Link to comment Share on other sites More sharing options...
illyism Posted February 14, 2009 Share Posted February 14, 2009 and I wikified this thread. I didn't include everything, as some required Messages. Link to comment Share on other sites More sharing options...
Cipscis Posted February 25, 2009 Share Posted February 25, 2009 I've had a look at the page illyism created on the GECK Wiki, and I've optimised some of the scripts (check the GECK Wiki page linked to by illyism above for the current versions). - For the "KarmaEffect" script, I've changed it so that the Karma modifier will be applied to whatever Actor equips the scripted item instead of modifying the player's Karma whenever any Actor equips or unequips the item. I've also noted that, for Amours, a scripted Object Effect should be used instead of an Object script. This will ensure that the effect won't break if the item is equipped via EquipItem - For the automatic door closing script, I've changed it to use GetOpenState and SetOpenState so that it will always work correctly. - For the "CALFPeffectSCR" script, I've changed it to use implied reference syntax instead of "ref" variables - basically removed unnecessary code. I haven't looked at it enough to try to optimise it in any other way though. - For the "LightSwitchScript" script, I've changed it to use implied reference syntax, just like with "CALFPeffectSCR", and I've also gotten rid of the "toggle" variable and used GetDisabled instead. I only just found this thread, so I haven't read it through it yet, but when I get the chance I'd like to have a look at the scripts that haven't been included on the Wiki page and see if they can't be shortened or optimised as well. Cipscis Link to comment Share on other sites More sharing options...
Sabat9 Posted February 25, 2009 Share Posted February 25, 2009 This is the script Keht and I developed for my Rad-Reducing Scrub Shower in Archie's Bunker. I used it to activate 12 "shower heads" grouped in a cluster, and implement a rads-reducing effect over a period of 15 seconds, during which the player is forced to remain in a certain spot (i.e., actually "in" the shower) I added the disable controls command to make sure the player had to actually stand under the shower for the full 15 seconds to actually get the effect. There may be a more elegant way to accomplish this, but disabling controls had the desired effect. this could probably be used to activate any kind of animated FX object and add some sort of "spell" effect based upon the animated FX...might be good for Strength Rays or something....anyway, it works like a charm for a rads-reducing shower 8P. scn AAAScrubShowerSingleValvefinal Float Timer Begin OnActivate player.CastImmediateOnSelf AAAShowerEffect; AAAShowerEffect is an actor effect with Restore Rads Effect set to duration 15, magnitude 20 Set Timer to 15 end begin GameMode If Timer > 0 set timer to timer - getsecondspassed DisablePlayerControls Shower1.Enable Shower2.Enable Shower3.Enable Shower4.Enable Shower5.Enable Shower6.Enable Shower7.Enable Shower8.Enable Shower9.Enable Shower10.Enable Shower11.Enable Shower12.Enable ShowerSound.Enable ShowerDrainSound.Enable Elseif timer <= 1 EnablePlayerControls Shower1.Disable Shower2.Disable Shower3.Disable Shower4.Disable Shower5.Disable Shower6.Disable Shower7.Disable Shower8.Disable Shower9.Disable Shower10.Disable Shower11.Disable Shower12.Disable ShowerSound.Disable ShowerDrainSound.Disable EndIf End Link to comment Share on other sites More sharing options...
Cipscis Posted February 25, 2009 Share Posted February 25, 2009 In a situation like this, you'll want to use Enable Parenting so that you can Enable/Disable many references at once by calling Enable/Disable on a single parent reference. This would enable you to reduce the code to this:ScriptName AAAScrubShowerSingleValvefinal float Timer Begin OnActivate player.CastImmediateOnSelf AAAShowerEffect ; AAAShowerEffect is an actor effect with Restore Rads Effect set to duration 15, magnitude 20 set Timer to 15 End Begin GameMode if Timer > 0 if Timer == 15 ; The timer has just started DisablePlayerControls 1 0 0 0 0 0 0 Shower1.Enable 0 endif set Timer to Timer - GetSecondsPassed elseif Timer <= 1 EnablePlayerControls 1 0 0 0 0 0 0 0 Shower1.Disable endif End Cipscis Link to comment Share on other sites More sharing options...
SpeedyB64 Posted February 25, 2009 Share Posted February 25, 2009 You should link all those things to an X marker and enable/disable that, would shorten the script a lot. Link to comment Share on other sites More sharing options...
Cipscis Posted February 25, 2009 Share Posted February 25, 2009 There isn't really any point in making an extra reference when one of the references that is already present can be used as an Enable Parent, although you're absolutely correct that Enable Parenting should be used. Cipscis Link to comment Share on other sites More sharing options...
Recommended Posts