The online racing simulator
Goto method in Scripts
(15 posts, started )
Goto method in Scripts
Hi, first of all im not a very experienced programer at all, but i was thinking that maybe a GOTO method (like DOS Batch has) inside the scripting system would be very handy.

For example in the wiki, there are 3 script files + autoexec modification to do the Indicator Control (emergency lights not taken in account, making it 4 files)

With this new GOTO method it could be something like this:

-- autoexec.lfs --
/run indicators

-- indicators.lfs --
/button 1 ctrl_f10
/button 2 ctrl_f11
/button 3 ctrl_f12
/goto off

: left
/echo < < < <
/ctrlf 10 /press 0 /goto off

: right
/echo > > > >
/ctrlf 11 /press 0 /goto off

: emergency
/echo < < > >
/ctrlf 12 /press 0 /goto off

: off
/ctrlf 10 /press 7 /goto left
/ctrlf 11 /press 8 /goto right
/ctrlf 12 /press 9 /goto emergency

This would require only 1 script file + autoexec modification... what do you think?

EDITED: I forgot the buttons declarations, fixed
EDITED 2: Another example with the F9-F12 (from 5 scripts to 1)

-- autoexec.lfs --
/run f9-f12

-- f9-f12.lfs --
/button 1 crtl_f12
/goto off

: F9
/ctrlf 12 /press F10 /goto F10

: F10
/ctrlf 12 /press F11 /goto F11

: F11
/ctrlf 12 /press F12 /goto F12

: F12
/ctrlf 12 /press F12 /goto off

: off
/ctrlf 12 /press F9 /goto F9
#2 - STF
It would certainly be a nice addition in the future.
+1.
There should be a whole new scripting method, with functions, etc.
I am failing to see the advantage. If it means extra work for the devs just so we can have all scripts into one file, then I don't see the point.

But I am usually the minority in things.
Quote from zurdospeed :Hi, first of all im not a very experienced programer at all, but i was thinking that maybe a GOTO method (like DOS Batch has) inside the scripting system would be very handy.

Yeah. Experienced programmers never use goto.
i probably think it is a good idea...but ihave no idea what you are talking about....it is like reading chineese for me

if somebody can explin in simpler terms that would be great
It just says that when you press a button, go and read only a part of the script file, where the actions are different. Now instead, when you press a button it loads another script file with the different actions

Quote from geeman1 :Yeah. Experienced programmers never use goto.

Well, I know what classes, variables, methods, conditionals are but my point here was just giving a new basic functionality to the scripting system, not converting it into a Hi Level scripting language.
The /goto would do exactly the same as the /run command. I see no point in adding this.

Controllable options (one button look, fuel levels, etc) within scripts would be a way better improvement, in my opinion.
Well said.
Quote from NightEye :The /goto would do exactly the same as the /run command..

Not really. The goto could execute multiple commands, so it would let use use "functions" inside a script.

+1 for the idea
Quote from Whiskey :Not really. The goto could execute multiple commands, so it would let use use "functions" inside a script.

+1 for the idea

Put your "functions" into separate script files and /run is essentially a function call, except for the lack of parameters and a return value.
quick question, can you have lfs open up a few programs when you run it this might be script related
Yes by using the /start command I believe it is, I did not read the documentation but I know you can and it is documented!
please pm me with specific instrutcions, i am a noob on what to make the command with
There is a command, I have now looked it up. But I will not give a direct answer as to what the command is because in my previous post I mentioned it WAS IN THE DOCUMENTATION. Read the "Command.txt" for more information at what you can and can not do using the LFS Scripting System.

I told you right where to look, but I'm not going to "give" you the answer after asking a second time, sorry for the how harsh this sounds, its not my intended tone. But I do intend to make the point of I gave you a very specific answer. Minimal reading will prove helpful to you.

Goto method in Scripts
(15 posts, started )
FGED GREDG RDFGDR GSFDG