How to add console commands to the game?

Your forum for all discussions around Modding.
User avatar
АНТИКЛАН
Posts: 39
Joined: Tue Mar 27, 2018 1:26 am

How to add console commands to the game?

Post by АНТИКЛАН »

Hello everybody! :hi:
Can anyone describe how to add console commands to the game? Desirable detail on a simple example.
Thank you.
User avatar
Guil
Posts: 7414
Joined: Fri Aug 21, 2015 8:43 pm
Location: Ireland

Re: How to add console commands to the game?

Post by Guil »

Go to the folder that has your log.txt and open the game.xml with something like notepad++ and look for a line with development in it, change that and console from false to true and then save the file. Open the game and then tap the key beside 0 and over tab to get the console to appear.
User avatar
АНТИКЛАН
Posts: 39
Joined: Tue Mar 27, 2018 1:26 am

Re: How to add console commands to the game?

Post by АНТИКЛАН »

Guil wrote: Thu Mar 29, 2018 2:47 pm Go to the folder that has your log.txt and open the game.xml with something like notepad++ and look for a line with development in it, change that and console from false to true and then save the file. Open the game and then tap the key beside 0 and over tab to get the console to appear.
I know that. I need information how to create new console commands for the game.
juf.de
Posts: 3816
Joined: Fri Mar 30, 2012 8:04 pm

Re: How to add console commands to the game?

Post by juf.de »

There was a mod called "console extension" for FS15 and a really crappy conversion to FS 17, maybe those can help you get further.
Search for those, it's the best hint i can give you. Be aware though, the FS 17 version is probably on one of those not-so-trustworthy sites.
Tutorials: log.txt, Giants Bilderhoster, erweiterter Texteditor, Konsole (PC)    /    Direktlink Giants Imagehoster
[PC] [Mac] [XB1] [PS4] in the thread title keeps the Forum clean / im Threadtitel hält das Forum übersichtlich
Playing on PC
User avatar
АНТИКЛАН
Posts: 39
Joined: Tue Mar 27, 2018 1:26 am

Re: How to add console commands to the game?

Post by АНТИКЛАН »

juf.de wrote: Thu Mar 29, 2018 7:02 pm There was a mod called "console extension" for FS15 and a really crappy conversion to FS 17, maybe those can help you get further.
Search for those, it's the best hint i can give you. Be aware though, the FS 17 version is probably on one of those not-so-trustworthy sites.
This is a clue! I'll look. We will understand the incomprehensible moments here. :biggrin2:
User avatar
АНТИКЛАН
Posts: 39
Joined: Tue Mar 27, 2018 1:26 am

Re: How to add console commands to the game?

Post by АНТИКЛАН »

All perfectly! I figured out how to add my console commands to the game! And to facilitate the life of future generations of programmers under the Farming Simulator I will describe this process in detail.
So. To add your console command to the game, there is a special function with parameters (or procedure, I plainly did not understand yet):

Code: Select all

addConsoleCommand("command", "description", "function", object);
Where:

"Command" - text that will be entered in the console to call the function executing the command.
"Description" - the text that will be displayed when you call help on the command by type: help command.
"Function" - name of the called function executing the command.
"Object" - optional object called by the function (this is what Stefan Geiger writes on the GDN forum: "If you have a global or static function, that needs no "self" parameter, you can have nil as the 4th parameter"). I myself have not yet fully understood the fourth parameter. Who knows exactly correct me if I'm wrong. I will be grateful.

In the end, all the addition of the command to the game is as follows:

Code: Select all

addConsoleCommand("command", "description", "functionName", nil);

function functionName(parameter1, parameter2, ...)
  your code
end;
The parameters defined in the function are then read from the command you typed by the type: command parameter parameter, etc.
Thank you for helping everyone who helped me with advice in solving this problem.
I apologize for my Google English. I hope this is useful to someone. :wink3:
Last edited by АНТИКЛАН on Sat Mar 31, 2018 2:21 am, edited 4 times in total.
juf.de
Posts: 3816
Joined: Fri Mar 30, 2012 8:04 pm

Re: How to add console commands to the game?

Post by juf.de »

I'm glad to read, you made some progress here.

So we will see some more mods from your side :D
Tutorials: log.txt, Giants Bilderhoster, erweiterter Texteditor, Konsole (PC)    /    Direktlink Giants Imagehoster
[PC] [Mac] [XB1] [PS4] in the thread title keeps the Forum clean / im Threadtitel hält das Forum übersichtlich
Playing on PC
Post Reply