Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Switch case issue
Claymix Offline
Junior Member

Posts: 4
Threads: 1
Joined: Jan 2019
Reputation: 0
#3
RE: Switch case issue

(01-15-2019, 01:59 PM)Mudbill Wrote: First off, I see this is a timer function. How are you calling it? Can you post the initial call to this function as well? Could it be calling the timer double at times?

The fEventSpeed variable should be set using floats instead of ints. When you set a float to a non-decimal number, it's actually set to an int and implicitly cast to a float. So fMyFloat = 5; is discouraged. Use fMyFloat = 5.0f; instead. This can help you avoid unexpected precision results.

The first time this function is called, DreamStep is set to 1, then it runs case 1 and breaks. After that, it adds a new timer which is meant to be 12 seconds, but due to the above, this might not be the case. Try printing out fEventSpeed before you call the timer.

PHP Code: (Select All)
if(GetLocalVarInt("DreamStep") < 5)
{
    AddDebugMessage("fEventSpeed = " fEventSpeedfalse);
    AddTimer("Dream1"fEventSpeed"Dream");


OH GOOD GRIEF. You're right. The timer is being called twice because I got cute with the code. I set up an if/else statement in the OnStart that checked if debug mode was on and if the player had the 1.3 Justine patch. From there, it called the "Dream" timer. But I also had a separate timer earlier in the OnStart that I had used originally to skip to a certain part of the cutscene. During testing, I changed this timer to "Dream" as well on accident so that there were two of them!


Anyway, I changed the ints to floats... good catch! I was lazy when I wrote the code.

Thanks a million, Mudbill. You're a life saver. I knew it was something stupid I'd done. Code can unforgivingly make you look like an idiot sometimes.  Rolleyes 

I'm glad that the community here is still active, considering I joined custom story creation late in the game!
01-15-2019, 09:44 PM
Find


Messages In This Thread
Switch case issue - by Claymix - 01-15-2019, 05:05 AM
RE: Switch case issue - by Mudbill - 01-15-2019, 01:59 PM
RE: Switch case issue - by Claymix - 01-15-2019, 09:44 PM
RE: Switch case issue - by Mudbill - 01-16-2019, 09:45 PM
RE: Switch case issue - by Claymix - 01-16-2019, 09:58 PM
RE: Switch case issue - by Mudbill - 01-17-2019, 06:20 PM
RE: Switch case issue - by Claymix - 01-17-2019, 06:26 PM



Users browsing this thread: 1 Guest(s)