Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Activator Scripts


Tonycubed2
 Share

Recommended Posts

Light Switch

What you will need.

Objects:

1. >activator >ImpButton01

2. >Light >pick one

3. >static >DweWallSconceSmall01

4. >static >DweWallSconceSmall01On

Place them all in the world. You can use any light object as long as there is an 'On' and 'Off' version. (#3, 4)

Create a new script and attach it to the ImpButton01 reference above (double click it in the Render Window)

The new script is an 'ObjectReference'.

Add the following properties to your script:

1. LightOnREF ->Object Reference

2. LightOffREF ->Object Reference

3. LightBulbREF ->Object Reference

4. QSTAstrolabeButtonPressX ->Sound

Link the objects to the corresponding objects you placed above.

Disable the 'Off' light object. Now place the On and Off light objects in the exact same location.

Now edit your script and add the code needed to control the light.

Scriptname LevelersButton40Switch extends ObjectReference  
{Turn lights on and off}

ObjectReference Property LightOnREF Auto
ObjectReference Property LightOffREF Auto
ObjectReference Property LightBulbREF Auto

Sound Property QSTAstrolabeButtonPressX Auto

int myState

Event OnActivate(ObjectReference akActionRef)
If akActionRef == Game.GetPlayer()
QSTAstrolabeButtonPressX.Play(Self)
Utility.Wait(0.2)

if myState == 1
myState = 0
LightOnREF.enable()
LightBulbREF.enable()
LightOffREF.disable()
else
myState = 1
LightOnREF.disable()
LightBulbREF.disable()
LightOffREF.enable()
endif
EndIf
endEvent
[/code]

If you want to daisy chain multiple lights to your one switch, simply set the 'enable parent' tab on the new "light set" to the light bulb of the first light (LightBulbREF). For the light fixture that is off, check the 'Set Enable State to Opposite of Parent' box. And make them all 'Pop In'.

Link to comment
Share on other sites

Don't forget we have actual states now, they can be really convenient. I've written a similar light switch script that uses states, that I put up on the wiki a while ago - Light Switch

Cipscis

EDIT:

Here's the actual light switch script:

ScriptName ManualLightSwitch extends ObjectReference

{Controls a set of lights with a master enable parent

marker (EnableMarker) and a switch with this script

attached to turn on and off when the switch is activated}


ObjectReference Property EnableMarker auto

{The marker set as the enable parent of all the lights}


Event OnInit()


	If (EnableMarker.IsDisabled())

		GoToState("LightsOff")

	Else

		GoToState("LightsOn")

	EndIf


EndEvent


State LightsOff


	Event OnBeginState()

		Disable()

	EndEvent


	Event OnActivate(ObjectReference akActionRef)

		GoToState("LightsOn")

	EndEvent


EndState


State LightsOn


	Event OnBeginState()

		Enable()

	EndEvent


	Event OnActivate(ObjectReference akActionRef)

		GoToState("LightsOff")

	EndEvent


EndState
Also, an automatic variation that works on a timer:
ScriptName TimedLightSwitch extends ObjectReference

{Controls a set of lights with a master enable parent marker with this

script attached to turn on and off at the times of the day specified

by the properties LightsOffTime and LightsOnTime}


float Property LightsOffTime = 7.0 auto

{The time at which lights should be turned off}

float Property LightsOnTime = 18.0 auto

{The time at which lights should be turned on}


float Function GetCurrentHourOfDay() global

{Returns the current time of day in hours since midnight}


	float Time = Utility.GetCurrentGameTime()

	Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bit

	Time *= 24 ; Convert from fraction of a day to number of hours

	Return Time


EndFunction


Function RegisterForSingleUpdateGameTimeAt(float GameTime)

{Registers for a single UpdateGameTime event at the next occurrence

of the specified GameTime (in hours since midnight)}


	float CurrentTime = GetCurrentHourOfDay()

	If (GameTime < CurrentTime)

		GameTime += 24

	EndIf


	RegisterForSingleUpdateGameTime(GameTime - CurrentTime)


EndFunction


Event OnInit()


	If (GetCurrentHourOfDay() > LightsOffTime)

		GoToState("LightsOff")

	Else

		GoToState("LightsOn")

	EndIf


EndEvent


State LightsOff


	Event OnBeginState()

		Disable()

		RegisterForSingleUpdateGameTimeAt(LightsOnTime)

	EndEvent


	Event OnUpdateGameTime()

		GoToState("LightsOn")

	EndEvent


EndState


State LightsOn


	Event OnBeginState()

		Enable()

		RegisterForSingleUpdateGameTimeAt(LightsOffTime)

	EndEvent


	Event OnUpdateGameTime()

		GoToState("LightsOff")

	EndEvent


EndState

Cipscis

Edited by Cipscis
Link to comment
Share on other sites

  • 3 weeks later...

Acitvates when Actor Enters Combat


ScriptName activateSelfOnCombatBegin extends Actor

{Script that lives on an actor that simply activates itself on Combat Begin}


import game

import debug


auto State waiting

	Event OnCombatStateChanged(Actor actorRef, int combatState)

		if combatState != 0 ; 0 = not in combat, so if the state isn't 0, they entered combat

			gotoState("allDone")

			activate(Self)

		endIf

	endEvent

endState


State allDone

	;do nothing

endState


Link to comment
Share on other sites

  • 10 months later...

Anyone ever think of making a custom script for the BlackReachLock? It would be a nice thing to have on a secure player home. So the animation plays both ways and not just once. Having a script that tells an animation on an object to trigger more than once would be nice.

Edited by Hannibalektr
Link to comment
Share on other sites

  • 9 months later...

Here is a super simple Activator script I made for anyone who wants to replace an item that is taken by the Player - with a static item.

I use it where I have put things on shelves, that the Player can take - but I don't want empty shelves, and I don't want items re-spawning.

Scriptname OVFMReplaceObjects extends ObjectReference

ObjectReference Property replacementItem Auto
Actor Property PlayerREF Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	If akNewContainer == PlayerREF
		replacementItem.Enable()
	endif
EndEvent

Simply place an item on a shelf that the player can take. (eg. Large Antlers)

Place ANOTHER item 'on top of it' (static item - model ship)

Set the 'model ship' to INITIALLY DISABLED (check box on item properties)

Double click the 'Large Antlers' and attach the script to the item

Set the properties of 'replacementItem' to the 'model ship'

 

You're done.  When the player takes the antlers off the shelf - the model ship will appear in it's stead.

** I know the script is super simple - but I've found it's kind of useful :)

 

Leianne

 

WHUPS ... sorry if I posted this under the wrong topic!!!

Edited by Leianne
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...