Discussion: Conditional statements in BF1942

Ask questions, discuss ideas, get answers
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Discussion: Conditional statements in BF1942

Post by Diamondback »

russ wrote:It returns a huge long stanza of text you'd need to parse to get the one line where it has a time. It just isn't doable.
Well, it was worth a try. Oh well :(
See my Strasbourg map project here.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Discussion: Conditional statements in BF1942

Post by Diamondback »

Some fun with conditional statements:

https://www.youtube.com/watch?v=ldCzG_g1SoQ
See my Strasbourg map project here.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Discussion: Conditional statements in BF1942

Post by Diamondback »

So I just discovered that there are some additional expressions that the console accepts:

1) exit. Typing the expression ''exit'' in your console will close your game and return you to your Desktop. Could be useful for certain things.
2) beginNoExecution and endNoExecution. I haven't been able to test what these to so far as the console spits out the "not allowed on highest level" problem. The good thing is that the game recognizes the commands. I imagine that these commands are identical in function to the beginRem/endRem expression, to render inactive certain lines of code.

This brings the list of statements (conditionals and other expressions) accepted by the console to the list below. Note that some of these statements were tested only with the Debugger, not the normal BF1942.exe.

alias
if/endIf
else
elseif
while/endWhile
return (stops the execution of the current script)
exit (quits the game to the desktop)
run
include
rem
beginRem/endRem
beginNoExecution/endNoExecution (no idea what that does, but the console recognizes it)

Conditional statements that I tested but that the console doesn't recognize (could be added with an EXE hack?):

for/endFor
when
break
case
See my Strasbourg map project here.
russ
Posts: 73
Joined: Sun Oct 29, 2017 8:12 am

Re: Discussion: Conditional statements in BF1942

Post by russ »

beginNoExecution/endNoExecution differs slightly from beginRem/endRem in that it still processes flow control statements.

You're missing unAlias, listAlias, quit (identical to exit), var (and related v_...), const (and related c_...) and echo.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Discussion: Conditional statements in BF1942

Post by Diamondback »

Thanks, I'll add them to the list above.
See my Strasbourg map project here.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Discussion: Conditional statements in BF1942

Post by Diamondback »

What would be the context of using the beginNoExecution/endNoExecution statements? Have you ever used it in a script somewhere?
See my Strasbourg map project here.
russ
Posts: 73
Joined: Sun Oct 29, 2017 8:12 am

Re: Discussion: Conditional statements in BF1942

Post by russ »

I haven't used it. You can use it across if statements which can be useful. If you use a beginrem/endrem across an if statement it breaks the flow control.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Discussion: Conditional statements in BF1942

Post by Diamondback »

russ wrote:It returns a huge long stanza of text you'd need to parse to get the one line where it has a time. It just isn't doable.
As I've just discovered, the output of consoleProfiler.report doesn't seem to return that long of a text if you assign the correct command to a variable and print the output using game.sayAll. Surprisingly, using a few basic variable assignments I was able to return the one line that I am interested in, that is the line which returns the number of frames and the elapsed time, in seconds. The rest of the text from consoleProfiler.report isn't returned, surprisingly enough.

Image

Image

Using the Debugger, one would at first enable the consoleProfiler class of commands by typing "consoleProfiler.enable 1".
Once that's done, we type "consoleProfiler.stopGlobalTimer" in the console. This starts our global timer.

To end the global timer, we type "consoleProfiler.stopGlobalTimer". The elapsed time between when we typed the previous command (startGlobalTimer) and when we typed the current command (stopGlobalTimer) is what is interesting to us. That elapsed time is saved by the "consoleProfiler.report" command, which we then type. Doing so returns a long list of integers such as the number of frames, FPS and the number of seconds elapsed between startGlobalTimer and stopGlobalTimer. This last parameter is what we want.

To get a summary of the long text returned by the report command, we can create a new variable, say var v_report, and assign it to the report command, like this: consoleProfiler.report -> v_report. Then, to see the summarized text (number of frames + elapsed time, in seconds), we could type in console: game.sayAll v_report. This will return the information we want (number of frames and the elapsed time), as you can see in the two images above.

As mentionned I haven't tested this outside of the Debugger, so I do not know if it works in online games. It probably doesn't, but this could be useful for players that want to find a way to keep track of the elapsed time, and possibly (and this is where all the fun is), create custom scripts to trigger events depending on the elapsed time.
See my Strasbourg map project here.
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Discussion: Conditional statements in BF1942

Post by Diamondback »

A problem I am running is the "consoleProfiler.startTimer/stopTimer" pair of commands. The first command takes a string as an argument and returns a uint (an positive integer). The second takes the same uint argument the first command takes, and returns nothing (void). I imagine that the uint parameter is the "timerID", which the Debugger complains about here (and not the elapsed time in seconds, which I always thought it was):

Image

I created a Timer object called "TimerTest", which I assign to the consoleProfiler.startTimer command as the string argument (objectTemplate.create Timer TimerTest), so it looks like this:

consoleProfiler.startTimer TimerTest.

The console seems to accept the command without any issue. But then, when I type consoleProfiler.stopTimer with a random integer, it gives me an error (as expected, because the value that I entered as an argument for that command surely isn't the same as the timerID). How do I find out what the timerID of the Timer object I have created is? object.info, object.list and objectTemplate.info don't seem to help at all. I also think it is probably not necessary to create a Timer class of object with objectTemplate.create (since these types of objects only work in the Objective GPM). Not really sure what to do here. Will keep experimenting.
See my Strasbourg map project here.
Post Reply