The online racing simulator
Scripting the custom view
(11 posts, started )
#1 - FL!P
Scripting the custom view
it would be really cool to have script commands to change the custom view's parameters, like X, Y and Z offsets, pitch, rotate, acceleration shifts viewpoint, etc. It would allow to script various custom views instead of the one per car we have now.

For example when I drive the BF1 in cockpit view, I find my point of view too low and in some corners the steering wheel and the driver's hand can hide the apex. So I use the custom view, with the same settings as the cockpit view but a bit higher. OTOH, when I watch replays I like to have the custom view set like the overhead onboard cam in F1 cars. If I made videos, I'd also use it to make "exotic" onboard cams, like behind the front wing, etc.

At the moment, obviously, there's only one custom view per car, so you have to change the settings by hand each time you want to change the view. If those parameters were scriptable, you could have all these cams defined in scripts and switch between them instantly.
Would this allow for the ability to save multiple custom cameras, and load them up at will sort of like a setup?

That would be very interesting. Having this on a per-car basis would be nice too.
#3 - FL!P
Yes, you'd load them by calling the script, either from the text input, a key equivalent, or a controller button. It doesn't mean you could save them, though. You'd have to write the script by hand (or to download it if someone else did).

You could make the scripts on a per-car basis, of course, but yes, it'd be great if prefixing their name with a car code — like BF1_overhead.lfs, FO8_overhead.lfs, FOX_overhead.lfs — allowed LFS to figure out which one to call based on the current car when you just run the "overhead" script.
Good idea. A great idea.

In the meantime could this work????? :

Make all your custom views in LFS for driving. Back-up all these files in the views folder (.cvw files) into a new subfolder. Then make all the custom views you want for each car, for your replay mode in LFS (as you said like the overhead onboard cams in F1)

Then Back up all those new views into another subfolder in the views folder.

So now you have copies of all the cars' driving views and all the cars' replay views in two speparate folders.

Then when you want to change the views from driving to replays... you can copy the backups from the subfolders back into the main LFS views folder, overwriting whatever is there. When you want to go back to driving, copy all the driving cams custom views back over the replay ones. Use the backup ones each time to make all the changes quickly. The backups are there so you never have to manually create them everytime in LFS using the user interface.

Perhapse after that you can create 2 batch files that will do this copying procedure for you. Can you run a batch file from inside lfs using /exec command?

If not then maybe a shortcut from your desktop, maybe you can make windows run the batch files with a certain Ctrl+Shift + Windows + KEY combination.

Yes a dirty way to do it. But it might work until you can do it all in LFS as you have asked.

You could make more folders for all the "exotic" cams as well.

Well I hope this helps in some way. If not feel free to tap me into a wall..
#5 - FL!P
Cool, I didn't know the views are saved in separate files, nor where. Thanks for the tip! I'll investigate the method you suggested (probably renaming the folders from a batch file rather than copying files, though).
Jason, you can run batch files with /exec from what I can remember.
Quote from dawesdust_12 :Jason, you can run batch files with /exec from what I can remember.

I couldnt figure out how a few weeks ago. But,yep, I just tried it again. You can, just remember that the current working directory is the LFS root directory. So to execute a batch file in the views folder for example, you must type "/exec data/views/batchfile.bat" or make a script file run this command.
#8 - FL!P
Thank you, guys. I'll try it and follow-up here with my findings.
#9 - FL!P
OK, I got it working, thanks to JasonJ's suggestion. Here's how, for those who'd be interested in doing it.

To use three different custom view sets named "driving", "onboard" and "exotic" (to keep my previous examples) with a single command that cycles between them:

1. Go to LFS\data and duplicate the views folder. Name the copy "views_onboard". Duplicate it again, and name the second copy "views_exotic".

2. Go to LFS's folder and create a text file named switchViews.bat (at the same level as the data folder).

3. Set the contents of this file to:

@echo off
setlocal

:: determine the current view
set flDriving=1
set flOnboard=1
set flExotic=1
if exist data\views_driving set flDriving=0
if exist data\views_onboard set flOnboard=0
if exist data\views_exotic set flExotic=0

:: make sure the folders are set as expected
if %flDriving%==0 if %flOnboard%==0 if %flExotic%==0 goto error1
if %flDriving%==1 if %flOnboard%==1 if %flExotic%==1 goto error2

:: do the switching
if %flDriving%==1 (
rename data\views views_driving
rename data\views_onboard views
goto end
)
if %flOnboard%==1 (
rename data\views views_onboard
rename data\views_exotic views
goto end
)
if %flExotic%==1 (
rename data\views views_exotic
rename data\views_driving views
goto end
)

:: report errors
:error1
echo Error: cannot determine the current view.
pause
goto end
:error2
echo Error: the required folders weren't found.
pause
goto end

:end
endlocal
exit

4. Save and close that file. Each time this script runs, it will rename the "views" folder into either "views_driving", "views_onboard" or "views_exotic", depending on the current set, and will rename into "views" the next of these three folders in the cycle. So calling the script the first time will switch from the driving set to the onboard one, the second time it will switch the set from onboard to exotic, the third time from exotic to driving, and so on. You can test it outside of LFS by double-clicking on it.

5. Launch LFS , go to Options > Game and set a key to run the script. For example set CTRL + F12 to /exec switchViews.bat.

Voilà, it's all set up. Since you didn't create a folder named "views_driving", this is the set which is currently active. Go to single player mode, and make sure the custom views of the cars you use are set in the driving position. When you're done, press CTRL + F12 to switch to the next views set (onboard).

Then, you just have to change the view (by pressing V or SHIFT + V) to switch to the new custom view if it wasn't active when you triggered the script, or if it was active, to switch to another view and back to the custom one to force it to load the new camera settings. Of course the first time the views won't be any different, since you just duplicated the original views folder. But now the active set is the onboard one, so go to Options > View and set your onboard camera. When you're done, run the script again, and set your "exotic" camera.

There's just a little problem: if you're running LFS in windowed mode, when you invoke the script you'll just see a Terminal window flashing briefly as the script is executed, and this is OK. But if you're in full screen mode, LFS will be minimized to the tasks bar and you'll have to click on it to restore it. It's not a big problem, because this isn't intended to be used while driving, but it seems to be a limitation of LFS. Not sure if it's a bug or a feature. If anyone knows a way to avoid it, please let me know.

I'd still like to be able to script the custom view, but in the meantime this is not too bad as workaround.
Thats pretty cool. I imagine if you make any in game changes to the custom views, the changes are saved and re-applied next time you cycle through them all. My initial idea was pretty clumsy and required alot of 'man-handling' of files. Wish I once learnt loops and crazy batch file stuff. Pretty cool. Great stuff.
#11 - FL!P
Quote from JasonJ :Thats pretty cool. I imagine if you make any in game changes to the custom views, the changes are saved and re-applied next time you cycle through them all.

Yes, they're saved in the current set, so with three sets you can have three different custom cams per car.

Quote from JasonJ :My initial idea was pretty clumsy and required alot of 'man-handling' of files. Wish I once learnt loops and crazy batch file stuff. Pretty cool. Great stuff.

Thank you! And your idea was a great starting point.

Scripting the custom view
(11 posts, started )
FGED GREDG RDFGDR GSFDG