Last active
April 6, 2021 07:55
-
-
Save ZwerOxotnik/dd5e952693bd68f8fdbb6cdea5b5a99b to your computer and use it in GitHub Desktop.
Just an example for Factorio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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