Jump to content

getLinkedRef question/help


Recommended Posts

Okay, I am trying to build a self-contained packin, which is essentially a mini electric power substation. I would like to use the packin in several places within my mod. Inside the packin I have a activator (MLS_ElectricalCabinet02) which is linked to a EnableMarker. Another activator (MLS_PoweredUtilityPole01) is connected to the EnableMarker via enable parent. The script below is attached to the MLS_ElectricalCabinet02 activator but it isn’t working at the moment. I want to define GridPowerEnabler based on the linkage from the MLS_ElectricalCabinet02 and the EnableMarker but can’t get the right syntax and or positioning to make it work. I thought something along the lines of the following would work but sadly it does not.
ObjectReference GridPowerEnabler = self.getLinkedRef(pLinkCustom01)
I also tried to use MLS_ElectricalCabinet02, after declaring it, but it didn’t seem to work either.
Suggestions welcomed and appreciated.
Scriptname MysticLake:MLS_GridPowerScript extends ObjectReference
{Controls a node with a enable parent marker. Script is placed on the activator, which is a lever}

;
;-- Properties --------------------------------------
;

Keyword Property pLinkCustom01 Auto Const Mandatory

; None of this seemed to work
; ObjectReference Property MLS_ElectricalCabinet02 Auto Const Mandatory
; ObjectReference GridPowerEnabler = MLS_ElectricalCabinet02.getLinkedRef(pLinkCustom01)
;
; or
; ObjectReference GridPowerEnabler = self.getLinkedRef(pLinkCustom01)

Event OnInit()
 
	If (GridPowerEnabler.IsDisabled())
		GoToState("GridPowerOff")
	Else
		GoToState("GridPowerOn")
	EndIf
 
EndEvent
 
State GridPowerOff
 
	Event OnBeginState(string asOldState)
		GridPowerEnabler.Disable()
	EndEvent
 
	Event OnActivate(ObjectReference akActionRef)
		GoToState("GridPowerOn")
	EndEvent
 
EndState
 
State GridPowerOn
 
	Event OnBeginState(string asOldState)
		GridPowerEnabler.Enable()
	EndEvent
 
	Event OnActivate(ObjectReference akActionRef)
		GoToState("GridPowerOff")
	EndEvent
EndState

 

Link to comment
Share on other sites

Declare the variable in the empty state so that it can be used throughout the script, but define it in the OnInit event.

 

Example:

Keyword Property pLinkCustom01 Auto Const Mandatory
ObjectReference GridPowerEnabler

Event OnInit()
  GridPowerEnabler = self.getLinkedRef(pLinkCustom01)
  ;other stuff
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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