For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Me don't understand TriggerLight

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
Skywolf
OldUnreal Member
Posts: 880
Joined: Sun Aug 02, 2009 12:20 pm

Me don't understand TriggerLight

Post by Skywolf »

So I was mapping around a bit and came to a point where a TriggerLight that would turn itself off after a short period of time would be very usefull. However TriggerPound seems to simply refuse to work. So decided to take a look at script and now I'm confused :D.

What on earth is the intended behavior of this thing? It seems to me that like half of the state's code can be removed without any negative consequences. Even then it still wouldn't work without a few modification but I assume that they didn't add half this stuff just for the lulz.

Original code:

Code: Select all

state() TriggerPound
{
      function Timer ()
      {
            if (poundTime >= RemainOnTime)
                  Disable ('Timer');
            poundTime += ChangeTime;
            Direction *= -1;
            SetTimer (ChangeTime, false);
      }
      function Trigger( actor Other, pawn EventInstigator )
      {
            if ( SavedTrigger!=None )
                  SavedTrigger.EndEvent();
            SavedTrigger = Other;
            SavedTrigger.BeginEvent();
            Direction = 1;
            poundTime = ChangeTime;                  // how much time will pass till reversal
            SetTimer (ChangeTime, false);            // wake up when it's time to reverse
            Enable   ('Timer');
            bStopTick=False;
      }
      function Reset()
      {
            SetTimer(0,false);
            Enable('Timer');
            Global.Reset();
      }
}
My code (left in everything that didn't break things just in case it actually does do something.):

Code: Select all

state() TriggerPound
{
      function Timer ()
      {
            Direction *= -1;
            bStopTick=False;
      }
      function Trigger( actor Other, pawn EventInstigator )
      {
            if ( SavedTrigger!=None )
                  SavedTrigger.EndEvent();
            SavedTrigger = Other;
            SavedTrigger.BeginEvent();
            if ( bInitiallyOn ) Direction = -1.0;
            else               Direction = 1.0;
            SetTimer (RemainOnTime, false);            // wake up when it's time to reverse
            Enable   ('Timer');
            bStopTick=False;
      }
      function Reset()
      {
            SetTimer(0,false);
            Enable('Timer');
            Global.Reset();
      }
}
Now the list of things I don't get: What are the SavedTrigger things supposed to do? And why is there a reset function when nothing even calls it? Does it even do anything usefull? And what's Enable ('Timer'); supposed to do after SetTimer? Isn't that something SetTimer does already?

Also, Why is Direction set in BeginPlay when every state already sets this by itself?


I hope My questions here aren't too stupid (they probably are though :-[) But can someone shed some light (pun intended) on what half this code is doing/supposed to do?
Last edited by Skywolf on Thu Nov 24, 2016 2:02 pm, edited 1 time in total.
I hate it when people ask me what my favorite game is. Just try to explain you're not talking about Unreal Tournament ::).
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Me don't understand TriggerLight

Post by Masterkent »

However TriggerPound seems to simply refuse to work.
Because the authors forgot to reset bStopTick in TriggerLight.TriggerPound.Timer:

Code: Select all

state() TriggerPound
{
      function Timer ()
      {
            if (poundTime >= RemainOnTime)
                  Disable ('Timer');
            poundTime += ChangeTime;
            Direction *= -1;
            SetTimer (ChangeTime, false);
            bStopTick = false; ///

Return to “UScript Board”