Guide to fix Tool Menu mod for Teardown & most variants for Invalid Order Functionality + Favorites not saving correctly
Foreword
This text only describe the process to edit the tool menu’s script to fix errors related to invalid order function (unable to open menu) and favorite not saving across games for the Tool menu mod and its variants of the game Teardown.
This guide will be in the simplest language possible by me, so many technical details and alternate steps will be excluded.
The original tool menu mod:
https://steamcommunity.com/sharedfiles/filedetails/?id=2418422455
My version of the original that already has the problems fixed:
https://steamcommunity.com/sharedfiles/filedetails/?id=2847011618
First steps
- Subscribe the tool menu mod in workshop if you haven’t
- Open the game, go to Mod manager and find the mod in the middle row and click on its name
- Click “Make local copy” button
- On the right you should see a new mod named after the original mode + “ Copy”
- Go to your documents folder (by default it is C:/Users/[Your Username]/Documents/)
- Open the folder named “Teardown”
- Open the folder named “mods”
- Open the folder named after the mod you copied + “ Copy”
- The main.lua file (or simply shown as “main”) is the file we will be looking into, open it with the text editor of your choice
Invalid Order Function
- Ctrl-F to open up find dialogue
- Search for “– sort by index”
- You should also see “table.sort(all_tools, by_index)” a few lines beneath
- Delete all lines from “– sort by index” to “table.sort(all_tools, by_index)” (including these 2 lines)
- Paste the following codes into the place where the “– sort by index” was
1
2
3
4
5
6
7
8
9
10
11-- sort by id
function by_id(a, b)
if a.id == nil then
return true
end
if b.id == nil then
return false
end
return a.id < b.id
end
table.sort(all_tools, by_id) - Ctrl-S to save file
Favorites not saving across sessions
- Ctrl-F to open up find dialogue
- Search for “function load_favorite_tools()”
- You should see 3 “end”s one after another in separate lines a few lines down, and moving from right to left each line
- Delete all lines from “function load_favorite_tools()” to the last end in the 3 ends (including these 2 lines)
- Paste the following codes into the place where the “function load_favorite_tools()” was
1
2
3
4
5
6
7
8
9
10
11
12
13function load_favorite_tools()
-- load from perst.
local fav_string = GetString(favorite_tools_reg)
local tool_ids = split(fav_string, ',')
-- update the favorite status of the tools
for i, tool in ipairs(all_tools) do
if table_contains(tool_ids, tool.id) then
all_tools[i].favorite = true
end
end
end - Ctrl-S to save file
After editing the Lua script
- Make sure you saved
- Go back to game and disable the mod from the workshop in the middle column if you have it enabled
- Enable the mod you edited on the right name after the workshop mod name + “ Copy”
- Everything should be done, load up a map to test it out
Quick and Shorter Guide but may not be suitable for people unfamiliar with lua scripting
Edit the main.lua lua script for the mod
Change the
1 | function generate_all_tools() |
to
1 | function generate_all_tools() |
or better just remove the by_order function and replace it with by_id then change the table.sort to use by_id since in the variants the modder may choose to add other functionality in the function
then for the favorite
change the
1 | function load_favorite_tools() |
to
1 | function load_favorite_tools() |