[GUIDE]How to make mods for MySummerCar?

NOTE: This is a work in progress please let me know if anything is wrong, something feels like its missing or you have any questions.
NOTE: Some of the code/snippets have been written on the fly and has not been tested. Some may be faulty but please notify if they are and I will correct it!
NOTE: If you have any questions, need help or perhaps are thinking about something NOT covered in this thread PLEASE POST YOUR "OFF TOPIC" QUESTION IN THIS THREAD:
http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/

Skip to actual guide!
Scoll down to the headline "So where should I start?" and begin there!

What will I cover?
I will cover where to start in order to start making mods.
I will provide some very helpful snippets of code.
I will provide useful links and a FAQ.

Why are you doing this?
When I got introduced to the game and my friend showed me the mods I thought it would be fun trying to make one myself but that was not as easy as I thought.
(I NEVER inteded to ever release the mod I created either... but it became too good lol)
With a bit if research I managed to find MSCLoader Wiki and that got me started and setup.
Once everything was setup and working I started by creating a mod-project using the template provided by @piotrulos (The creator of the MSCLoader and forever a legend) and here is where I ended up stuck.
If I wanted to make some changes to an object in the game... How would I proceed?
If I wanted to make some changes to information in-game... How would I proceed?
This is where I ended up researching further and how I ended up finding the new thread created just 30 minutes earlier.
This thread is where I ended up being active in for a while when I was getting around and learning the process of making mods. (This is my first time ever...)
You can find this thread here: http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/

... and this is why I'm creating this guide, simple as that :)

(This part bellow is optional)
My initial instinct was to create a plugin that would make a list of all gameobjects in the current scene (World)... that way I knew what I could work with..
MySummerCar SceneObjects SourceCode: https://pastebin.com/pVqttvzH
MySummerCar Scene Objects list: https://pastebin.com/tkXq5mYd (Version: Dec 2017, this has changed!)

This was however, very, unnecessary since @zamp has created, litteraly, the ultimate developer toolkit for modding!

Also, after this I started PM conversations with @kunedo who has been very helpful with Ideas... hes just a really friendly and amazing guy all around helping etc. Thanks, really!

So where should I start?
First
, you will need an IDE; Visual Studio.
You can find it here: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15

Secondly, you should start with finding the MSCLoader Wiki and start setting up your environment. Read through and learn how to use the MSCLoader:
You can find MSCLoader Wiki here:
https://github.com/piotrulos/MSCModLoader/wiki

NOTE: You may download either x86 or x64 bit version of Unity and reading both for player and developer is very useful.

Third, start by downloading and "installing" the "Developer Toolkit" so you can easily find and quickly modify gameobjects in the world.
Saves a lot of time not having to make changes, build and restart the game every time you try a new set of code for example in placing or re-placing gameobject in the world.
You can find Developer Toolkit here:
http://www.racedepartment.com/downloads/plugin-developer-toolkit.17214/

NOTE: Some Objects/Components also needs referenses to Assembly-CSharp.dll file.
("Steam\steamapps\common\My Summer Car\mysummercar_Data\Managed\Assembly-CSharp.dll")
Drivetrain, for example, does need this reference to work properly.
Thanks to @tommojphillips for finding this!

How can I make changes in-game?
This is fairly easy and basic kowledge. MySummerCar is created using Unity® software and that opens up a whole lot of methods, classes and libraries we can use.
Transforms, for example, is used to store an objects position, rotation, scale and parenting state.
MySummerCar is also using an asset called PlayMaker which makes it a whole lot harder at the same time. Depending on your goal ofcourse.

First, if you would like to make changes to example the car, Satsuma for example...
We need to create a variable/reference name:
Code:
GameObject satsuma; // Making a variable
Right now the reference is empty and we need to give it a reference to the object in the game..
Give it a reference/value:
Code:
satsuma = GameObject.Find("SATSUMA(557kg, 248)"); // Giving our variable a reference/value
Now the reference is set and we can access for example the transforms of the object to move or make changes. We can also activate/deactivate the object in the world. Now that we know how to access an object... How can I make changes to the information in the game?
This part is a bit tricky.. You need to find out which GameObject in the scene is "hosting" the component which makes these changes in order to change them... Unless they are maintained by a singleton instance. If they are maintained by singleton and are instanced they can, globally, be read or changed without the need of the "hosting" object.

Making changes to a component/variable:
Code:
satsumaDriveTrain = GameObject.Find("SATSUMA(557kg, 248)").GetComponent<Drivetrain>();
This means that you are getting the component "DriveTrain" on the Object "SATSUMA(557kg, 248)" and you may make changes or read values/variables from that component.

If it is a singleton variable or information you are looking for you may use a foreach method to get what you want to find:
Making a foreach for PlayMaker FSM:
Code:
// FloatVariables can be BoolVariables, StringVariables, GameObjectVariables, ObjectVariables, MaterialVariables and IntVariables
foreach (var flt in PlayMakerGlobals.Instance.Variables.FloatVariables)
{
    switch (flt.Name)
    {
        case "PlayerCurrentVehicle": // This is not a float
            _carCurrent = flt.Value.ToString();
            break;
        case "PlayerFatigue":
            _fatigue = flt;
            break;
        case "PlayerThirst":
            _thirst = flt;
            break;
        case "PlayerHunger":
            _hunger = flt;
            break;
        case "PlayerStress":
            _stress = flt;
            break;
    }
}

