Skip to content

Instantly share code, notes, and snippets.

@ZwerOxotnik
Last active April 6, 2021 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZwerOxotnik/dd5e952693bd68f8fdbb6cdea5b5a99b to your computer and use it in GitHub Desktop.
Save ZwerOxotnik/dd5e952693bd68f8fdbb6cdea5b5a99b to your computer and use it in GitHub Desktop.
Just an example for Factorio
-- This is just an example file
-- interacting with https://lua-api.factorio.com/latest/LuaCommandProcessor.html#LuaCommandProcessor.add_command
local function attach_commands(module)
for key, command in pairs(module.commands) do
local name = command.name or key
local description = command.description or {"special-command-description"}
commands.add_command(name, description, command.func)
-- maybe even other actions...
end
end
local module = {}
module.commands = {
test = {
description = {"test"},
func = function() game.print("test") end
},
test2 = {
func = function() game.print("test2") end
},
-- etc
}
attach_commands(module)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment