Resource icon

[API][FOR MOD MAKERS] ScrewablePartAPI - Make your mod parts screwable 2.1.3

Login or Register an account to download this content
Last update for this year.

Changelog:
  • Fixed issue preventing parts from beeing removeable after a screw has been unscrewed.
  • Improved when to check if all screws are tight/untight.
  • Like
Reactions: gigel fieraru
It's now possible to set the tightness of screws by code.
This can for example be used to "cheat" by setting the screw of every part to 8, making the part fixed.

The performance has also been improved by making the screw models collider be a trigger.
This will prevent them from colliding with other colliders helping with performance and potential issues caused by collision.

  • Reorganized project folders.
  • Made the collider of a screw be a trigger to improve performance and prevent issues with colliders interacting with each other.
  • Added unity asset bundle project.
  • Added SetScrewPosition function that allows setting of the screw tightness by code.
  • Screw tightness is now checked on each screw in.
  • Made array of screws public accessible.
I just realised the last release had a bug where the assets wouldn't be loaded when the version recieved from the server was the same as the current one (up to date).
I also noticed that when the screws where loaded from the save that if they were all tight, the part could still be removed by right clicking.

Changelog:
Fixed api not loading assets when version recieved from server was up to date.
Fixed part collider not beeing disabled when screws where tightened on load (loaded from save)
The api has now been converted to be a mod.
This gives me many advantages. Like beeing able to load in menu and beeing able to load stuff before any other mod using the ScrewablePartAPI.

!!!Warning!!!: ALL mods using this api have to be updated for this version to work. If one of the mods is not using the new >2.1.0 version none of the mods will work.
It is also important to remove the .dll file inside the References folder:

This file is located under <Mods install location>\Mods\References\ScrewablePartAPI.dll



This for example allows me to load the assets bundle just once. The mod using the api doesn't have to load the bundle anymore the mod also doesn't need to include the screwableapi.unity3d file in it's own Assets folder.

The problem with this is that this means that the api is now no longer located in the "References" folder. It now goes in the normal "Mods" folder like any other mod.
This then means:
All mods have to use the new version as the api won't load when two .dll files are present (one in Mods folder and one in References folder)
Mods have to be updated and the reference to the api .dll has to be changed.
If this update is installed any mod using the old version won't work and will crash!

Changelog:
Converted api into a mod to get some of the mod advantages like loading in menu.
Improved loading time thanks to cconversion to mod.
Added auto updater & ability to install other versions (last 5 from server).
Removed the need to call a function by the mod dev to get the show screw size feature. This is now enabled in code by the mod dev and can be enabled/disabled by the user in the Mod Settings of the ScrewablePartAPI.
Added ability to disable update checking in Mod Settings. (last 5 will still be available in Mod Settings).
I have reworked the screwable part api improving the code by alot and making it easier to use.

Changelog (v2.0.0):
  • Reworked API creating a V2.
  • Improved loading
  • Improved logic running in the background
  • Improved performance of the logic
  • Made loading/saving easier
  • Made setup of a screwable part simpler and quicker
  • Reduced code size
  • Improved performance when creating more than one screwable part (the more parts you have the more performance gets saved)

For compatibility the old version is still included.
I recommend anyone using the old version to update their mod
and use the new version as it makes alot of things easier and the whole thing faster.

The old version < v2.0.0 will no longer be updated.
Bugs will not be fixed.

The wiki will be updated some time after this release to have a seperate guide for the V2 version.
The wiki for the < v2.0.0 is also outdated and hasn't been updated for quite some time now.
Changelog (v1.4.3):
  • Fixed api always requiring to have the screw save file have the extension ".txt"
Fixed another issue preventing users from screwing in/out any screw.

This was a bug overseen when fixing the bugs from v1.4.0.
I also removed really old obsolte code.
To make sure mods not using the most recent version still work if an update is released I make sure to keep all method calls still there. No longer recommended uses are marked as [Obsolete]
Make sure to update your own mods to have the latest features and fixes.

To keep the code size down and reduce the risks of adding bugs by mistaking old code for new one. Methods marked as [Obsolete] will be removed after a while for the next update.


!!! v1.4.0 was bugged (re-released as 1.4.1 with fix) !!!

Changelog (v1.4.1):
Fixed issue of v1.4.0

Simplified creation of a screwable part by using a new clas "Screw"
Meaning you only have to pass a single array of Screw objects

example:
C#:
new ScrewablePart(screwListSave, screwableAssetsBundle, esp_module_part.rigidPart,
    new Screw[] {
        new Screw(new Vector3(0.09f, -0.002f, -0.052f), new Vector3(-90, 0, 0), 0.8f, 8, ScrewablePart.ScrewType.Screw1),
        new Screw(new Vector3(0.09f, -0.002f, 0.0528f), new Vector3(-90, 0, 0), 0.8f, 8, ScrewablePart.ScrewType.Screw2),
        new Screw(new Vector3(-0.092f, -0.002f, 0.0528f), new Vector3(-90, 0, 0), 0.8f, 8, ScrewablePart.ScrewType.Nut),
        new Screw(new Vector3(-0.092f, -0.002f, -0.052f), new Vector3(-90, 0, 0), 0.8f, 8),
    });