How do I detect if a player is in vehicle/car/"drive mode"?
Taking a look back to our code earlier we can use the PlayMaker FSM here and check if player is in any vehicle.
Code:
if (FsmVariables.GlobalVariables.FindFsmString("PlayerCurrentVehicle").Value != "")
{
    //Player is in drive mode
}

How do I use custom assets?
Code:
//Define objects
AssetBundle assets;
GameObject turbo;

//Onload.. We load, initialize and give references.
assets = LoadAssets.LoadBundle(this, "turbo.unity3d"); // Load this asset
turbo = assets.LoadAsset("turbo_prefab.prefab") as GameObject; //get specific prefab
assets.Unload(false); //Unload once all prefabs has been gathered to clean memory

//Placement
turbo = GameObject.Instantiate(turbo); //Instantiate object in the world
// OPTIONAL: turbo.transform.SetParent(GameObject.Find("satsu").transform, false); // We can set it as child object

//We set pos, rot & scale | Be aware, there are localPosition and Position. Choose relative to the use.
turbo.transform.localPosition = new Vector3(0.3f, 0.16f, 1.02f);
turbo.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
turbo.transform.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);

(I cant find the player!)
How do I find player?
@piotrulos stated in an early comment/reply that:
In 0.4 OnLoad will be called after game is fully loaded.
When OnLoad is called you can simply use this code:
Code:
GameObject player = GameObject.Find("PLAYER"); // Simple as this

OLD TUTORIAL; MSCLoader <= 0.3.5;
Finding the player is a bit tricky compared to finding another object in the world since it is "spawing" rather late.
Once OnLoad has finished running in your mod it has most likely not spawned yet and will result in a nullreference exception.
How do we make this work?
There are multiple options but I'm going to show you two:
Code:
//First option is the Coroutine method:

void Something()
{
   //Start coroutine
  StartCoroutine(setup());
}

IEnumerator setup()
{
   yield return new WaitForSeconds(15f); // Wait for something 15 sec
   ModConsole.Print("Success!");
}

Code:
//Second option is the update method:

public override void Update()
{
    //Loops untill player has spawned. May cause some lagg...
    if((GameObject)player == null)
        player = GameObject.Find("PLAYER");

    //Wrap other codes inside this container
    if(player != null)
    {
    //Run mod...
    }
}

**Threading removed**

Good luck and have fun!

Annoyances (and tips) of building mods:

When you are making mods you'll be, eventually, annoyed by three (major) things...
1: As a developer you need to manually copy the mod to the mod folder every time you makes changes/build the mod.
But that can be fixed by using this piece of code:
Code:
copy /Y "$(TargetDir)$(TargetName).dll" "C:\Users\YOURUSERNAME\Documents\MySummerCar\Mods"
It's basicly a "batch"/CMD command to copy the mod dll file to the location of your MSC mod folder.
How do I do that?
aaf95f2caf42619f48dcaefb508a5bb6.png

A: Right-click -> Properties
B: Find the tab "Build Events"
C: Find "Post-Build Event Command line" textarea and modify/copy the code above for everything you want to move with the build on each seperate lines.
D: Save.
E: Build and Enjoy!

2: You will need to restart the game a lot in order to test out the mod and check it out. (There, currently, isn't a way around this atm)
3: Bad reviews.
You may get bad reviews from users who doesn't "install" the mod correct, haven't bought the actual game and is playing on pirate copies etc.
My advice.. Brush it off and don't bother. If you enjoy creating, create and if you get a bad review or someone is being mean, ignore them and continue with your work.

My experiences and mods:
My experience has been great, No dubt. BUT lately i must admit that my interests have turned and I have been forced to focus on diffrent things. Work as an example has been very hectic.
I caught a break now and I wanted to help out the community :)

MySummerMultiMod: http://www.racedepartment.com/downloads/mysummermultimod.19405/

Useful links:
MSCLoader Wiki : https://github.com/piotrulos/MSCModLoader/wiki
PlayMakerFSM : All PlayMaker FSM
@zamp : https://github.com/zamp/MSC-Mods
@Roman266 : https://github.com/GishaSeven/Plugins-for-MSC-ModLoader
@tommojphillips : 2 Links below.
ModAPI: https://github.com/tommojphillips/ModAPI/wiki
Demo: https://github.com/tommojphillips/AttachObjectDemo

Special thanks to everyone who has provided information or helped with some outdated information!

Good nite everyone :sleep:
 
Last edited:
(Im New To Modding So Forgive My Stupidity) How Do i Get The Object I Made to show Up In the game?

First you must create the asset-bundle using the correct version of unity. How you do this can be found on MSCLoader wiki, which is referenced in the post.

Once the bundle is created, check out the section "How do I use custom assets?".

Good luck.
 
[GUIDE]How to make mods for MySummerCar?

NOTE: This is a work in progress please let me know if anything is wrong, something feels like its missing or you have any questions.
NOTE: Some of the code/snippets have been written on the fly and has not been tested. Some may be faulty but please notify if they are and I will correct it!
NOTE: If you have any questions, need help or perhaps are thinking about something NOT covered in this thread PLEASE POST YOUR "OFF TOPIC" QUESTION IN THIS THREAD:
http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/

Skip to actual guide!
Scoll down to the headline "So where should I start?" and begin there!

What will I cover?
I will cover where to start in order to start making mods.
I will provide some very helpful snippets of code.
I will provide useful links and a FAQ.

Why are you doing this?
When I got introduced to the game and my friend showed me the mods I thought it would be fun trying to make one myself but that was not as easy as I thought.
(I NEVER inteded to ever release the mod I created either... but it became too good lol)
With a bit if research I managed to find MSCLoader Wiki and that got me started and setup.
Once everything was setup and working I started by creating a mod-project using the template provided by @piotrulos (The creator of the MSCLoader and forever a legend) and here is where I ended up stuck.
If I wanted to make some changes to an object in the game... How would I proceed?
If I wanted to make some changes to information in-game... How would I proceed?
This is where I ended up researching further and how I ended up finding the new thread created just 30 minutes earlier.
This thread is where I ended up being active in for a while when I was getting around and learning the process of making mods. (This is my first time ever...)
You can find this thread here: http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/

... and this is why I'm creating this guide, simple as that :)

(This part bellow is optional)
My initial instinct was to create a plugin that would make a list of all gameobjects in the current scene (World)... that way I knew what I could work with..
MySummerCar SceneObjects SourceCode: https://pastebin.com/pVqttvzH
MySummerCar Scene Objects list: https://pastebin.com/tkXq5mYd (Version: Dec 2017, this has changed!)

This was however, very, unnecessary since @zamp has created, litteraly, the ultimate developer toolkit for modding!

Also, after this I started PM conversations with @kunedo who has been very helpful with Ideas... hes just a really friendly and amazing guy all around helping etc. Thanks, really!

So where should I start?
First
, you will need an IDE; Visual Studio.
You can find it here: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15

Secondly, you should start with finding the MSCLoader Wiki and start setting up your environment. Read through and learn how to use the MSCLoader:
You can find MSCLoader Wiki here:
https://github.com/piotrulos/MSCModLoader/wiki

NOTE: You may download either x86 or x64 bit version of Unity and reading both for player and developer is very useful.

Third, start by downloading and "installing" the "Developer Toolkit" so you can easily find and quickly modify gameobjects in the world.
Saves a lot of time not having to make changes, build and restart the game every time you try a new set of code for example in placing or re-placing gameobject in the world.
You can find Developer Toolkit here:
http://www.racedepartment.com/downloads/plugin-developer-toolkit.17214/

NOTE: Some Objects/Components also needs referenses to Assembly-CSharp.dll file.
("Steam\steamapps\common\My Summer Car\mysummercar_Data\Managed\Assembly-CSharp.dll")
Drivetrain, for example, does need this reference to work properly.
Thanks to @tommojphillips for finding this!

How can I make changes in-game?
This is fairly easy and basic kowledge. MySummerCar is created using Unity® software and that opens up a whole lot of methods, classes and libraries we can use.
Transforms, for example, is used to store an objects position, rotation, scale and parenting state.
MySummerCar is also using an asset called PlayMaker which makes it a whole lot harder at the same time. Depending on your goal ofcourse.

First, if you would like to make changes to example the car, Satsuma for example...
We need to create a variable/reference name:
Code:
GameObject satsuma; // Making a variable
Right now the reference is empty and we need to give it a reference to the object in the game..
Give it a reference/value:
Code:
satsuma = GameObject.Find("SATSUMA(557kg, 248)"); // Giving our variable a reference/value
Now the reference is set and we can access for example the transforms of the object to move or make changes. We can also activate/deactivate the object in the world. Now that we know how to access an object... How can I make changes to the information in the game?
This part is a bit tricky.. You need to find out which GameObject in the scene is "hosting" the component which makes these changes in order to change them... Unless they are maintained by a singleton instance. If they are maintained by singleton and are instanced they can, globally, be read or changed without the need of the "hosting" object.

Making changes to a component/variable:
Code:
satsumaDriveTrain = GameObject.Find("SATSUMA(557kg, 248)").GetComponent<Drivetrain>();
This means that you are getting the component "DriveTrain" on the Object "SATSUMA(557kg, 248)" and you may make changes or read values/variables from that component.

If it is a singleton variable or information you are looking for you may use a foreach method to get what you want to find:
Making a foreach for PlayMaker FSM:
Code:
// FloatVariables can be BoolVariables, StringVariables, GameObjectVariables, ObjectVariables, MaterialVariables and IntVariables
foreach (var flt in PlayMakerGlobals.Instance.Variables.FloatVariables)
{
    switch (flt.Name)
    {
        case "PlayerCurrentVehicle": // This is not a float
            _carCurrent = flt.Value.ToString();
            break;
        case "PlayerFatigue":
            _fatigue = flt;
            break;
        case "PlayerThirst":
            _thirst = flt;
            break;
        case "PlayerHunger":
            _hunger = flt;
            break;
        case "PlayerStress":
            _stress = flt;
            break;
    }
}

