GetSecondsPassed

Post » Tue Mar 15, 2011 5:13 am

Hola,

I'm trying to setup a simple timer from a terminal.

When the player hits a terminal menu option, the timer should begin.

Once it's counted down from say, 5 seconds, it randomly changes a variable to a certain percentage.

IF the percentage is below 50%, then a message pops up.

Whatever I try, it just doesn't seem to popping up with any message.

It should at the very least be popping up with the debug message Ive set in the header of the script to notify me that at least 5 seconds have gone by.

short vortexencounterfloat timerbegin GameMode   if timer < 5      set timer to timer + GetSecondsPassed   else      set vortexencounter to getrandompercent      showMessage defaulttester      set timer to 5   endifif vortexencounter <= 50	ShowMessage AhaOneofThoseHERE				endifend


any ideas what I'm doing wrong? Appreciated :)
User avatar
Kaylee Campbell
 
Posts: 3463
Joined: Mon Mar 05, 2007 11:17 am

Post » Mon Mar 14, 2011 6:23 pm

Hmm. What is this script on? If its in the result block of the terminal, then theres your problem. THose scripts run just once so they're arent used for timers. Make a script and attach it to the terminal, give the terminal a ref ID (for examples sake I will use MyTerminalRef) then put this is the result script of the choice on the terminal.

Set MyTerminalRef.MyTimerVariable to 1


Then make this script to attach to the terminal object.

short vortexencountershort MyTimerVariablefloat timerbegin GameModeIf MytimerVariable == 1   if timer < 5      set timer to timer + GetSecondsPassed   else      set vortexencounter to getrandompercent      showMessage defaulttester      set timer to 5      set MyTimerVariable to 2   endifendifIf MyTimerVariable == 2   Set MyTimerVariable to 0   if vortexencounter >= 50	ShowMessage AhaOneofThoseHERE				endifendifend


This will now ONLY run when the variable is 1, and only show the message 1 time, then set the variable back to its default of 0. Also I made it if the percent is >= to 50, now <=. Since the percent ranges from 0-99 not 1-100, having it 50 or less makes it 51% chance to show it, and 49% chance not to. This way its 0-49 and 50-99, therefor 50/50 chance. Hope this helps you. :)

Gunmaster95
User avatar
Tikarma Vodicka-McPherson
 
Posts: 3426
Joined: Fri Feb 02, 2007 9:15 am

Post » Mon Mar 14, 2011 10:22 pm

Hmm. What is this script on? If its in the result block of the terminal, then theres your problem. THose scripts run just once so they're arent used for timers. Make a script and attach it to the terminal, give the terminal a ref ID (for examples sake I will use MyTerminalRef) then put this is the result script of the choice on the terminal.

Set MyTerminalRef.MyTimerVariable to 1


Then make this script to attach to the terminal object.

short vortexencountershort MyTimerVariablefloat timerbegin GameModeIf MytimerVariable == 1   if timer < 5      set timer to timer + GetSecondsPassed   else      set vortexencounter to getrandompercent      showMessage defaulttester      set timer to 5      set MyTimerVariable to 2   endifendifIf MyTimerVariable == 2   Set MyTimerVariable to 0   if vortexencounter >= 50	ShowMessage AhaOneofThoseHERE				endifendifend


This will now ONLY run when the variable is 1, and only show the message 1 time, then set the variable back to its default of 0. Also I made it if the percent is >= to 50, now <=. Since the percent ranges from 0-99 not 1-100, having it 50 or less makes it 51% chance to show it, and 49% chance not to. This way its 0-49 and 50-99, therefor 50/50 chance. Hope this helps you. :)

Gunmaster95


Bloody ingenius! An initialiser! *Slaps forehead* Doh! Thanks Gun :)
User avatar
Amy Siebenhaar
 
Posts: 3426
Joined: Fri Aug 10, 2007 1:51 am

Post » Mon Mar 14, 2011 7:49 pm

Bloody ingenius! An initialiser! *Slaps forehead* Doh! Thanks Gun :)


