Timing Issues

Post » Tue May 17, 2011 2:09 am

You know, you guys that have successfully made Fallout 3 mods have my undying admiration. I've been a computer programmer since 1995 and it baffles to me to no end as to why things do or do not work; it's almost like a random occurence as to whether a line I type is going to function the way I expect it to.

I'm stuck yet again, this time with a timer that I've set within a Begin GameMode block. The first timer was copied from FWE Triage section so I could have a menu within the Player inventory; it is working correctly, my menu is displayed and I'm allowed to select an item from it. The menu allows the Player to select a time frame: 1 to 3, 4 to 6, 7 to 9, 10 to 12 and 13 hours; this also works the way I want it to and one of those sections is listed below. The problem comes in the section of code after that.

I save off the current TimeScale as I've read here on the forum, I enter my BeginProst == 3 section, time speeds up and the screen blacks out, and that's it. The screen stays black, which confuses me because I thought FadeToBlackISFX was set to fade out then in. Also, time does not ever go back to normal. I've tried numerous things but nothing ever works; sometimes I can get the screen fading to come back, but the time never slows down. What am I doing wrong?

Thank you in advance for your time and energy!
Rig

Begin GameMode    if Timer > 0        set Timer to Timer - GetSecondsPassed    else        if BeginProst == 1            ShowMessage yapmMenu            set BeginProst to 2        endif    endif    if BeginProst == 2        set ButtonX to GetButtonPressed        if ButtonX == 0            set BeginProst to 3            set ButtonX to -1            set numHours to 1 + GetRandomPercent * (3 - 1) / 99            set SleepTimer to 5        elseif ButtonX == 1            .            .            .        endif        set myTime to TimeScale    endif    if BeginProst == 3        set iCharisma to Player.GetActorValue Charisma        ;I want the time to fly within a 5 second period; perhaps that's my problem        set TimeScale to (360 * numHours * 2)        ;Advance time        imod FadeToBlackISFX        ;SetPCSleepHours seems to crash the game on a random basis.        ;SetPCSleepHours numHours        if SleepTimer >= 0            set SleepTimer to SleepTimer - GetSecondsPassed        else            ;Done advancing time            set TimeScale to myTime            set BeginProst to 4        endif    endif

User avatar
Naughty not Nice
 
Posts: 3527
Joined: Sat Nov 04, 2006 6:14 am

Post » Tue May 17, 2011 2:22 pm

I don't imagine setting the timescale that high makes the game happy, it's probably got something to do with that. And FadeToBlackISFX does go back to normal, the whole fade should take 4 seconds.
User avatar
Genevieve
 
Posts: 3424
Joined: Sun Aug 13, 2006 4:22 pm

Post » Tue May 17, 2011 10:09 am

Thanks!

Do you know if that's true about too high of a number in TimeScale? I was unable to find any kind of reference to a max limit to that.

So, what is preventing my code from resetting the TimeScale to what the Player's original value was?

Good that FadeToBlackISFX works the way I thought. What would prevent that from coming back from black?

Is there some way to just drop to black, period and then I can use rimod to set it back to normal? Is there some entirely different way that I should do this? Should I perhaps, take up a new hobby completely like knitting because obviously I'm not cut out for this? :)

Rig
User avatar
T. tacks Rims
 
Posts: 3447
Joined: Wed Oct 10, 2007 10:35 am

Post » Tue May 17, 2011 1:29 am

Hardcode the timescale to a much lower number, like 120. If the rest of the script now works, then its the timescale to high that is the problem.

There are other shaders that probably 'go to black' and stay there. Try the others out and see.

Hobbies are for fun. If you don't enjoy it, then don't do it. All hobbies have a learning curve and have their share of problems. :shrug:
User avatar
Julie Ann
 
Posts: 3383
Joined: Thu Aug 23, 2007 5:17 am

Post » Tue May 17, 2011 8:39 am

Hobbies are for fun. If you don't enjoy it, then don't do it. All hobbies have a learning curve and have their share of problems. :shrug:

:) Yeah, I know. Thanks.

No, it doesn't seem to be the TimeScale number; I set it to 120 and it still fades to black, speeds up and never returns to normal. It's got to be something so fundemental that I'm doing wrong that all you people just assume I know what I'm doing.

So, the gist is that I simply want X amount of time to pass. SetPCSleepHours seems to crash the game to desktop on a somewhat random basis. I'm unsure if this is because the save file I'm using to test it out is unformatted in some way, my mod has some random element that is causing this to occur or it's simply a bug in SetPCSleepHours (which, really, I seriously doubt; no one else seems to have any trouble with it.) I've tried creating a completely new game and the error still occurs, so I'm figuring it has to be my mod.

Is there any other way to make time advance? Neither of the two methods that I've read on the board here are working, and I haven't the slightest idea why.

Rig
User avatar
katsomaya Sanchez
 
Posts: 3368
Joined: Tue Jun 13, 2006 5:03 am

Post » Tue May 17, 2011 10:20 am

It may also be a part of your script that you did not post.

