Jump to content

How can i create a Objectreference from a Form?


vegae7

Recommended Posts

Hi.

 

I want to get a Ref from a FormID. But i dont know how. Can anyone help me? Big THX :smile:

Scriptname VegaTestScript extends ObjectReference

Actor Property PlayerRef Auto Hidden
Form Property someForm Auto Hidden
Location Property PlayerLocation Auto Hidden
Location Property ReflLocation Auto Hidden
ObjectReference Property MyTestRef Auto Hidden

Event OnClose(ObjectReference akActionRef)
  PlayerRef = Game.GetPlayer()
  if (akActionRef == PlayerRef)

	someForm = Game.GetForm(0x00123456)
	;ReflLocation = someForm.GetCurrentLocation()
	;MyTestRef = someForm.GetReference()
	;MyTestRef = new someForm
	;ReflLocation = MyTestRe.GetCurrentLocation()
	;MyTestRef = Game.GetReference(0x00123456)
	PlayerLocation = PlayerRef.GetCurrentLocation()

	if (PlayerLocation == ReflLocation)
		Debug.Notification("Same location")
	else
		Debug.Notification("Not same location")
	endif
  endIf
EndEvent
Link to comment
Share on other sites

You need the placeAtMe function of ObjectReference. Give in a form object (or anything that extends form) and you get an ObjectReference back.

 

Example:

Form property someForm auto const

Event OnClose(ObjectReference akActionRef)
  PlayerRef = Game.GetPlayer()
  if (akActionRef == PlayerRef)
        PlayerRef.placeAtMe(someForm)
  endIf
EndEvent
Edited by DarthWayne
Link to comment
Share on other sites

  • Recently Browsing   0 members

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