PDA

View Full Version : Error, Script vs. class name mismatch (Main/TriggerLight)


Tano
11-10-2009, 03:04 PM
Hello to everyone.
I've this error while i try to compile the sample in the documentation:


//================================================== ===================
// TriggerLight.
// A lightsource which can be triggered on or off.
//================================================== ===================
class TriggerLight extends Light;

//---------------------------------------------------------------------
// Variables.

var() float ChangeTime; // Time light takes to change from on to off.
var() bool bInitiallyOn; // Whether it's initially on.
var() bool bDelayFullOn; // Delay then go full-on.

var ELightType InitialType; // Initial type of light.
var float InitialBrightness; // Initial brightness.
var float Alpha, Direction;
var actor Trigger;

//---------------------------------------------------------------------
// Engine functions.

// Called at start of gameplay.
function BeginPlay()
{
// Remember initial light type and set new one.
Disable( 'Tick' );
InitialType = LightType;
InitialBrightness = LightBrightness;
if( bInitiallyOn )
{
Alpha = 1.0;
Direction = 1.0;
}
else
{
LightType = LT_None;
Alpha = 0.0;
Direction = -1.0;
}
}

// Called whenever time passes.
function Tick( float DeltaTime )
{
LightType = InitialType;
Alpha += Direction * DeltaTime / ChangeTime;
if( Alpha > 1.0 )
{
Alpha = 1.0;
Disable( 'Tick' );
if( Trigger != None )
Trigger.ResetTrigger();
}
else if( Alpha < 0.0 )
{
Alpha = 0.0;
Disable( 'Tick' );
LightType = LT_None;
if( Trigger != None )
Trigger.ResetTrigger();
}
if( !bDelayFullOn )
LightBrightness = Alpha * InitialBrightness;
else if( (Direction>0 &amp;amp;amp;&amp;amp;amp; Alpha!=1) || Alpha==0 )
LightBrightness = 0;
else
LightBrightness = InitialBrightness;
}

//---------------------------------------------------------------------
// Public states.

// Trigger turns the light on.
state() TriggerTurnsOn
{
function Trigger( actor Other, pawn EventInstigator )
{
Trigger = None;
Direction = 1.0;
Enable( 'Tick' );
}
}

// Trigger turns the light off.
state() TriggerTurnsOff

{
function Trigger( actor Other, pawn EventInstigator )
{
Trigger = None;
Direction = -1.0;
Enable( 'Tick' );
}
}

// Trigger toggles the light.
state() TriggerToggle
{
function Trigger( actor Other, pawn EventInstigator )
{
log("Toggle");
Trigger = Other;
Direction *= -1;
Enable( 'Tick' );
}
}

// Trigger controls the light.
state() TriggerControl
{
function Trigger( actor Other, pawn EventInstigator )
{
Trigger = Other;
if( bInitiallyOn ) Direction = -1.0;
else Direction = 1.0;
Enable( 'Tick' );
}
function UnTrigger( actor Other, pawn EventInstigator )
{
Trigger = Other;
if( bInitiallyOn ) Direction = 1.0;
else Direction = -1.0;
Enable( 'Tick' );
}
}


I recive this error:


D:\UDK\UDK-2009-11\Binaries\..\Development\Src\MyMod\Classes\Main. uc : Error, Script vs. class name mismatch (Main/TriggerLight)
D:\UDK\UDK-2009-11\Binaries\..\Development\Src\MyMod\Classes\Main. uc : Error, Script vs. class name mismatch (Main/TriggerLight)
D:\UDK\UDK-2009-11\Development\Src\MyMod\Classes\TriggerLight.uc(1 4) : Error, Unrecognized type 'ELightType'
Compile aborted due to errors.

Anyone can help me to understand where i wrong? Thanks a lot.

Tano
11-10-2009, 03:32 PM
I fixed it by naming my file TriggerLight. But the compiler give me an error on: ELightType.. It can't recognize. Why? ò_ò

Taxxem
11-10-2009, 03:43 PM
I do not fully know Unrealscript yet but looking at your code you have:
var ELightType InitialType;

This appears to be exactly taken from the scriptreference page. ELightType is an enumeration. I do not have the code in front of me but you are extending to Light. So I would check to see where ELightType is created and see what the problem is. According to the document it comes from the Actor Script.

Also the example does say, "Note that this code may differ from that which appears in the current Unreal source, as this documentation is not synced with the code."

elmuerte
11-10-2009, 03:58 PM
the filename and class name must be the same, you file is named main.uc which is wrong