Jump to content
TeardownMods

Universal Door Latch Framework 1.5.2

   (4 reviews)

1 Screenshot

About This File

This mod will be migrated to steam workshop when available and will no longer be updated. Files will remain. This line will contain a link to the workshop page when this occurs. I apologize for the inconvenience, and thank you for your interest.

 

 

What it does:

This script allows for a generalized approach to latching doors without the need to give joints individual names and write custom scripts to look for those name specifically.

 

Permissions:

You can use this in any map without the need to ask for permission as long as you:

  1. List credit on the mod page with a link to this page.
  2. Do not include the script within your map itself, as this can cause problems; Instead, have your users grab the newest version from here.
     

How it works:

When the door is near enough to the closed position (limit "0"), it will apply a slight force to keep it closed. When you grab the door, it removes that force, allowing you to open the door. following this, it will remain loose until the door returns to its closed position. That means that if you leave a car door open, you could use your brakes to close it. This is different than other implementations that use interactions (button prompt) that switch the direction of the force. This is due mostly to my own preference, but also due to how the script checks for each door. It could probably be easily changed though if you prefer that method.

 

For Users:

Drop the folder from the .zip into your /documents/teardown/mods/ folder.

308235531_LEBI.png.34d62164ac8b4d4930f269356122bc7e.png

 

For developers:

Add "tags="Latch"" to the VOX of each shape. DO NOT TAG THE JOINT! Otherwise, the script will not work.

Add sound effects by extending the tag to "Latch=Vehicle" or "Latch=Structure".

Custom sounds can be added with "LatchOpenSound=../mod_name/path_to_sound.ogg" and "LatchCloseSound=../mod_name_path_to_sound.ogg". Ensure that the path always starts with "../" followed by the name of the FOLDER your mod is in, and then the rest of the path to the sound. If you get no sound instead of a custom one, it's probably a typo.

Please ensure that all joints you wish to latch are in the closed position at limit 0, as this is what the script considers the "closed" position. This generally means that the door is closed in the .vox file.

An example vehicle (The yellow van from the thumbnail) is included in the files.

xml.png.06cd1097b2a5d97a8ee6a7cf885894f5.png

 

Edited by Magnymbus
Added migration disclaimer


What's New in Version 1.5.2   See changelog

Released

NEW FEATURES

Custom sounds now have a fallback if the Latch tag has a value and only one custom sound is listed. Currently, this does not check if the file and path are valid, as I have no idea how to do that. Once I figure that out, it will be a PROPER fallback system. Syntax below.

tags="Latch=Vehicle LatchOpenSound=../mod_name/path_to_sound.ogg LatchCloseSound=../mod_name/path_to_sound.ogg"


BUG FIXES

If the Latch tag has a value, the script will attempt to use that as a fallback if you included either LatchOpen/CloseSound tags but did not give them values. Fallbacks do not currently work if the file path is simply invalid.
Error reports should be slightly more verbose now.


UNDER THE HOOD

A few systems were completely rewritten in order to fix how tables were being handled and to slightly increase the potential verbosity of debugging. Other than the (admittedly not very useful yet) fallback system, this shouldn't effect how users or developers interact with the script.

  • Like 2
  • Thanks 1

User Feedback

Recommended Comments

What a nice idea! Do I understand the script correctly that you run it initially to find all objects with the tag "latch" and store it in the "hasLatch" table? Later in the tick method you check if with one of those objects an interaction is happening?

Link to comment
Share on other sites
5 hours ago, viperbone said:

What a nice idea! Do I understand the script correctly that you run it initially to find all objects with the tag "latch" and store it in the "hasLatch" table? Later in the tick method you check if with one of those objects an interaction is happening?

It looks for what shape you grab. Interactions are the button prompts, but otherwise yes. I just found that the script doesn't handle more than 3 doors correctly, so I'm currently trying to fix that.

Link to comment
Share on other sites
1 hour ago, Magnymbus said:

It looks for what shape you grab. Interactions are the button prompts, but otherwise yes. I just found that the script doesn't handle more than 3 doors correctly, so I'm currently trying to fix that.

Ok. Hopefully that fixed it... Let me know if it's still broken.

Link to comment
Share on other sites
18 hours ago, osamahsah said:

Hey man i have been working hard on the same code but I have posted it 19 hr ago bye any chance did you steal it just wodering 

 

I guarantee I didn't steal it. I worked on it for three days. I can send you old versions with bad code if you want proof. What's yours? I would like to see it! Maybe we can share ideas and see if the script can be improved?

I looked at what I thought might be it (The van) but it doesn't seem to have a script for the doors, just the doors themselves.

Edited by Magnymbus
Link to comment
Share on other sites

Excuse me, I don't know if I'm at fault but the new Latch.lua v1.4 won't work in my TD v0.4.6. The first problem is that I don't have the folder "mods" in my document/teardown folder; The second is that the name of the .lua file I downloaded is "main.lua" instead of "latch.lua", I've tried to rename it to "latch.lua", copy it together with the .ogg files into my level folder and add the script line to my .xml within <scene> but it was in vain. I'm sure the hinges are in the "closed" state at "limit 0".😟

Link to comment
Share on other sites
On 12/17/2020 at 9:50 AM, wu_dl said:

Excuse me, I don't know if I'm at fault but the new Latch.lua v1.4 won't work in my TD v0.4.6. The first problem is that I don't have the folder "mods" in my document/teardown folder; The second is that the name of the .lua file I downloaded is "main.lua" instead of "latch.lua", I've tried to rename it to "latch.lua", copy it together with the .ogg files into my level folder and add the script line to my .xml within <scene> but it was in vain. I'm sure the hinges are in the "closed" state at "limit 0".😟

This is due to using the wrong version of Teardown. The changes to 1.4 were only available to the experimental branch, but those changes should now be on the main branch. Try again. Sorry it took me so long to reply, it's been a long month.

Link to comment
Share on other sites
On 12/20/2020 at 10:45 PM, Jacob Mario said:

I can't seem to download the latch.Lua it keeps coming up with this.

Screenshot (2).png

Nothing I can do about that, but the new version of Teardown should have the new modloader. Just follow the new instructions and let me know how it goes.

  • Thanks 1
Link to comment
Share on other sites
On 2/8/2021 at 11:43 AM, ViroGamer said:

This mod works perfectly as it should to keep car doors closed yet when I open them this happefa.JPG.a6ae78c1b1a48875553bae38e2719428.JPGns 

I PMed you about this. Hopefully we can get that fixed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...