Jump to content

Activate steam with lever only when the valve is turned. And disable default animation and enable wit lever.


wref48

Recommended Posts

Hi,

 

I have no experience in coding and while it was interesting to understand the logic behind the ready made scripts I mostly find it quite frustrating to make my own. So here's what I want to do:

 

I have a lever that activates a steam jet. I want it to not activate the jet unless a valve is turned.

 

 

I used the "lights" script to activate the steam jet and below is how I tried to make it check for the valve status. But as far as I understood Enable/Disable is about showing/hiding the object rather if it is "active" and nothing similar to IsActive/Activated/etc works.

ScriptName ActivateSteam1 extends ObjectReference

ObjectReference Property EnableMarker auto
{The marker set as the enable parent of all the lights}

ObjectReference Property SteamLever auto

Event OnInit()

	If (EnableMarker.IsDisabled())
		GoToState("LightsOff")
	Else
		GoToState("LightsOn")
	EndIf

EndEvent

State LightsOff

	Event OnBeginState()
		EnableMarker.Disable()
	EndEvent

	Event OnActivate(ObjectReference akActionRef)
		GoToState("LightsOn")
	EndEvent

EndState

State LightsOn

	Event OnBeginState()
	
If SteamLever.IsDisabled
		GoToState("LightsOff")
	Else
		GoToState("LightsOn1")
	EndIf

EndEvent
		
EndState

State LightsOn1

	Event OnBeginState()
		EnableMarker.Enable()
	EndEvent

	Event OnActivate(ObjectReference akActionRef)
		GoToState("LightsOff")
	EndEvent

EndState

And If you made it this far, I have something else I want to do, but don't have a remote idea how to make it work.

I want to disable the animation on a dweller cog by default and enable it with a lever activation.

 

Thanks in advance.

 

Link to comment
Share on other sites

Hello, This almost looks like one of my scripts :smile:

 

This can be done with two scripts. One on each of the switches.

With a double fault script on the lever. So the steam will turn off

when the valve is turned off as well as when the lever is turned off.

The steam is set from the [ Enable Parent ] tab to the LeverMarker.

Both markers need to start off disabled as well as the steam.

 

Valve Script:

 

 

 

ScriptName _ValveSwitch Extends ObjectReference

;* ValveMarker Switch *

ObjectReference Property LeverMarker auto
ObjectReference Property ValveMarker auto

Event OnInit()
If (ValveMarker.IsDisabled())
GoToState("ValveOff")
Else
GoToState("ValveOn")
EndIf
EndEvent

State ValveOff
Event OnBeginState()
ValveMarker.Disable()
LeverMarker.Disable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
GoToState("ValveOn")
EndEvent
EndState

State ValveOn
Event OnBeginState()
ValveMarker.Enable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
GoToState("ValveOff")
EndEvent
EndState

 

 

 

 

Lever Script:

 

 

 

ScriptName _LeverSwitch Extends ObjectReference
;* LeverMarker Switch *
ObjectReference Property LeverMarker auto
ObjectReference Property ValveMarker auto
Event OnInit()
If (LeverMarker.IsDisabled())
GoToState("LeverOff")
Else
GoToState("LeverOn")
EndIf
EndEvent
State LeverOff
Event OnBeginState()
LeverMarker.Disable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
If(LeverMarker.IsDisabled()&&(ValveMarker.IsEnabled()))
GoToState("LeverOn")
Else
GoToState("LeverOff")
EndIf
EndEvent
EndState
State LeverOn
Event OnBeginState()
LeverMarker.Enable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
If(LeverMarker.IsDisabled()&&(ValveMarker.IsEnabled()))
GoToState("LeverOn")
Else
GoToState("LeverOff")
EndIf
EndEvent
EndState

 

 

 

Untested but should do the trick.

 

As far as your other task ... I just did that!

How I did it was to unpack the Skyrim.bsa found the, (in my case) the vent thingy.

Duplicated it, then with NifSkope removed the Havok parts and added the new

.nif to my mods .bsa file. Use a script just like the valve script or just use the

[ Enabler Parent ] tabs and link them to already made switch marker (like the LeverMarker)

One set to disabled the other set to opposite of parent ( if the parent starts disabled, like your LeverMarker )

Not sure if this is the best way to do it, but it worked for me. Love to see an alternative method ...

 

Only one slight problem: A very small flash when they swap.

As long as the player isn't looking directly at it, it works fine.

So set the switch for that up in a way they have to be turned.

Edited by NexusComa
Link to comment
Share on other sites

Hey NexusComa, thanks a lot for your reply. I've tried applying what you've suggested, but it's still the same problem. Enable/disable just hides or shows the objects, so while it works with lights or steam, it just hides the lever and valve altogether. It has something to do with the activator being "active" or not, rather than being enabled/disabled. I tried going back to "my" old script and after many tries I've managed to compile with no errors using as the condition

If (SteamValve.Activate(Game.GetPlayer()))

But it doesn't really do anything.

 

Maybe you can figure something out.

 

www.creationkit.com/index.php?title=Activate_-_ObjectReference

Link to comment
Share on other sites

Hey NexusComa, thanks a lot for your reply. I've tried applying what you've suggested, but it's still the same problem. Enable/disable just hides or shows the objects, so while it works with lights or steam, it just hides the lever and valve altogether. It has something to do with the activator being "active" or not, rather than being enabled/disabled. I tried going back to "my" old script and after many tries I've managed to compile with no errors using as the condition

If (SteamValve.Activate(Game.GetPlayer()))

