Difference between revisions of "SetPropertyValue - ScriptObject"
Jump to navigation
Jump to search
imported>Plplecuyer |
imported>Qazaaq (grammar) |
||
Line 5: | Line 5: | ||
'''Member of:''' [[ScriptObject Script]] | '''Member of:''' [[ScriptObject Script]] | ||
Sets | Sets the value of a property on this script by name, synchronously. | ||
== Syntax == | == Syntax == |
Latest revision as of 23:45, 27 September 2016
Member of: ScriptObject Script
Sets the value of a property on this script by name, synchronously.
Syntax[edit | edit source]
Function SetPropertyValue(string asProperyName, Var aValue) native
Parameters[edit | edit source]
- asPropertyName: The name of the property to set
- aValue: The value to set the property to
Return Value[edit | edit source]
None.
Examples[edit | edit source]
; Set the value of the "DamageMultiplier" property on the "CombatOverhaul" script
; We use CastAs to make sure we don't depend on the script we want to call the function on
ScriptObject combatScript = FormFromOtherMod.CastAs("CombatOverhaul")
; note the '.0' to ensure it is a float, 1 won't work for float properties
combatScript.SetPropertyValue("DamageMultiplier", 1.0)
Notes[edit | edit source]
- If the property name don't exist, the function will error. You may want to check for the existence of the mod you want to talk to before using this.
- The value type must match exactly. You cannot give it a float if the property expects an int, or an Actor if the property expects an ObjectReference. Normally the compiler would do these casts for you in a normal property set, but it doesn't know what the type is, so it is your responsibility to match them up.
- The compiler cannot check the property name for you, so make sure to triple check everything!