How do I detect if a player is in vehicle/car/"drive mode"?
Taking a look back to our code earlier we can use the PlayMaker FSM here and check if player is in any vehicle.
Code:
if (FsmVariables.GlobalVariables.FindFsmString("PlayerCurrentVehicle").Value != "")
{
    //Player is in drive mode
}

How do I use custom assets?
Code:
//Define objects
AssetBundle assets;
GameObject turbo;

//Onload.. We load, initialize and give references.
assets = LoadAssets.LoadBundle(this, "turbo.unity3d"); // Load this asset
turbo = assets.LoadAsset("turbo_prefab.prefab") as GameObject; //get specific prefab
assets.Unload(false); //Unload once all prefabs has been gathered to clean memory

//Placement
turbo = GameObject.Instantiate(turbo); //Instantiate object in the world
// OPTIONAL: turbo.transform.SetParent(GameObject.Find("satsu").transform, false); // We can set it as child object

//We set pos, rot & scale | Be aware, there are localPosition and Position. Choose relative to the use.
turbo.transform.localPosition = new Vector3(0.3f, 0.16f, 1.02f);
turbo.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
turbo.transform.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);

(I cant find the player!)
How do I find player?

When OnLoad is called you can simply use this code:
Code:
GameObject player = GameObject.Find("PLAYER"); // Simple as this

OLD TUTORIAL; MSCLoader <= 0.3.5;
Finding the player is a bit tricky compared to finding another object in the world since it is "spawing" rather late.
Once OnLoad has finished running in your mod it has most likely not spawned yet and will result in a nullreference exception.
How do we make this work?
There are multiple options but I'm going to show you two:
Code:
//First option is the Coroutine method:

void Something()
{
   //Start coroutine
  StartCoroutine(setup());
}

IEnumerator setup()
{
   yield return new WaitForSeconds(15f); // Wait for something 15 sec
   ModConsole.Print("Success!");
}

Code:
//Second option is the update method:

public override void Update()
{
    //Loops untill player has spawned. May cause some lagg...
    if((GameObject)player == null)
        player = GameObject.Find("PLAYER");

    //Wrap other codes inside this container
    if(player != null)
    {
    //Run mod...
    }
}

**Threading removed**

Good luck and have fun!

Annoyances (and tips) of building mods:

When you are making mods you'll be, eventually, annoyed by three (major) things...
1: As a developer you need to manually copy the mod to the mod folder every time you makes changes/build the mod.
But that can be fixed by using this piece of code:
Code:
copy /Y "$(TargetDir)$(TargetName).dll" "C:\Users\YOURUSERNAME\Documents\MySummerCar\Mods"
It's basicly a "batch"/CMD command to copy the mod dll file to the location of your MSC mod folder.
How do I do that?
aaf95f2caf42619f48dcaefb508a5bb6.png

A: Right-click -> Properties
B: Find the tab "Build Events"
C: Find "Post-Build Event Command line" textarea and modify/copy the code above for everything you want to move with the build on each seperate lines.
D: Save.
E: Build and Enjoy!

2: You will need to restart the game a lot in order to test out the mod and check it out. (There, currently, isn't a way around this atm)
3: Bad reviews.
You may get bad reviews from users who doesn't "install" the mod correct, haven't bought the actual game and is playing on pirate copies etc.
My advice.. Brush it off and don't bother. If you enjoy creating, create and if you get a bad review or someone is being mean, ignore them and continue with your work.

My experiences and mods:
My experience has been great, No dubt. BUT lately i must admit that my interests have turned and I have been forced to focus on diffrent things. Work as an example has been very hectic.
I caught a break now and I wanted to help out the community :)

MySummerMultiMod: http://www.racedepartment.com/downloads/mysummermultimod.19405/

Useful links:
MSCLoader Wiki : https://github.com/piotrulos/MSCModLoader/wiki
PlayMakerFSM : All PlayMaker FSM
@zamp : https://github.com/zamp/MSC-Mods
@Roman266 : https://github.com/GishaSeven/Plugins-for-MSC-ModLoader
@tommojphillips : 2 Links below.
ModAPI: https://github.com/tommojphillips/ModAPI/wiki
Demo: https://github.com/tommojphillips/AttachObjectDemo

Special thanks to everyone who has provided information or helped with some outdated information!

Good nite everyone :sleep:
I have now downloaded Visual studio, so what next?? i can like ****ing know where to code etc. Thrash guide. contact me on discord, so i can now, wich is wich, and what is what!!!!!!
 
[GUIDE]How to make mods for MySummerCar?

NOTE: This is a work in progress please let me know if anything is wrong, something feels like its missing or you have any questions.
NOTE: Some of the code/snippets have been written on the fly and has not been tested. Some may be faulty but please notify if they are and I will correct it!
NOTE: If you have any questions, need help or perhaps are thinking about something NOT covered in this thread PLEASE POST YOUR "OFF TOPIC" QUESTION IN THIS THREAD:
http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/

