Skip to content

Custom Scripts#

Shared Scripts

Our Discord server allows members to share their Lua scripts.

Copy the LUA file into the scripts folder (more information below). If the script is bundled in a ZIP/RAR package, extract the contents of the package into the scripts folder. If the folder does not exist, create it yourself.

The developer of the script may provide additional steps to import their scripts. Any question regarding a shared script must be asked to its creator.

The Lua engine of 2Take1Menu allows you to expand the functionality of the menu by creating you own features. You can make use of the Lua API to code scripts and run them from within 2Take1, as well as import scripts created by other users.

New releases of 2Take1 often include updates to the API. If you are developing a Lua script, stay tuned to the release notes, as your creation may require a workaround after a new update.

Similarly, if you are using a script created by other user, keep in mind that it might stop working properly after a new release, so ask its creator to update it.

Lua API

Management and execution#

2Take1 will scan for Lua scripts in the following folder. Keep in mind that, if you make changes to the folder while 2Take1 is running, you will have to refresh the scripts index:

%appdata%\PopstarDevs\2Take1Menu\scripts\

While the menu is injected, go to Local Tab → Scripts, look for the name of the script and select it to load its features. You may access the features of the script in:

  • Local Tab → Script Features
  • Online Tab → Online Players → Script Features

autoexec.lua#

Be careful not to load autoexec.lua itself in the script.

You may create a script named autoexec.lua, that will be loaded automatically when 2Take1 is injected. Possible use cases for this behavior include loading other scripts or external data.

Sample snippets

Credits to Proddy and Moist for providing these snippets.

%appdata%\PopstarDevs\2Take1Menu\scripts\autoexec.lua
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
local function LoadSpecificLua()
    local rootPath = utils.get_appdata_path("PopstarDevs\\2Take1Menu\\scripts", "")
    local luaFiles = {"Example.lua", "Example2.lua"}
    for i=1,#luaFiles do
        local path = rootPath .. "\\" .. luaFiles[i]
        if utils.file_exists(path) then
            local chunk, err = loadfile(path)
            if err then
                ui.notify_above_map("Error loading " .. loadFiles[i] .. "\nError in console", "Autoexec", 140)  
                print(err)
            else
                chunk()
            end
        end
    end
end
LoadSpecificLua()

Example.lua and Example2.lua will be loaded automatically when 2Take1 is injected.

%appdata%\PopstarDevs\2Take1Menu\scripts\autoexec.lua
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
local function LoadAllLua()
    local rootPath = utils.get_appdata_path("PopstarDevs\\2Take1Menu\\scripts", "")
    local scriptName = debug.getinfo(1, "S").source:sub(autoloadDir:len() + 2)
    local excludedFiles = {["autoexec.lua"] = true, ["DoNotLoadMe.lua"] = true}
    local luaFiles = utils.get_all_files_in_directory(rootPath, "lua")
    for i=1,#luaFiles do
        if not excludedFiles[luaFiles[i]] then
            local path = rootPath .. "\\" .. luaFiles[i]
            local chunk, err = loadfile(path)
            if err then
                ui.notify_above_map("Error loading " .. loadFiles[i] .. "\nError in console", "Autoexec", 140)  
                print(err)
            else
                chunk()
            end
        end
    end
end
LoadAllLua()

All scripts in the scripts folder (except DoNotLoadMe.lua and autoexec.lua itself) will be loaded automatically when 2Take1 is injected.

Engine features#

The following features are also found in Local Tab → Scripts:

  • Refresh Scripts – Force 2Take1 to scan the scripts folder for scripts.
  • Reset State – Unload all scripts and restart the Lua engine.
  • Allocate Debug Console – Show a console window to debug your script.
  • Trusted Mode – Allow the scripts to edit locals, globals and stats. If you are using scripts from other authors, make sure you trust them before enabling this feature.
Back to top