Appearance
Getting Started
To create a script, place a .lua file in the scripts folder within the .neon/NeonFabricData/scripts directory.
API Definitions (Autocomplete, optional)
For improved editor support (autocomplete), you can download the Lua type definitions for your IDE.
Script Metadata
You can define metadata at the top of your script using --- @tag value format.
lua
--- @unsafe trueSupported Tags
| Tag | Description |
|---|---|
@unsafe | Set to true to enable unsafe mode (access to more APIs). If a script is marked unsafe, it will only load if the user has explicitly marked the script as unsafe, even if this is set to false scripts should not be blindly trusted, this is not trying to block everything malicious. |
Registering Features
Every script usually registers one or more features.
lua
local feature = neon.register_feature("Auto Example", "Automatically does something")
local auto_toggle = feature.register_boolean("Auto Toggle", false)
local auto_toggle_hidden = feature.register_boolean("Auto Toggle", false, function()
return false
end)
feature.on("game_tick", function()
if auto_toggle.value then
-- logic
end
end)Registering Commands
Scripts can also register custom chat commands. You can define arguments and the execution handler directly in the register_command call.
lua
neon.register_command(
"test",
"A test command",
{ "alias1", "alias2" },
{
{ name = "message", type = enums.argument_type.string, optional = false },
{ name = "hello", type = enums.argument_type.string, optional = false },
{ name = "amount", type = enums.argument_type.integer, optional = true, completer = function(input)
local options = { "1", "5", "10", "15", "20" }
local suggestions = {}
for _, v in ipairs(options) do
if v:lower():find(input:lower(), 1, true) == 1 then
table.insert(suggestions, v)
end
end
return suggestions
end }
},
function(msg, hello, amount)
print("Message: " .. msg)
print("Message two: " .. hello)
if amount then
print("Amount: " .. amount)
end
end
)