The online racing simulator
LFS Script System
(189 posts, started )
LFS Script System
Hello Programmers.

In the next test patch (U12) will be the first version of an LFS script system. These scripts are simple at the moment, just a list of /commands.

The idea right now is that anyone can build small scripts to reassign controller buttons, depending on the car selected. A common example : they may want the paddle shifters assigned to shift up and down when they drive a BF1, but their sequential shift stick ro be assigned to shift up and down when they get in a fox.

What I've done to make that possible :

- made the script system to run a sequence of commands in a text file
- added /axis, /btn and /key commands : e.g. /btn shift_up 5
- call a script called CAR.txt when you get in a CAR (CAR being XFG, XRG, etc...)
- allowed script files to call script files : e.g. FOX.txt contains a line /run sequential (which calls sequential.txt)

I think this system has potential to become quite powerful. There isn't anything in it specific to controllers. If in future there was a way to write small programs in LFS, this would be the basis of it (needing variables, conditional statements, jumps, pauses, etc). But I'm not doing that now. For now I just want to ask you if you can think of some "events" in the program that should call a script file. Just like the event of getting in a CAR calls the CAR.txt script.

To just make it clear what I mean, for example I could attach a script "entry.txt" which is called whenever LFS goes into the main entry screen. Another "start_race.txt" when the light goes green. Though I can't see any point in those, and probably won't implement them, they are just an example so you know what I'm talking about.

By the way, I've added a few extra commands for the scripts :

/echo X [ makes message X appear on local computer screen ]
/say Y [ makes message Y appear as if typed by the user ]
// this is a comment

I also plan to add a few more things like /fov and /g_shift_lateral - so people can use the CAR.txt files to automatically set up some other things for specific cars.

Another thought I had was perhaps I should give them an extension .lfs instead of .txt - although they are text files, and it wouldn't make any difference at the moment, these scripts might be useful in future with a file association, and they might become a cut down LFS programming language so it might then become annoying that we didn't call them .lfs in the first place.

Well, any comments are welcome. I plan to release the first version tomorrow, but could add any events or features to it that you might find useful.
Quote from Scawen :The idea right now is that anyone can build small scripts to reassign controller buttons, depending on the car selected.

I assume that includes total dumbasses

Great idea. Have a banana :banana:

What in LFS should trigger a script. What about a particular track, or possibly car/track combo. I.E. One config for BF1/KY Oval, 1 for BF1/SO1. Or possibly typing stuff in to the / console.
Well, anyone who wants to. It won't be very hard to do that shifter thing, specially as I'm providing "sequential.txt" "road.txt" and "paddle.txt" as default (but empty) though it is a bit "programmer-ish" and some people really don't like to edit lists of commands like /btn horn 8. But beginners would never need to use this. Some people who use LFS for a long time, start to wish they didn't need to change certain things each time they get in a car.
Quote from Scawen :Well, anyone who wants to. It won't be very hard to do that shifter thing, though it is a bit "programmer-ish" and some people really don't like to edit lists of commands. But beginners would never need to use this. Some people who use LFS for a long time, start to wish they didn't need to change certain things each time they get in a car.

So that basically means I can make my life easier for LFS sumo . Have another banana :banana:
/pit
/join
/spectate
/disconnect
/connect [IP]
/exit
/lights [on/off]
/sleep [ms]
/rightturnsignal [on/off]
/leftturnsignal [on/off]

All I can think of....
Quote from duke_toaster :What in LFS should trigger a script. What about a particular track, or possibly car/track combo. I.E. One config for BF1/KY Oval, 1 for BF1/SO1. Or possibly typing stuff in to the / console.

Well you can always run a script manually ( /run script_name ).
Post above: I should have thought of that

Quote from wheel4hummer :/pit
/join
/spectate
/disconnect
/connect [IP]
/exit
/lights [on/off]
/sleep [ms]
/rightturnsignal [on/off]
/leftturnsignal [on/off]

All I can think of....

What about

lyt (autocross layout)
hazards (hazard lights)
horn
skin (player changes skin to a specific skin)

Please could sleep be in seconds

EDIT:
otherdudejoins (or similar, when a particular person joins)
-
(thisnameistaken) DELETED by thisnameistaken
-
(Schooner) DELETED by Schooner
Quote from thisnameistaken :/end_race might be useful - so I can automatically switch my force-feedback off before some git ploughs into me at 3000mph+

Umm, I'm getting confused by your terminology.

Do you mean you would like a scipt "end_race.lfs" to be triggered when the local car ends a race? Not a command /end_race?

Same to wheel4hummer and duke_toaster. I don't think you are talking about new /commands?

I really don't want long lists of commands, I just want to tell me what you absolutely 100% really could do with. Because I will be here for ever coding for 1000 events otherwise.
Quote from Schooner :Just thinking that scripting will make it much harder for simple people, thinking of a way to automate it.

Well, I hope that I can do the scripting
#10 - Vain
We need a command to make one button cycle through a series of button presses. F.e. my lower left and right buttons on my momo trigger 7-0 and 8-0 cycles (for indicators) and one of my buttons triggers a F9-F10-F12-F12 cycle (press the button once, tyrestats come up, press it again, damage comes up, press it again, pitstrategy comes up, press it again, pit strategy goes away, press it again, tyrestats come up, etc). I did this via the Logitech profiler, but I believe your script-thingy wants to replace that.
You could do that by 'overloading' the /btn command so that:
/btn horn 8
works as it's supposed to do and
/btn horn lights indicateleft indicateright 8
makes 8 trigger a cycle of horn, lights, left indicators and right indicators.
(That is, if I understood the syntax of the command correctly).

Vain
Quote from Scawen :Same to wheel4hummer and duke_toaster. I don't think you are talking about new /commands?

I meant those events to trigger the .lfs scripts. Sorry for any confusion caused to anyone
Quote from Scawen :If in future there was a way to write small programs in LFS, this would be the basis of it

This would indeed be good, especially if it would be made to be able to fully control LFS, ie. it could be used to implement new rules for some totally different type of racing... However, I do wonder if creating a new "language" for it is really worth the effort as there are plenty of lightweight, free "scripting" languages that could easily be implemented as part of LFS and thus get a full featured language with minimal development time.
Quote from Scawen :/echo X [ makes message X appear on local computer screen ]

Yay!
Any possibility of a local version of /rcm? overridden by remote obviously.
Quote from Vain :/btn horn 8
(That is, if I understood the syntax of the command correctly).

Well, no...

/btn horn 8 will assign the horn to button 8 on your controller.

It's so for example you could make selecting a single seater, reassign button 8 to pit speed limiter, and selecting a road car assigns the horn to button 8.
#15 - Vain
Then I understood it right.

I want the line
/btn indicateleft noindicators 8
to assign controllerbutton 8 to a cycle-command so that upon the first buttonpress the left indicators start (like when we currently press "7"), upon the second buttonpress the indicators stop (like when we currently press "0") and upon the third time I press controllerbutton 8 the car starts indicating left again and so on.
By the way this makes
/btn horn 7
just a special case of the above cycle-command.

This is a really handy way of assigning multiple actions to one button. The button sequentially triggers the function of the cycle one after another with each time I press the assigned button. This works well for indicators and the F9-F10-F12-F12 cycle.

Vain
What just crossed my mind is this. Event could be the track sector number that local car is in (not necessarily splits, but those little sectors that track is made of) and that would trigger scrips (if the script with appropriate sector number exists) that set the brake balance (or anti roll bars, and other possible live settings) for different corners. For example SO Long has smoth braking zone for that first slow left corner, but other hard braking zones are much more bumpier and easier to lock the fronts.

I imagine this might be useful particulary for BF1 if it had more live settings like real thing has, so we could program differential settings and everything else for each corner separately.

Is this too crazy?
Quote from Misko :What just crossed my mind is this. Event could be the track sector number that local car is in (not necessarily splits, but those little sectors that track is made of) and that would trigger scrips (if the script with appropriate sector number exists) that set the brake balance (or anti roll bars, and other possible live settings) for different corners. For example SO Long has smoth braking zone for that first slow left corner, but other hard braking zones are much more bumpier and easier to lock the fronts.

I imagine this might be useful particulary for BF1 if it had more live settings like real thing has, so we could program differential settings and everything else for each corner separately.

Is this too crazy?