It sounds to me like the time is 'constatnly' being set and advanced, over and over again, and the same with the shader, constantly being called. So it seems to 'never' end.

Put a message box in there where you set the timer, and see if it comes up more than once. And make it a pop-up box with an okay to make sure catch them all.
User avatar
Riky Carrasco
 
Posts: 3429
Joined: Tue Nov 06, 2007 12:17 am

Post » Tue May 17, 2011 10:09 am

It may also be a part of your script that you did not post.

It sounds to me like the time is 'constatnly' being set and advanced, over and over again, and the same with the shader, constantly being called. So it seems to 'never' end.

Put a message box in there where you set the timer, and see if it comes up more than once. And make it a pop-up box with an okay to make sure catch them all.

Awesome, I did that between my last post and yours and sure enough, it was continuously popping up. Now I just have to figure out how to rewrite it so it won't do that.

Thanks for your help
Rig
User avatar
Jessica Thomson
 
Posts: 3337
Joined: Fri Jul 21, 2006 5:10 am

Post » Tue May 17, 2011 3:25 am

Nope, I still can't get it to work. It seems to be crashing at the imod call because it never goes black before dying. It ran correctly the very first time I tested it, when the numHours was 1.

Here is the entire script; an object script on an item in the Player inventory identical to the Triage Menu from FWE.

If anybody has any ideas I would greatly appreciate them.

Rig

scn yapmMenuItemScriptshort BeginProstshort ButtonXshort iProbshort numHoursshort rndNumfloat Timershort DoOncebegin OnEquip Player    ;Can't do this in combat, be serious    if Player.IsInCombat == 1        set Timer to 0.6        set BeginProst to 0        set iProb to 0        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmInCombatMsg    elseif (Player.GetInZone MerestiMetro == 1) || (Player.GetInZone OasisZone == 1) || (Player.GetInZone RepDaveZone == 1)        set Timer to 0.6        set BeginProst to 1        set iProb to 1        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmClosePipBoyMsg    elseif (Player.GetInZone MegatonZone == 1) || (Player.GetInZone BigTownZone == 1) || (Player.GetInZone CitadelZone ==  1) || (Player.GetInZone TempleOftheUnionZone == 1) || (Player.GetInZone  TenpennyTowerZone == 1)        set Timer to 0.6        set BeginProst to 1        set iProb to 2        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmClosePipBoyMsg    elseif (Player.GetInZone ParadiseFallsZone ==  1) || (Player.GetInZone DLC01PittZone == 1)        set Timer to 0.6        set BeginProst to 1        set iProb to 3        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmClosePipBoyMsg    elseif Player.GetInZone WastelandZone == 1        set Timer to 0.6        set BeginProst to 0        set iProb to 0        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmWastelandMsg    elseif (Player.GetInZone AbandonedSewer == 1) || (Player.GetInZone FloodedSewer == 1) || (Player.GetInZone  IrradiatedSewer == 1) || (Player.GetInZone TepidSewer == 1) || (Player.GetInZone yFreedomStreetSewers == 1) ||  (Player.GetInZone yInfestedSewer == 1)        set Timer to 0.6        set BeginProst to 0        set iProb to 0        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmSewerMsg    elseif (Player.GetInZone DLC02AnchorageBattleZone) || (Player.GetInZone DLC02VSSZone)        set Timer to 0.6        set BeginProst to 0        set iProb to 0        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmAnchorageMsg    elseif (Player.GetInZone DLC05EngineCoreZone) || (Player.GetInZone DLC05WasteDisposal) || (Player.GetInZone  DLC05ZetaZone)        set Timer to 0.6        set BeginProst to 0        set iProb to 0        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmZetaMsg    else        set Timer to 0.6        set BeginProst to 0        set iProb to 0        Player.UnequipItem yapmMenuItem 0 1        ShowMessage yapmNotAllowedMsg    endifendbegin GameMode    if Timer > 0        set Timer to Timer - GetSecondsPassed    else        if BeginProst == 1            ShowMessage yapmMenu            set BeginProst to 2        endif    endif    if BeginProst == 2        set ButtonX to GetButtonPressed        if ButtonX == 0            set BeginProst to 3            set DoOnce to 0            set ButtonX to -1            set numHours to 1 + GetRandomPercent * (3 - 1) / 99        elseif ButtonX == 1            set BeginProst to 3            set DoOnce to 0            set ButtonX to -1            set numHours to 4 + GetRandomPercent * (6 - 4) / 99        elseif ButtonX == 2            set BeginProst to 3            set DoOnce to 0            set ButtonX to -1            set numHours to 7 + GetRandomPercent * (9 - 7) / 99        elseif ButtonX == 3            set BeginProst to 3            set DoOnce to 0            set ButtonX to -1            set numHours to 10 + GetRandomPercent * (12 - 10) / 99        elseif ButtonX == 4            set BeginProst to 3            set DoOnce to 0            set ButtonX to -1            ShowMessage yapmStaminaMsg            set numHours to 13        elseif ButtonX == 5            set BeginProst to 3            set DoOnce to 0            set ButtonX to -1            set numHours to 0            Return        endif    endif    if BeginProst == 3        if DoOnce == 0            set DoOnce to 1            imod FadeToBlackISFX            SetPCSleepHours numHours        endif    endifend

