Jump to content

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


wref48

Recommended Posts

Use the pressure plate script not the button script [ PressurePlate ].

Then add your custom script xmarker script and the [ defaultBlockFollowerActivation ]

 

I think with the lever letting it be and not trying to switch it back would be fine. After all it is a toggle switch.

In real life I wouldn't expect a lever to switch itself after I turned a valve ...

 

Also, you need to be careful when editing scripts. The script you are showing me is a default game script.

If you change it in anyway it may/will effect the entire game. If you want to change a default script like that

you need to make a copy by a different name.

 

I checked the SteamLever.Activate(Game.GetPlayer()) It worked fine for me.

Having the Lever switch back if you turn the Valve off is a bit harder then I was thinking.

I all most got it but have to call it a day ... I will looking into this more tomorrow.

Link to comment
Share on other sites

OK ...

Make sure you have all the properties set to the correct things

in the Creation Kit. (note: one goes to the Steam Lever itself)

 

Valve Script:

 

 

 

ScriptName _ValveSwitch Extends ObjectReference
;* ValveMarker Switch *

ObjectReference Property SteamLever auto
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()
If(LeverMarker.IsEnabled())
SteamLever.Activate(Game.GetPlayer())

Endif
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
Int RF = 0 ;Reset flag

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
If(RF==(0))
RF=(1)
Utility.Wait(2.0)
Activate(self)
Else
RF=(0)
EndIf
EndIf
EndEvent
EndState

State LeverOn
Event OnBeginState()
LeverMarker.Enable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
GoToState("LeverOff")
EndEvent
EndState

 

Link to comment
Share on other sites

I've just posted that script as an example, I do try not to change the originals, but a very valid advise to any future readers.

 

And thanks a lot for the script, it does change the lever position as intended, though if you spam, it is possible to change its default position (the one it returns to when the marker is off).

 

I really had no idea how to approach making a button out of a trigger, so I continued tinkering with the defaultbutton script. Seem logical enough - play the animationdown then the animation up, but for some reason it wasn't working. It did work as intended when I added Utility.Wait as in your script with 0.2 seconds of wait(to make it go up almost immediately).

 

I've also managed to disable the animation on movable static objects. I've used the method you've mentioned as it appears it's impossible to disable this kind of animations via a script. There is a flash when the objects swap places, BUT only if you make a marker their parent, if you actually include their state in the activator script there is no flash and the transition is very smooth.

Link to comment
Share on other sites

Ya, I knew I had it but it didn't work until I added the Wait ... Have to wait for the Valve ... I was thinking it would work better the other way around.

Like the 1st set of scripts, then use the lever in the valves place and the valve in the levers place. Then you wouldn't have to worry about switching

back the lever at all via script.

 

I'll try your suggestion on the flash as it drives me a bit nuts ... (I just make it so my switches face away from it's effect)

One is moving so when it pops back there is a good chance it will not line up to the still version ...

That said being able to stop a vent or other movement is worth it.

 

As far as the spamming problem, I posted a fix for that ..

 

"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 "activate" ...

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.

Edited by NexusComa
Link to comment
Share on other sites

  • Recently Browsing   0 members

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