+1
/set_fule_start <percentage of full here>
/set_fule_pit <percentage of full here>
/get_laps <returns lap ammout>
/get_client_car <returns clients car> // BF1, FOX, FOX, ect.
/get_client_lap <returns clients lap>
/get_server_lap <returns the first place guys' lap number>

Also, an event that returns the track name would be nice, or a script that is fired on track name.

Here's want I'm thinking.

I getinto the FOX around BL1. I have a script that is called as soon as I get into the FOX that looks for the track that I am on and then sets the ammout of fule accordanly. Also it would be nice to get the lap ammout in the server. We could have dnyamic pit stops that you would only have to think about once! I thinnk you all know where I'm going with this.

switch( /cars )
{
case "FOX":
switch( /get_server_laps )
{
case 1 - 5:
/set_fule_start 10;
break;
case 6 - 10:
/set_fule_start 20;
break;
case 11 - 15:
/set_fule_start 30;
break;
case 16 - 20:
/set_fule_start 40;
break;
}
break;
case "FO8":
break;
case "BF1":
break;
}

Quote from Vain :By the way this makes
/btn horn 7
just a special case of the above cycle-command.

It doesn't really, because HORN is one of those buttons that continues to activate as long as the button is held down. So it's not an example of something that can be cycled (like F9 to F12).

I see what you mean though but in this batch of patches I won't be doing assigning of controller buttons to new functions that aren't currently assignable.
Quote from Scawen :Well, no...

/btn horn 8 will assign the horn to button 8 on your controller.

It's so for example you could make selecting a single seater, reassign button 8 to pit speed limiter, and selecting a road car assigns the horn to button 8.

You have cut a part out of Vains script. He suggests to overload the /button command a bit so you can make a button run different commands in a fixed order each time you press it. This could make a button run a F9 F10 F11 F12 F12 cycle.
Hmm, this is getting too complicated. The requests are going much too far.

The idea of this thread was really just to see if people had some ideas of events that occurred, that they wanted me to make run a script, using the current simple system (list of /commands in a text file) before tomorrow's version.

Or perhaps one or two new /commands that would be useful run from a script.

There's no time now for large requests, as I am still dealing with large lists of recent requests from the test patches (yes there were some relevant and good requests on those thread amongst the outrageous repetition and irrelevant suggestions as well).

I really just meant for anyone who wanted an event or /command added to the current simple system, to explain what they would be using for and in what situation, so I could understand it in context and that would inspire me to do the coding for it tomorrow. I can't divert to making a full language now, that was just a thing that might happen in the future.
-
(thisnameistaken) DELETED by thisnameistaken
-
(thisnameistaken) DELETED by thisnameistaken
#22 - SamH
Scawen, this sounds great. It's a fabulous way forward.

Re: the file extension, ".lfs" rather than ".txt" would be a healthy move, I think. Initially, I thought it would make things more difficult for more numpty LFSers - there are LFSers who are amazing drivers, and baffled by the concept of Windows Files and Folders, without having to think extensions too - but I think on reflection you should go for it.

You can rely on one of us, in no-time-flat, to produce a "dotLFSEditor", with a friendly GUI, which spits out fox.lfs files etc. I'd go as far as to say PLEASE don't worry about the GUI, let the community have a play! Ya know we wanna
Great feature!!

Now I don't have to change the shift buttons each time I change to a S-S I love it.

I can think of lots of events, but very few interesting things to do with them... InSim takes care of lots of things now...

BTW, a big -1 for the "automatic" live settings changing, sorry.
I like the idea of being able to tweak cars via these simple scripts. Makes a lot of sense and it's more flexible than having per car configs for the controls.

The one thing I would like to request that if there are new events created that are used to trigger the scripts, can the events also be sent to insim, so that insim could be used for these things as well? And will /echo make it out to insim?

Kegetys:
While having a built in scripting language in LFS would be cool, I think that could be more efficiently addressed by the community in creating an insim program that embeds python, lua or something similar. It would just pass the events onto the scripting engine and expos the lfs commands that can be issued as native scripting commands.
One event could be every time when car is put on track (in grid or pits). Unfortunately I have use for it...

LFS Script System
(189 posts, started )
FGED GREDG RDFGDR GSFDG