Skip to actual guide!
Scoll down to the headline "So where should I start?" and begin there!

What will I cover?
I will cover where to start in order to start making mods.
I will provide some very helpful snippets of code.
I will provide useful links and a FAQ.

Why are you doing this?
When I got introduced to the game and my friend showed me the mods I thought it would be fun trying to make one myself but that was not as easy as I thought.
(I NEVER inteded to ever release the mod I created either... but it became too good lol)
With a bit if research I managed to find MSCLoader Wiki and that got me started and setup.
Once everything was setup and working I started by creating a mod-project using the template provided by @piotrulos (The creator of the MSCLoader and forever a legend) and here is where I ended up stuck.
If I wanted to make some changes to an object in the game... How would I proceed?
If I wanted to make some changes to information in-game... How would I proceed?
This is where I ended up researching further and how I ended up finding the new thread created just 30 minutes earlier.
This thread is where I ended up being active in for a while when I was getting around and learning the process of making mods. (This is my first time ever...)
You can find this thread here: http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/

... and this is why I'm creating this guide, simple as that :)

(This part bellow is optional)
My initial instinct was to create a plugin that would make a list of all gameobjects in the current scene (World)... that way I knew what I could work with..
MySummerCar SceneObjects SourceCode: https://pastebin.com/pVqttvzH
MySummerCar Scene Objects list: https://pastebin.com/tkXq5mYd (Version: Dec 2017, this has changed!)

This was however, very, unnecessary since @zamp has created, litteraly, the ultimate developer toolkit for modding!

Also, after this I started PM conversations with @kunedo who has been very helpful with Ideas... hes just a really friendly and amazing guy all around helping etc. Thanks, really!

So where should I start?
First
, you will need an IDE; Visual Studio.
You can find it here: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15

Secondly, you should start with finding the MSCLoader Wiki and start setting up your environment. Read through and learn how to use the MSCLoader:
You can find MSCLoader Wiki here:
https://github.com/piotrulos/MSCModLoader/wiki

NOTE: You may download either x86 or x64 bit version of Unity and reading both for player and developer is very useful.

Third, start by downloading and "installing" the "Developer Toolkit" so you can easily find and quickly modify gameobjects in the world.
Saves a lot of time not having to make changes, build and restart the game every time you try a new set of code for example in placing or re-placing gameobject in the world.
You can find Developer Toolkit here:
http://www.racedepartment.com/downloads/plugin-developer-toolkit.17214/

NOTE: Some Objects/Components also needs referenses to Assembly-CSharp.dll file.
("Steam\steamapps\common\My Summer Car\mysummercar_Data\Managed\Assembly-CSharp.dll")
Drivetrain, for example, does need this reference to work properly.
Thanks to @tommojphillips for finding this!

How can I make changes in-game?
This is fairly easy and basic kowledge. MySummerCar is created using Unity® software and that opens up a whole lot of methods, classes and libraries we can use.
Transforms, for example, is used to store an objects position, rotation, scale and parenting state.
MySummerCar is also using an asset called PlayMaker which makes it a whole lot harder at the same time. Depending on your goal ofcourse.

First, if you would like to make changes to example the car, Satsuma for example...
We need to create a variable/reference name:
Code:
GameObject satsuma; // Making a variable
Right now the reference is empty and we need to give it a reference to the object in the game..
Give it a reference/value:
Code:
satsuma = GameObject.Find("SATSUMA(557kg, 248)"); // Giving our variable a reference/value
Now the reference is set and we can access for example the transforms of the object to move or make changes. We can also activate/deactivate the object in the world. Now that we know how to access an object... How can I make changes to the information in the game?
This part is a bit tricky.. You need to find out which GameObject in the scene is "hosting" the component which makes these changes in order to change them... Unless they are maintained by a singleton instance. If they are maintained by singleton and are instanced they can, globally, be read or changed without the need of the "hosting" object.

Making changes to a component/variable:
Code:
satsumaDriveTrain = GameObject.Find("SATSUMA(557kg, 248)").GetComponent<Drivetrain>();
This means that you are getting the component "DriveTrain" on the Object "SATSUMA(557kg, 248)" and you may make changes or read values/variables from that component.

If it is a singleton variable or information you are looking for you may use a foreach method to get what you want to find:
Making a foreach for PlayMaker FSM:
Code:
// FloatVariables can be BoolVariables, StringVariables, GameObjectVariables, ObjectVariables, MaterialVariables and IntVariables
foreach (var flt in PlayMakerGlobals.Instance.Variables.FloatVariables)
{
    switch (flt.Name)
    {
        case "PlayerCurrentVehicle": // This is not a float
            _carCurrent = flt.Value.ToString();
            break;
        case "PlayerFatigue":
            _fatigue = flt;
            break;
        case "PlayerThirst":
            _thirst = flt;
            break;
        case "PlayerHunger":
            _hunger = flt;
            break;
        case "PlayerStress":
            _stress = flt;
            break;
    }
}

How do I detect if a player is in vehicle/car/"drive mode"?
Taking a look back to our code earlier we can use the PlayMaker FSM here and check if player is in any vehicle.
Code:
if (FsmVariables.GlobalVariables.FindFsmString("PlayerCurrentVehicle").Value != "")
{
    //Player is in drive mode
}

How do I use custom assets?
Code:
//Define objects
AssetBundle assets;
GameObject turbo;

//Onload.. We load, initialize and give references.
assets = LoadAssets.LoadBundle(this, "turbo.unity3d"); // Load this asset
turbo = assets.LoadAsset("turbo_prefab.prefab") as GameObject; //get specific prefab
assets.Unload(false); //Unload once all prefabs has been gathered to clean memory

//Placement
turbo = GameObject.Instantiate(turbo); //Instantiate object in the world
// OPTIONAL: turbo.transform.SetParent(GameObject.Find("satsu").transform, false); // We can set it as child object

//We set pos, rot & scale | Be aware, there are localPosition and Position. Choose relative to the use.
turbo.transform.localPosition = new Vector3(0.3f, 0.16f, 1.02f);
turbo.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
turbo.transform.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);

(I cant find the player!)
How do I find player?

When OnLoad is called you can simply use this code:
Code:
GameObject player = GameObject.Find("PLAYER"); // Simple as this

OLD TUTORIAL; MSCLoader <= 0.3.5;
Finding the player is a bit tricky compared to finding another object in the world since it is "spawing" rather late.
Once OnLoad has finished running in your mod it has most likely not spawned yet and will result in a nullreference exception.
How do we make this work?
There are multiple options but I'm going to show you two:
Code:
//First option is the Coroutine method:

void Something()
{
   //Start coroutine
  StartCoroutine(setup());
}

IEnumerator setup()
{
   yield return new WaitForSeconds(15f); // Wait for something 15 sec
   ModConsole.Print("Success!");
}

Code:
//Second option is the update method:

public override void Update()
{
    //Loops untill player has spawned. May cause some lagg...
    if((GameObject)player == null)
        player = GameObject.Find("PLAYER");

    //Wrap other codes inside this container
    if(player != null)
    {
    //Run mod...
    }
}

**Threading removed**

Good luck and have fun!

Annoyances (and tips) of building mods:

When you are making mods you'll be, eventually, annoyed by three (major) things...
1: As a developer you need to manually copy the mod to the mod folder every time you makes changes/build the mod.
But that can be fixed by using this piece of code:
Code:
copy /Y "$(TargetDir)$(TargetName).dll" "C:\Users\YOURUSERNAME\Documents\MySummerCar\Mods"
It's basicly a "batch"/CMD command to copy the mod dll file to the location of your MSC mod folder.
How do I do that?
aaf95f2caf42619f48dcaefb508a5bb6.png

A: Right-click -> Properties
B: Find the tab "Build Events"
C: Find "Post-Build Event Command line" textarea and modify/copy the code above for everything you want to move with the build on each seperate lines.
D: Save.
E: Build and Enjoy!

2: You will need to restart the game a lot in order to test out the mod and check it out. (There, currently, isn't a way around this atm)
3: Bad reviews.
You may get bad reviews from users who doesn't "install" the mod correct, haven't bought the actual game and is playing on pirate copies etc.
My advice.. Brush it off and don't bother. If you enjoy creating, create and if you get a bad review or someone is being mean, ignore them and continue with your work.

My experiences and mods:
My experience has been great, No dubt. BUT lately i must admit that my interests have turned and I have been forced to focus on diffrent things. Work as an example has been very hectic.
I caught a break now and I wanted to help out the community :)

MySummerMultiMod: http://www.racedepartment.com/downloads/mysummermultimod.19405/

Useful links:
MSCLoader Wiki : https://github.com/piotrulos/MSCModLoader/wiki
PlayMakerFSM : All PlayMaker FSM
@zamp : https://github.com/zamp/MSC-Mods
@Roman266 : https://github.com/GishaSeven/Plugins-for-MSC-ModLoader
@tommojphillips : 2 Links below.
ModAPI: https://github.com/tommojphillips/ModAPI/wiki
Demo: https://github.com/tommojphillips/AttachObjectDemo

Special thanks to everyone who has provided information or helped with some outdated information!

Good nite everyone :sleep:
nice, so iam wondering how do i make a gui and inside of that gui there is a button that selects the car so gameobject find and then that button will say FITTAN because that's the car i want to modify, and i want to make it driveable. could you show me how?
 
[GUIDE]How to make mods for MySummerCar?

NOTE: This is a work in progress please let me know if anything is wrong, something feels like its missing or you have any questions.
NOTE: Some of the code/snippets have been written on the fly and has not been tested. Some may be faulty but please notify if they are and I will correct it!
NOTE: If you have any questions, need help or perhaps are thinking about something NOT covered in this thread PLEASE POST YOUR "OFF TOPIC" QUESTION IN THIS THREAD:
http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/

Skip to actual guide!
Scoll down to the headline "So where should I start?" and begin there!

