I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX
Compiler issues
Like any other compiler there are issues with the parsing therefor this page exists to mention those common issues and how to get around them.
Parsing Issues[edit]
Comment Issues related to the comments
- Having an end of multi-line comment proceeded by a line comment on the same line.
Correct |
Wrong |
/* if(!bUseForVehicles)
return Super.DamageTaken(Enemy, Injured);
else{//Branch4: Do vehicle code here, optimized?}
*/ /*local int LogInitHealth;*/ /*, LogDamage, LogConversion;*/ |
/* if(!bUseForVehicles)
return Super.DamageTaken(Enemy, Injured);
else{//Branch4: Do vehicle code here, optimized?}*/ /*local int LogInitHealth;*//*, LogDamage, LogConversion;*/ |
DefaultProperties Issues related to the defaultproperties block
- Placing a { on the same line of the defaultproperties declaration will cause the parser to skip the defaultproperties block thus :all of your default values will not be compiled, to get around this is easy just place the { on the next line!.
Correct |
Wrong |
defaultproperties { } |
defaultproperties{ } |
Switch Issues related to the switch block when attempting to access DefaultProperties from a static function.
- Using the syntax Default.Identifier (to resolve a DefaultProperties reference from a static function) within a switch block confuses the compiler, which assumes the script has an error, and suggests 'default:', as in the default case for a switch statement. The error message is Error, Missing ':' in 'Default. See examples for some workarounds.
Correct |
Wrong |
// A workaround is necessary. // Example using the class name directly.. case 1: Class'GameMessage'.Static.CallMe (); break; // ..or an if-else block to replace the switch-case statement.. // ..or a local proxy variable: static function Test (int Index) { local class<LocalMessage> ClassNameWorkaround; ClassNameWorkaround = Default.ClassName; // ... case 1: ClassNameWorkaround.Static.CallMe (); break; // ... } |
var class<LocalMessage> ClassName; static function Test (int Index) { switch (Index) { case 1: Default.ClassName.Static.CallMe (); break; default: break; } } DefaultProperties { ClassName = Class'GameMessage' } |
DefaultProperties Issues related to the defaultproperties block and the mathematical syntax for representing negative numbers. No warnings from the compiler.
- In mathematics, a negative number is sometimes represented in parenthesis, as in the expression 1 + (-1). The parenthesis are not recognized, and thus the value becomes 0.0f (default-initialized).
Correct |
Wrong |
var float A; DefaultProperties { A = -1.0f } |
var float A; DefaultProperties { A = (-1.0f) // A is 0.0f } |
DefaultProperties Issues related to the defaultproperties block and const values. No warnings from the compiler.
- A const value would appear default-initialized (0.0f, 0, false) when used in a defaultproperties block.
Correct |
Wrong |
var float A; DefaultProperties { A = 2.71828f } |
var float A; const C = 2.71828f; DefaultProperties { A = C // A is 0.0f } |