Mhm... I'm probably missing something obvious but the ruddy thing says it's an unknown variable its calling to. The terminal ID is exact as I copy/pasted aswell as the variable. Hmmm...
User avatar
Ashley Clifft
 
Posts: 3468
Joined: Thu Jul 26, 2007 5:56 am

Post » Mon Mar 14, 2011 2:22 pm

Time will not pass in a GameMode block of code when you are in a terminal menu.
User avatar
Facebook me
 
Posts: 3442
Joined: Wed Nov 08, 2006 8:05 am

Post » Mon Mar 14, 2011 5:59 pm

Time will not pass in a GameMode block of code when you are in a terminal menu.


yup, Gun pointed that out, Im just currently having a problem setting a reference as a result of a terminal choice.

I want to trigger the timer by setting a variable as the result which runs in gamemode on a script attached to the terminal, but everytime I go to compile, it tells me it wont have it.
User avatar
Patrick Gordon
 
Posts: 3366
Joined: Thu May 31, 2007 5:38 am

Post » Mon Mar 14, 2011 5:41 pm

No, Gunmaster pointed out that scripts in a result script only run once. I am pointing out that time does not pass when you are in a terminal using the GameMode block of code. You might have better luck with a MenuMode instead.

Perhaps if you tell us the error, we can help. Exactly what it says, and exactly the entire script you are putting on the terminal.
User avatar
Krista Belle Davis
 
Posts: 3405
Joined: Tue Aug 22, 2006 3:00 am

Post » Tue Mar 15, 2011 1:24 am

WillieSea is absolutely right, I assumed you wanted it to run once they exited the terminal, if you want the message to pop up while they are in the terminal use MenuMode instead of GameMode. Or else it wont do anything until you exit the terminal. Also change the line 'Set timer to 5' to 'set timer to 0' so its starts off from the start again, or else it will only work once. Also as to the variable, you must have the variable in the script ON the terminal, use the terminals reference ID instead of MyTeminalRef (unless thats what you made it) an make the terminal a persistant reference (which is probably what you did not do) then it should work. Let us know if it continues not to.
User avatar
Bird
 
Posts: 3492
Joined: Fri Nov 30, 2007 12:45 am

Post » Tue Mar 15, 2011 4:09 am

WillieSea is absolutely right, I assumed you wanted it to run once they exited the terminal, if you want the message to pop up while they are in the terminal use MenuMode instead of GameMode. Or else it wont do anything until you exit the terminal. Also change the line 'Set timer to 5' to 'set timer to 0' so its starts off from the start again, or else it will only work once. Also as to the variable, you must have the variable in the script ON the terminal, use the terminals reference ID instead of MyTeminalRef (unless thats what you made it) an make the terminal a persistant reference (which is probably what you did not do) then it should work. Let us know if it continues not to.


Everything you've said matches what I wanted, the script is to run when they leave the terminal and the script is on that terminal. The only thing I need to change is the set timer to 0, I see what I've done wrong there.

The terminal however is a submenu, so it isn't physically ingame, but the terminal it runs off is a persistent ref.
User avatar
ijohnnny
 
Posts: 3412
Joined: Sun Oct 22, 2006 12:15 am

Post » Mon Mar 14, 2011 9:14 pm

You need to use the ref of the terminal that you attached the script to, and make that terminal a persistant ref. If you put the script on the sub terminal, but are telling it to change the variable in the top level terminal, it wont work. Put the script on the top level terminal, that is physically ingame.
User avatar
Micah Judaeah
 
Posts: 3443
Joined: Tue Oct 24, 2006 6:22 pm

Post » Tue Mar 15, 2011 12:58 am

You need to use the ref of the terminal that you attached the script to, and make that terminal a persistant ref. If you put the script on the sub terminal, but are telling it to change the variable in the top level terminal, it wont work. Put the script on the top level terminal, that is physically ingame.


Gotcha, I'll try this and then get back to you :) Cheers bud.
User avatar
Jessica Nash
 
Posts: 3424
Joined: Tue Dec 19, 2006 10:18 pm


Return to Fallout 3