1st Value = position of the screw
2nd Value = rotation of the screw
3rd Value = scale (x y and z)
4th Value = screw size (wrench size needed
5th Value = screw type (the model)

3rd to 5th values are optional.
If ommited these values are used:
3rd = 1f
4th = 10
5th = ScrewablePart.ScrewType.Screw2

There is also an optional static function that can be called inside your ModSettings method.
This will add a Checkbox to your mods Mod Settings called "Show screw size"
If the user ticks this checkbox. The size of the screw currently looked at is displayed to the user.
*Size will only be shown when having a tool in hand*
Changelog 1.3.3
  • Moved logic in constructors to seperate functions
  • Added new Constructor that reduces loading time and adds a simpler way to use
  • Marked old constructors as obsolete
  • Improved screwing logic a bit
  • Removed loading of assets bundle for each screwable part
  • Improved loading time on entering game
* Mods using an older version will continue to work.


Most of the changes are not visible.

I made the creation of screwable parts simpler by including a ScrewType enum for all the available screws.

You can now also use the scale function of the constructor much easier.
I added default values meaning you can ommit some of the parameters:
screwType defaults to Screw1
screwsScale defaults to null (will then use Vector3(1, 1, 1) for each screw
screwSizeForAll defaults to 10 (ratchet/wrench size 10)

You can also set screwsScale to a single vector to use for all screws like this:
new Vector3[] { new Vector3(1.5f, 1.5f, 1.5f) }
Meaning all screws will use a scale of 1.5 1.5 1.5

I also improved the loading time by removing the loading of the assets bundle inside each ScrewablePart. You now have to load the asset bundle before you define your ScrewablePart's and pass it in the constructor. (Make sure to .Unload it after defining all you parts).
  • Like
Reactions: tommojphillips
Quick update to increase the size of all hitboxes. This should make it easier to hit them.

  • Changed hitbox for all screws to be a SphereCollider
  • Changed size of SphereCollider to be the same size as the screw
  • Replaced the DetectScrewing() method with a MonoBehaviour class that gets added as an component to each ScrewablePart getting created.
  • Fixed the problems with screws getting highlighted that should not be highlighted
  • Fixed the problems with screws staying highlighted
  • Marked DetectBolting as Obsolete
  • Fixed the partFixed attribute of the ScrewablePart not updating as of the Logic update
  • Fixed missing logic AddComponent in MakePartScrewable that does not get screwableScale passed to it
- fixed a problem with the setScrewsOnAssemble Method where the parentGameObject could be null as it might be called before the screws are generated.
- Added check to make sure screws are only added to parentGameObject if no Vectro3 array is not null (empty).
- Fixed a problem where if a save was found (was not null) It would not add parts that are not inside the saveFile. -
- Now it will load the default information.
- Added method for adding a clamp model usefull when you want to connect tubes/pipes realisticly
- Fixed clamp gameObject naming to be parentGameObject.name_CLAMP1
Changelog (v1.2):
  • Optimized DetectScrewing to first check if tool is in hand.
  • Fixed/Added xml code documentation (the xml file is only needed for developing. Not needed in release version).
  • Added more xml code documentation.
  • Added Spanner/Ratchet detection.
  • Ratchet now works like it should.
  • Code cleanup into methods for ScrewIn/ScrewOut
  • Fixed version number to be the latest v1.2
github.com/DonnerPlays/ScrewablePartAPI

Changelog v1.1

  • Moved loading the bolt model to use into seperate method.
  • Fixed screws default position not saving (stupid arrays...)
  • Fixed aiming at bolt detection, was not checking if the parent object was the same which caused the next DetectBolting to change the first
  • Made detection if easier to read
  • Added partFixed changes to false when a screw is unscrewed
  • Fixed collider enable/disable switch not working correctly
  • Fixed "activebolt" (green) not changing when using more than one screwablepart
  • Added screw sound
  • Changed the method how the wrench size is get
  • Changed time used to detect when another screw can happen to using the games value (which is currently 0.1f)
  • Reduced hitbox for all screws to be only the head.
  • Changed hitbox for nut to be a mesh collider.
    this also fixes the problem with having multiple bolts nearby getting highlighted
  • Added MakePartScrewable Method that also takes the Scale for each screw
  • Changed setScrewsOnAssemble to reset back to default location too.

Latest News

How long have you been simracing

  • < 1 year

    Votes: 344 15.6%
  • < 2 years

    Votes: 232 10.5%
  • < 3 years

    Votes: 231 10.5%
  • < 4 years

    Votes: 175 8.0%
  • < 5 years

    Votes: 293 13.3%
  • < 10 years

    Votes: 256 11.6%
  • < 15 years

    Votes: 163 7.4%
  • < 20 years

    Votes: 124 5.6%
  • < 25 years

    Votes: 99 4.5%
  • Ok, I am a dinosaur

    Votes: 284 12.9%
Back
Top