What will I cover?
I will cover where to start in order to start making mods.
I will provide some very helpful snippets of code.
I will provide useful links and a FAQ.

Why are you doing this?
When I got introduced to the game and my friend showed me the mods I thought it would be fun trying to make one myself but that was not as easy as I thought.
(I NEVER inteded to ever release the mod I created either... but it became too good lol)
With a bit if research I managed to find MSCLoader Wiki and that got me started and setup.
Once everything was setup and working I started by creating a mod-project using the template provided by @piotrulos (The creator of the MSCLoader and forever a legend) and here is where I ended up stuck.
If I wanted to make some changes to an object in the game... How would I proceed?
If I wanted to make some changes to information in-game... How would I proceed?
This is where I ended up researching further and how I ended up finding the new thread created just 30 minutes earlier.
This thread is where I ended up being active in for a while when I was getting around and learning the process of making mods. (This is my first time ever...)
You can find this thread here: http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/

... and this is why I'm creating this guide, simple as that :)

(This part bellow is optional)
My initial instinct was to create a plugin that would make a list of all gameobjects in the current scene (World)... that way I knew what I could work with..
MySummerCar SceneObjects SourceCode: https://pastebin.com/pVqttvzH
MySummerCar Scene Objects list: https://pastebin.com/tkXq5mYd (Version: Dec 2017, this has changed!)

This was however, very, unnecessary since @zamp has created, litteraly, the ultimate developer toolkit for modding!

Also, after this I started PM conversations with @kunedo who has been very helpful with Ideas... hes just a really friendly and amazing guy all around helping etc. Thanks, really!

So where should I start?
First
, you will need an IDE; Visual Studio.
You can find it here: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15

Secondly, you should start with finding the MSCLoader Wiki and start setting up your environment. Read through and learn how to use the MSCLoader:
You can find MSCLoader Wiki here:
https://github.com/piotrulos/MSCModLoader/wiki

NOTE: You may download either x86 or x64 bit version of Unity and reading both for player and developer is very useful.

Third, start by downloading and "installing" the "Developer Toolkit" so you can easily find and quickly modify gameobjects in the world.
Saves a lot of time not having to make changes, build and restart the game every time you try a new set of code for example in placing or re-placing gameobject in the world.
You can find Developer Toolkit here:
http://www.racedepartment.com/downloads/plugin-developer-toolkit.17214/

NOTE: Some Objects/Components also needs referenses to Assembly-CSharp.dll file.
("Steam\steamapps\common\My Summer Car\mysummercar_Data\Managed\Assembly-CSharp.dll")
Drivetrain, for example, does need this reference to work properly.
Thanks to @tommojphillips for finding this!

How can I make changes in-game?
This is fairly easy and basic kowledge. MySummerCar is created using Unity® software and that opens up a whole lot of methods, classes and libraries we can use.
Transforms, for example, is used to store an objects position, rotation, scale and parenting state.
MySummerCar is also using an asset called PlayMaker which makes it a whole lot harder at the same time. Depending on your goal ofcourse.

First, if you would like to make changes to example the car, Satsuma for example...
We need to create a variable/reference name:
Code:
GameObject satsuma; // Making a variable
Right now the reference is empty and we need to give it a reference to the object in the game..
Give it a reference/value:
Code:
satsuma = GameObject.Find("SATSUMA(557kg, 248)"); // Giving our variable a reference/value
Now the reference is set and we can access for example the transforms of the object to move or make changes. We can also activate/deactivate the object in the world. Now that we know how to access an object... How can I make changes to the information in the game?
This part is a bit tricky.. You need to find out which GameObject in the scene is "hosting" the component which makes these changes in order to change them... Unless they are maintained by a singleton instance. If they are maintained by singleton and are instanced they can, globally, be read or changed without the need of the "hosting" object.

Making changes to a component/variable:
Code:
satsumaDriveTrain = GameObject.Find("SATSUMA(557kg, 248)").GetComponent<Drivetrain>();
This means that you are getting the component "DriveTrain" on the Object "SATSUMA(557kg, 248)" and you may make changes or read values/variables from that component.

If it is a singleton variable or information you are looking for you may use a foreach method to get what you want to find:
Making a foreach for PlayMaker FSM:
Code:
// FloatVariables can be BoolVariables, StringVariables, GameObjectVariables, ObjectVariables, MaterialVariables and IntVariables
foreach (var flt in PlayMakerGlobals.Instance.Variables.FloatVariables)
{
    switch (flt.Name)
    {
        case "PlayerCurrentVehicle": // This is not a float
            _carCurrent = flt.Value.ToString();
            break;
        case "PlayerFatigue":
            _fatigue = flt;
            break;
        case "PlayerThirst":
            _thirst = flt;
            break;
        case "PlayerHunger":
            _hunger = flt;
            break;
        case "PlayerStress":
            _stress = flt;
            break;
    }
}

How do I detect if a player is in vehicle/car/"drive mode"?
Taking a look back to our code earlier we can use the PlayMaker FSM here and check if player is in any vehicle.
Code:
if (FsmVariables.GlobalVariables.FindFsmString("PlayerCurrentVehicle").Value != "")
{
    //Player is in drive mode
}