User avatar
Prohibited
 
Posts: 3293
Joined: Tue Jun 12, 2007 6:13 am

Post » Tue May 17, 2011 10:28 am

I've been a computer programmer since 1995 and it baffles to me to no end as to why things do or do not work; it's almost like a random occurence as to whether a line I type is going to function the way I expect it to.


I got nothing constructive to add, other than saying I feel your pain :) I am a Unix engineer and do a lot of shell scripting and coded C in the past, and the scripting language in this game definitely does not behave like you'd expect in C or unix shells, especially the timing thing.
User avatar
Auguste Bartholdi
 
Posts: 3521
Joined: Tue Jun 13, 2006 11:20 am

Post » Tue May 17, 2011 9:56 am

I got nothing constructive to add, other than saying I feel your pain :) I am a Unix engineer and do a lot of shell scripting and coded C in the past, and the scripting language in this game definitely does not behave like you'd expect in C or unix shells, especially the timing thing.

Maybe not constructive, but it did make me feel much better, at least I know I'm not the only one. The experienced modders make this look so effortless. :)

Rig
User avatar
Marie
 
Posts: 3405
Joined: Thu Jun 29, 2006 12:05 am

Post » Tue May 17, 2011 5:27 am

Hmmm interesting script. I recommend the following troubleshooting procedure:

1. At the bottom of your script, change the code to:

    if BeginProst == 3        if DoOnce == 0            set DoOnce to 1            ; imod FadeToBlackISFX            ; SetPCSleepHours numHours            printc "numHours set to: %x" numHours        endif    endif


This will run the code without doing the imod or setting the PCSleep hours, but will tell you in the console what numHours is set to (perhaps you are setting it to an illegal value, which you would never see because it crashes). If the number seems sound, leave the imod line commented but try the sleeping line (to see if your imod has issues). If not, reverse and comment the SetPCSleepHours and let the imod through to see if the force-sleep is the issue.

Luck!

Miax
User avatar
Sammie LM
 
Posts: 3424
Joined: Thu Nov 30, 2006 1:59 pm

Post » Tue May 17, 2011 9:01 am

Hmmm interesting script.

:) Interesting how? Non-standard? Is there a better way to do something like this?

Anyway, it is definitely the SetPCSleepHours; no matter what numHours is set to it crashes the game. I tried this, but it won't set the time faster for any longer than 15 or so game minutes; i.e. in my test game it is 8:14 and at the apparent end of the routine when I selected ButtonX == 4, it is 8:30. I test this by repeatedly hitting the T key to see what time it is, and time stops going faster at 8:30.

Rig

if BeginProst == 3    if DoOnce == 0        set DoOnce to 1        ;imod FadeToBlackISFX        ;SetPCSleepHours numHours        set oldTimeScale to TimeScale        set TimeScale to 360        set SleepTimer to numHours * 10               endif    if SleepTimer > 0        set SleepTimer to SleepTimer - GetSecondsPassed    else        set TimeScale to oldTimeScale    endifendif

User avatar
Vincent Joe
 
Posts: 3370
Joined: Wed Sep 26, 2007 1:13 pm

Post » Tue May 17, 2011 7:36 am

:) Interesting how? Non-standard? Is there a better way to do something like this?
....    if SleepTimer > 0....


Wow, I'm not sure how I missed that one. :blush2: Let's see if it works now.

Rig
User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm

Post » Tue May 17, 2011 1:11 pm

I'm sorry to keep going on about this, but I can't figure out why it isn't doing what I expect. Maybe I just don't understand the math involved.
    if BeginProst == 3        if DoOnce == 0            set DoOnce to 1            ;imod FadeToBlackISFX            ;SetPCSleepHours numHours            set oldTimeScale to TimeScale            set TimeScale to numHours * 360printc "TimeScale is: %g" TimeScale            set SleepTimer to 5         endif        if SleepTimer > 0            set SleepTimer to SleepTimer - GetSecondsPassedprintc "SleepTimer: %g" SleepTimer        else            set TimeScale to oldTimeScale        endif    endif


So, when I tested this, TimeScale was 2880. 2880 / 360 = 8, so that was numHours. 2880 / 60 = 48, so since TimeScale is X Game Minutes = 1 Real Minutes, that means to me that for every real second, 48 minutes should pass in the game. The SleepTimer appeared to successfully count down to 0, so that means 48 * 5 = 240 / 60 = 4 means 4 hours should have passed in the game. But it didn't, only 4 minutes passed.

Quite obviously I have some multiplier completely off, but I cannot get my head around what I'm missing.

Thank you for your time and patience, :)

Rig

PS: Oh, and I can't thank you enough for showing me printc. This type of command is what I'm used to using at work, so much better than ShowMessage!
User avatar
Conor Byrne
 
Posts: 3411
Joined: Wed Jul 11, 2007 3:37 pm


Return to Fallout 3

cron