But it doesn't really do anything.

 

Maybe you can figure something out.

 

www.creationkit.com/index.php?title=Activate_-_ObjectReference

 

The scripts I posted have nothing to do with checking if anything is active ...

They simply react off the marker(s) being enabled or disabled.

 

The Valve and Lever do not use the [ Enable Parent ] tab as they are always enabled and in view.

The only part of that setup that needs to use the [ Enable Parent ] tab would be the steam.

 

Make one marker for the valve and one marker for the lever (both set to initially disabled).

You can even rename your xmarkers to have relevant names (LeverMarker and ValveMarker).

Put the Valve script on your valve and the Lever script on your lever ...

Then make sure the xmarkers are set in the properties on both scripts from the CK.

Each script uses the same two xmarkers.

 

When you activate the valve it will enable the ValveMarker that is how the lever script knows it's activated or not.

as in:

 

Event OnActivate(ObjectReference akActionRef)
If(LeverMarker.IsDisabled()&&(ValveMarker.IsEnabled()))
GoToState("LeverOn")
Else
The scripts work perfectly and do exactly what you asked. Try them out ...
Link to comment
Share on other sites

" It has something to do with the activator being "active" or not, rather than being enabled/disabled. "

 

When you activate something it will do it's animation then it's no longer activated. So, there is no testing for "if something is active" ... as that is a temporary state.

But, you can test if something is enabled or not. In this case we are enabling and disabling the xmarkers. Then testing that value in the scripts. If the ValveMarker

is enabled we know the valve was activated (turned on). If the ValveMarker is disabled we know the valve was activated again (turned off). Think of the xmarkers

as global variables being set to true or false, or on and off, or in this case enabled and disabled ...

Edited by NexusComa
Link to comment
Share on other sites

I was a bit confused about the markers, but now I see how it works, very ingenious :) Thanks a lot NexusComa it works like a charm. The only issue now is that even if the steam is disabled the lever is stuck in "active" position so I guess I have to include the original lever scrip with animations into your script and tweak it a bit so it would go to not active position when the steam is off.

 

Also since you seem to have the answers to all my questions :) before I attempt it, maybe you happen to have a script that converts a pressure plate into a button.

Link to comment
Share on other sites

The lever will stay in it's current state true, but the script acts like a toggle switch and only cares if it was activated or not.

As in there is no on and off state to the lever just like the valve it is merely toggle activated.

But, you could tweak the switch back if you wanted to.

 

Valve Script:

 

 

 

ScriptName _ValveSwitch Extends ObjectReference
;* ValveMarker Switch *

ObjectReference Property SteamLever auto ; <- set to the lever
ObjectReference Property ValveMarker auto

Event OnInit()
If (ValveMarker.IsDisabled())
GoToState("ValveOff")
Else
GoToState("ValveOn")
EndIf
EndEvent

State ValveOff
Event OnBeginState()
ValveMarker.Disable()
SteamLever.Actavate() ; <- here we just activate the lever (make it switch back)
EndEvent

Event OnActivate(ObjectReference akActionRef)
GoToState("ValveOn")
EndEvent

EndState

State ValveOn
Event OnBeginState()
ValveMarker.Enable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
GoToState("ValveOff")
EndEvent
EndState

 

 

 

As far as the pressure plate and button they are both activators and can use the same scripts.

However a pressure plate can be a bit click happy and go off many times as the player walks over it.

So, you need to add to the script a way to not let it keep reactivating until the first activation is completed.

 

Something like:

 

Int KF = 0 ; kick flag

 

If(KF==(0))

KF=(1)

 

; code

; code

; code

 

KF=(0)

Endif

 

A setup like this is pretty much needed for all switches.

To stop the player from spamming it ...

 

Some Switches and/or Activators have animations that take a bit. In cases like that

it never hurts to toss in a Utility.wait(5.0). With the time in seconds set to however long

the animation takes plus a second. Above the KF=(0) command.

 

Also, we are not setting this up for only the player. As is anyone could use the Lever or Valve. That may cause problems

with followers. So find the script [ defaultBlockFollowerActivation ] and add it to the valve and lever activators with the other scripts.

Now we are free to use the Valve script to activate the lever and still have it set so followers can't activate them.

 

:)

Edited by NexusComa
Link to comment
Share on other sites

Thanks again. You have a typo in Activator, but even when I correct it and try to compile it it say " argument akactivator is not specified and has no default value".

 

I tried putting ObjectReference akActivator in brackets, but then it says "no viable alternative at input 'ObjectReference".

Link to comment
Share on other sites

It compiles, but doesn't return the level to its initial place. Any way to include the animation commands into the lever script? I've tried and it even compiles, but has no effect either.

 

Also that's the default button script and I made it work the pressure plate, but by default when you activate it it goes down and when you do it again it goes up. I tried to make it so it would go up and down, but failed miserably. It's either stuck in down position or goes up and down like crazy. I though what I was doing made sense, but not to papyrus apparently. So how do I make it go up and down in a single activate?

 

 

 


scriptName defaultButtonSCRIPT extends objectReference
{quick script for a button object.}

bool property useOnce = FALSE auto
{Can be used only once? Default: FALSE}

auto STATE active
	EVENT onActivate(objectReference actronaut)
		;playAnimationandWait("down")
		playAnimation("down")
		gotoState("inactive")
		activate(self as ObjectReference)
		playAnimation("up")
		gotoState("active")
	endEVENT
endSTATE

STATE inactive
	; do nothing in this state
endSTATE

int Property TriggerType  Auto  



 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...