How do I use custom assets?
Code:
//Define objects
AssetBundle assets;
GameObject turbo;

//Onload.. We load, initialize and give references.
assets = LoadAssets.LoadBundle(this, "turbo.unity3d"); // Load this asset
turbo = assets.LoadAsset("turbo_prefab.prefab") as GameObject; //get specific prefab
assets.Unload(false); //Unload once all prefabs has been gathered to clean memory

//Placement
turbo = GameObject.Instantiate(turbo); //Instantiate object in the world
// OPTIONAL: turbo.transform.SetParent(GameObject.Find("satsu").transform, false); // We can set it as child object

//We set pos, rot & scale | Be aware, there are localPosition and Position. Choose relative to the use.
turbo.transform.localPosition = new Vector3(0.3f, 0.16f, 1.02f);
turbo.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
turbo.transform.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);

(I cant find the player!)
How do I find player?

When OnLoad is called you can simply use this code:
Code:
GameObject player = GameObject.Find("PLAYER"); // Simple as this

OLD TUTORIAL; MSCLoader <= 0.3.5;
Finding the player is a bit tricky compared to finding another object in the world since it is "spawing" rather late.
Once OnLoad has finished running in your mod it has most likely not spawned yet and will result in a nullreference exception.
How do we make this work?
There are multiple options but I'm going to show you two:
Code:
//First option is the Coroutine method:

void Something()
{
   //Start coroutine
  StartCoroutine(setup());
}

IEnumerator setup()
{
   yield return new WaitForSeconds(15f); // Wait for something 15 sec
   ModConsole.Print("Success!");
}

Code:
//Second option is the update method:

public override void Update()
{
    //Loops untill player has spawned. May cause some lagg...
    if((GameObject)player == null)
        player = GameObject.Find("PLAYER");

    //Wrap other codes inside this container
    if(player != null)
    {
    //Run mod...
    }
}

**Threading removed**

Good luck and have fun!

Annoyances (and tips) of building mods:

When you are making mods you'll be, eventually, annoyed by three (major) things...
1: As a developer you need to manually copy the mod to the mod folder every time you makes changes/build the mod.
But that can be fixed by using this piece of code:
Code:
copy /Y "$(TargetDir)$(TargetName).dll" "C:\Users\YOURUSERNAME\Documents\MySummerCar\Mods"
It's basicly a "batch"/CMD command to copy the mod dll file to the location of your MSC mod folder.
How do I do that?
aaf95f2caf42619f48dcaefb508a5bb6.png

A: Right-click -> Properties
B: Find the tab "Build Events"
C: Find "Post-Build Event Command line" textarea and modify/copy the code above for everything you want to move with the build on each seperate lines.
D: Save.
E: Build and Enjoy!

2: You will need to restart the game a lot in order to test out the mod and check it out. (There, currently, isn't a way around this atm)
3: Bad reviews.
You may get bad reviews from users who doesn't "install" the mod correct, haven't bought the actual game and is playing on pirate copies etc.
My advice.. Brush it off and don't bother. If you enjoy creating, create and if you get a bad review or someone is being mean, ignore them and continue with your work.

My experiences and mods:
My experience has been great, No dubt. BUT lately i must admit that my interests have turned and I have been forced to focus on diffrent things. Work as an example has been very hectic.
I caught a break now and I wanted to help out the community :)

MySummerMultiMod: http://www.racedepartment.com/downloads/mysummermultimod.19405/

Useful links:
MSCLoader Wiki : https://github.com/piotrulos/MSCModLoader/wiki
PlayMakerFSM : All PlayMaker FSM
@zamp : https://github.com/zamp/MSC-Mods
@Roman266 : https://github.com/GishaSeven/Plugins-for-MSC-ModLoader
@tommojphillips : 2 Links below.
ModAPI: https://github.com/tommojphillips/ModAPI/wiki
Demo: https://github.com/tommojphillips/AttachObjectDemo

Special thanks to everyone who has provided information or helped with some outdated information!

Good nite everyone :sleep:
all I want to learn is how to fix outdated mods to work with the latest version of msc
 
Nice tutorial, thanks!

But I can't import asset bundles. Once I try it, I get this famous error:
Error: Mod MyMod throw an error!
Details: Object reference not set to an instance of an object in Void OnLoad()


I'm not really sure what it means.

Mod source code

Structure of my ccassets.unity3d (taken from manifest):
Assets:
- Assets/ccobject.fbx
- Assets/ccobject.prefab

To create bundles I used this tutorial from the MSCLoader Github Wiki.
I had to change on line in the script for creating asset bundles (for the menu item) from
BuildPipeline.BuildAssetBundles("AssetBundles");
to
BuildPipeline.BuildAssetBundles("AssetBundles", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
Otherwise the Unity Editor throw an error.

I hope my description is detailed enough and you can help me.
Thank you!


Edit - PROBLEM SOLVED:
I used the wrong Unity Version (not 5.0.0).
your answer should be pinned:D
 

Latest News

Are you buying car setups?

  • Yes

  • No


Results are only viewable after voting.
Back
Top