Jump to content

Papyrus question


wref48

Recommended Posts

Hi,
 
I've heard that people around here might know a thing or two about papyrus.
 
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". So this is what I managed to do so far, but the SteamValve.Activate part doesn't seem to have any effect.

ScriptName ActivateSteam1 extends ObjectReference

ObjectReference Property EnableMarker auto

ObjectReference Property SteamValve 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("Lights")
	EndEvent

EndState


State Lights

	Event OnBeginState()
		 If (SteamValve.Activate(Game.GetPlayer()))
		GoToState("LightsOn")
	Else
		GoToState("Lightsoff")
	EndIf
	EndEvent


EndState

State LightsOn

	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

Hi.

May I advise to change a little the title of your post?

 

Steam... Valve...

 

People will get confused.

 

 

Change it to:

 

"Activate/Deactivate a gas stream with a lever only when its valve is turned on"

 

Link to comment

Hi,

 

I've heard that people around here might know a thing or two about papyrus.

 

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". So this is what I managed to do so far, but the SteamValve.Activate part doesn't seem to have any effect.

 

ScriptName ActivateSteam1 extends ObjectReference

ObjectReference Property EnableMarker auto

ObjectReference Property SteamValve 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("Lights")
	EndEvent

EndState


State Lights

	Event OnBeginState()
		 If (SteamValve.Activate(Game.GetPlayer()))
		GoToState("LightsOn")
	Else
		GoToState("Lightsoff")
	EndIf
	EndEvent


EndState

State LightsOn

	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.

 

I'm gonna make a some assumptions here:

  • EnableMarker is a parent marker for the steam jet?
  • From the looks of it you put this script on the steam instead of the controlling lever object? (That would be backwards)

You are correct in the understanding that "Enable" and "Disable" effectively hides objects and stops any AI/scripts/etc from processing on them.

 

I've not been able to wrap my head around states personally. Though in full disclosure I've not really tried. I've done C/C++/Java/JavaScript and they don't really have that type of thing so I stick with variables to control states and such. So I'll detail a scenario that might suit your needs using another method.

 

You would attach this script to the controlling valve object. This script would control turning the steam on and off. It would go something like this:

 

 

 

ScriptName ToggleSteam extends ObjectReference
{Put this on the lever object}

; This EnableMarker should be a generic marker placed in the world and set as the parent enabler for your steam.
; This is so if you have multiple steam or other objects you can control them all with one enable/disable command.
; If you only have one object and do not want to make a marker for just one you can pass the steam reference directly as well.
ObjectReference Property EnableMarker auto
{Parent enable marker for steam object(s)}
 
bool isEnabled = false
{Default state to set steam when our activating lever object gets spawned}
 
Event OnInit ()
    if (isEnabled)
        EnableMarker.Enable()
    else
        EnableMarker.Disable()
    endif
EndEvent
 
Event OnActivate (ObjectReference akActionRef)
    ; only allow player to activate - remove if you want to allow npcs
    if (!akActionRef == Game.GetPlayer())
        return
    endif
    ; toggle status and turn steam on
    if (isEnabled)
        isEnabled = false
        EnableMarker.Disable()
    else
        isEnabled = true
        EnableMarker.Enable()
    endif
EndEvent
 

 

 

 

 

An alternative is to use the default enabled state as you place the parent marker and have the code check if it's enabled and set the isEnabled boolean and proceed accordingly. Or if you understand the usage of states better than I, you could use the states to do the toggling instead of the if/else in the OnActivate. Though I think this might be less code involvement. I'm not sure about speed efficiency. Though this is pretty light code regardless.

 

Fair warning. I haven't actually tried to compile this, but after proof reading a few times it looks pretty sound.

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use