Jump to content

Script: If two Xmarkers are disabled then disable the third one


Zorkaz

Recommended Posts

I need help with a simple script

 

What I want to do:

 

There are two Xmarkers (FirstActivator and SecondActivator)

 

If they are disabled you can press a button and a third Xmarker (FinalActivator)

gets disabled, otherwise the button won't do anything

 

 

Here's my script, which get's compiled but doesn't work

Thanks in advance

 

 

Scriptname AWPCheckifThingsEnabled extends ObjectReference


ObjectReference Property FirstActivator Auto

ObjectReference Property SecondActivator Auto


ObjectReference Property FinalActivator Auto

Sound Property SoundToPlay Auto Const

Auto State Broken
Event OnInit()
; block default activation
BlockActivation(true)
EndEvent

Event OnActivate(ObjectReference refAction)
ObjectReference refPlayer = Game.GetPlayer()

If (FirstActivator.IsDisabled())
If (SecondActivator.IsDisabled())
SoundToPlay.PlayAndWait(self)
FinalActivator.Disable()

Else
FinalActivator.Enable()


EndIf



; enable default activation
BlockActivation(false)
; go to fixed state
GotoState("Fixed")
EndIf

EndEvent
EndState

State Fixed

EndState




 

Link to comment
Share on other sites

It looks like the reason that will never work is the script starts with activation blocked so event OnActivate will never fire to unblock itself.

 

Unclear on your usecase logic for BlockActivation on the button and Enable on the FinalActivator, here is some simplified code that exposes the recursive issue;

Scriptname AWPCheckifThingsEnabled extends ObjectReference

ObjectReference Property FirstActivator Auto
ObjectReference Property SecondActivator Auto
ObjectReference Property FinalActivator Auto
Sound           Property SoundToPlay Auto Const

Event OnLoad()
   If (FirstActivator.IsDisabled() == TRUE) && (SecondActivator.IsDisabled() == TRUE)
      Self.BlockActivation(abBlocked = true,  abHideActivateText = true)
   ElseIf (FirstActivator.IsDisabled() == FALSE) && (SecondActivator.IsDisabled() == FALSE)
      Self.BlockActivation(abBlocked = false,  abHideActivateText = false)
   Else
      ;this is the case for one activator being disabled and one enabled
   EndIf
EndEvent

;what happens if activators start disabled but are enabled whilst button 3d is loaded to enable the button ?

Event OnActivate(ObjectReference refAction)
   If (FirstActivator.IsDisabled() == TRUE) && (SecondActivator.IsDisabled() == TRUE)
      ;this will never ever fire as button activation is blocked in this state, LOL !
      SoundToPlay.PlayAndWait(Self)
      FinalActivator.Disable()
   ElseIf (FirstActivator.IsDisabled() == FALSE) && (SecondActivator.IsDisabled() == FALSE)
      FinalActivator.Enable()
   Else
      ;this is the case for one activator being disabled and one enabled
   EndIf
EndEvent
Link to comment
Share on other sites

OnActivate event is supposed to fire even if BlockActivation(true) is set. It's just the default activation processing that's no longer supposed to take place. Which was the main goal of what this script originally did, as it was ment for activators that need to be "fixed" before they can be default-activated. But the "fixing" part seems to have been lobotomized.

 

However, if you do BlockActivation(true, true), then the option to activate will disappear, the activator can't be activated anymore by player and the event consequently won't fire.

 

Why do you even use the fix script for this, Zorkaz? The whole state and oninit cruft is superfluous for what you want to do here. All you need on your button is OnActivate.

 

You can optionally test if activated by player if you don't want companions NPCs or whatever to activate your button.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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