UnrealScript in LegendaryExplorer (original) (raw)

There are two good general UnrealScript references:

  1. The official docs: docs.unrealengine.com/udk/Three/UnrealScriptHome.html
  2. The wiki: wiki.beyondunreal.com/UnrealScript_reference

I've often found the wiki to be more illuminating than the official docs, but both contain useful information. If either site is ever down, you can access them through the wayback machine on archive.org

The UnrealScript that you can write in LegendaryExplorer is a slightly different dialect than the one used in UnrealEd/UDK. In this list of differences, UScript will refer to the UnrealEd/UDK dialect of UnrealScript, and LEXScript will refer to the LegendaryExplorer dialect.

defaultproperties

The defaultproperties format in LEXScript has many differences to UScript, so read this section carefully.

The defaultproperties block is used to specify default values for a class or struct's properties. When used for a struct, the keyword is structdefaultproperties instead. The block can only contain subobject declarations and assignments to class/struct members. Unlike in UScript, it cannot contain dynamic array manipulation operations. In UScript, spaces are discouraged and newlines are significant and restricted in where they can be used. In LEXScript, whitespace and newlines are not significant, so use them (or don't) wherever you want. Semicolons after each assignment statement are optional.

Every assigned value must be a literal, expressions are not allowed:

Structs:

There are no struct literals in regular code, except for special syntax for vectors (vect(0.0, 0.0, 0.0)) and rotators (rot(0, 0, 0)). You cannot use that special syntax in defaultproperties, but there is a general struct literal syntax. You can provide values for some or all properties. Any properties you don't specify will get their values from the struct's defaults.

StructProp = {X=1,Y=2,Z=0} //you can split larger structs onto multiple lines. StructProp = { Default = TRUE, GameplayPhysics = TRUE, EffectPhysics = TRUE, BlockingVolume = TRUE }

Static Arrays:

You must assign each index individually. You do not need to assign them all; any you do not specify will have their default value, or inherit from the base class when applicable.

Prop[0] = 'AName' Prop[2] = 'AnotherName'

Dynamic Arrays:

There are no dynamic array literals in regular code, but there is in defaultproperties. You must assign the whole array literal, you cannot assign to specific indices.

ArrayProp = (5, 9, 23, 87) //you can split arrays onto multiple lines. This is especially useful for arrays of structs Points = ({InVal = 0.0, OutVal = 0.35, ArriveTangent = 0.0, LeaveTangent = 0.0, InterpMode = EInterpCurveMode.CIM_Linear}, {InVal = 0.35, OutVal = 0.1, ArriveTangent = 0.0, LeaveTangent = 0.0, InterpMode = EInterpCurveMode.CIM_Linear}, {InVal = 1.0, OutVal = 0.1, ArriveTangent = 0.0, LeaveTangent = 0.0, InterpMode = EInterpCurveMode.CIM_Linear}, {InVal = 4.0, OutVal = 0.012, ArriveTangent = 0.0, LeaveTangent = 0.0, InterpMode = EInterpCurveMode.CIM_Linear} )

Delegates:

DelegateProp = FunctionName //function is in the same class DelegateProp = Class'ClassName'.FunctionName //function is in a different class

Objects:

//for a class, you just give the class name ClassProp = Class'ClassName' //for any other kind of object, you must give the Instanced Full Path of the object in this file (which can be found in the Metadata tab for that object in Package Editor). ObjectProp = SkeletalMesh'BioBaseResources.MissingResources.Missing_Creature_Class' //In addition to the normal class literals, you can use the name of a subobject ObjectProp = subobjectName

SubObjects:

SubObjects can only be declared in defaultproperties, not structdefaultproperties. They may contain other subobjects. Examples:

Begin Object Class=BioDynamicAnimSet Name=MY_DYN_HMM_BC_SniperSpecial m_nmOrigSetName = 'HMM_BC_SniperSpecial' Sequences = (AnimSequence'BIOG_HMM_BC_A.HMM_BC_SniperSpecial_BC_Start') m_pBioAnimSetData = BioAnimSetData'BIOG_HMM_BC_A.HMM_BC_SniperSpecial_BioAnimSetData' End Object

//SubObjects declared with "Begin Template" will use a same-named SubObject in the defaultproperties of the current class's super class as their Archetype Begin Template Class=SkeletalMeshComponent Name=SkeletalMeshComponent0 Begin Template Class=AnimNodeSequence Name=AnimNodeSeq0 End Template Animations = AnimNodeSeq0 ReplacementPrimitive = None RBCollideWithChannels = {Pawn = TRUE, Vehicle = TRUE} End Template

Enums:

EnumProp = EnumType.EnumValue

Names:

Booleans:

Integers and Bytes

Byte literals are the same as int literals, they just have to be in the range 0 to 255

ByteProp = 0xF //numbers starting with 0x are interpreted as hexadecimal IntProp = -8903

Floats:

FloatProp = 10.43 FloatProp = -8903 FloatProp = 1.45e12 //scientific notation can be used

Strings:

StringRef:

string refs are tlk ids