Skip to content

Instantly share code, notes, and snippets.

@SmileYzn
Last active September 2, 2021 17:08
Show Gist options
  • Save SmileYzn/b33b4b3bed33c75cf7bcdf0802d2ce8f to your computer and use it in GitHub Desktop.
Save SmileYzn/b33b4b3bed33c75cf7bcdf0802d2ce8f to your computer and use it in GitHub Desktop.
Amx Mod X Compile Lua Script for XL-LITE code editor
-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local config = require "core.config"
local command = require "core.command"
local keymap = require "core.keymap"
local console = require "plugins.console"
-- AMX Mod X compiler path
config.compilerPath = "D:/Files/Desktop/lite-xl/compiler"
-- AMX Mod X include folder (Inside compiler path)
config.compilerInclude = "include"
-- AMX Mod X compiler executable (Inside compiler path)
config.compilerExe = "amxxpc.exe"
-- AMX Mod X Output plugin extension
config.outputExtension = "amxx"
command.add(nil,
{
["amxx:build-plugin"] = function()
-- The current AMX Mod X source file path
local filePath = core.active_view:get_filename();
-- AMX Mod X compiler executable
local executablePath = string.format("%s/%s", config.compilerPath, config.compilerExe)
-- Check executable before try to compile
if system.get_file_info(executablePath) == nil then
core.log(string.format("Cannot find executable compiler path: %s", executablePath))
else
-- AMX Mod X compiler include
local includePath = string.format("%s/%s", config.compilerPath, config.compilerInclude)
-- AMX Mod X binary output file path (Convert old .sma extension to .amxx)
local outputPath = string.format("%s.%s",filePath:match("(.+)%..+"), config.outputExtension)
-- AMX Mod X compiler command line
local fullCommand = string.format("%s -i%s -o%s %s", executablePath, includePath, outputPath, filePath)
-- If compilercommand is null
if fullCommand == nil then
core.log("AMX Mod X Compiler: Command is empty.")
else
console.run
{
command = fullCommand,
file_pattern = "(.*):(%d+):(%d+): (.*)$",
error_pattern = "error",
warning_pattern = "warning",
on_complete = function()
core.log("AMX Mod X Compiler: Compilation Complete.")
end
}
end
end
end
})
keymap.add { ["ctrl+b"] = "amxx:build-plugin" }
@SmileYzn
Copy link
Author

SmileYzn commented Sep 2, 2021

This will compile amxmodx plugins using amxxpc.exe

You can add custom path or change as you want 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment