Jump to content

Assigning a variable to a property?


batman99000

Recommended Posts

So I am creating a script to enable/disable objects through message box, and one of my properties are:

ObjectReference[] Property ItemsToDisable Auto

Is there a simple way to assign a variable to the property? I was hoping I could just put the variable name in front of the property and cal it good, but that obviously didn't work.

 

Any help is greatly appreciated.

Link to comment
Share on other sites

On the object that you attached the script to there is a properties button. If you highlight the script and press the properties button a new window appears. On the new window there will be a list of properties, if you highlight a property the grey area to the right will be populated with various fields depending upon the type of property.

 

Since you are using an array of objectreferences for your property, the size of the array will be dependent upon the number of entries you fill in the Creation Kit (up to 128 as that is the limit for arrays).

Link to comment
Share on other sites

 

 

Say I wanted to assign the variable "int item" to the property, how would I give it that variable?

 

You cannot assign an integer to an objectreference.

 

 

 

 

In the end, I want "if this item in the array is disabled, enable it"
Int ArraySize = MyArray.Length
Int Index = 0
While Index < ArraySize
  Form Entry = MyArray[Index]
  If (Entry as ObjectReference).IsDisabled()
    (Entry as ObjectReference).Enable()
  EndIf
  Index += 1
EndWhile

Replace MyArray with whatever you are calling your array.

Link to comment
Share on other sites

Okay. Lets assume that your index entries on the array match the button entries on the message box.

 

In your event where the message box shows

If button == 0
  EnableOrDisableArrayObject(button)
ElseIf button == 1
  EnableOrDisableArrayObject(button)
EndIf

The function is placed somewhere in the empty state of the script

Function EnableOrDisableArrayObject(Int Index)
  Form Entry = MyArray[Index]
  If (Entry as ObjectReference).IsDisabled()
    (Entry as ObjectReference).Enable()
  Else
    (Entry as ObjectReference).Disable()
  EndIf
EndFunction

Replace MyArray with whatever you are calling your array.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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