Skip to content

Commit 66526bb

Browse files
committed
Update to 0.6.0
1 parent aa3a9f3 commit 66526bb

18 files changed

+151
-408
lines changed

.editorconfig

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trim_trailing_whitespace = true
1313
indent_style = tab
1414
insert_final_newline = true
1515

16-
[*.{txt,yml}]
16+
[*.{txt,yml,json}]
1717
indent_style = space
1818
indent_size = 2
1919
insert_final_newline = false
@@ -24,7 +24,7 @@ indent_size = 2
2424
insert_final_newline = true
2525
trim_trailing_whitespace = false
2626

27-
[*.{json,md}]
27+
[*.md]
2828
indent_style = tab
2929
indent_size = 2
3030
insert_final_newline = false

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,19 @@ What it can do
5858
--------------
5959

6060
* Filter parameters of commands
61-
* Add switchable commands via map settings
61+
* Add switchable, customizable commands via map settings
6262
* Double check of commands
6363
* Use built-in error handling of commands
6464
* Use modular structure
6565
* Remotely and safely disable your mod
66+
* Auto adds remote access for rcon and for other mods/scenarios
6667
* Auto publishing on [mods.portal.com](https://mods.factorio.com/) and on your GitHub repository
6768

6869
What it enables you to do
6970
-------------------------
7071

7172
* Handle sounds by a [script](.scripts/handle_sounds.sh)
72-
* Make switchable, simpler and safer [commands](models/BetterCommands/README.md)
73+
* Make switchable, simpler and safer [commands](https://github.com/ZwerOxotnik/factorio-BetterCommands)
7374
* Make "isolated" modules
7475
* Expand your modules
7576
* More possibilities to control logic
@@ -120,7 +121,6 @@ How to start?
120121
* **Change or delete** .github/ISSUE_TEMPLATE/*
121122
* **Change or delete** .github/workflows/* (please read [this](https://github.com/shanemadden/factorio-mod-portal-publish))
122123
* Handle files in [control.lua](control.lua)
123-
* Change settings in [models/BetterCommands/control.lua](models/BetterCommands/control.lua) if you want
124124

125125
Notes
126126
-----
@@ -159,7 +159,7 @@ sudo apt install p7zip-full jq git -y
159159
Optional Dependencies
160160
---------------------
161161

162-
* <a href="github.com/ZwerOxotnik/zk-lib" target="_blank"><code>zk-lib</code></a> - for localization of [BetterCommands](models/BetterCommands/control.lua) and [event handler](/control.lua), currently
162+
* <a href="github.com/ZwerOxotnik/zk-lib" target="_blank"><code>zk-lib</code></a> - for localization of [event handler](/control.lua), currently
163163

164164
‼️ Important Links (Translations, Discord Support)
165165
---------------------------------------------------------------

changelog.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 0.6.0
3+
Date: 2023-09-07
4+
Changes:
5+
- Auto adds remote access for rcon and for other mods/scenarios
6+
- Improved commands greatly
7+
---------------------------------------------------------------------------------------------------
28
Version: 0.5.1
39
Date: 2022-01-07
410
Changes:

const-commands.lua

+26-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
-- Recommended to know about https://lua-api.factorio.com/latest/LuaCommandProcessor.html#LuaCommandProcessor.add_command
2-
3-
--[[
1+
--[[ Uses https://github.com/ZwerOxotnik/factorio-BetterCommands
42
Returns tables of commands without functions as command "settings". All parameters are optional!
5-
Contains:
6-
name :: string: The name of your /command. (default: key of the table)
7-
description :: string or LocalisedString: The description of your command. (default: nil)
8-
is_allowed_empty_args :: boolean: Ignores empty parameters in commands, otherwise stops the command. (default: true)
9-
input_type :: string: filter for parameters by type of input. (default: nil)
10-
possible variants:
11-
"player" - Stops execution if can't find a player by parameter
12-
"team" - Stops execution if can't find a team (force) by parameter
13-
allow_for_server :: boolean: Allow execution of a command from a server (default: false)
14-
only_for_admin :: boolean: The command can be executed only by admins (default: false)
3+
Contains:
4+
name :: string: The name of your /command. (default: key of the table)
5+
description :: string or LocalisedString: The description of your command. (default: nil)
6+
is_allowed_empty_args :: boolean: Ignores empty parameters in commands, otherwise stops the command. (default: true)
7+
input_type :: string: Filter for parameters by type of input. (default: nil)
8+
possible variants:
9+
"player" - Stops execution if can't find a player by parameter
10+
"team" - Stops execution if can't find a team (force) by parameter
11+
allow_for_server :: boolean: Allow execution of a command from a server (default: false)
12+
only_for_admin :: boolean: The command can be executed only by admins (default: false)
13+
allow_for_players :: string[]: Allows to use the command for players with specified names (default: nil)
14+
max_input_length :: uint: Max amount of characters for command (default: 500)
15+
is_logged :: boolean: Logs the command into .log file (default: false)
16+
alternative_names :: string[]: Alternative names for the command (all commands should be added) (default: nil)
17+
is_one_time_use :: boolean: Disables the command after using it (default: false)
18+
is_one_time_use_for_player :: boolean: Disables for a player after using it (default: false)
19+
is_one_time_use_for_force :: boolean: Disables for a force after using it (default: false)
20+
global_cooldown :: uint: The command can be used each N seconds (default: nil)
21+
player_cooldown :: uint: The command can be used each N seconds for players (default: nil)
22+
force_cooldown :: uint: The command can be used each N seconds for forces (default: nil)
23+
disable_cooldown_for_admins :: boolean: Disables cooldown for admins (default: false)
24+
disable_cooldown_for_server :: boolean: Disables cooldown for server (default: true)
1525
]]--
16-
---@type table<string, table>
17-
return {}
26+
---@type table<string, BetterCommand>
27+
return {
28+
}

control.lua

+31-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ require("defines")
88

99
---@type table<string, module>
1010
local modules = {}
11-
modules.better_commands = require("models/BetterCommands/control")
1211
modules.example_module = require("models/example-module")
1312
modules.data_consistency_example = require("models/data-consistency-example")
1413
-- modules.empty_module = require("models.empty-module")
1514

1615

16+
--- Adds https://github.com/ZwerOxotnik/factorio-BetterCommands if exists
17+
if script.active_mods["BetterCommands"] then
18+
local is_ok, better_commands = pcall(require, "__BetterCommands__/BetterCommands/control")
19+
if is_ok then
20+
better_commands.COMMAND_PREFIX = MOD_SHORT_NAME
21+
modules.better_commands = better_commands
22+
end
23+
end
24+
25+
1726
-- Safe disabling of this mod remotely on init stage
1827
-- Useful for other map developers and in some rare cases for mod devs
1928
if remote.interfaces["disable-" .. script.mod_name] then
@@ -29,7 +38,14 @@ if remote.interfaces["disable-" .. script.mod_name] then
2938
module.on_init = update_global_data_on_disabling
3039
end
3140
else
32-
modules.better_commands:handle_custom_commands(modules.example_module) -- adds commands
41+
if modules.better_commands then
42+
if modules.better_commands.handle_custom_commands then
43+
modules.better_commands.handle_custom_commands(modules.example_module) -- adds commands
44+
end
45+
if modules.better_commands.expose_global_data then
46+
modules.better_commands.expose_global_data()
47+
end
48+
end
3349
end
3450

3551

@@ -45,6 +61,19 @@ event_handler = event_handler or require("event_handler")
4561
event_handler.add_libraries(modules)
4662

4763

64+
-- Auto adds remote access for rcon and for other mods/scenarios via zk-lib
65+
if script.active_mods["zk-lib"] then
66+
local is_ok, remote_interface_util = pcall(require, "__zk-lib__/static-libs/lualibs/control_stage/remote-interface-util")
67+
if is_ok and remote_interface_util.expose_global_data then
68+
remote_interface_util.expose_global_data()
69+
end
70+
local is_ok, rcon_util = pcall(require, "__zk-lib__/static-libs/lualibs/control_stage/rcon-util")
71+
if is_ok and rcon_util.expose_global_data then
72+
rcon_util.expose_global_data()
73+
end
74+
end
75+
76+
4877
-- This is a part of "gvv", "Lua API global Variable Viewer" mod. https://mods.factorio.com/mod/gvv
4978
-- It makes possible gvv mod to read sandboxed variables in the map or other mod if following code is inserted at the end of empty line of "control.lua" of each.
5079
if script.active_mods["gvv"] then require("__gvv__.gvv")() end

defines.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Change everything in this file in your mod!
1+
-- Change data in this file in your mod!
22
local _data = {
33
MOD_NAME = "example-mod",
44
MOD_PATH = "__example-mod__",
@@ -8,8 +8,10 @@ local _data = {
88
AUTHOR = "ZwerOxotnik"
99
}
1010

11-
if not MAKE_DEFINE_GLOBAL or (not IS_DATA_STAGE and script and script.active_mods) then
12-
return _data
11+
if (not IS_DATA_STAGE and script and script.active_mods) then
12+
if not MAKE_DEFINE_GLOBAL then
13+
return _data
14+
end
1315
end
1416

1517
--- Make content of _data global

info.json

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
2-
"name": "example-mod",
3-
"version": "0.5.2",
4-
"factorio_version": "1.1",
5-
"title": "Example mod",
6-
"author": "Put your nickname",
7-
"contact": "Put your contacts",
8-
"homepage": "Put a link",
9-
"description": "See locale/en ",
10-
"dependencies": [
11-
"? zk-lib >= 0.10.0",
12-
"(?) gvv"
13-
]
2+
"name": "example-mod",
3+
"version": "0.6.0",
4+
"factorio_version": "1.1",
5+
"title": "Example mod",
6+
"author": "Put your nickname",
7+
"contact": "Put your contacts",
8+
"homepage": "Put a link",
9+
"description": "Put description here",
10+
"dependencies": [
11+
"? zk-lib >= 0.10.0",
12+
"? BetterCommands",
13+
"(?) gvv"
14+
]
1415
}

models/BetterCommands/README.md

-19
This file was deleted.

0 commit comments

Comments
 (0)