This repository was archived by the owner on Jul 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Code Guide 01
Marvin Beym edited this page Apr 7, 2020
·
7 revisions
Please continue only if you have done the Unity Guide.
- add the compiled dll from "Releases" to your games References folder. (
- add the dll to your Visual Studio references and disable local copy!. Otherwise it will always export the file to your build folder
- add
using ScrewablePartAPI;to the top of your .cs file of your mod.
- you need to create an object from the ScrewablePart class.
- make it public and static -> example:
public static ScrewablePart exhaust_header_screwable - do this for every part you want to have screwable.

You first load your saveFile using the static function ` SortedList<String, Screws> screwListSave = ScrewablePart.LoadScrews(this, "test.txt");
turbocharger_big_exhaust_header_screwable = new ScrewablePart(screwListSave, this, turbocharger_big_exhaust_header_part.rigidPart,
new Vector3[]
{
new Vector3(0.169f, 0.076f, -0.022f), //Screw1
new Vector3(0.13f, 0.0296f, -0.022f), //Screw2
new Vector3(-0.003f, 0.08f, -0.022f), //Screw3
new Vector3(-0.137f, 0.0296f, -0.022f), //Screw4
new Vector3(-0.174f, 0.076f, -0.022f) //Screw5
},
new Vector3[]
{
new Vector3(0, 0, 0), //Screw1
new Vector3(0, 0, 0), //Screw2
new Vector3(0, 0, 0), //Screw3
new Vector3(0, 0, 0), //Screw4
new Vector3(0, 0, 0) //Screw5
}, 8, "screwable_nut");
`
- At the top you load the saveFile. If it returns null then no saveFile could be loaded and the values defined below will be used.
- the first parameter is your mod class (usually this)
- the last parameter is your save file name (NO PATH, only the name + .extension) everything else is made automatically)
After that:
- then you create the Parts using the Constructor
- the first value is your saveFile either null or it is a List.
- then your mod class (usually this)
- then your gameObject where you want to attach the screws to. This should always be your modapiPart.rigidPart!!!
- the 4th/5th parameter is important!!! -> read below
- the 5th parameter is the screw size -> so which wrench is needed.
- the 6th parameter is the screw model to use choose: "screwable_nut" = the nut "screwable_screw1" = screw for screwdriver "screwable_screw2" = shortest screw used with wrench "screwable_screw3" = longest screw used with wrench
3th/4th parameter:
- Here you declare the position of each screw based on the parentGameObject (so 0, 0, 0 is the center of the parent) and the rotation.
- For each screw you want to have you create an new Vector
- in the example above 5 Screws are created because the Length of the array is 5
To get the desired position create them with all 0 and when they are loaded use the Mods "DeveloperToolset" and NoClip (search them on racedepartment) to position them when ingame.
DeveloperToolset guide: press ctrl + Z to open the hud. then search for "SCREW" then adjust position and rotation to fit where you want the part to be. copy the values into the Vector(x, y, z).
If done continue to Code Guide 02.