diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000..e829d58
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,2 @@
+# stylua reformat (2-space indent)
+c35fa6c75ce007705636ab18878c9a0d73e8fa2d
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 0000000..2ccbdb3
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,29 @@
+name: Lint
+
+on:
+ push:
+ branches: [master]
+ pull_request:
+ branches: [master]
+
+jobs:
+ luacheck:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install luacheck
+ run: sudo apt-get update && sudo apt-get install -y lua-check
+ - name: Run luacheck
+ run: luacheck .
+
+ stylua:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install stylua
+ run: |
+ curl -fsSL https://github.com/JohnnyMorganz/StyLua/releases/latest/download/stylua-linux-x86_64.zip -o stylua.zip
+ unzip stylua.zip -d /usr/local/bin
+ chmod +x /usr/local/bin/stylua
+ - name: Check formatting
+ run: stylua --check .
diff --git a/.luacheckrc b/.luacheckrc
new file mode 100644
index 0000000..962fb1b
--- /dev/null
+++ b/.luacheckrc
@@ -0,0 +1,200 @@
+-- .luacheckrc for CreativeMod (Factorio 2.0)
+-- Based on Nexela/Factorio-luacheckrc, adapted for Factorio 2.0 API
+
+-- Ignore patterns:
+-- 111/__ : setting non-standard global with __ prefix
+-- 21./%w+_$ : mutating/accessing variable ending in _
+-- 21./^_[_%w]+$ : mutating/accessing variable starting with _
+-- 213/^%a$ : single-character variable in a loop
+-- 213/index : loop variable named "index"
+-- 213/key : loop variable named "key"
+local IGNORE = {
+ "111/__", -- setting non-standard global with __ prefix
+ "21.", -- unused variable/argument/loop variable (legacy codebase, very noisy)
+ "231", -- variable never accessed (legacy codebase)
+ "311", -- value assigned to variable but unused (common in GUI building)
+ "411", -- variable previously defined (legacy codebase)
+ "421", -- shadowing definition of variable (legacy codebase)
+ "431", -- shadowing upvalue (common in nested scopes)
+ "542", -- empty if branch
+ "6..", -- whitespace warnings (stylua will handle formatting)
+}
+local NOT_GLOBALS = { "coroutine", "io", "socket", "dofile", "loadfile" }
+
+local LINE_LENGTH = false
+
+-----------------------------------------------------------
+-- Factorio 2.0 std definitions
+-----------------------------------------------------------
+
+-- Globals available in both data and control stages
+stds.factorio = {
+ read_globals = {
+ "serpent", "log", "__DebugAdapter",
+ table = { fields = { "deepcopy", "compare" } },
+ string = { fields = { "trim", "split" } },
+ math = { fields = { "round" } },
+ },
+}
+
+-- Factorio 2.0 control stage globals
+stds.factorio_control = {
+ read_globals = {
+ game = { other_fields = true, read_only = false },
+ "script",
+ "remote",
+ "rendering",
+ "commands",
+ "settings",
+ "rcon",
+ "helpers", -- Factorio 2.0: new utility global
+ "prototypes", -- Factorio 2.0: replaces game.*_prototypes
+ storage = { other_fields = true, read_only = false },
+ defines = {
+ other_fields = true,
+ },
+ },
+ globals = {
+ "global", -- Factorio 2.0: deprecated alias for storage
+ },
+}
+
+-- Factorio 2.0 data stage globals
+stds.factorio_data = {
+ globals = {
+ data = {
+ other_fields = true,
+ },
+ },
+ read_globals = {
+ "mods",
+ "settings",
+ defines = {
+ other_fields = true,
+ },
+ },
+}
+
+-- Factorio base mod globals available during data stage
+stds.factorio_base_data = {
+ globals = {
+ "circuit_connector_definitions", -- base mod global, sometimes modified
+ },
+ read_globals = {
+ "basic_belt_animation_set",
+ "crash_trigger",
+ "default_orange_color",
+ "ending_patch_prototype",
+ "pipecoverspictures",
+ "sound_variations",
+ "standard_train_wheels",
+ "universal_connector_template",
+ "volume_multiplier",
+ },
+}
+
+-- CreativeMod's own globals (all the module tables defined in scripts/)
+stds.creative_mod = {
+ globals = {
+ "autofill_requester_chest",
+ "cheats",
+ "configurable_super_boiler",
+ "creative_cargo_wagon",
+ "creative_chest",
+ "creative_chest_util",
+ "creative_lab",
+ "creative_mode_defines",
+ "creative_provider_chest",
+ "duplicating_cargo_wagon",
+ "duplicating_chest",
+ "duplicating_chest_util",
+ "duplicating_provider_chest",
+ "duplicator",
+ "equipments",
+ "events",
+ "fluid_providers_util",
+ "fluid_void",
+ "global_util",
+ "gui",
+ "gui_entity",
+ "gui_menu",
+ "gui_menu_admin",
+ "gui_menu_buildoptions",
+ "gui_menu_cheats",
+ "gui_menu_magicwand",
+ "gui_menu_modding",
+ "item_providers_util",
+ "item_source",
+ "item_void",
+ "magic_wand_creator",
+ "magic_wand_healer",
+ "magic_wand_modifier",
+ "mod_compatibler",
+ "output_or_remove_item_operation_mode",
+ "random_item_source",
+ "remote_interface",
+ "rights",
+ "static_item_container_type",
+ "super_boiler",
+ "super_cooler",
+ "transport_belt_item_distance",
+ "util",
+ "void_cargo_wagon",
+ "void_chest_util",
+ "void_lab",
+ -- Functions defined as globals in instant_cheats.lua
+ "is_player_valid_for_instant_request",
+ "is_player_valid_for_instant_trash",
+ "handle_entity_logistic_slot_changed",
+ "handle_player_main_inventory_changed",
+ "handle_player_trash_inventory_changed",
+ -- Functions defined as globals in events.lua
+ "full_store_or_log_message",
+ "get_character_request_slot_count",
+ -- Variables used as globals in data-final-fixes.lua
+ "additional_pastable_entities",
+ "chest_data",
+ -- Variables used as globals in data-stage files
+ "fixed_icons",
+ "hidden",
+ "regpipe",
+ "visible",
+ },
+}
+
+-----------------------------------------------------------
+-- Default configuration
+-----------------------------------------------------------
+
+std = "lua52+factorio+factorio_control+creative_mod"
+not_globals = NOT_GLOBALS
+ignore = IGNORE
+quiet = 1
+codes = true
+max_cyclomatic_complexity = false
+max_line_length = LINE_LENGTH
+max_code_line_length = LINE_LENGTH
+max_string_line_length = LINE_LENGTH
+max_comment_line_length = LINE_LENGTH
+
+exclude_files = {
+ "**/.trash/",
+ "**/.history/",
+ "**/.vscode/",
+ "**/comparison-report.html",
+}
+
+-----------------------------------------------------------
+-- Per-file overrides
+-----------------------------------------------------------
+
+-- Data stage files
+files["data.lua"].std = "lua52+factorio+factorio_data+factorio_base_data+creative_mod"
+files["data-final-fixes.lua"].std = "lua52+factorio+factorio_data+factorio_base_data+creative_mod"
+files["settings.lua"].std = "lua52+factorio+factorio_data+creative_mod"
+files["prototypes/"].std = "lua52+factorio+factorio_data+factorio_base_data+creative_mod"
+
+-- defines.lua is loaded in both stages
+files["defines.lua"] = {
+ std = "lua52+factorio+creative_mod",
+}
diff --git a/comparison-report.html b/comparison-report.html
new file mode 100644
index 0000000..19a0ab4
--- /dev/null
+++ b/comparison-report.html
@@ -0,0 +1,1308 @@
+
+
+
+
+
+
CreativeMod vs EditorExtensions
+
Comprehensive analysis of two Factorio creative/testing mods — features, performance, architecture, and a roadmap for CreativeMod's future. Generated March 2026.
+
+
+
+
+
1. Overview & Identity
+
+
+
+
+
AuthorsY.Petremann, rk84, Mooncat, Chrisgbk, jodli
+
Factorio version2.0
+
Dependenciesbase >= 2.0.0
+
Lua files~35
+
PhilosophyFull cheat suite with normal gameplay
+
Core mechanicToggle-able cheats with access rights
+
Editor modeNot used — stays in character mode
+
+
+
+
+
Authorraiguard
+
Factorio version2.0
+
Dependenciesbase >= 2.0.42, flib >= 0.16.2
+
Lua files~25
+
PhilosophyEnhanced testing tools + editor toggle
+
Core mechanicMap editor toggle with inventory sync
+
Editor modeCentral — quick toggle with Ctrl+Alt+E
+
+
+
+
+
Fundamental Difference
+
CreativeMod gives you god-powers while playing normally with your character. You walk around, pick up items, ride trains — but you're invincible, run fast, build instantly, and have infinite resources. It's a cheat-enhanced normal game.
+
EditorExtensions gives you powerful testing tools and makes the map editor pleasant to use. You toggle between editor and character mode. When in editor, you have instant build/deconstruct natively. When in character, you're mostly normal (with some reach/speed bonuses from /cheat).
+
+
+
+
2. Feature Comparison Matrix
+
+
Player Cheats
+
+
+ | Feature |
+ CreativeMod |
+ EditorExtensions |
+
+
+ | Cheat mode (free crafting) |
+ Per-player toggle |
+ /cheat command |
+
+
+ | Invincible player |
+ Toggle per-player, destructible = false |
+ Not provided |
+
+
+ | Running speed boost |
+ Configurable modifier (default 2x) |
+ Super exoskeleton equipment (2x per) |
+
+
+ | Mining speed boost |
+ Configurable modifier (default 1000x) |
+ Not provided |
+
+
+ | Crafting speed boost |
+ Configurable modifier |
+ Cheat mode = instant |
+
+
+ | Long reach |
+ Personal + team level |
+ 1,000,000 bonus via /cheat |
+
+
+ | Instant blueprint |
+ Scripted: revive ghosts next tick |
+ Native editor feature (when in editor) |
+
+
+ | Instant deconstruction |
+ Scripted: destroy next tick |
+ Native editor feature (when in editor) |
+
+
+ | Instant request (logistics) |
+ Auto-fills logistic requests |
+ Not provided |
+
+
+ | Instant trash clear |
+ Auto-clears trash inventory |
+ Not provided |
+
+
+ | Keep last item in hand |
+ Restores cursor after placing |
+ Not provided |
+
+
+ | Repair mined items |
+ Full health on mine |
+ Not provided |
+
+
+ | God mode (no character) |
+ Toggle, transfers items |
+ Editor mode = god mode |
+
+
+ | Inventory bonus slots |
+ Configurable |
+ Not provided (editor has inf. inventory) |
+
+
+ | Health bonus |
+ Configurable |
+ Not provided |
+
+
+
+
Team / Force Cheats
+
+
+ | Feature |
+ CreativeMod |
+ EditorExtensions |
+
+
+ | Research all technologies |
+ One-click |
+ /cheat or debug world |
+
+
+ | Instant research |
+ Ongoing: complete on start |
+ Not provided |
+
+
+ | Team-wide reach/speed/etc. |
+ Full force-level modifiers |
+ Not provided |
+
+
+ | Inserter capacity bonus |
+ Configurable |
+ Not provided |
+
+
+ | Evolution factor control |
+ Set exact value per-force |
+ Not provided |
+
+
+ | Chart all map |
+ One-click |
+ Not provided (editor reveals map) |
+
+
+ | Kill all units |
+ One-click |
+ Not provided |
+
+
+
+
Surface / World Cheats
+
+
+ | Feature |
+ CreativeMod |
+ EditorExtensions |
+
+
+ | Freeze daytime |
+ Per-surface toggle |
+ Not provided (editor has render_as_day) |
+
+
+ | Set daytime |
+ Per-surface slider |
+ Not provided |
+
+
+ | Peaceful mode |
+ Per-surface toggle |
+ Not provided |
+
+
+ | Destroy/remove all enemies |
+ Per-surface |
+ Not provided |
+
+
+ | Prevent enemy spawning |
+ Per-surface, removes on chunk gen |
+ Not provided |
+
+
+ | Surface properties (pressure, gravity, mag field) |
+ Per-surface controls |
+ Not provided |
+
+
+
+
Global / Map Settings Cheats
+
+
+ | Feature |
+ CreativeMod |
+ EditorExtensions |
+
+
+ | Pollution toggle |
+ Yes |
+ No |
+
+
+ | Enemy evolution control |
+ Full control (time/destroy/pollution factors) |
+ No |
+
+
+ | Enemy expansion control |
+ Min/max cooldown |
+ No |
+
+
+ | Game speed |
+ 0.1x – 100x slider |
+ No |
+
+
+
+
Creative Entities
+
+
+ | Entity Type |
+ CreativeMod |
+ EditorExtensions |
+
+
+ | Item source chest (all items) |
+ Creative Chest + Creative Provider Chest |
+ Aggregate Chest + Aggregate Provider Chest (quality-aware) |
+
+
+ | Infinity chest |
+ Void chest, void requester, void storage |
+ 6 logistic variants (normal + all 5 logistics) |
+
+
+ | Duplicating chest |
+ Duplicating + Duplicating Provider |
+ Not provided |
+
+
+ | Item on belt source |
+ Matter Source (filter-based) |
+ Infinity Loader (1x1, per-lane, auto-snap, combinator-pasteable) |
+
+
+ | Item on belt void |
+ Matter Void |
+ Infinity Loader (bidirectional) |
+
+
+ | Item duplicator |
+ Duplicator entity |
+ Not provided |
+
+
+ | Random item source |
+ Random Item Source entity |
+ Not provided |
+
+
+ | Infinity pipe |
+ Fluid Source + Fluid Void |
+ Infinity Pipe (combinator-pasteable) |
+
+
+ | Electric source/sink |
+ 6 variants (active/passive + source/sink/interface) |
+ Infinity Accumulator with mode/priority/power GUI |
+
+
+ | Heat source/sink |
+ Heat Source + Heat Void (fixed temps) |
+ Infinity Heat Pipe (configurable temp) |
+
+
+ | Super boiler |
+ 3 variants (super, super cooler, configurable) |
+ Not provided |
+
+
+ | Cargo wagons |
+ Creative + Duplicating + Void wagon |
+ Infinity Cargo + Infinity Fluid Wagon |
+
+
+ | Linked chest/belt |
+ Linked Chest + Linked Belt |
+ Linked Chest + Linked Belt with visual connection UI |
+
+
+ | Super lab |
+ Creative Lab + Void Lab |
+ Super Lab (100x speed, void energy) |
+
+
+ | Super robots |
+ Invincible construction + logistic bots |
+ Speed 1M, no energy, 1000 payload |
+
+
+ | Super roboport |
+ Huge radius |
+ 200-tile logistics, 400-tile construction, 1000YW charging |
+
+
+ | Super radar |
+ Full map reveal |
+ 20-chunk reveal (more realistic) |
+
+
+ | Super beacon |
+ Huge range |
+ 64-tile range, 10 slots, allows productivity |
+
+
+ | Super inserter |
+ Not provided |
+ Void energy, fast rotation |
+
+
+ | Super locomotive |
+ Not provided |
+ 10MW void energy, max speed 10 |
+
+
+ | Super pump |
+ Not provided |
+ 0-600k fluid/s, custom GUI slider |
+
+
+ | Super electric pole |
+ Super pole + super substation |
+ Super pole + super substation (64-tile) |
+
+
+ | Enemy spawner items |
+ Alien attractor proxies (small/medium/large) |
+ Not provided |
+
+
+ | Cloned enemy entities |
+ Auto-generated for ALL enemies in game |
+ Not provided |
+
+
+ | Infinite resources |
+ Auto-generated infinite versions of all resources |
+ Not provided |
+
+
+
+
Equipment
+
+
+ | Equipment |
+ CreativeMod |
+ EditorExtensions |
+
+
+ | Fusion reactor |
+ 5.4PW, 1x1 |
+ 1000YW, 1x1, all categories |
+
+
+ | Roboport |
+ 1000 bots, 200 range (needs on_tick energy refill!) |
+ 1000 bots, 100 range, 1000GJ native charging |
+
+
+ | Exoskeleton |
+ Not provided |
+ +2 movement, 1kW, 1x1 |
+
+
+ | Energy shield |
+ Not provided |
+ 1M shield, 1x1 |
+
+
+ | Night vision |
+ Not provided |
+ Perfect daylight, 1x1 |
+
+
+ | Battery |
+ Not provided |
+ 1000YJ capacity, 1x1 |
+
+
+
+
Modules
+
+
+ | Module |
+ CreativeMod |
+ EditorExtensions |
+
+
+ | Super speed / efficiency / productivity |
+ Not provided |
+ +250% each, plus inverse variants |
+
+
+ | Super clean / dirty modules |
+ Not provided |
+ +-250% pollution |
+
+
+
+
Tools & Utilities
+
+
+ | Feature |
+ CreativeMod |
+ EditorExtensions |
+
+
+ | Magic wands (terrain editing) |
+ 3 wands: Creator, Healer, Modifier with pattern support |
+ Not provided (editor has native tile/entity editing) |
+
+
+ | Build options (destructible, minable, etc.) |
+ 6 toggles applied at build time |
+ Not provided |
+
+
+ | Free fluid recipes |
+ Auto-generated for all fluids |
+ Not provided (infinity pipe suffices) |
+
+
+ | Void technology (infinite research sink) |
+ Consumes 4B science packs |
+ Not provided |
+
+
+ | Testing lab (isolated surface) |
+ Not provided |
+ Personal or shared, with force/research isolation |
+
+
+ | Editor toggle |
+ Not provided |
+ Shortcut + keybind, with inventory sync |
+
+
+ | Inventory sync (editor ↔ character) |
+ Not provided |
+ Full sync of cursor, main, guns, armor, ammo |
+
+
+ | Inventory filter import/export |
+ Not provided |
+ Serializable filter presets |
+
+
+ | Access rights system |
+ 5-category tiered permissions |
+ Admin-only editor toggle |
+
+
+ | Remote API for other mods |
+ 16 remote functions |
+ 3 remote functions |
+
+
+ | In-game GUI menu |
+ Full tabbed menu (cheats, admin, wands, modding) |
+ Per-entity GUIs only |
+
+
+
+
+
3. Architecture & Code Quality
+
+
+
+
+
Strengths
+
+ - Comprehensive feature coverage
+ - Dedicated
defines.lua for all constants
+ - Remote interface for mod interop
+ - Rich access rights system
+
+
Weaknesses
+
+ - Monolithic event dispatcher — single
on_event for ~25 events with string-based lookup
+ - Every tick function called unconditionally (no
enabled guard)
+ - Legacy code remnants (old creative chest alongside new)
+ - No use of
flib or GUI library — manual GUI construction
+ - Entity registration via function lookup table (complex, hard to follow)
+ table.remove() during ipairs iteration (bug-prone)
+ - No type annotations or LSP support
+
+
+
+
+
+
Strengths
+
+ - Clean module system — each script exports
.events, .on_init, etc.
+ - Uses
flib for GUI, events, and utilities
+ - LuaLS type annotations (
types.lua)
+ - Event-driven architecture (minimal polling)
+ - Pre-cached API lookups for hot paths
+ - Self-cleaning migration code
+ - Clean data-phase prototype utilities (
copy_prototype, recursive_tint)
+
+
Weaknesses
+
+ - No event filters on build/destroy events (missed optimization)
+ - Infinity fluid wagon on_tick could be expensive with many wagons
+ - Depends on external library (flib)
+
+
+
+
+
+
+
+
CreativeMod: on_tick Cost
+
+
The on_tick handler calls 20 sub-tick functions every single tick, unconditionally, even when Creative Mode is disabled or no creative entities are placed:
+
+
+
+ | Tick Function | Work Per Tick | Cost |
+
+ gui.tick() |
+ Iterates ALL players, compares player.opened to cached value |
+ |
+
+
+ cheats.tick() |
+ 3 pending lists: instant blueprint, instant deconstruction, enemy removal |
+ |
+
+
+ creative_chest_util.tick() |
+ 1 chest per tick (spread across groups) |
+ |
+
+
+ creative_lab.tick() |
+ Up to 10 labs, inner loop over ALL tool items per lab |
+ 10/tick cap, but nested loop |
+
+
+ duplicating_chest.tick() |
+ Up to 10 chests per tick |
+ |
+
+
+ fluid_void.tick() |
+ ALL fluid voids, every tick |
+ |
+
+
+ super_boiler.tick() |
+ ALL super boilers, set energy + heat fluid |
+ |
+
+
+ item_source.tick() |
+ ALL item sources, + potential find_entities_filtered per entity |
+ Worst case: N entities × entity search |
+
+
+ duplicator.tick() |
+ ALL duplicators, same as item_source |
+ |
+
+
+ item_void.tick() |
+ ALL item voids, + potential entity search |
+ |
+
+
+ equipments.tick() |
+ ALL registered equipments, set energy |
+ Linear, but lightweight op |
+
+
+ random_item_source.tick() |
+ ALL random item sources |
+ |
+
+
+
+
+
Key Problems
+
+ - No early-out when CM is disabled. All 20 functions run even if
storage.creative_mode.enabled == false.
+ - gui.tick() polls player.opened every tick. Factorio has
on_gui_opened / on_gui_closed events that could replace this entirely.
+ - item_source / duplicator / item_void have no rate limiting and call
find_entities_filtered on cache misses, which can spike.
+ - fluid_void and super_boiler process ALL entities every tick with no batching.
+ table.remove() inside ipairs in equipments.tick() causes index skipping bugs.
+
+
+
EditorExtensions: on_tick Cost
+
+
+
+ | Tick Function | Work Per Tick | Cost |
+
+ infinity-wagon on_tick |
+ ALL infinity fluid wagons: validate, sync fluid, check position |
+ Linear with wagon count, but well-optimized (cached refs, flip-flop) |
+
+
+ infinity-loader on_nth_tick[15] |
+ Open loader GUIs only (typically 0-1) |
+ |
+
+
+ update-notification on_nth_tick[180] |
+ Legacy loaders (self-cleaning, temporary) |
+ |
+
+
+
+
+
+
Performance Verdict
+
EditorExtensions is dramatically more efficient. It has 1 on_tick handler (fluid wagons only) vs CreativeMod's 20 unconditional tick functions. EE achieves most of its functionality through Factorio's native infinity entities (which are C++-side, zero Lua cost) and event-driven handlers. CreativeMod's architecture dates from before infinity entities existed, which explains the scripted approach — but it's now a major performance liability.
+
+
+
+
5. Where EditorExtensions Wins
+
+
+
Performance
+
Nearly zero per-tick Lua cost. Most entities use Factorio's native infinity-container, infinity-pipe, and electric-energy-interface prototypes which run in C++ with zero scripting overhead. CreativeMod scripts what Factorio can do natively.
+
+
+
+
Infinity Loader
+
The standout entity. A 1x1 loader that auto-snaps to adjacent belts, supports per-lane filters, and can be copy-pasted with constant combinators. CreativeMod's Matter Source is more complex but less ergonomic — it's a separate source entity that needs to face the right direction, has no auto-snapping, and requires per-tick scripting.
+
+
+
+
Infinity Accumulator GUI
+
The custom GUI for the accumulator lets you set mode (input/output/buffer), priority (primary/secondary/tertiary), and exact power level from kW to YW. CreativeMod has 6 separate entity types for different EEI configurations. EE's approach is one entity with a rich GUI — much more user-friendly.
+
+
+
+
Testing Lab
+
An isolated testing surface per player (or shared per force) with its own research tree. You can test blueprints in a clean environment without affecting your main game. CreativeMod has no equivalent.
+
+
+
+
Editor Toggle + Inventory Sync
+
Seamless switching between character and editor mode with full inventory preservation. One keybind (Ctrl+Alt+E). CreativeMod doesn't use the editor at all, which means it has to script instant build/deconstruct manually (expensive).
+
+
+
+
Equipment Suite
+
6 equipment types covering all needs (reactor, roboport, exoskeleton, shield, night vision, battery), all 1x1, fitting all grid categories. CreativeMod has only 2 (reactor + roboport), and the roboport needs an on_tick energy refill hack.
+
+
+
+
Super Modules
+
7 module types (+250% and -250% variants for speed, efficiency, productivity, pollution). CreativeMod has none.
+
+
+
+
Quality Awareness
+
Aggregate chests create separate filter entries per quality level. CreativeMod doesn't account for the quality system introduced in Space Age.
+
+
+
+
Code Quality
+
Clean module architecture, flib usage, type annotations, no legacy code. Each script is self-contained with clear event exports. Much easier to maintain and extend.
+
+
+
+
6. Where CreativeMod Wins
+
+
+
Normal Gameplay Experience
+
This is CreativeMod's killer feature. You play the game normally — walk around as your character, ride in trains, get in vehicles, use the hotbar — but with god-like powers. EditorExtensions requires toggling to editor mode for instant build/deconstruct, which puts you in a different controller with a different feel. CreativeMod's instant blueprint and deconstruction work while you're in character mode.
+
+
+
+
Cheat Granularity
+
70+ individually toggleable cheats across 5 categories (personal, team, surface, global, build options). Everything is a slider or toggle. EditorExtensions is more of an all-or-nothing approach — you're either in editor or you're not.
+
+
+
+
Multiplayer Access Control
+
A full rights system with admin-only, own-team-only, current-surface-only, and free access levels. Each cheat category has its own permission tier. Perfect for multiplayer servers where you want some players to have creative powers but not all. EditorExtensions only has admin-gated editor toggle.
+
+
+
+
Enemy Interaction
+
Alien attractors that spawn enemy bases on demand. Auto-generated placeable clones of every enemy in the game (spawners, worms, units). Enemy destruction/removal per surface. Evolution factor control. None of this exists in EditorExtensions.
+
+
+
+
Magic Wands
+
Three selection tools for terrain editing (tile painting with patterns, resource creation, entity healing/killing, property modification). These work in normal gameplay without entering the editor. EditorExtensions relies on the native editor for these operations.
+
+
+
+
World Control
+
Surface-level controls for daytime, peaceful mode, enemy spawning, surface properties (gravity, pressure, magnetic field for Space Age). Global controls for pollution, evolution, expansion, game speed. EditorExtensions has none of these.
+
+
+
+
Infinite Resources
+
Auto-generates infinite versions of every resource in the game, placeable from inventory. Useful for testing mining setups without resource depletion.
+
+
+
+
Remote API
+
16 remote interface functions for other mods to interact with CreativeMod (enable/disable events, blacklists for instant blueprint/deconstruction, modding UI hooks). EditorExtensions has 3.
+
+
+
+
In-Game GUI
+
A full tabbed menu accessible from a toolbar button, with pages for cheats, admin rights, magic wand settings, and modding tools. Everything is discoverable and accessible without console commands. EditorExtensions requires /cheat console commands.
+
+
+
+
7. Feature Gaps Analysis
+
+
What CreativeMod is missing (that EE has)
+
+ | Gap | Impact | Difficulty to Add |
+
+ | Super modules (+250% speed/efficiency/productivity/pollution) |
+ Medium — useful for testing factory designs |
+ Easy — data-only, no scripting needed |
+
+
+ | Super exoskeleton, energy shield, night vision, battery equipment |
+ Medium — quality of life |
+ Easy — data-only |
+
+
+ | Super inserter |
+ Low — niche |
+ Easy — data-only |
+
+
+ | Super locomotive |
+ Low — niche |
+ Easy — data-only |
+
+
+ | Super pump with adjustable speed GUI |
+ Medium — useful for fluid testing |
+ Medium — needs GUI + hidden fluid trick |
+
+
+ | Infinity loader (1x1, auto-snap, per-lane) |
+ High — much better UX than matter source |
+ Medium — need hidden chest + snap logic |
+
+
+ | Testing lab (isolated surface) |
+ High — great for blueprint testing |
+ Medium — surface/force management |
+
+
+ | Quality-aware aggregate chest |
+ High for Space Age — quality is core mechanic |
+ Easy — iterate quality prototypes in data-final-fixes |
+
+
+ | Super fuel item |
+ Low |
+ Easy — data-only |
+
+
+ | Combinator-paste for infinity entities |
+ Medium — UX improvement |
+ Easy — on_entity_settings_pasted handler |
+
+
+
+
What EditorExtensions is missing (that CM has)
+
+ | Gap | Impact | Why EE doesn't have it |
+
+ | Per-player character cheats (invincible, speed, mining, etc.) |
+ High — the core "play normally with cheats" experience |
+ Different philosophy: EE uses editor mode instead |
+
+
+ | Instant blueprint/deconstruct in character mode |
+ High — key UX difference |
+ EE delegates this to native editor capabilities |
+
+
+ | Team/surface/global cheat controls |
+ High for sandbox play |
+ Out of scope for EE's "testing tools" focus |
+
+
+ | Magic wands (terrain, healer, modifier) |
+ Medium — creative building tool |
+ Editor has native tile/entity editing |
+
+
+ | Enemy interaction (attractors, placeable enemies) |
+ Medium — useful for testing defenses |
+ Not in scope |
+
+
+ | Access rights system |
+ High for multiplayer servers |
+ Not in scope |
+
+
+ | In-game GUI menu |
+ Medium — discoverability |
+ EE uses per-entity GUIs + console |
+
+
+ | Evolution/expansion/pollution controls |
+ Medium |
+ Not in scope |
+
+
+ | Game speed control |
+ Medium |
+ Not in scope |
+
+
+ | Infinite resource entities |
+ Low-Medium |
+ Not in scope |
+
+
+ | Keep-last-item / repair-mined-item |
+ Medium QoL |
+ Not in scope |
+
+
+
+
+
8. Roadmap: CreativeMod Next Gen
+
+
Here's a prioritized improvement plan for bringing CreativeMod to the next level, leveraging Factorio 2.0/Space Age capabilities while preserving its unique "play normally with cheats" identity.
+
+
Phase 1: Performance Overhaul (High Priority)
+
+
+
Critical
+
Add an enabled guard to on_tick
+
Wrap the entire tick body in if not storage.creative_mode.enabled then return end. Currently all 20 tick functions run even when CM is disabled. This is the single biggest quick win.
+
+
+
+
Critical
+
Replace gui.tick() polling with events
+
The GUI tick polls player.opened for all players every tick. Replace with on_gui_opened and on_gui_closed events. This eliminates a per-player-per-tick loop entirely.
+
+
+
+
Critical
+
Replace scripted fluid void with native infinity-pipe
+
The fluid void currently iterates all entities every tick and clears fluidboxes in Lua. Factorio's native infinity-pipe with remove_unfiltered_fluids = true does this in C++ with zero Lua cost. The creative chest already uses infinity-container — apply the same pattern to fluid void.
+
+
+
+
Critical
+
Replace scripted super boiler with native heat-interface
+
Super boilers set energy = 1e15 and heat fluid every tick in Lua. A heat-interface prototype with mode = "at-least" achieves this natively with zero tick cost.
+
+
+
+
Critical
+
Add event filters to build/destroy events
+
Register on_built_entity, on_robot_built_entity, on_player_mined_entity, etc. with name filters for only CreativeMod entities. This lets the engine skip the Lua call entirely for non-CM entities, which is the vast majority in a normal game.
+
script.on_event(defines.events.on_built_entity, handler, {
+ {filter = "name", name = "creative-mod_item-source"},
+ {filter = "name", name = "creative-mod_fluid-source"},
+ -- ... etc
+})
+
+
+
+
Critical
+
Add rate limiting to item_source / duplicator / item_void
+
These currently process ALL entities every tick with no cap. Apply the same "10 per tick" round-robin pattern used by duplicating chests. Also, use register_on_object_destroyed instead of checking entity.valid in the loop.
+
+
+
+
Important
+
Replace equipment energy refill with prototype-level solution
+
The equipments.tick() sets equipment.energy = 1e25 for every registered equipment every tick. Instead, give the equipment prototype a sufficiently large energy_source.buffer_capacity and energy_source.input_flow_limit so it self-charges. Or use the super fusion reactor equipment (like EE does) with enough output to keep everything charged.
+
+
+
+
Important
+
Use on_nth_tick for non-critical updates
+
For entities that don't need per-tick updates (creative labs, void labs, duplicating chests), move to on_nth_tick with appropriate intervals (5-15 ticks). The visual difference is imperceptible but the CPU savings are proportional.
+
+
+
+
Important
+
Fix table.remove() during ipairs
+
In equipments.tick() and other places, table.remove() is called during forward ipairs iteration, which skips elements. Iterate in reverse or use a separate removal pass.
+
+
+
Phase 2: Feature Modernization (Medium Priority)
+
+
+
Important
+
Add Space Age quality support
+
Creative chests and aggregate chests should include items at all quality levels. Iterate prototypes.quality in data-final-fixes.lua and create filter entries for each quality tier. This is essential for Space Age compatibility.
+
+
+
+
Important
+
Add super modules
+
Data-only addition: 7 module prototypes (+250% speed/efficiency/productivity/clean and inverse variants). No scripting needed. Copy EE's approach.
+
+
+
+
Important
+
Complete the equipment suite
+
Add super exoskeleton, energy shield, night vision, and battery equipment. All data-only, no scripting. This also eliminates the need for the equipments.tick() energy refill hack if the fusion reactor provides enough power.
+
+
+
+
Important
+
Add an infinity loader entity
+
A 1x1 loader-1x1 with per_lane_filters = true and a hidden infinity chest. Auto-snap to adjacent belts. This would replace or complement the existing Matter Source with a much more ergonomic UX and zero per-tick cost.
+
+
+
+
Important
+
Add a testing lab feature
+
Create an isolated surface per player for blueprint testing. Integrate with the existing GUI menu — a "Testing Lab" button that teleports you to a clean lab-tile surface with all research. Preserve the character (don't enter editor), so it fits CM's philosophy.
+
+
+
+
Important
+
Add Space Age surface controls
+
The surface cheats already have pressure/gravity/magnetic-field controls. Extend with platform-related cheats: list and teleport to space platforms, set platform state, eject/clear items. Add planet navigation shortcuts.
+
+
+
Phase 3: Architecture Refresh (Lower Priority)
+
+
+
Nice to have
+
Adopt flib for GUI construction
+
The manual GUI code in gui-menu-cheats.lua (3000+ lines) would benefit enormously from flib's declarative GUI builder. This also brings free event routing, standard styling, and easier maintenance.
+
+
+
+
Nice to have
+
Modularize the event system
+
Replace the monolithic event dispatcher with per-module event tables (like EE does). Each script exports its events, and control.lua merges them. This makes it easy to add/remove features and improves code readability.
+
+
+
+
Nice to have
+
Add LuaLS type annotations
+
Add a types.lua with ---@class and ---@field annotations for all storage structures. This enables IDE support and catches bugs at development time.
+
+
+
+
Nice to have
+
Clean up legacy entity code
+
Remove old creative chest code path (pre-infinity-container). Remove the unused autofill requester chest tick (already commented out). Consolidate the 6 EEI entity variants into a single entity with a mode-selection GUI (like EE's accumulator).
+
+
+
+
Nice to have
+
Use register_on_object_destroyed
+
Instead of checking entity.valid in every tick loop and calling table.remove(), register entities with register_on_object_destroyed and handle cleanup in the on_object_destroyed event. This is cleaner and removes validity checks from hot paths.
+
+
+
The Dream: Best of Both Worlds
+
+
+
The Vision
+
CreativeMod's unique value proposition is "play the game normally, but with superpowers". No other mod does this as comprehensively. The path forward is clear:
+
+ - Keep the soul: Normal character gameplay with toggle-able cheats and rich controls. This is what players love.
+ - Steal the engine: Replace scripted entity behavior with native Factorio prototypes wherever possible (infinity containers, infinity pipes, heat interfaces). This eliminates 80%+ of the on_tick cost.
+ - Borrow the polish: Add EE's best entities (infinity loader, infinity accumulator GUI, super modules, full equipment suite). These are additive — they don't replace CM's identity.
+ - Embrace Space Age: Quality support, platform controls, surface property management. CreativeMod already has surface cheats — extending to space platforms is natural.
+
+
With Phase 1 performance fixes alone, CreativeMod could go from "noticeably impacts UPS" to "nearly zero overhead" while keeping all its unique features. Combined with Phase 2's feature additions, it would be the definitive creative mod for Factorio 2.0.
+
+
+
+
+
diff --git a/control.lua b/control.lua
index c8b3835..e933562 100644
--- a/control.lua
+++ b/control.lua
@@ -56,12 +56,14 @@ script.on_event(defines.events.on_player_trash_inventory_changed, events.on_play
-- Other events.
local events_except_on_tick = {}
for _, event in pairs(defines.events) do
- if event ~= defines.events.on_tick
- and event ~= defines.events.on_player_main_inventory_changed
- and event ~= defines.events.on_entity_logistic_slot_changed
- and event ~= defines.events.on_player_trash_inventory_changed then
- table.insert(events_except_on_tick, event)
- end
+ if
+ event ~= defines.events.on_tick
+ and event ~= defines.events.on_player_main_inventory_changed
+ and event ~= defines.events.on_entity_logistic_slot_changed
+ and event ~= defines.events.on_player_trash_inventory_changed
+ then
+ table.insert(events_except_on_tick, event)
+ end
end
script.on_event(events_except_on_tick, events.on_event)
diff --git a/data-final-fixes.lua b/data-final-fixes.lua
index c79be7d..46309c7 100644
--- a/data-final-fixes.lua
+++ b/data-final-fixes.lua
@@ -1,29 +1,29 @@
-- Create free recipe for each fluid.
for _, fluid in pairs(data.raw["fluid"]) do
- if fluid.name ~= "fluid-unknown" then
- local entity_localised_name
- -- Use their original name.
- if fluid.localised_name then
- entity_localised_name = fluid.localised_name
- else
- entity_localised_name = { "fluid-name." .. fluid.name }
- end
- data:extend({
- {
- type = "recipe",
- name = creative_mode_defines.names.free_fluid_recipe_prefix .. fluid.name,
- localised_name = entity_localised_name,
- category = creative_mode_defines.names.recipe_categories.free_fluids,
- ingredients = {},
- results = {
- { type = "fluid", name = fluid.name, amount = 5000 },
- },
- main_product = fluid.name,
- subgroup = creative_mode_defines.names.item_subgroups.free_fluids,
- enabled = false,
- },
- })
- end
+ if fluid.name ~= "fluid-unknown" then
+ local entity_localised_name
+ -- Use their original name.
+ if fluid.localised_name then
+ entity_localised_name = fluid.localised_name
+ else
+ entity_localised_name = { "fluid-name." .. fluid.name }
+ end
+ data:extend({
+ {
+ type = "recipe",
+ name = creative_mode_defines.names.free_fluid_recipe_prefix .. fluid.name,
+ localised_name = entity_localised_name,
+ category = creative_mode_defines.names.recipe_categories.free_fluids,
+ ingredients = {},
+ results = {
+ { type = "fluid", name = fluid.name, amount = 5000 },
+ },
+ main_product = fluid.name,
+ subgroup = creative_mode_defines.names.item_subgroups.free_fluids,
+ enabled = false,
+ },
+ })
+ end
end
-- Some mods (e.g. Bob's Modules) add limitations to all productivity modules. But we want our super productivity module to be limitless.
@@ -33,135 +33,134 @@ data.raw["module"][creative_mode_defines.names.recipes.super_productivity_module
-- All possible data raw names for items that have place results of entities.
local possible_data_raw_types_for_items_of_entities = {
- "item",
- "item-with-entity-data", -- 0.13
- "item-with-label", -- 0.13
+ "item",
+ "item-with-entity-data", -- 0.13
+ "item-with-label", -- 0.13
}
-- Make a dictionary for recording all items' place results, so we can find whether the items for the enemy worms and spawners already exist.
local item_place_results = {}
for _, raw_name in pairs(possible_data_raw_types_for_items_of_entities) do
- local data_raw = data.raw[raw_name]
- if data_raw then
- for _, item in pairs(data_raw) do
- if item.place_result then
- item_place_results[item.place_result] = true
- end
- end
- end
+ local data_raw = data.raw[raw_name]
+ if data_raw then
+ for _, item in pairs(data_raw) do
+ if item.place_result then
+ item_place_results[item.place_result] = true
+ end
+ end
+ end
end
-- Returns whether there is already an item for the given entity.
local function has_item_for_enemy_entity(entity)
- return item_place_results[entity.name] == true
+ return item_place_results[entity.name] == true
end
-- Make a dictionary for recording all spawner's result units, so we can find whether a unit is really spawnable.
local spawnable_units = {}
local unit_spawners = data.raw["unit-spawner"]
if unit_spawners then
- for _, spawner in pairs(unit_spawners) do
- local result_units = spawner.result_units
- if result_units then
- for _, unit_data in pairs(result_units) do
- spawnable_units[unit_data[1] or unit_data.unit] = true
- end
- end
- end
+ for _, spawner in pairs(unit_spawners) do
+ local result_units = spawner.result_units
+ if result_units then
+ for _, unit_data in pairs(result_units) do
+ spawnable_units[unit_data[1] or unit_data.unit] = true
+ end
+ end
+ end
end
-- Returns whether there is a spawner that can spawn the given entity.
local function has_spawner_for_enemy_unit(entity)
- return spawnable_units[entity.name] == true
+ return spawnable_units[entity.name] == true
end
-- Clones the enemy entities in the given data raw and creates item and recipe for them.
-- It will not touch those entities that already have an item to build it.
local function clone_enemy_entities_in_data_raw_and_create_recipe(raw_name)
- if not data.raw[raw_name] then
- return
- end
+ if not data.raw[raw_name] then
+ return
+ end
- -- We will extend the data after the following for-loop, to avoid problem caused by altering the iterating list.
- local new_data = {}
- for _, entity in pairs(data.raw[raw_name]) do
- -- Add item and recipe only if
- -- a) for structures: there is no item for the entity. If there is already an item, there is high chance that its recipe is also there.
- -- b) for units: there is spawner for the unit. If there is no spawner for the unit, there is high chance that the unit is created by script for special purpose.
- if
- (raw_name == "unit" and has_spawner_for_enemy_unit(entity))
- or (raw_name ~= "unit" and not has_item_for_enemy_entity(entity))
- then
- local entity_name = creative_mode_defines.names.enemy_entity_prefix .. entity.name
- local entity_localised_name
- if settings.startup[creative_mode_defines.names.settings.enemy_structures_add_name_suffix].value then
- -- Add suffix to these new spawners and worms.
- if entity.localised_name then
- entity_localised_name = { "entity-name.creative-mode_enemy-object", entity.localised_name }
- else
- entity_localised_name =
- { "entity-name.creative-mode_enemy-object", "__ENTITY__" .. entity.name .. "__" }
- end
- else
- -- Use their original name.
- if entity.localised_name then
- entity_localised_name = entity.localised_name
- else
- entity_localised_name = { "entity-name." .. entity.name }
- end
- end
- local item_name = creative_mode_defines.names.enemy_item_prefix .. entity.name
- local recipe_name = creative_mode_defines.names.enemy_recipe_prefix .. entity.name
+ -- We will extend the data after the following for-loop, to avoid problem caused by altering the iterating list.
+ local new_data = {}
+ for _, entity in pairs(data.raw[raw_name]) do
+ -- Add item and recipe only if
+ -- a) for structures: there is no item for the entity. If there is already an item, there is high chance that its recipe is also there.
+ -- b) for units: there is spawner for the unit. If there is no spawner for the unit, there is high chance that the unit is created by script for special purpose.
+ if
+ (raw_name == "unit" and has_spawner_for_enemy_unit(entity))
+ or (raw_name ~= "unit" and not has_item_for_enemy_entity(entity))
+ then
+ local entity_name = creative_mode_defines.names.enemy_entity_prefix .. entity.name
+ local entity_localised_name
+ if settings.startup[creative_mode_defines.names.settings.enemy_structures_add_name_suffix].value then
+ -- Add suffix to these new spawners and worms.
+ if entity.localised_name then
+ entity_localised_name = { "entity-name.creative-mode_enemy-object", entity.localised_name }
+ else
+ entity_localised_name = { "entity-name.creative-mode_enemy-object", "__ENTITY__" .. entity.name .. "__" }
+ end
+ else
+ -- Use their original name.
+ if entity.localised_name then
+ entity_localised_name = entity.localised_name
+ else
+ entity_localised_name = { "entity-name." .. entity.name }
+ end
+ end
+ local item_name = creative_mode_defines.names.enemy_item_prefix .. entity.name
+ local recipe_name = creative_mode_defines.names.enemy_recipe_prefix .. entity.name
- -- Clone the entity.
- -- We don't use the original entity because that will make their corpse collide with our structures.
- local new_entity = util.table.deepcopy(entity)
- new_entity.name = entity_name
- new_entity.flags = { "player-creation" } -- Reset the flags so it is blueprintable and repairable.
- new_entity.localised_name = entity_localised_name
- -- Make the entity minable.
- new_entity.minable = { hardness = 0.2, mining_time = 0.5, result = item_name }
- -- No autoplace.
- new_entity.autoplace = nil
- if not settings.startup[creative_mode_defines.names.settings.unhide_items].value then
- new_entity.hidden = true
- end
- table.insert(new_data, new_entity)
- -- Support for composed icons.
- local icons = entity.icons
- if icons then
- fixed_icons = icons
- else
- fixed_icons = {
- { icon = entity.icon },
- }
- end
- -- Create item for the entity.
- table.insert(new_data, {
- type = "item",
- name = item_name,
- localised_name = entity_localised_name, -- Item does not know the entity's custom localised name, so we have to also use custom localised name for it.
- icon_size = entity.icon_size,
- icon_mipmaps = entity.icon_mipmaps,
- icons = fixed_icons,
- subgroup = creative_mode_defines.names.item_subgroups.enemies,
- --order = entity.order,
- place_result = entity_name,
- stack_size = 50,
- })
- -- And recipe.
- table.insert(new_data, {
- type = "recipe",
- name = recipe_name,
- category = creative_mode_defines.names.recipe_categories.enemies,
- ingredients = {},
- results = { { type = "item", name = item_name, amount = 1 } },
- enabled = false,
- })
- end
- end
+ -- Clone the entity.
+ -- We don't use the original entity because that will make their corpse collide with our structures.
+ local new_entity = util.table.deepcopy(entity)
+ new_entity.name = entity_name
+ new_entity.flags = { "player-creation" } -- Reset the flags so it is blueprintable and repairable.
+ new_entity.localised_name = entity_localised_name
+ -- Make the entity minable.
+ new_entity.minable = { hardness = 0.2, mining_time = 0.5, result = item_name }
+ -- No autoplace.
+ new_entity.autoplace = nil
+ if not settings.startup[creative_mode_defines.names.settings.unhide_items].value then
+ new_entity.hidden = true
+ end
+ table.insert(new_data, new_entity)
+ -- Support for composed icons.
+ local icons = entity.icons
+ if icons then
+ fixed_icons = icons
+ else
+ fixed_icons = {
+ { icon = entity.icon },
+ }
+ end
+ -- Create item for the entity.
+ table.insert(new_data, {
+ type = "item",
+ name = item_name,
+ localised_name = entity_localised_name, -- Item does not know the entity's custom localised name, so we have to also use custom localised name for it.
+ icon_size = entity.icon_size,
+ icon_mipmaps = entity.icon_mipmaps,
+ icons = fixed_icons,
+ subgroup = creative_mode_defines.names.item_subgroups.enemies,
+ --order = entity.order,
+ place_result = entity_name,
+ stack_size = 50,
+ })
+ -- And recipe.
+ table.insert(new_data, {
+ type = "recipe",
+ name = recipe_name,
+ category = creative_mode_defines.names.recipe_categories.enemies,
+ ingredients = {},
+ results = { { type = "item", name = item_name, amount = 1 } },
+ enabled = false,
+ })
+ end
+ end
- -- Extend data.
- if #new_data > 0 then
- data:extend(new_data)
- end
+ -- Extend data.
+ if #new_data > 0 then
+ data:extend(new_data)
+ end
end
-- Worms.
@@ -176,11 +175,11 @@ clone_enemy_entities_in_data_raw_and_create_recipe("unit")
-- Absolute resistance.
local resistances = {}
for _, damage_type in pairs(data.raw["damage-type"]) do
- local damage_type_name = damage_type.name
- table.insert(resistances, {
- type = damage_type_name,
- percent = 100,
- })
+ local damage_type_name = damage_type.name
+ table.insert(resistances, {
+ type = damage_type_name,
+ percent = 100,
+ })
end
-- Make the super robots to have absolute resistance.
@@ -192,7 +191,7 @@ data.raw["construction-robot"][creative_mode_defines.names.entities.super_constr
-- Allow the creative lab to accept all research materials.
local tools = {}
for _, tool in pairs(data.raw["tool"]) do
- table.insert(tools, tool.name)
+ table.insert(tools, tool.name)
end
data.raw["lab"][creative_mode_defines.names.entities.creative_lab].inputs = tools
@@ -204,122 +203,119 @@ local data_raw_resource = data.raw["resource"]
-- Record all infinite minables first.
local infinite_minables = {}
for _, resource in pairs(data_raw_resource) do
- if resource.infinite then
- local minable = resource.minable
- if minable then
- local results = minable.results
- if results then
- for _, result in pairs(results) do
- local result_name = (result.type or "item") .. "." .. (result.name or result[1])
- infinite_minables[result_name] = true
- end
- else
- local result = minable.result
- if result then
- local result_name = (minable.type or "item") .. "." .. result
- infinite_minables[result_name] = true
- end
- end
- end
- end
+ if resource.infinite then
+ local minable = resource.minable
+ if minable then
+ local results = minable.results
+ if results then
+ for _, result in pairs(results) do
+ local result_name = (result.type or "item") .. "." .. (result.name or result[1])
+ infinite_minables[result_name] = true
+ end
+ else
+ local result = minable.result
+ if result then
+ local result_name = (minable.type or "item") .. "." .. result
+ infinite_minables[result_name] = true
+ end
+ end
+ end
+ end
end
-- Find all resources that don't have the corresponding infinite minables.
local finite_resource_names = {}
for _, resource in pairs(data_raw_resource) do
- if not resource.infinite then
- local minable = resource.minable
- if minable then
- local results = minable.results
- if results then
- local results_count = #results
- for _, result in pairs(results) do
- local result_name = (result.type or "item") .. "." .. (result.name or result[1])
- if infinite_minables[result_name] then
- results_count = results_count - 1
- end
- end
- if results_count > 0 then
- table.insert(finite_resource_names, resource.name)
- end
- else
- local result = minable.result
- if result then
- local result_name = (minable.type or "item") .. "." .. result
- if not infinite_minables[result_name] then
- table.insert(finite_resource_names, resource.name)
- end
- end
- end
- end
- end
+ if not resource.infinite then
+ local minable = resource.minable
+ if minable then
+ local results = minable.results
+ if results then
+ local results_count = #results
+ for _, result in pairs(results) do
+ local result_name = (result.type or "item") .. "." .. (result.name or result[1])
+ if infinite_minables[result_name] then
+ results_count = results_count - 1
+ end
+ end
+ if results_count > 0 then
+ table.insert(finite_resource_names, resource.name)
+ end
+ else
+ local result = minable.result
+ if result then
+ local result_name = (minable.type or "item") .. "." .. result
+ if not infinite_minables[result_name] then
+ table.insert(finite_resource_names, resource.name)
+ end
+ end
+ end
+ end
+ end
end
-- Create infinite version of the recorded resources.
for _, name in pairs(finite_resource_names) do
- local resource = util.table.deepcopy(data_raw_resource[name])
- resource.name = creative_mode_defines.names.infinite_resource_prefix .. name
- if resource.localised_name then
- resource.localised_name = { "entity-name.creative-mode_infinite-resource", resource.localised_name }
- else
- resource.localised_name = { "entity-name.creative-mode_infinite-resource", "__ENTITY__" .. name .. "__" }
- end
- local icons = resource.icons
- if icons then
- if resource.icon_size == 32 then
- table.insert(icons, {
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/infinite-resource-32.png",
- icon_size = 32,
- })
- elseif resource.icon_size == 64 then
- table.insert(
- icons,
- { icon = creative_mode_defines.mod_directory .. "/graphics/icons/infinite-resource-64.png" }
- )
- end
- else
- if resource.icon_size == 32 then
- resource.icons = {
- { icon = resource.icon, icon_size = 32 },
- {
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/infinite-resource-32.png",
- icon_size = 32,
- },
- }
- elseif resource.icon_size == 64 then
- resource.icons = {
- { icon = resource.icon },
- { icon = creative_mode_defines.mod_directory .. "/graphics/icons/infinite-resource-64.png" },
- }
- end
- end
- resource.infinite = true
- resource.minimum = 60000
- resource.normal = 300000
- resource.infinite_depletion_amount = 10
- resource.resource_patch_search_radius = 1
- local minable = resource.minable
- if minable then
- local results = minable.results
- if results then
- for _, result in pairs(results) do
- result.amount_min = 10
- result.amount_max = 10
- if not result.name then
- result.name = result[1]
- result[1] = nil
- result[2] = nil
- end
- end
- else
- local result = minable.result
- if result then
- minable.amount_min = 10
- minable.amount_max = 10
- end
- end
- end
- resource.autoplace = nil
+ local resource = util.table.deepcopy(data_raw_resource[name])
+ resource.name = creative_mode_defines.names.infinite_resource_prefix .. name
+ if resource.localised_name then
+ resource.localised_name = { "entity-name.creative-mode_infinite-resource", resource.localised_name }
+ else
+ resource.localised_name = { "entity-name.creative-mode_infinite-resource", "__ENTITY__" .. name .. "__" }
+ end
+ local icons = resource.icons
+ if icons then
+ if resource.icon_size == 32 then
+ table.insert(icons, {
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/infinite-resource-32.png",
+ icon_size = 32,
+ })
+ elseif resource.icon_size == 64 then
+ table.insert(icons, { icon = creative_mode_defines.mod_directory .. "/graphics/icons/infinite-resource-64.png" })
+ end
+ else
+ if resource.icon_size == 32 then
+ resource.icons = {
+ { icon = resource.icon, icon_size = 32 },
+ {
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/infinite-resource-32.png",
+ icon_size = 32,
+ },
+ }
+ elseif resource.icon_size == 64 then
+ resource.icons = {
+ { icon = resource.icon },
+ { icon = creative_mode_defines.mod_directory .. "/graphics/icons/infinite-resource-64.png" },
+ }
+ end
+ end
+ resource.infinite = true
+ resource.minimum = 60000
+ resource.normal = 300000
+ resource.infinite_depletion_amount = 10
+ resource.resource_patch_search_radius = 1
+ local minable = resource.minable
+ if minable then
+ local results = minable.results
+ if results then
+ for _, result in pairs(results) do
+ result.amount_min = 10
+ result.amount_max = 10
+ if not result.name then
+ result.name = result[1]
+ result[1] = nil
+ result[2] = nil
+ end
+ end
+ else
+ local result = minable.result
+ if result then
+ minable.amount_min = 10
+ minable.amount_max = 10
+ end
+ end
+ end
+ resource.autoplace = nil
- data:extend({ resource })
+ data:extend({ resource })
end
diff --git a/data.lua b/data.lua
index 21b8239..16ceb00 100644
--- a/data.lua
+++ b/data.lua
@@ -11,5 +11,5 @@ require("prototypes.style")
require("prototypes.sprite")
if not util.array_contains_key(mods, "space-exploration-postprocess") then
- require("prototypes.technology")
+ require("prototypes.technology")
end
diff --git a/defines.lua b/defines.lua
index 0d6a77c..3dfe959 100644
--- a/defines.lua
+++ b/defines.lua
@@ -16,22 +16,22 @@ creative_mode_defines.empty_png = {}
creative_mode_defines.empty_png.path = "__core__/graphics/empty.png"
-- Data about the empty.png
creative_mode_defines.empty_png.data = {
- filename = creative_mode_defines.empty_png.path,
- priority = "extra-high",
- width = 1,
- height = 1,
+ filename = creative_mode_defines.empty_png.path,
+ priority = "extra-high",
+ width = 1,
+ height = 1,
}
creative_mode_defines.empty_animation = {
- filename = creative_mode_defines.empty_png.path,
- priority = "extra-high",
- width = 1,
- height = 1,
- frame_count = 1,
+ filename = creative_mode_defines.empty_png.path,
+ priority = "extra-high",
+ width = 1,
+ height = 1,
+ frame_count = 1,
}
-- Better data for energy source for creative tools that don't require electricity.
creative_mode_defines.non_electric_energy_source = {
- type = "void", -- Old one used burner, that is no longer necessary.
+ type = "void", -- Old one used burner, that is no longer necessary.
}
-- Names and values
@@ -40,1366 +40,1343 @@ creative_mode_defines.values = {}
-- Setting names
creative_mode_defines.names.settings = {
- default_initial_action = creative_mode_defines.name_prefix .. "default-initial-action",
- unhide_items = creative_mode_defines.name_prefix .. "unhide-items",
- creative_chest_size = creative_mode_defines.name_prefix .. "creative-chest-size",
- creative_chest_contains_hidden_items = creative_mode_defines.name_prefix .. "creative-chest-contains-hidden-items",
- autofill_requester_chest_size = creative_mode_defines.name_prefix .. "autofill-requester-chest-size",
- duplicating_chest_size = creative_mode_defines.name_prefix .. "duplicating-chest-size",
- void_requester_chest_size = creative_mode_defines.name_prefix .. "void-requester-chest-size",
- void_chest_size = creative_mode_defines.name_prefix .. "void-chest-size",
- void_storage_chest_size = creative_mode_defines.name_prefix .. "void-storage-chest-size",
- time_for_void_technology = creative_mode_defines.name_prefix .. "time-for-void-technology",
- creative_cargo_wagon_size = creative_mode_defines.name_prefix .. "creative-cargo-wagon-size",
- creative_cargo_wagon_contains_hidden_items = creative_mode_defines.name_prefix
- .. "creative-cargo-wagon-contains-hidden-items",
- duplicating_cargo_wagon_size = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon-size",
- void_cargo_wagon_size = creative_mode_defines.name_prefix .. "void-cargo-wagon-size",
- enemy_structures_add_name_suffix = creative_mode_defines.name_prefix .. "enemy-structures-add-name-suffix",
- infinity_chest_control = creative_mode_defines.name_prefix .. "infinity-chest-control",
- enable_invincible_player_by_default = creative_mode_defines.name_prefix .. "enable-invincible-player-by-default",
- enable_instant_blueprint_by_default = creative_mode_defines.name_prefix .. "enable-instant-blueprint-by-default",
- enable_instant_deconstruction_by_default = creative_mode_defines.name_prefix
- .. "enable-instant-deconstruction-by-default",
- enable_personal_long_reach_by_default = creative_mode_defines.name_prefix
- .. "enable-personal-long-reach-by-default",
- enable_personal_fast_run_by_default = creative_mode_defines.name_prefix .. "enable-personal-fast-run-by-default",
- default_technology_research_cheat_type = creative_mode_defines.name_prefix
- .. "default-technology-research-cheat-type",
- override_evolution_factor_by_default = creative_mode_defines.name_prefix .. "override-evolution-factor-by-default",
- default_evolution_factor = creative_mode_defines.name_prefix .. "default-evolution-factor",
+ default_initial_action = creative_mode_defines.name_prefix .. "default-initial-action",
+ unhide_items = creative_mode_defines.name_prefix .. "unhide-items",
+ creative_chest_size = creative_mode_defines.name_prefix .. "creative-chest-size",
+ creative_chest_contains_hidden_items = creative_mode_defines.name_prefix .. "creative-chest-contains-hidden-items",
+ autofill_requester_chest_size = creative_mode_defines.name_prefix .. "autofill-requester-chest-size",
+ duplicating_chest_size = creative_mode_defines.name_prefix .. "duplicating-chest-size",
+ void_requester_chest_size = creative_mode_defines.name_prefix .. "void-requester-chest-size",
+ void_chest_size = creative_mode_defines.name_prefix .. "void-chest-size",
+ void_storage_chest_size = creative_mode_defines.name_prefix .. "void-storage-chest-size",
+ time_for_void_technology = creative_mode_defines.name_prefix .. "time-for-void-technology",
+ creative_cargo_wagon_size = creative_mode_defines.name_prefix .. "creative-cargo-wagon-size",
+ creative_cargo_wagon_contains_hidden_items = creative_mode_defines.name_prefix
+ .. "creative-cargo-wagon-contains-hidden-items",
+ duplicating_cargo_wagon_size = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon-size",
+ void_cargo_wagon_size = creative_mode_defines.name_prefix .. "void-cargo-wagon-size",
+ enemy_structures_add_name_suffix = creative_mode_defines.name_prefix .. "enemy-structures-add-name-suffix",
+ infinity_chest_control = creative_mode_defines.name_prefix .. "infinity-chest-control",
+ enable_invincible_player_by_default = creative_mode_defines.name_prefix .. "enable-invincible-player-by-default",
+ enable_instant_blueprint_by_default = creative_mode_defines.name_prefix .. "enable-instant-blueprint-by-default",
+ enable_instant_deconstruction_by_default = creative_mode_defines.name_prefix
+ .. "enable-instant-deconstruction-by-default",
+ enable_personal_long_reach_by_default = creative_mode_defines.name_prefix .. "enable-personal-long-reach-by-default",
+ enable_personal_fast_run_by_default = creative_mode_defines.name_prefix .. "enable-personal-fast-run-by-default",
+ default_technology_research_cheat_type = creative_mode_defines.name_prefix
+ .. "default-technology-research-cheat-type",
+ override_evolution_factor_by_default = creative_mode_defines.name_prefix .. "override-evolution-factor-by-default",
+ default_evolution_factor = creative_mode_defines.name_prefix .. "default-evolution-factor",
}
-- Setting - default action values
creative_mode_defines.values.default_initial_actions = {
- show_popup = "Show popup",
- enable = "Enable",
- enable_all = "Enable all",
- disable = "Disable",
- disable_permanently = "Disable permanently",
+ show_popup = "Show popup",
+ enable = "Enable",
+ enable_all = "Enable all",
+ disable = "Disable",
+ disable_permanently = "Disable permanently",
}
-- Setting - default technology research cheat types
creative_mode_defines.values.default_technology_research_cheat_types = {
- research_all = "Research all",
- instant_research = "Instant research",
- nothing = "Nothing",
+ research_all = "Research all",
+ instant_research = "Instant research",
+ nothing = "Nothing",
}
-- Entity names
creative_mode_defines.names.entities = {
- creative_chest = creative_mode_defines.name_prefix .. "creative-chest",
- new_creative_chest = creative_mode_defines.name_prefix .. "new-creative-chest",
- creative_provider_chest = creative_mode_defines.name_prefix .. "creative-provider-chest",
- inf_requester_chest = creative_mode_defines.name_prefix .. "inf-requester-chest",
- inf_provider_chest = creative_mode_defines.name_prefix .. "inf-provider-chest",
- new_creative_provider_chest = creative_mode_defines.name_prefix .. "new-creative-provider-chest",
- autofill_requester_chest = creative_mode_defines.name_prefix .. "autofill-requester-chest",
- new_autofill_requester_chest = creative_mode_defines.name_prefix .. "new-autofill-requester-chest",
- duplicating_chest = creative_mode_defines.name_prefix .. "duplicating-chest",
- duplicating_provider_chest = creative_mode_defines.name_prefix .. "duplicating-provider-chest",
- void_requester_chest = creative_mode_defines.name_prefix .. "void-requester-chest",
- void_chest = creative_mode_defines.name_prefix .. "void-chest",
- void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
- super_loader = creative_mode_defines.name_prefix .. "super-loader",
- super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
- linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
- linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
- creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
- duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
- void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",
- super_logistic_robot = creative_mode_defines.name_prefix .. "super-logistic-robot",
- super_construction_robot = creative_mode_defines.name_prefix .. "super-construction-robot",
- super_roboport = creative_mode_defines.name_prefix .. "super-roboport",
- fluid_source = creative_mode_defines.name_prefix .. "fluid-source",
- fluid_void = creative_mode_defines.name_prefix .. "fluid-void",
- new_fluid_void = creative_mode_defines.name_prefix .. "new-fluid-void",
- super_boiler = creative_mode_defines.name_prefix .. "super-boiler",
- super_cooler = creative_mode_defines.name_prefix .. "super-cooler",
- configurable_super_boiler = creative_mode_defines.name_prefix .. "configurable-super-boiler",
- heat_source = creative_mode_defines.name_prefix .. "heat-source",
- heat_void = creative_mode_defines.name_prefix .. "heat-void",
- item_source = creative_mode_defines.name_prefix .. "item-source",
- duplicator = creative_mode_defines.name_prefix .. "duplicator",
- item_void = creative_mode_defines.name_prefix .. "item-void",
- random_item_source = creative_mode_defines.name_prefix .. "random-item-source",
- creative_lab = creative_mode_defines.name_prefix .. "creative-lab",
- void_lab = creative_mode_defines.name_prefix .. "void-lab",
- active_electric_energy_interface_output = creative_mode_defines.name_prefix
- .. "active-electric-energy-interface-output",
- active_electric_energy_interface_input = creative_mode_defines.name_prefix
- .. "active-electric-energy-interface-input",
- passive_electric_energy_interface = creative_mode_defines.name_prefix .. "passive-electric-energy-interface",
- energy_source = creative_mode_defines.name_prefix .. "energy-source",
- passive_energy_source = creative_mode_defines.name_prefix .. "passive-energy-source",
- energy_void = creative_mode_defines.name_prefix .. "energy-void",
- passive_energy_void = creative_mode_defines.name_prefix .. "passive-energy-void",
- super_electric_pole = creative_mode_defines.name_prefix .. "super-electric-pole",
- super_substation = creative_mode_defines.name_prefix .. "super-substation",
- magic_wand_smoke_creator = creative_mode_defines.name_prefix .. "magic-wand-smoke-creator",
- magic_wand_smoke_healer = creative_mode_defines.name_prefix .. "magic-wand-smoke-healer",
- magic_wand_smoke_modifier = creative_mode_defines.name_prefix .. "magic-wand-smoke-modifier",
- super_radar = creative_mode_defines.name_prefix .. "super-radar",
- super_radar_2 = creative_mode_defines.name_prefix .. "super-radar-2",
- alien_attractor_proxy_small = creative_mode_defines.name_prefix .. "alien-attractor-proxy-small",
- alien_attractor_proxy_medium = creative_mode_defines.name_prefix .. "alien-attractor-proxy-medium",
- alien_attractor_proxy_large = creative_mode_defines.name_prefix .. "alien-attractor-proxy-large",
- super_beacon = creative_mode_defines.name_prefix .. "super-beacon",
+ creative_chest = creative_mode_defines.name_prefix .. "creative-chest",
+ new_creative_chest = creative_mode_defines.name_prefix .. "new-creative-chest",
+ creative_provider_chest = creative_mode_defines.name_prefix .. "creative-provider-chest",
+ inf_requester_chest = creative_mode_defines.name_prefix .. "inf-requester-chest",
+ inf_provider_chest = creative_mode_defines.name_prefix .. "inf-provider-chest",
+ new_creative_provider_chest = creative_mode_defines.name_prefix .. "new-creative-provider-chest",
+ autofill_requester_chest = creative_mode_defines.name_prefix .. "autofill-requester-chest",
+ new_autofill_requester_chest = creative_mode_defines.name_prefix .. "new-autofill-requester-chest",
+ duplicating_chest = creative_mode_defines.name_prefix .. "duplicating-chest",
+ duplicating_provider_chest = creative_mode_defines.name_prefix .. "duplicating-provider-chest",
+ void_requester_chest = creative_mode_defines.name_prefix .. "void-requester-chest",
+ void_chest = creative_mode_defines.name_prefix .. "void-chest",
+ void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
+ super_loader = creative_mode_defines.name_prefix .. "super-loader",
+ super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
+ linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
+ linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
+ creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
+ duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
+ void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",
+ super_logistic_robot = creative_mode_defines.name_prefix .. "super-logistic-robot",
+ super_construction_robot = creative_mode_defines.name_prefix .. "super-construction-robot",
+ super_roboport = creative_mode_defines.name_prefix .. "super-roboport",
+ fluid_source = creative_mode_defines.name_prefix .. "fluid-source",
+ fluid_void = creative_mode_defines.name_prefix .. "fluid-void",
+ new_fluid_void = creative_mode_defines.name_prefix .. "new-fluid-void",
+ super_boiler = creative_mode_defines.name_prefix .. "super-boiler",
+ super_cooler = creative_mode_defines.name_prefix .. "super-cooler",
+ configurable_super_boiler = creative_mode_defines.name_prefix .. "configurable-super-boiler",
+ heat_source = creative_mode_defines.name_prefix .. "heat-source",
+ heat_void = creative_mode_defines.name_prefix .. "heat-void",
+ item_source = creative_mode_defines.name_prefix .. "item-source",
+ duplicator = creative_mode_defines.name_prefix .. "duplicator",
+ item_void = creative_mode_defines.name_prefix .. "item-void",
+ random_item_source = creative_mode_defines.name_prefix .. "random-item-source",
+ creative_lab = creative_mode_defines.name_prefix .. "creative-lab",
+ void_lab = creative_mode_defines.name_prefix .. "void-lab",
+ active_electric_energy_interface_output = creative_mode_defines.name_prefix
+ .. "active-electric-energy-interface-output",
+ active_electric_energy_interface_input = creative_mode_defines.name_prefix
+ .. "active-electric-energy-interface-input",
+ passive_electric_energy_interface = creative_mode_defines.name_prefix .. "passive-electric-energy-interface",
+ energy_source = creative_mode_defines.name_prefix .. "energy-source",
+ passive_energy_source = creative_mode_defines.name_prefix .. "passive-energy-source",
+ energy_void = creative_mode_defines.name_prefix .. "energy-void",
+ passive_energy_void = creative_mode_defines.name_prefix .. "passive-energy-void",
+ super_electric_pole = creative_mode_defines.name_prefix .. "super-electric-pole",
+ super_substation = creative_mode_defines.name_prefix .. "super-substation",
+ magic_wand_smoke_creator = creative_mode_defines.name_prefix .. "magic-wand-smoke-creator",
+ magic_wand_smoke_healer = creative_mode_defines.name_prefix .. "magic-wand-smoke-healer",
+ magic_wand_smoke_modifier = creative_mode_defines.name_prefix .. "magic-wand-smoke-modifier",
+ super_radar = creative_mode_defines.name_prefix .. "super-radar",
+ super_radar_2 = creative_mode_defines.name_prefix .. "super-radar-2",
+ alien_attractor_proxy_small = creative_mode_defines.name_prefix .. "alien-attractor-proxy-small",
+ alien_attractor_proxy_medium = creative_mode_defines.name_prefix .. "alien-attractor-proxy-medium",
+ alien_attractor_proxy_large = creative_mode_defines.name_prefix .. "alien-attractor-proxy-large",
+ super_beacon = creative_mode_defines.name_prefix .. "super-beacon",
}
-- Technology names
creative_mode_defines.names.technology = {
- void_technology = creative_mode_defines.name_prefix .. "void-technology",
+ void_technology = creative_mode_defines.name_prefix .. "void-technology",
}
-- Equipment names
creative_mode_defines.names.equipments = {
- super_fusion_reactor_equipment = creative_mode_defines.name_prefix .. "super-fusion-reactor-equipment",
- super_personal_roboport_equipment = creative_mode_defines.name_prefix .. "super-personal-roboport-equipment",
+ super_fusion_reactor_equipment = creative_mode_defines.name_prefix .. "super-fusion-reactor-equipment",
+ super_personal_roboport_equipment = creative_mode_defines.name_prefix .. "super-personal-roboport-equipment",
}
-- Item names
creative_mode_defines.names.items = {
- creative_chest = creative_mode_defines.name_prefix .. "creative-chest",
- creative_provider_chest = creative_mode_defines.name_prefix .. "creative-provider-chest",
- inf_requester_chest = creative_mode_defines.name_prefix .. "inf-requester-chest",
- inf_provider_chest = creative_mode_defines.name_prefix .. "inf-provider-chest",
- autofill_requester_chest = creative_mode_defines.name_prefix .. "autofill-requester-chest",
- duplicating_chest = creative_mode_defines.name_prefix .. "duplicating-chest",
- duplicating_provider_chest = creative_mode_defines.name_prefix .. "duplicating-provider-chest",
- void_requester_chest = creative_mode_defines.name_prefix .. "void-requester-chest",
- void_chest = creative_mode_defines.name_prefix .. "void-chest",
- void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
- super_loader = creative_mode_defines.name_prefix .. "super-loader",
- super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
- linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
- linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
- creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
- duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
- void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",
- super_logistic_robot = creative_mode_defines.name_prefix .. "super-logistic-robot",
- super_construction_robot = creative_mode_defines.name_prefix .. "super-construction-robot",
- super_roboport = creative_mode_defines.name_prefix .. "super-roboport",
- fluid_source = creative_mode_defines.name_prefix .. "fluid-source",
- fluid_void = creative_mode_defines.name_prefix .. "fluid-void",
- new_fluid_void = creative_mode_defines.name_prefix .. "new-fluid-void",
- super_boiler = creative_mode_defines.name_prefix .. "super-boiler",
- super_cooler = creative_mode_defines.name_prefix .. "super-cooler",
- configurable_super_boiler = creative_mode_defines.name_prefix .. "configurable-super-boiler",
- heat_source = creative_mode_defines.name_prefix .. "heat-source",
- heat_void = creative_mode_defines.name_prefix .. "heat-void",
- item_source = creative_mode_defines.name_prefix .. "item-source",
- duplicator = creative_mode_defines.name_prefix .. "duplicator",
- item_void = creative_mode_defines.name_prefix .. "item-void",
- random_item_source = creative_mode_defines.name_prefix .. "random-item-source",
- creative_lab = creative_mode_defines.name_prefix .. "creative-lab",
- void_lab = creative_mode_defines.name_prefix .. "void-lab",
- active_electric_energy_interface_output = creative_mode_defines.name_prefix
- .. "active-electric-energy-interface-output",
- active_electric_energy_interface_input = creative_mode_defines.name_prefix
- .. "active-electric-energy-interface-input",
- passive_electric_energy_interface = creative_mode_defines.name_prefix .. "passive-electric-energy-interface",
- energy_source = creative_mode_defines.name_prefix .. "energy-source",
- passive_energy_source = creative_mode_defines.name_prefix .. "passive-energy-source",
- energy_void = creative_mode_defines.name_prefix .. "energy-void",
- energy_absorption = creative_mode_defines.name_prefix .. "energy-absorption",
- passive_energy_void = creative_mode_defines.name_prefix .. "passive-energy-void",
- super_electric_pole = creative_mode_defines.name_prefix .. "super-electric-pole",
- super_substation = creative_mode_defines.name_prefix .. "super-substation",
- magic_wand_creator = creative_mode_defines.name_prefix .. "magic-wand-creator",
- magic_wand_healer = creative_mode_defines.name_prefix .. "magic-wand-healer",
- magic_wand_modifier = creative_mode_defines.name_prefix .. "magic-wand-modifier",
- super_radar = creative_mode_defines.name_prefix .. "super-radar",
- super_radar_2 = creative_mode_defines.name_prefix .. "super-radar-2",
- alien_attractor_small = creative_mode_defines.name_prefix .. "alien-attractor-small",
- alien_attractor_medium = creative_mode_defines.name_prefix .. "alien-attractor-medium",
- alien_attractor_large = creative_mode_defines.name_prefix .. "alien-attractor-large",
- super_beacon = creative_mode_defines.name_prefix .. "super-beacon",
- super_speed_module = creative_mode_defines.name_prefix .. "super-speed-module",
- super_effectivity_module = creative_mode_defines.name_prefix .. "super-effectivity-module",
- super_productivity_module = creative_mode_defines.name_prefix .. "super-productivity-module",
- super_clean_module = creative_mode_defines.name_prefix .. "super-clean-module",
- super_slow_module = creative_mode_defines.name_prefix .. "super-slow-module",
- super_consumption_module = creative_mode_defines.name_prefix .. "super-consumption-module",
- super_pollution_module = creative_mode_defines.name_prefix .. "super-pollution-module",
- belt_immunity_equipment = "belt-immunity-equipment",
- super_fusion_reactor_equipment = creative_mode_defines.name_prefix .. "super-fusion-reactor-equipment",
- super_personal_roboport_equipment = creative_mode_defines.name_prefix .. "super-personal-roboport-equipment",
+ creative_chest = creative_mode_defines.name_prefix .. "creative-chest",
+ creative_provider_chest = creative_mode_defines.name_prefix .. "creative-provider-chest",
+ inf_requester_chest = creative_mode_defines.name_prefix .. "inf-requester-chest",
+ inf_provider_chest = creative_mode_defines.name_prefix .. "inf-provider-chest",
+ autofill_requester_chest = creative_mode_defines.name_prefix .. "autofill-requester-chest",
+ duplicating_chest = creative_mode_defines.name_prefix .. "duplicating-chest",
+ duplicating_provider_chest = creative_mode_defines.name_prefix .. "duplicating-provider-chest",
+ void_requester_chest = creative_mode_defines.name_prefix .. "void-requester-chest",
+ void_chest = creative_mode_defines.name_prefix .. "void-chest",
+ void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
+ super_loader = creative_mode_defines.name_prefix .. "super-loader",
+ super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
+ linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
+ linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
+ creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
+ duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
+ void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",
+ super_logistic_robot = creative_mode_defines.name_prefix .. "super-logistic-robot",
+ super_construction_robot = creative_mode_defines.name_prefix .. "super-construction-robot",
+ super_roboport = creative_mode_defines.name_prefix .. "super-roboport",
+ fluid_source = creative_mode_defines.name_prefix .. "fluid-source",
+ fluid_void = creative_mode_defines.name_prefix .. "fluid-void",
+ new_fluid_void = creative_mode_defines.name_prefix .. "new-fluid-void",
+ super_boiler = creative_mode_defines.name_prefix .. "super-boiler",
+ super_cooler = creative_mode_defines.name_prefix .. "super-cooler",
+ configurable_super_boiler = creative_mode_defines.name_prefix .. "configurable-super-boiler",
+ heat_source = creative_mode_defines.name_prefix .. "heat-source",
+ heat_void = creative_mode_defines.name_prefix .. "heat-void",
+ item_source = creative_mode_defines.name_prefix .. "item-source",
+ duplicator = creative_mode_defines.name_prefix .. "duplicator",
+ item_void = creative_mode_defines.name_prefix .. "item-void",
+ random_item_source = creative_mode_defines.name_prefix .. "random-item-source",
+ creative_lab = creative_mode_defines.name_prefix .. "creative-lab",
+ void_lab = creative_mode_defines.name_prefix .. "void-lab",
+ active_electric_energy_interface_output = creative_mode_defines.name_prefix
+ .. "active-electric-energy-interface-output",
+ active_electric_energy_interface_input = creative_mode_defines.name_prefix
+ .. "active-electric-energy-interface-input",
+ passive_electric_energy_interface = creative_mode_defines.name_prefix .. "passive-electric-energy-interface",
+ energy_source = creative_mode_defines.name_prefix .. "energy-source",
+ passive_energy_source = creative_mode_defines.name_prefix .. "passive-energy-source",
+ energy_void = creative_mode_defines.name_prefix .. "energy-void",
+ energy_absorption = creative_mode_defines.name_prefix .. "energy-absorption",
+ passive_energy_void = creative_mode_defines.name_prefix .. "passive-energy-void",
+ super_electric_pole = creative_mode_defines.name_prefix .. "super-electric-pole",
+ super_substation = creative_mode_defines.name_prefix .. "super-substation",
+ magic_wand_creator = creative_mode_defines.name_prefix .. "magic-wand-creator",
+ magic_wand_healer = creative_mode_defines.name_prefix .. "magic-wand-healer",
+ magic_wand_modifier = creative_mode_defines.name_prefix .. "magic-wand-modifier",
+ super_radar = creative_mode_defines.name_prefix .. "super-radar",
+ super_radar_2 = creative_mode_defines.name_prefix .. "super-radar-2",
+ alien_attractor_small = creative_mode_defines.name_prefix .. "alien-attractor-small",
+ alien_attractor_medium = creative_mode_defines.name_prefix .. "alien-attractor-medium",
+ alien_attractor_large = creative_mode_defines.name_prefix .. "alien-attractor-large",
+ super_beacon = creative_mode_defines.name_prefix .. "super-beacon",
+ super_speed_module = creative_mode_defines.name_prefix .. "super-speed-module",
+ super_effectivity_module = creative_mode_defines.name_prefix .. "super-effectivity-module",
+ super_productivity_module = creative_mode_defines.name_prefix .. "super-productivity-module",
+ super_clean_module = creative_mode_defines.name_prefix .. "super-clean-module",
+ super_slow_module = creative_mode_defines.name_prefix .. "super-slow-module",
+ super_consumption_module = creative_mode_defines.name_prefix .. "super-consumption-module",
+ super_pollution_module = creative_mode_defines.name_prefix .. "super-pollution-module",
+ belt_immunity_equipment = "belt-immunity-equipment",
+ super_fusion_reactor_equipment = creative_mode_defines.name_prefix .. "super-fusion-reactor-equipment",
+ super_personal_roboport_equipment = creative_mode_defines.name_prefix .. "super-personal-roboport-equipment",
}
-- Item group names
creative_mode_defines.names.item_groups = {
- creative_tools = creative_mode_defines.name_prefix .. "creative-tools",
+ creative_tools = creative_mode_defines.name_prefix .. "creative-tools",
}
-- Item subgroup names
creative_mode_defines.names.item_subgroups = {
- items = creative_mode_defines.name_prefix .. "items",
- vehicles = creative_mode_defines.name_prefix .. "vehicles",
- fluids = creative_mode_defines.name_prefix .. "fluids",
- advanced = creative_mode_defines.name_prefix .. "advanced",
- energy = creative_mode_defines.name_prefix .. "energy",
- magic_wands = creative_mode_defines.name_prefix .. "magic-wands",
- enemies = creative_mode_defines.name_prefix .. "enemies",
- modules = creative_mode_defines.name_prefix .. "modules",
- equipments = creative_mode_defines.name_prefix .. "equipments",
- free_fluids = creative_mode_defines.name_prefix .. "free-fluids",
+ items = creative_mode_defines.name_prefix .. "items",
+ vehicles = creative_mode_defines.name_prefix .. "vehicles",
+ fluids = creative_mode_defines.name_prefix .. "fluids",
+ advanced = creative_mode_defines.name_prefix .. "advanced",
+ energy = creative_mode_defines.name_prefix .. "energy",
+ magic_wands = creative_mode_defines.name_prefix .. "magic-wands",
+ enemies = creative_mode_defines.name_prefix .. "enemies",
+ modules = creative_mode_defines.name_prefix .. "modules",
+ equipments = creative_mode_defines.name_prefix .. "equipments",
+ free_fluids = creative_mode_defines.name_prefix .. "free-fluids",
}
-- Recipe names
creative_mode_defines.names.recipes = {
- creative_chest = creative_mode_defines.name_prefix .. "creative-chest",
- new_creative_chest = creative_mode_defines.name_prefix .. "new-creative-chest",
- creative_provider_chest = creative_mode_defines.name_prefix .. "creative-provider-chest",
- inf_requester_chest = creative_mode_defines.name_prefix .. "inf-requester-chest",
- inf_provider_chest = creative_mode_defines.name_prefix .. "inf-provider-chest",
- autofill_requester_chest = creative_mode_defines.name_prefix .. "autofill-requester-chest",
- duplicating_chest = creative_mode_defines.name_prefix .. "duplicating-chest",
- duplicating_provider_chest = creative_mode_defines.name_prefix .. "duplicating-provider-chest",
- void_requester_chest = creative_mode_defines.name_prefix .. "void-requester-chest",
- void_chest = creative_mode_defines.name_prefix .. "void-chest",
- void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
- super_loader = creative_mode_defines.name_prefix .. "super-loader",
- super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
- linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
- linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
- creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
- duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
- void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",
- super_logistic_robot = creative_mode_defines.name_prefix .. "super-logistic-robot",
- super_construction_robot = creative_mode_defines.name_prefix .. "super-construction-robot",
- super_roboport = creative_mode_defines.name_prefix .. "super-roboport",
- fluid_source = creative_mode_defines.name_prefix .. "fluid-source",
- fluid_void = creative_mode_defines.name_prefix .. "fluid-void",
- super_boiler = creative_mode_defines.name_prefix .. "super-boiler",
- super_cooler = creative_mode_defines.name_prefix .. "super-cooler",
- configurable_super_boiler = creative_mode_defines.name_prefix .. "configurable-super-boiler",
- heat_source = creative_mode_defines.name_prefix .. "heat-source",
- heat_void = creative_mode_defines.name_prefix .. "heat-void",
- item_source = creative_mode_defines.name_prefix .. "item-source",
- duplicator = creative_mode_defines.name_prefix .. "duplicator",
- item_void = creative_mode_defines.name_prefix .. "item-void",
- random_item_source = creative_mode_defines.name_prefix .. "random-item-source",
- creative_lab = creative_mode_defines.name_prefix .. "creative-lab",
- void_lab = creative_mode_defines.name_prefix .. "void-lab",
- active_electric_energy_interface_output = creative_mode_defines.name_prefix
- .. "active-electric-energy-interface-output",
- active_electric_energy_interface_input = creative_mode_defines.name_prefix
- .. "active-electric-energy-interface-input",
- passive_electric_energy_interface = creative_mode_defines.name_prefix .. "passive-electric-energy-interface",
- energy_source = creative_mode_defines.name_prefix .. "energy-source",
- passive_energy_source = creative_mode_defines.name_prefix .. "passive-energy-source",
- energy_void = creative_mode_defines.name_prefix .. "energy-void",
- energy_absorption = creative_mode_defines.name_prefix .. "energy-absorption",
- passive_energy_void = creative_mode_defines.name_prefix .. "passive-energy-void",
- super_electric_pole = creative_mode_defines.name_prefix .. "super-electric-pole",
- super_substation = creative_mode_defines.name_prefix .. "super-substation",
- magic_wand_creator = creative_mode_defines.name_prefix .. "magic-wand-creator",
- magic_wand_healer = creative_mode_defines.name_prefix .. "magic-wand-healer",
- magic_wand_modifier = creative_mode_defines.name_prefix .. "magic-wand-modifier",
- super_radar = creative_mode_defines.name_prefix .. "super-radar",
- super_radar_2 = creative_mode_defines.name_prefix .. "super-radar-2",
- alien_attractor_small = creative_mode_defines.name_prefix .. "alien-attractor-small",
- alien_attractor_medium = creative_mode_defines.name_prefix .. "alien-attractor-medium",
- alien_attractor_large = creative_mode_defines.name_prefix .. "alien-attractor-large",
- super_beacon = creative_mode_defines.name_prefix .. "super-beacon",
- super_speed_module = creative_mode_defines.name_prefix .. "super-speed-module",
- super_effectivity_module = creative_mode_defines.name_prefix .. "super-effectivity-module",
- super_productivity_module = creative_mode_defines.name_prefix .. "super-productivity-module",
- super_clean_module = creative_mode_defines.name_prefix .. "super-clean-module",
- super_slow_module = creative_mode_defines.name_prefix .. "super-slow-module",
- super_consumption_module = creative_mode_defines.name_prefix .. "super-consumption-module",
- super_pollution_module = creative_mode_defines.name_prefix .. "super-pollution-module",
- belt_immunity_equipment = creative_mode_defines.name_prefix .. "belt-immunity-equipment",
- super_fusion_reactor_equipment = creative_mode_defines.name_prefix .. "super-fusion-reactor-equipment",
- super_personal_roboport_equipment = creative_mode_defines.name_prefix .. "super-personal-roboport-equipment",
+ creative_chest = creative_mode_defines.name_prefix .. "creative-chest",
+ new_creative_chest = creative_mode_defines.name_prefix .. "new-creative-chest",
+ creative_provider_chest = creative_mode_defines.name_prefix .. "creative-provider-chest",
+ inf_requester_chest = creative_mode_defines.name_prefix .. "inf-requester-chest",
+ inf_provider_chest = creative_mode_defines.name_prefix .. "inf-provider-chest",
+ autofill_requester_chest = creative_mode_defines.name_prefix .. "autofill-requester-chest",
+ duplicating_chest = creative_mode_defines.name_prefix .. "duplicating-chest",
+ duplicating_provider_chest = creative_mode_defines.name_prefix .. "duplicating-provider-chest",
+ void_requester_chest = creative_mode_defines.name_prefix .. "void-requester-chest",
+ void_chest = creative_mode_defines.name_prefix .. "void-chest",
+ void_storage_chest = creative_mode_defines.name_prefix .. "void-storage-chest",
+ super_loader = creative_mode_defines.name_prefix .. "super-loader",
+ super_loader2 = creative_mode_defines.name_prefix .. "super-loader2",
+ linked_chest = creative_mode_defines.name_prefix .. "linked-chest",
+ linked_belt = creative_mode_defines.name_prefix .. "linked-belt",
+ creative_cargo_wagon = creative_mode_defines.name_prefix .. "creative-cargo-wagon",
+ duplicating_cargo_wagon = creative_mode_defines.name_prefix .. "duplicating-cargo-wagon",
+ void_cargo_wagon = creative_mode_defines.name_prefix .. "void-cargo-wagon",
+ super_logistic_robot = creative_mode_defines.name_prefix .. "super-logistic-robot",
+ super_construction_robot = creative_mode_defines.name_prefix .. "super-construction-robot",
+ super_roboport = creative_mode_defines.name_prefix .. "super-roboport",
+ fluid_source = creative_mode_defines.name_prefix .. "fluid-source",
+ fluid_void = creative_mode_defines.name_prefix .. "fluid-void",
+ super_boiler = creative_mode_defines.name_prefix .. "super-boiler",
+ super_cooler = creative_mode_defines.name_prefix .. "super-cooler",
+ configurable_super_boiler = creative_mode_defines.name_prefix .. "configurable-super-boiler",
+ heat_source = creative_mode_defines.name_prefix .. "heat-source",
+ heat_void = creative_mode_defines.name_prefix .. "heat-void",
+ item_source = creative_mode_defines.name_prefix .. "item-source",
+ duplicator = creative_mode_defines.name_prefix .. "duplicator",
+ item_void = creative_mode_defines.name_prefix .. "item-void",
+ random_item_source = creative_mode_defines.name_prefix .. "random-item-source",
+ creative_lab = creative_mode_defines.name_prefix .. "creative-lab",
+ void_lab = creative_mode_defines.name_prefix .. "void-lab",
+ active_electric_energy_interface_output = creative_mode_defines.name_prefix
+ .. "active-electric-energy-interface-output",
+ active_electric_energy_interface_input = creative_mode_defines.name_prefix
+ .. "active-electric-energy-interface-input",
+ passive_electric_energy_interface = creative_mode_defines.name_prefix .. "passive-electric-energy-interface",
+ energy_source = creative_mode_defines.name_prefix .. "energy-source",
+ passive_energy_source = creative_mode_defines.name_prefix .. "passive-energy-source",
+ energy_void = creative_mode_defines.name_prefix .. "energy-void",
+ energy_absorption = creative_mode_defines.name_prefix .. "energy-absorption",
+ passive_energy_void = creative_mode_defines.name_prefix .. "passive-energy-void",
+ super_electric_pole = creative_mode_defines.name_prefix .. "super-electric-pole",
+ super_substation = creative_mode_defines.name_prefix .. "super-substation",
+ magic_wand_creator = creative_mode_defines.name_prefix .. "magic-wand-creator",
+ magic_wand_healer = creative_mode_defines.name_prefix .. "magic-wand-healer",
+ magic_wand_modifier = creative_mode_defines.name_prefix .. "magic-wand-modifier",
+ super_radar = creative_mode_defines.name_prefix .. "super-radar",
+ super_radar_2 = creative_mode_defines.name_prefix .. "super-radar-2",
+ alien_attractor_small = creative_mode_defines.name_prefix .. "alien-attractor-small",
+ alien_attractor_medium = creative_mode_defines.name_prefix .. "alien-attractor-medium",
+ alien_attractor_large = creative_mode_defines.name_prefix .. "alien-attractor-large",
+ super_beacon = creative_mode_defines.name_prefix .. "super-beacon",
+ super_speed_module = creative_mode_defines.name_prefix .. "super-speed-module",
+ super_effectivity_module = creative_mode_defines.name_prefix .. "super-effectivity-module",
+ super_productivity_module = creative_mode_defines.name_prefix .. "super-productivity-module",
+ super_clean_module = creative_mode_defines.name_prefix .. "super-clean-module",
+ super_slow_module = creative_mode_defines.name_prefix .. "super-slow-module",
+ super_consumption_module = creative_mode_defines.name_prefix .. "super-consumption-module",
+ super_pollution_module = creative_mode_defines.name_prefix .. "super-pollution-module",
+ belt_immunity_equipment = creative_mode_defines.name_prefix .. "belt-immunity-equipment",
+ super_fusion_reactor_equipment = creative_mode_defines.name_prefix .. "super-fusion-reactor-equipment",
+ super_personal_roboport_equipment = creative_mode_defines.name_prefix .. "super-personal-roboport-equipment",
}
-- Recipe category names
creative_mode_defines.names.recipe_categories = {
- free_fluids = creative_mode_defines.name_prefix .. "free-fluids",
- energy_absorption = creative_mode_defines.name_prefix .. "energy-absorption",
+ free_fluids = creative_mode_defines.name_prefix .. "free-fluids",
+ energy_absorption = creative_mode_defines.name_prefix .. "energy-absorption",
}
-- Entity fast replaceable group names
creative_mode_defines.names.fast_replaceable_groups = {
- creative_chest = creative_mode_defines.name_prefix .. "creative-chest",
- fluid_source_void = creative_mode_defines.name_prefix .. "fluid-source-void",
- heat_source_void = creative_mode_defines.name_prefix .. "heat-source-void",
- item_source_void_duplicator = creative_mode_defines.name_prefix .. "item-source-void-duplicator",
- energy_source_void = creative_mode_defines.name_prefix .. "energy-source-void",
- electric_energy_interface = creative_mode_defines.name_prefix .. "electric-energy-interface",
+ creative_chest = creative_mode_defines.name_prefix .. "creative-chest",
+ fluid_source_void = creative_mode_defines.name_prefix .. "fluid-source-void",
+ heat_source_void = creative_mode_defines.name_prefix .. "heat-source-void",
+ item_source_void_duplicator = creative_mode_defines.name_prefix .. "item-source-void-duplicator",
+ energy_source_void = creative_mode_defines.name_prefix .. "energy-source-void",
+ electric_energy_interface = creative_mode_defines.name_prefix .. "electric-energy-interface",
}
-- Interface name
creative_mode_defines.names.interface = "creative-mode"
-- GUI element names
creative_mode_defines.names.gui = {
- popup = creative_mode_defines.name_prefix .. "popup",
- popup_label = creative_mode_defines.name_prefix .. "popup-label",
- popup_label2 = creative_mode_defines.name_prefix .. "popup-label2",
- popup_buttons_container = creative_mode_defines.name_prefix .. "popup-buttons-container",
- enable_creative_mode_yes = creative_mode_defines.name_prefix .. "enable-creative-mode_yes",
- enable_creative_mode_yes_with_cheats = creative_mode_defines.name_prefix .. "enable-creative-mode_yes-with-cheats",
- enable_creative_mode_no = creative_mode_defines.name_prefix .. "enable-creative-mode_no",
- enable_creative_mode_no_permanently = creative_mode_defines.name_prefix .. "enable-creative-mode_no-permanently",
- disable_creative_mode_yes = creative_mode_defines.name_prefix .. "disable-creative-mode_yes",
- disable_creative_mode_no = creative_mode_defines.name_prefix .. "disable-creative-mode_no",
- permanent_disable_creative_mode_yes = creative_mode_defines.name_prefix .. "permanent-disable-creative-mode_yes",
- permanent_disable_creative_mode_no = creative_mode_defines.name_prefix .. "permanent-disable-creative-mode_no",
- main_menu_open_button = creative_mode_defines.name_prefix .. "main-menu-open-button",
- main_menu_container = creative_mode_defines.name_prefix .. "main-menu-container",
- main_menu_frame = creative_mode_defines.name_prefix .. "main-menu-frame",
- main_menu_open_cheats_button = creative_mode_defines.name_prefix .. "main-menu-open-cheats-button",
- main_menu_open_build_options_button = creative_mode_defines.name_prefix .. "main-menu-open-build-options-button",
- main_menu_open_magic_wand_button = creative_mode_defines.name_prefix .. "main-menu-open-magic-wand-button",
- main_menu_open_modding_button = creative_mode_defines.name_prefix .. "main-menu-open-modding-button",
- main_menu_open_admin_button = creative_mode_defines.name_prefix .. "main-menu-open-admin-button",
- cheats_menus_container = creative_mode_defines.name_prefix .. "cheats-menus-container",
- cheats_menu_frame = creative_mode_defines.name_prefix .. "cheats-menu-frame",
- personal_cheats_menu_button = creative_mode_defines.name_prefix .. "personal-cheats-menu-button",
- team_cheats_menu_button = creative_mode_defines.name_prefix .. "team-cheats-menu-button",
- surface_cheats_menu_button = creative_mode_defines.name_prefix .. "surface-cheats-menu-button",
- global_cheats_menu_button = creative_mode_defines.name_prefix .. "global-cheats-menu-button",
- personal_cheats_menu_frame = creative_mode_defines.name_prefix .. "personal-cheats-menu-frame",
- personal_cheats_outer_container = creative_mode_defines.name_prefix .. "personal-cheats-outer-container",
- personal_cheats_targets_scroll_pane = creative_mode_defines.name_prefix .. "personal-cheats-targets-scroll-pane",
- personal_cheats_targets_container = creative_mode_defines.name_prefix .. "personal-cheats-targets-container",
- personal_cheats_targets_inner_container = creative_mode_defines.name_prefix
- .. "personal-cheats-targets-inner-container",
- personal_cheats_target_index_button_prefix = creative_mode_defines.name_prefix
- .. "personal-cheats-target-index-button-",
- personal_cheats_targets_select_all_button = creative_mode_defines.name_prefix
- .. "personal-cheats-targets-select-all-button",
- personal_cheats_cheats_scroll_pane = creative_mode_defines.name_prefix .. "personal-cheats-cheats-scroll-pane",
- personal_cheats_cheats_container = creative_mode_defines.name_prefix .. "personal-cheats-cheats-container",
- cheat_mode_container = creative_mode_defines.name_prefix .. "cheat-mode-container",
- cheat_mode_label = creative_mode_defines.name_prefix .. "cheat-mode-label",
- cheat_mode_on_button = creative_mode_defines.name_prefix .. "cheat-mode-on-button",
- cheat_mode_off_button = creative_mode_defines.name_prefix .. "cheat-mode-off-button",
- invincible_player_container = creative_mode_defines.name_prefix .. "invincible-player-container",
- invincible_player_label = creative_mode_defines.name_prefix .. "invincible-player-label",
- invincible_player_on_button = creative_mode_defines.name_prefix .. "invincible-player-on-button",
- invincible_player_off_button = creative_mode_defines.name_prefix .. "invincible-player-off-button",
- keep_last_item_container = creative_mode_defines.name_prefix .. "keep-last-item-container",
- keep_last_item_label = creative_mode_defines.name_prefix .. "keep-last-item-label",
- keep_last_item_on_button = creative_mode_defines.name_prefix .. "keep-last-item-on-button",
- keep_last_item_off_button = creative_mode_defines.name_prefix .. "keep-last-item-off-button",
- repair_mined_item_container = creative_mode_defines.name_prefix .. "repair-mined-item-container",
- repair_mined_item_label = creative_mode_defines.name_prefix .. "repair-mined-item-label",
- repair_mined_item_on_button = creative_mode_defines.name_prefix .. "repair-mined-item-on-button",
- repair_mined_item_off_button = creative_mode_defines.name_prefix .. "repair-mined-item-off-button",
- instant_request_container = creative_mode_defines.name_prefix .. "instant-request-container",
- instant_request_label = creative_mode_defines.name_prefix .. "instant-request-label",
- instant_request_on_button = creative_mode_defines.name_prefix .. "instant-request-on-button",
- instant_request_off_button = creative_mode_defines.name_prefix .. "instant-request-off-button",
- instant_trash_container = creative_mode_defines.name_prefix .. "instant-trash-container",
- instant_trash_label = creative_mode_defines.name_prefix .. "instant-trash-label",
- instant_trash_on_button = creative_mode_defines.name_prefix .. "instant-trash-on-button",
- instant_trash_off_button = creative_mode_defines.name_prefix .. "instant-trash-off-button",
- instant_blueprint_container = creative_mode_defines.name_prefix .. "instant-blueprint-container",
- instant_blueprint_label = creative_mode_defines.name_prefix .. "instant-blueprint-label",
- instant_blueprint_on_button = creative_mode_defines.name_prefix .. "instant-blueprint-on-button",
- instant_blueprint_off_button = creative_mode_defines.name_prefix .. "instant-blueprint-off-button",
- instant_deconstruction_container = creative_mode_defines.name_prefix .. "instant_deconstruction-container",
- instant_deconstruction_label = creative_mode_defines.name_prefix .. "instant_deconstruction-label",
- instant_deconstruction_on_button = creative_mode_defines.name_prefix .. "instant_deconstruction-on-button",
- instant_deconstruction_off_button = creative_mode_defines.name_prefix .. "instant_deconstruction-off-button",
- reach_distance_container = creative_mode_defines.name_prefix .. "reach-distance-container",
- reach_distance_label = creative_mode_defines.name_prefix .. "reach-distance-label",
- reach_distance_textfield = creative_mode_defines.name_prefix .. "reach-distance-textfield",
- reach_distance_separator = creative_mode_defines.name_prefix .. "reach-distance-separator",
- reach_distance_apply_button = creative_mode_defines.name_prefix .. "reach-distance-apply-button",
- build_distance_container = creative_mode_defines.name_prefix .. "build-distance-container",
- build_distance_label = creative_mode_defines.name_prefix .. "build-distance-label",
- build_distance_textfield = creative_mode_defines.name_prefix .. "build-distance-textfield",
- build_distance_separator = creative_mode_defines.name_prefix .. "build-distance-separator",
- build_distance_apply_button = creative_mode_defines.name_prefix .. "build-distance-apply-button",
- resource_reach_distance_container = creative_mode_defines.name_prefix .. "resource-reach-distance-container",
- resource_reach_distance_label = creative_mode_defines.name_prefix .. "resource-reach-distance-label",
- resource_reach_distance_textfield = creative_mode_defines.name_prefix .. "resource-reach-distance-textfield",
- resource_reach_distance_separator = creative_mode_defines.name_prefix .. "resource-reach-distance-separator",
- resource_reach_distance_apply_button = creative_mode_defines.name_prefix .. "resource-reach-distance-apply-button",
- item_drop_distance_container = creative_mode_defines.name_prefix .. "item-drop-distance-container",
- item_drop_distance_label = creative_mode_defines.name_prefix .. "item-drop-distance-label",
- item_drop_distance_textfield = creative_mode_defines.name_prefix .. "item-drop-distance-textfield",
- item_drop_distance_separator = creative_mode_defines.name_prefix .. "item-drop-distance-separator",
- item_drop_distance_apply_button = creative_mode_defines.name_prefix .. "item-drop-distance-apply-button",
- item_pickup_distance_container = creative_mode_defines.name_prefix .. "item-pickup-distance-container",
- item_pickup_distance_label = creative_mode_defines.name_prefix .. "item-pickup-distance-label",
- item_pickup_distance_textfield = creative_mode_defines.name_prefix .. "item-pickup-distance-textfield",
- item_pickup_distance_separator = creative_mode_defines.name_prefix .. "item-pickup-distance-separator",
- item_pickup_distance_apply_button = creative_mode_defines.name_prefix .. "item-pickup-distance-apply-button",
- loot_pickup_distance_container = creative_mode_defines.name_prefix .. "loot-pickup-distance-container",
- loot_pickup_distance_label = creative_mode_defines.name_prefix .. "loot-pickup-distance-label",
- loot_pickup_distance_textfield = creative_mode_defines.name_prefix .. "loot-pickup-distance-textfield",
- loot_pickup_distance_separator = creative_mode_defines.name_prefix .. "loot-pickup-distance-separator",
- loot_pickup_distance_apply_button = creative_mode_defines.name_prefix .. "loot-pickup-distance-apply-button",
- mining_speed_container = creative_mode_defines.name_prefix .. "mining-speed-container",
- mining_speed_label = creative_mode_defines.name_prefix .. "mining-speed-label",
- mining_speed_textfield = creative_mode_defines.name_prefix .. "mining-speed-textfield",
- mining_speed_separator = creative_mode_defines.name_prefix .. "mining-speed-separator",
- mining_speed_apply_button = creative_mode_defines.name_prefix .. "mining-speed-apply-button",
- running_speed_container = creative_mode_defines.name_prefix .. "running-speed-container",
- running_speed_label = creative_mode_defines.name_prefix .. "running-speed-label",
- running_speed_textfield = creative_mode_defines.name_prefix .. "running-speed-textfield",
- running_speed_separator = creative_mode_defines.name_prefix .. "running-speed-separator",
- running_speed_apply_button = creative_mode_defines.name_prefix .. "running-speed-apply-button",
- crafting_speed_container = creative_mode_defines.name_prefix .. "crafting-speed-container",
- crafting_speed_label = creative_mode_defines.name_prefix .. "crafting-speed-label",
- crafting_speed_textfield = creative_mode_defines.name_prefix .. "crafting-speed-textfield",
- crafting_speed_separator = creative_mode_defines.name_prefix .. "crafting-speed-separator",
- crafting_speed_apply_button = creative_mode_defines.name_prefix .. "crafting-speed-apply-button",
- inventory_bonus_container = creative_mode_defines.name_prefix .. "inventory-bonus-container",
- inventory_bonus_label = creative_mode_defines.name_prefix .. "inventory-bonus-label",
- inventory_bonus_textfield = creative_mode_defines.name_prefix .. "inventory-bonus-textfield",
- inventory_bonus_separator = creative_mode_defines.name_prefix .. "inventory-bonus-separator",
- inventory_bonus_apply_button = creative_mode_defines.name_prefix .. "inventory-bonus-apply-button",
- quickbar_bonus_container = creative_mode_defines.name_prefix .. "quickbar-bonus-container",
- quickbar_bonus_label = creative_mode_defines.name_prefix .. "quickbar-bonus-label",
- quickbar_bonus_textfield = creative_mode_defines.name_prefix .. "quickbar-bonus-textfield",
- quickbar_bonus_separator = creative_mode_defines.name_prefix .. "quickbar-bonus-separator",
- quickbar_bonus_apply_button = creative_mode_defines.name_prefix .. "quickbar-bonus-apply-button",
- health_bonus_container = creative_mode_defines.name_prefix .. "health-bonus-container",
- health_bonus_label = creative_mode_defines.name_prefix .. "health-bonus-label",
- health_bonus_textfield = creative_mode_defines.name_prefix .. "health-bonus-textfield",
- health_bonus_separator = creative_mode_defines.name_prefix .. "health-bonus-separator",
- health_bonus_apply_button = creative_mode_defines.name_prefix .. "health-bonus-apply-button",
- god_mode_container = creative_mode_defines.name_prefix .. "god-mode-container",
- god_mode_label = creative_mode_defines.name_prefix .. "god-mode-label",
- god_mode_on_button = creative_mode_defines.name_prefix .. "god-mode-on-button",
- god_mode_off_button = creative_mode_defines.name_prefix .. "god-mode-off-button",
- personal_cheats_all_button_container = creative_mode_defines.name_prefix .. "personal-cheats-all-button-container",
- personal_cheats_enable_all_button = creative_mode_defines.name_prefix .. "personal-cheats-enable-all-button",
- personal_cheats_disable_all_button = creative_mode_defines.name_prefix .. "personal-cheats-disable-all-button",
- personal_cheats_not_included_in_enable_all_note = creative_mode_defines.name_prefix
- .. "personal-cheats-not-included-in-enable-all-note",
- team_cheats_menu_frame = creative_mode_defines.name_prefix .. "team-cheats-menu-frame",
- team_cheats_outer_container = creative_mode_defines.name_prefix .. "team-cheats-outer-container",
- team_cheats_targets_scroll_pane = creative_mode_defines.name_prefix .. "team-cheats-targets-scroll-pane",
- team_cheats_targets_container = creative_mode_defines.name_prefix .. "team-cheats-targets-container",
- team_cheats_targets_inner_container = creative_mode_defines.name_prefix .. "team-cheats-targets-inner-container",
- team_cheats_target_name_button_prefix = creative_mode_defines.name_prefix .. "team-cheats-target-name-button-",
- team_cheats_targets_select_all_button = creative_mode_defines.name_prefix
- .. "team-cheats-targets-select-all-button",
- team_cheats_cheats_scroll_pane = creative_mode_defines.name_prefix .. "team-cheats-cheats-scroll-pane",
- team_cheats_cheats_container = creative_mode_defines.name_prefix .. "team-cheats-cheats-container",
- creative_tools_recipes_container = creative_mode_defines.name_prefix .. "creative-tools-recipes-container",
- creative_tools_recipes_label = creative_mode_defines.name_prefix .. "creative-tools-recipes-label",
- creative_tools_recipes_on_button = creative_mode_defines.name_prefix .. "creative-tools-recipes-on-button",
- creative_tools_recipes_off_button = creative_mode_defines.name_prefix .. "creative-tools-recipes-off-button",
- loaders_recipes_container = creative_mode_defines.name_prefix .. "loaders-recipes-container",
- loaders_recipes_label = creative_mode_defines.name_prefix .. "loaders-recipes-label",
- loaders_recipes_on_button = creative_mode_defines.name_prefix .. "loaders-recipes-on-button",
- loaders_recipes_off_button = creative_mode_defines.name_prefix .. "loaders-recipes-off-button",
- all_technologies_container = creative_mode_defines.name_prefix .. "all-technologies-container",
- all_technologies_label = creative_mode_defines.name_prefix .. "all-technologies-label",
- all_technologies_unlock_button = creative_mode_defines.name_prefix .. "all-technologies-unlock-button",
- all_technologies_reset_button = creative_mode_defines.name_prefix .. "all-technologies-reset-button",
- instant_research_container = creative_mode_defines.name_prefix .. "instant-research-container",
- instant_research_label = creative_mode_defines.name_prefix .. "instant-research-label",
- instant_research_on_button = creative_mode_defines.name_prefix .. "instant-research-on-button",
- instant_research_off_button = creative_mode_defines.name_prefix .. "instant-research-off-button",
- team_reach_distance_container = creative_mode_defines.name_prefix .. "team-reach-distance-container",
- team_reach_distance_label = creative_mode_defines.name_prefix .. "team-reach-distance-label",
- team_reach_distance_textfield = creative_mode_defines.name_prefix .. "team-reach-distance-textfield",
- team_reach_distance_separator = creative_mode_defines.name_prefix .. "team-reach-distance-separator",
- team_reach_distance_apply_button = creative_mode_defines.name_prefix .. "team-reach-distance-apply-button",
- team_build_distance_container = creative_mode_defines.name_prefix .. "team-build-distance-container",
- team_build_distance_label = creative_mode_defines.name_prefix .. "team-build-distance-label",
- team_build_distance_textfield = creative_mode_defines.name_prefix .. "team-build-distance-textfield",
- team_build_distance_separator = creative_mode_defines.name_prefix .. "team-build-distance-separator",
- team_build_distance_apply_button = creative_mode_defines.name_prefix .. "team-build-distance-apply-button",
- team_resource_reach_distance_container = creative_mode_defines.name_prefix
- .. "team-resource-reach-distance-container",
- team_resource_reach_distance_label = creative_mode_defines.name_prefix .. "team-resource-distance-label",
- team_resource_reach_distance_textfield = creative_mode_defines.name_prefix .. "team-resource-distance-textfield",
- team_resource_reach_distance_separator = creative_mode_defines.name_prefix .. "team-resource-distance-separator",
- team_resource_reach_distance_apply_button = creative_mode_defines.name_prefix
- .. "team-resource-distance-apply-button",
- team_item_drop_distance_container = creative_mode_defines.name_prefix .. "team-item-drop-distance-container",
- team_item_drop_distance_label = creative_mode_defines.name_prefix .. "team-item-drop-distance-label",
- team_item_drop_distance_textfield = creative_mode_defines.name_prefix .. "team-item-drop-distance-textfield",
- team_item_drop_distance_separator = creative_mode_defines.name_prefix .. "team-item-drop-distance-separator",
- team_item_drop_distance_apply_button = creative_mode_defines.name_prefix .. "team-item-drop-distance-apply-button",
- team_item_pickup_distance_container = creative_mode_defines.name_prefix .. "team-item-pickup-distance-container",
- team_item_pickup_distance_label = creative_mode_defines.name_prefix .. "team-item-pickup-distance-label",
- team_item_pickup_distance_textfield = creative_mode_defines.name_prefix .. "team-item-pickup-distance-textfield",
- team_item_pickup_distance_separator = creative_mode_defines.name_prefix .. "team-item-pickup-distance-separator",
- team_item_pickup_distance_apply_button = creative_mode_defines.name_prefix
- .. "team-item-pickup-distance-apply-button",
- team_loot_pickup_distance_container = creative_mode_defines.name_prefix .. "team-loot-pickup-distance-container",
- team_loot_pickup_distance_label = creative_mode_defines.name_prefix .. "team-loot-pickup-distance-label",
- team_loot_pickup_distance_textfield = creative_mode_defines.name_prefix .. "team-loot-pickup-distance-textfield",
- team_loot_pickup_distance_separator = creative_mode_defines.name_prefix .. "team-loot-pickup-distance-separator",
- team_loot_pickup_distance_apply_button = creative_mode_defines.name_prefix
- .. "team-loot-pickup-distance-apply-button",
- team_mining_speed_container = creative_mode_defines.name_prefix .. "team-mining-speed-container",
- team_mining_speed_label = creative_mode_defines.name_prefix .. "team-mining-speed-label",
- team_mining_speed_textfield = creative_mode_defines.name_prefix .. "team-mining-speed-textfield",
- team_mining_speed_separator = creative_mode_defines.name_prefix .. "team-mining-speed-separator",
- team_mining_speed_apply_button = creative_mode_defines.name_prefix .. "team-mining-speed-apply-button",
- team_running_speed_container = creative_mode_defines.name_prefix .. "team-running-speed-container",
- team_running_speed_label = creative_mode_defines.name_prefix .. "team-running-speed-label",
- team_running_speed_textfield = creative_mode_defines.name_prefix .. "team-running-speed-textfield",
- team_running_speed_separator = creative_mode_defines.name_prefix .. "team-running-speed-separator",
- team_running_speed_apply_button = creative_mode_defines.name_prefix .. "team-running-speed-apply-button",
- team_crafting_speed_container = creative_mode_defines.name_prefix .. "team-crafting-speed-container",
- team_crafting_speed_label = creative_mode_defines.name_prefix .. "team-crafting-speed-label",
- team_crafting_speed_textfield = creative_mode_defines.name_prefix .. "team-crafting-speed-textfield",
- team_crafting_speed_separator = creative_mode_defines.name_prefix .. "team-crafting-speed-separator",
- team_crafting_speed_apply_button = creative_mode_defines.name_prefix .. "team-crafting-speed-apply-button",
- character_inventory_bonus_container = creative_mode_defines.name_prefix .. "character-inventory-bonus-container",
- character_inventory_bonus_label = creative_mode_defines.name_prefix .. "character-inventory-bonus-label",
- character_inventory_bonus_textfield = creative_mode_defines.name_prefix .. "character-inventory-bonus-textfield",
- character_inventory_bonus_separator = creative_mode_defines.name_prefix .. "character-inventory-bonus-separator",
- character_inventory_bonus_apply_button = creative_mode_defines.name_prefix
- .. "character-inventory-bonus-apply-button",
- quickbar_count_container = creative_mode_defines.name_prefix .. "quickbar-count-container",
- quickbar_count_label = creative_mode_defines.name_prefix .. "quickbar-count-label",
- quickbar_count_textfield = creative_mode_defines.name_prefix .. "quickbar-count-textfield",
- quickbar_count_separator = creative_mode_defines.name_prefix .. "quickbar-count-separator",
- quickbar_count_apply_button = creative_mode_defines.name_prefix .. "quickbar-count-apply-button",
- character_health_bonus_container = creative_mode_defines.name_prefix .. "character-health-bonus-container",
- character_health_bonus_label = creative_mode_defines.name_prefix .. "character-health-bonus-label",
- character_health_bonus_textfield = creative_mode_defines.name_prefix .. "character-health-bonus-textfield",
- character_health_bonus_separator = creative_mode_defines.name_prefix .. "character-health-bonus-separator",
- character_health_bonus_apply_button = creative_mode_defines.name_prefix .. "character-health-bonus-apply-button",
- inserter_capacity_bonus_container = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-container",
- inserter_capacity_bonus_label = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-label",
- inserter_capacity_bonus_textfield = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-textfield",
- inserter_capacity_bonus_separator = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-separator",
- inserter_capacity_bonus_apply_button = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-apply-button",
- bulk_inserter_capacity_bonus_container = creative_mode_defines.name_prefix
- .. "bulk-inserter-capacity-bonus-container",
- bulk_inserter_capacity_bonus_label = creative_mode_defines.name_prefix .. "bulk-inserter-capacity-bonus-label",
- bulk_inserter_capacity_bonus_textfield = creative_mode_defines.name_prefix
- .. "bulk-inserter-capacity-bonus-textfield",
- bulk_inserter_capacity_bonus_separator = creative_mode_defines.name_prefix
- .. "bulk-inserter-capacity-bonus-separator",
- bulk_inserter_capacity_bonus_apply_button = creative_mode_defines.name_prefix
- .. "bulk-inserter-capacity-bonus-apply-button",
- evolution_factor_container = creative_mode_defines.name_prefix .. "evolution-factor-container",
- evolution_factor_label = creative_mode_defines.name_prefix .. "evolution-factor-label",
- evolution_factor_textfield = creative_mode_defines.name_prefix .. "evolution-factor-textfield",
- evolution_factor_separator = creative_mode_defines.name_prefix .. "evolution-factor-separator",
- evolution_factor_apply_button = creative_mode_defines.name_prefix .. "evolution-factor-apply-button",
- chart_all_container = creative_mode_defines.name_prefix .. "chart-all-container",
- chart_all_label = creative_mode_defines.name_prefix .. "chart-all-label",
- chart_all_apply_button = creative_mode_defines.name_prefix .. "chart-all-apply-button",
- kill_all_units_container = creative_mode_defines.name_prefix .. "kill-all-units-container",
- kill_all_units_label = creative_mode_defines.name_prefix .. "kill-all-units-label",
- kill_all_units_apply_button = creative_mode_defines.name_prefix .. "kill-all-units-apply-button",
- team_cheats_all_button_container = creative_mode_defines.name_prefix .. "team-cheats-all-button-container",
- team_cheats_enable_all_button = creative_mode_defines.name_prefix .. "team-cheats-enable-all-button",
- team_cheats_disable_all_button = creative_mode_defines.name_prefix .. "team-cheats-disable-all-button",
- team_cheats_not_included_in_enable_all_note = creative_mode_defines.name_prefix
- .. "team-cheats-not-included-in-enable-all-note",
- surface_cheats_menu_frame = creative_mode_defines.name_prefix .. "surface-cheats-menu-frame",
- surface_cheats_outer_container = creative_mode_defines.name_prefix .. "surface-cheats-outer-container",
- surface_cheats_targets_scroll_pane = creative_mode_defines.name_prefix .. "surface-cheats-targets-scroll-pane",
- surface_cheats_targets_container = creative_mode_defines.name_prefix .. "surface-cheats-targets-container",
- surface_cheats_targets_inner_container = creative_mode_defines.name_prefix
- .. "surface-cheats-targets-inner-container",
- surface_cheats_target_name_button_prefix = creative_mode_defines.name_prefix
- .. "surface-cheats-target-name-button-",
- surface_cheats_targets_select_all_button = creative_mode_defines.name_prefix
- .. "surface-cheats-targets-select-all-button",
- surface_cheats_cheats_scroll_pane = creative_mode_defines.name_prefix .. "surface-cheats-cheats-scroll-pane",
- surface_cheats_cheats_container = creative_mode_defines.name_prefix .. "surface-cheats-cheats-container",
- freeze_daytime_container = creative_mode_defines.name_prefix .. "freeze-daytime-container",
- freeze_daytime_label = creative_mode_defines.name_prefix .. "freeze-daytime-label",
- freeze_daytime_on_button = creative_mode_defines.name_prefix .. "freeze-daytime-on-button",
- freeze_daytime_off_button = creative_mode_defines.name_prefix .. "freeze-daytime-off-button",
- daytime_container = creative_mode_defines.name_prefix .. "daytime-container",
- daytime_label = creative_mode_defines.name_prefix .. "daytime-label",
- daytime_textfield = creative_mode_defines.name_prefix .. "daytime-textfield",
- daytime_separator = creative_mode_defines.name_prefix .. "daytime-separator",
- daytime_apply_button = creative_mode_defines.name_prefix .. "daytime-apply-button",
- daytime_selection_container = creative_mode_defines.name_prefix .. "daytime-selection-container",
- daytime_selection_label = creative_mode_defines.name_prefix .. "daytime-selection-label",
- daytime_selection_midday_button = creative_mode_defines.name_prefix .. "daytime-selection-midday-button",
- daytime_selection_midnight_button = creative_mode_defines.name_prefix .. "daytime-selection-midnight-button",
- peaceful_mode_container = creative_mode_defines.name_prefix .. "peaceful-mode-container",
- peaceful_mode_label = creative_mode_defines.name_prefix .. "peaceful-mode-label",
- peaceful_mode_on_button = creative_mode_defines.name_prefix .. "peaceful-mode-on-button",
- peaceful_mode_off_button = creative_mode_defines.name_prefix .. "peaceful-mode-off-button",
- destroy_all_enemies_container = creative_mode_defines.name_prefix .. "destroy-all-enemies-container",
- destroy_all_enemies_label = creative_mode_defines.name_prefix .. "destroy-all-enemies-label",
- destroy_all_enemies_apply_button = creative_mode_defines.name_prefix .. "destroy-all-enemies-apply-button",
- remove_all_enemies_container = creative_mode_defines.name_prefix .. "remove-all-enemies-container",
- remove_all_enemies_label = creative_mode_defines.name_prefix .. "remove-all-enemies-label",
- remove_all_enemies_apply_button = creative_mode_defines.name_prefix .. "remove-all-enemies-apply-button",
- dont_generate_enemy_container = creative_mode_defines.name_prefix .. "dont-generate-enemy-container",
- dont_generate_enemy_label = creative_mode_defines.name_prefix .. "dont-generate-enemy-label",
- dont_generate_enemy_on_button = creative_mode_defines.name_prefix .. "dont-generate-enemy-on-button",
- dont_generate_enemy_off_button = creative_mode_defines.name_prefix .. "dont-generate-enemy-off-button",
- surface_pressure_container = creative_mode_defines.name_prefix .. "surface-pressure-container",
- surface_pressure_label = creative_mode_defines.name_prefix .. "surface-pressure-label",
- surface_pressure_textfield = creative_mode_defines.name_prefix .. "surface-pressure-textfield",
- surface_pressure_separator = creative_mode_defines.name_prefix .. "surface-pressure-separator",
- surface_pressure_apply_button = creative_mode_defines.name_prefix .. "surface-pressure-apply-button",
- surface_magnetic_field_container = creative_mode_defines.name_prefix .. "surface-magentic-field-container",
- surface_magnetic_field_label = creative_mode_defines.name_prefix .. "surface-magentic-field-label",
- surface_magnetic_field_textfield = creative_mode_defines.name_prefix .. "surface-magentic-field-textfield",
- surface_magnetic_field_separator = creative_mode_defines.name_prefix .. "surface-magentic-field-separator",
- surface_magnetic_field_apply_button = creative_mode_defines.name_prefix .. "surface-magentic-field-apply-button",
- surface_gravity_container = creative_mode_defines.name_prefix .. "surface-gravity-container",
- surface_gravity_label = creative_mode_defines.name_prefix .. "surface-gravity-label",
- surface_gravity_textfield = creative_mode_defines.name_prefix .. "surface-gravity-textfield",
- surface_gravity_separator = creative_mode_defines.name_prefix .. "surface-gravity-separator",
- surface_gravity_apply_button = creative_mode_defines.name_prefix .. "surface-gravity-apply-button",
- global_cheats_menu_frame = creative_mode_defines.name_prefix .. "global-cheats-menu-frame",
- global_cheats_table = creative_mode_defines.name_prefix .. "global-cheats-table",
- global_cheats_cheats_scroll_pane = creative_mode_defines.name_prefix .. "global-cheats-cheats-scroll-pane",
- global_cheats_cheats_container = creative_mode_defines.name_prefix .. "global-cheats-cheats-container",
- pollution_container = creative_mode_defines.name_prefix .. "pollution-container",
- pollution_label = creative_mode_defines.name_prefix .. "pollution-label",
- pollution_on_button = creative_mode_defines.name_prefix .. "pollution-on-button",
- pollution_off_button = creative_mode_defines.name_prefix .. "pollution-off-button",
- enemy_evolution_container = creative_mode_defines.name_prefix .. "enemy-evolution-container",
- enemy_evolution_label = creative_mode_defines.name_prefix .. "enemy-evolution-label",
- enemy_evolution_on_button = creative_mode_defines.name_prefix .. "enemy-evolution-on-button",
- enemy_evolution_off_button = creative_mode_defines.name_prefix .. "enemy-evolution-off-button",
- evolution_time_factor_container = creative_mode_defines.name_prefix .. "evolution-time-factor-container",
- evolution_time_factor_label = creative_mode_defines.name_prefix .. "evolution-time-factor-label",
- evolution_time_factor_textfield = creative_mode_defines.name_prefix .. "evolution-time-factor-textfield",
- evolution_time_factor_separator = creative_mode_defines.name_prefix .. "evolution-time-factor-separator",
- evolution_time_factor_apply_button = creative_mode_defines.name_prefix .. "evolution-time-factor-apply-button",
- evolution_destroy_factor_container = creative_mode_defines.name_prefix .. "evolution-destroy-factor-container",
- evolution_destroy_factor_label = creative_mode_defines.name_prefix .. "evolution-destroy-factor-label",
- evolution_destroy_factor_textfield = creative_mode_defines.name_prefix .. "evolution-destroy-factor-textfield",
- evolution_destroy_factor_separator = creative_mode_defines.name_prefix .. "evolution-destroy-factor-separator",
- evolution_destroy_factor_apply_button = creative_mode_defines.name_prefix
- .. "evolution-destroy-factor-apply-button",
- evolution_pollution_factor_container = creative_mode_defines.name_prefix .. "evolution-pollution-factor-container",
- evolution_pollution_factor_label = creative_mode_defines.name_prefix .. "evolution-pollution-factor-label",
- evolution_pollution_factor_textfield = creative_mode_defines.name_prefix .. "evolution-pollution-factor-textfield",
- evolution_pollution_factor_separator = creative_mode_defines.name_prefix .. "evolution-pollution-factor-separator",
- evolution_pollution_factor_apply_button = creative_mode_defines.name_prefix
- .. "evolution-pollution-factor-apply-button",
- enemy_expansion_container = creative_mode_defines.name_prefix .. "enemy-expansion-container",
- enemy_expansion_label = creative_mode_defines.name_prefix .. "enemy-expansion-label",
- enemy_expansion_on_button = creative_mode_defines.name_prefix .. "enemy-expansion-on-button",
- enemy_expansion_off_button = creative_mode_defines.name_prefix .. "enemy-expansion-off-button",
- enemy_expansion_min_cooldown_container = creative_mode_defines.name_prefix
- .. "enemy-expansion-min-cooldown-container",
- enemy_expansion_min_cooldown_label = creative_mode_defines.name_prefix .. "enemy-expansion-min-cooldown-label",
- enemy_expansion_min_cooldown_textfield = creative_mode_defines.name_prefix
- .. "enemy-expansion-min-cooldown-textfield",
- enemy_expansion_min_cooldown_separator = creative_mode_defines.name_prefix
- .. "enemy-expansion-min-cooldown-separator",
- enemy_expansion_min_cooldown_apply_button = creative_mode_defines.name_prefix
- .. "enemy-expansion-min-cooldown-apply-button",
- enemy_expansion_max_cooldown_container = creative_mode_defines.name_prefix
- .. "enemy-expansion-max-cooldown-container",
- enemy_expansion_max_cooldown_label = creative_mode_defines.name_prefix .. "enemy-expansion-max-cooldown-label",
- enemy_expansion_max_cooldown_textfield = creative_mode_defines.name_prefix
- .. "enemy-expansion-max-cooldown-textfield",
- enemy_expansion_max_cooldown_separator = creative_mode_defines.name_prefix
- .. "enemy-expansion-max-cooldown-separator",
- enemy_expansion_max_cooldown_apply_button = creative_mode_defines.name_prefix
- .. "enemy-expansion-max-cooldown-apply-button",
- game_speed_container = creative_mode_defines.name_prefix .. "game-speed-container",
- game_speed_label = creative_mode_defines.name_prefix .. "game-speed-label",
- game_speed_textfield = creative_mode_defines.name_prefix .. "game-speed-textfield",
- game_speed_separator = creative_mode_defines.name_prefix .. "game-speed-separator",
- game_speed_apply_button = creative_mode_defines.name_prefix .. "game-speed-apply-button",
- build_options_menus_container = creative_mode_defines.name_prefix .. "build-options-menus_container",
- build_options_frame = creative_mode_defines.name_prefix .. "build-options-frame",
- build_options_outer_contianer = creative_mode_defines.name_prefix .. "build-options-outer-container",
- build_options_targets_scroll_pane = creative_mode_defines.name_prefix .. "build-options-targets-scroll-pane",
- build_options_targets_container = creative_mode_defines.name_prefix .. "build-options-targets-container",
- build_options_targets_inner_container = creative_mode_defines.name_prefix
- .. "build-options-targets-inner-container",
- build_options_target_index_button_prefix = creative_mode_defines.name_prefix
- .. "build-options-target-index-button-",
- build_options_targets_select_all_button = creative_mode_defines.name_prefix
- .. "build-options-targets-select-all-button",
- build_options_cheats_scroll_pane = creative_mode_defines.name_prefix .. "build-options-cheats-scroll-pane",
- build_options_cheats_container = creative_mode_defines.name_prefix .. "build-options-cheats-container",
- build_active_container = creative_mode_defines.name_prefix .. "build-active-container",
- build_active_label = creative_mode_defines.name_prefix .. "build-active-label",
- build_active_on_button = creative_mode_defines.name_prefix .. "build-active-on-button",
- build_active_off_button = creative_mode_defines.name_prefix .. "build-active-off-button",
- build_destructible_container = creative_mode_defines.name_prefix .. "build-destructible-container",
- build_destructible_label = creative_mode_defines.name_prefix .. "build-destructible-label",
- build_destructible_on_button = creative_mode_defines.name_prefix .. "build-destructible-on-button",
- build_destructible_off_button = creative_mode_defines.name_prefix .. "build-destructible-off-button",
- build_minable_container = creative_mode_defines.name_prefix .. "build-minable-container",
- build_minable_label = creative_mode_defines.name_prefix .. "build-minable-label",
- build_minable_on_button = creative_mode_defines.name_prefix .. "build-minable-on-button",
- build_minable_off_button = creative_mode_defines.name_prefix .. "build-minable-off-button",
- build_rotatable_container = creative_mode_defines.name_prefix .. "build-rotatable-container",
- build_rotatable_label = creative_mode_defines.name_prefix .. "build-rotatable-label",
- build_rotatable_on_button = creative_mode_defines.name_prefix .. "build-rotatable-on-button",
- build_rotatable_off_button = creative_mode_defines.name_prefix .. "build-rotatable-off-button",
- build_operable_container = creative_mode_defines.name_prefix .. "build-operable-container",
- build_operable_label = creative_mode_defines.name_prefix .. "build-operable-label",
- build_operable_on_button = creative_mode_defines.name_prefix .. "build-operable-on-button",
- build_operable_off_button = creative_mode_defines.name_prefix .. "build-operable-off-button",
- build_full_health_container = creative_mode_defines.name_prefix .. "build-full-health-container",
- build_full_health_label = creative_mode_defines.name_prefix .. "build-full-health-label",
- build_full_health_on_button = creative_mode_defines.name_prefix .. "build-full-health-on-button",
- build_full_health_off_button = creative_mode_defines.name_prefix .. "build-full-health-off-button",
- build_team_container = creative_mode_defines.name_prefix .. "build-team-container",
- build_team_label = creative_mode_defines.name_prefix .. "build-team-label",
- build_team_targets_drop_down_container = creative_mode_defines.name_prefix
- .. "build-team-targets-drop-down-container",
- build_team_current_button = creative_mode_defines.name_prefix .. "build-team-current-button",
- build_team_targets_scroll_pane = creative_mode_defines.name_prefix .. "build-team-targets-scroll-pane",
- build_team_targets_container = creative_mode_defines.name_prefix .. "build-team-targets-container",
- build_team_targets_inner_container = creative_mode_defines.name_prefix .. "build-team-targets-inner-container",
- build_team_target_name_button_prefix = creative_mode_defines.name_prefix .. "build-team-target-name-button-",
- magic_wand_menus_container = creative_mode_defines.name_prefix .. "magic-wand-menus-container",
- magic_wand_frame = creative_mode_defines.name_prefix .. "magic-wand-frame",
- magic_wand_creator_menu_button = creative_mode_defines.name_prefix .. "magic-wand-creator-menu-button",
- magic_wand_healer_menu_button = creative_mode_defines.name_prefix .. "magic-wand-healer-menu-button",
- magic_wand_modifier_menu_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-menu-button",
- magic_wand_creator_frame = creative_mode_defines.name_prefix .. "magic-wand-creator-frame",
- magic_wand_creator_frame_title_container = creative_mode_defines.name_prefix
- .. "magic-wand-creator-frame-title-container",
- magic_wand_creator_frame_title = creative_mode_defines.name_prefix .. "magic-wand-creator-frame-title",
- magic_wand_creator_get_item_button = creative_mode_defines.name_prefix .. "magic-wand-creator-get-item-button",
- magic_wand_creator_scroll_pane = creative_mode_defines.name_prefix .. "magic-wand-creator-scroll-pane",
- magic_wand_creator_container = creative_mode_defines.name_prefix .. "magic-wand-creator-container",
- magic_wand_creator_select_mode_container = creative_mode_defines.name_prefix
- .. "magic-wand-creator-select-mode-container",
- magic_wand_creator_select_mode_label = creative_mode_defines.name_prefix .. "magic-wand-creator-select-mode-label",
- magic_wand_creator_alt_select_mode_container = creative_mode_defines.name_prefix
- .. "magic-wand-creator-alt-select-mode-container",
- magic_wand_creator_alt_select_mode_label = creative_mode_defines.name_prefix
- .. "magic-wand-creator-alt-select-mode-label",
- magic_wand_creator_correct_tiles_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-creator-correct-tiles-checkbox",
- magic_wand_creator_dont_kill_by_tiles_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-creator-dont-kill-by-tiles-checkbox",
- magic_wand_creator_tiles_table = creative_mode_defines.name_prefix .. "magic-wand-creator-tiles-table",
- magic_wand_creator_tile_name_button_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-creator-tile-name-button-",
- magic_wand_creator_resources_table = creative_mode_defines.name_prefix .. "magic-wand-creator-resources-table",
- magic_wand_creator_resource_name_button_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-name-button-",
- magic_wand_creator_rsc_amt_slider_container = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-container",
- magic_wand_creator_rsc_amt_slider_label = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-label",
- magic_wand_creator_rsc_amt_slider_spacing_1 = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-spacing-1",
- magic_wand_creator_rsc_amt_slider_button_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-button-",
- magic_wand_creator_rsc_amt_slider_spacing_2 = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-spacing-2",
- magic_wand_creator_rsc_amt_slider_textfield = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-textfield",
- magic_wand_creator_use_pattern_container = creative_mode_defines.name_prefix
- .. "magic-wand-creator-use-pattern-container",
- magic_wand_creator_use_pattern_label = creative_mode_defines.name_prefix .. "magic-wand-creator-use-pattern-label",
- magic_wand_creator_use_pattern_drop_down = creative_mode_defines.name_prefix
- .. "magic-wand-creator-use-pattern-drop-down",
- magic_wand_creator_tile_or_resource_2_container = creative_mode_defines.name_prefix
- .. "magic-wand-creator-tile-or-resource-2-container",
- magic_wand_creator_tiles_table_2 = creative_mode_defines.name_prefix .. "magic-wand-creator-tiles-table-2",
- magic_wand_creator_tile_name_button_2_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-creator-tile-name-button-2-",
- magic_wand_creator_resources_table_2 = creative_mode_defines.name_prefix .. "magic-wand-creator-resources-table-2",
- magic_wand_creator_resource_name_button_2_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-name-button-2-",
- magic_wand_creator_rsc_amt_slider_container_2 = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-container-2",
- magic_wand_creator_rsc_amt_slider_label_2 = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-label-2",
- magic_wand_creator_rsc_amt_slider_spacing_1_2 = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-spacing-1-2",
- magic_wand_creator_rsc_amt_slider_button_2_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-button-2-",
- magic_wand_creator_rsc_amt_slider_spacing_2_2 = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-spacing-2-2",
- magic_wand_creator_rsc_amt_slider_textfield_2 = creative_mode_defines.name_prefix
- .. "magic-wand-creator-resource-amount-slider-textfield-2",
- magic_wand_creator_also_remove_decoratives_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-creator-also-remove-decoratives-checkbox",
- magic_wand_creator_dont_remove_characters_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-creator-dont-remove-characters-checkbox",
- magic_wand_creator_dont_remove_tiles_with_entities_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-creator-dont-remove-tiles-with-entities-checkbox",
- magic_wand_creator_dont_kill_by_removing_tiles_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-creator-dont-kill-by-removing-tiles-checkbox",
- magic_wand_creator_alt_forces_label = creative_mode_defines.name_prefix .. "magic-wand-creator-alt-forces-label",
- magic_wand_creator_alt_forces_table = creative_mode_defines.name_prefix .. "magic-wand-creator-alt-forces-table",
- magic_wand_creator_alt_force_name_checkbox_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-creator-alt-force-name-checkbox-",
- magic_wand_creator_alt_forces_select_all_button = creative_mode_defines.name_prefix
- .. "magic-wand-creator-alt-forces-select-all-button",
- magic_wand_healer_frame = creative_mode_defines.name_prefix .. "magic-wand-healer-frame",
- magic_wand_healer_frame_title_container = creative_mode_defines.name_prefix
- .. "magic-wand-healer-frame-title-container",
- magic_wand_healer_frame_title = creative_mode_defines.name_prefix .. "magic-wand-healer-frame-title",
- magic_wand_healer_get_item_button = creative_mode_defines.name_prefix .. "magic-wand-healer-get-item-button",
- magic_wand_healer_scroll_pane = creative_mode_defines.name_prefix .. "magic-wand-healer-scroll-pane",
- magic_wand_healer_container = creative_mode_defines.name_prefix .. "magic-wand-healer-container",
- magic_wand_healer_select_mode_container = creative_mode_defines.name_prefix
- .. "magic-wand-healer-select-mode-container",
- magic_wand_healer_select_mode_label = creative_mode_defines.name_prefix .. "magic-wand-healer-select-mode-label",
- magic_wand_healer_alt_select_mode_container = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-select-mode-container",
- magic_wand_healer_alt_select_mode_label = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-select-mode-label",
- magic_wand_healer_revive_ghosts_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-healer-revive-ghosts-checkbox",
- magic_wand_healer_heal_forces_label = creative_mode_defines.name_prefix .. "magic-wand-healer-heal-forces-label",
- magic_wand_healer_heal_forces_table = creative_mode_defines.name_prefix .. "magic-wand-healer-heal-forces-table",
- magic_wand_healer_heal_force_name_checkbox_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-healer-heal-force-name-checkbox-",
- magic_wand_healer_heal_forces_select_all_button = creative_mode_defines.name_prefix
- .. "magic-wand-healer-heal-forces-select-all-button",
- magic_wand_healer_alt_actions_container = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-actions-container",
- magic_wand_healer_alt_set_hp_radiobutton = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-set-hp-radiobutton",
- magic_wand_healer_alt_kill_radiobutton = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-kill-radiobutton",
- magic_wand_healer_alt_dont_affect_characters_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-dont-affect-characters-checkbox",
- magic_wand_healer_alt_dont_affect_indestructible_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-dont-affect-indestructible-checkbox",
- magic_wand_healer_alt_forces_label = creative_mode_defines.name_prefix .. "magic-wand-healer-alt-forces-label",
- magic_wand_healer_alt_forces_table = creative_mode_defines.name_prefix .. "magic-wand-healer-alt-forces-table",
- magic_wand_healer_alt_force_name_checkbox_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-force-name-checkbox-",
- magic_wand_healer_alt_forces_select_all_button = creative_mode_defines.name_prefix
- .. "magic-wand-healer-alt-forces-select-all-button",
- magic_wand_modifier_frame = creative_mode_defines.name_prefix .. "magic-wand-modifier-frame",
- magic_wand_modifier_frame_title_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-frame-title-container",
- magic_wand_modifier_frame_title = creative_mode_defines.name_prefix .. "magic-wand-modifier-frame-title",
- magic_wand_modifier_get_item_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-get-item-button",
- magic_wand_modifier_scroll_pane = creative_mode_defines.name_prefix .. "magic-wand-modifier-scroll-pane",
- magic_wand_modifier_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-container",
- magic_wand_modifier_select_mode_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-select-mode-container",
- magic_wand_modifier_select_mode_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-select-mode-label",
- magic_wand_modifier_alt_select_mode_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-alt-select-mode-container",
- magic_wand_modifier_alt_select_mode_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-alt-select-mode-label",
- magic_wand_modifier_std_ignore_characters_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-std-ignore-characters-checkbox",
- magic_wand_modifier_std_ignore_healthless_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-std-ignore-healthless-checkbox",
- magic_wand_modifier_std_ignore_indestructible_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-std-ignore-indestructible-checkbox",
- magic_wand_modifier_std_forces_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-std-forces-label",
- magic_wand_modifier_std_forces_table = creative_mode_defines.name_prefix .. "magic-wand-modifier-std-forces-table",
- magic_wand_modifier_std_force_name_checkbox_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-std-force-name-checkbox-",
- magic_wand_modifier_std_forces_select_all_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-std-forces-select-all-button",
- magic_wand_modifier_alt_ignore_characters_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-alt-ignore-characters-checkbox",
- magic_wand_modifier_alt_ignore_healthless_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-alt-ignore-healthless-checkbox",
- magic_wand_modifier_alt_ignore_indestructible_checkbox = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-alt-ignore-indestructible-checkbox",
- magic_wand_modifier_alt_forces_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-alt-forces-label",
- magic_wand_modifier_alt_forces_table = creative_mode_defines.name_prefix .. "magic-wand-modifier-alt-forces-table",
- magic_wand_modifier_alt_force_name_checkbox_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-alt-force-name-checkbox-",
- magic_wand_modifier_alt_forces_select_all_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-alt-forces-select-all-button",
- magic_wand_modifier_quick_actions_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-quick-actions-label",
- magic_wand_modifier_quick_actions_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-quick-actions-container",
- magic_wand_modifier_quick_action_container_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-quick-action-container-",
- magic_wand_modifier_quick_action_remove_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-quick-action-remove-button",
- magic_wand_modifier_quick_action_separator = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-quick-action-separator",
- magic_wand_modifier_quick_action_name_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-quick-action-name-label",
- magic_wand_modifier_quick_action_colon_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-quick-action-colon-label",
- magic_wand_modifier_quick_action_value_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-quick-action-value-label",
- magic_wand_modifier_remove_all_quick_actions_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-remove-all-quick-actions-button",
- magic_wand_modifier_popup_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-popup-container",
- magic_wand_modifier_popup_entities_frame = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-entities-frame",
- magic_wand_modifier_popup_entities_frame_title_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-entities-frame-title-container",
- magic_wand_modifier_popup_entities_frame_title_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-entities-frame-title-label",
- magic_wand_modifier_popup_entities_frame_refresh_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-entities-frame-refresh-button",
- magic_wand_modifier_popup_entities_sroll_pane = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-entities-scroll-pane",
- magic_wand_modifier_popup_entities_table = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-entities-table",
- magic_wand_modifier_popup_entity_name_slot_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-entity-slot-",
- magic_wand_modifier_popup_item_on_ground_name_slot_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-item-on-ground-slot-",
- magic_wand_modifier_popup_ghost_entity_name_slot_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-ghost-entity-slot-",
- magic_wand_modifier_popup_ghost_tile_name_slot_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-ghost-tile-slot-",
- magic_wand_modifier_popup_entity_count_label_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-entity-count-label-",
- magic_wand_modifier_popup_item_on_ground_count_label_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-item-on-ground-count-label-",
- magic_wand_modifier_popup_ghost_entity_count_label_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-ghost-entity-count-label-",
- magic_wand_modifier_popup_ghost_tile_count_label_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-ghost-tile-count-label-",
- magic_wand_modifier_popup_actions_frame = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-actions-frame",
- magic_wand_modifier_popup_actions_frame_title_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-actions-frame-title-container",
- magic_wand_modifier_popup_actions_frame_title_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-actions-frame-title-label",
- magic_wand_modifier_popup_actions_frame_close_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-popup-actions-frame-close-button",
- magic_wand_modifier_active_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-active-container",
- magic_wand_modifier_active_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-active-label",
- magic_wand_modifier_active_on_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-active-on-button",
- magic_wand_modifier_active_off_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-active-off-button",
- magic_wand_modifier_destructible_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-destructible-container",
- magic_wand_modifier_destructible_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-destructible-label",
- magic_wand_modifier_destructible_on_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-destructible-on-button",
- magic_wand_modifier_destructible_off_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-destructible-off-button",
- magic_wand_modifier_minable_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-minable-container",
- magic_wand_modifier_minable_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-minable-label",
- magic_wand_modifier_minable_on_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-minable-on-button",
- magic_wand_modifier_minable_off_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-minable-off-button",
- magic_wand_modifier_rotatable_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-rotatable-container",
- magic_wand_modifier_rotatable_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-rotatable-label",
- magic_wand_modifier_rotatable_on_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-rotatable-on-button",
- magic_wand_modifier_rotatable_off_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-rotatable-off-button",
- magic_wand_modifier_operable_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-operable-container",
- magic_wand_modifier_operable_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-operable-label",
- magic_wand_modifier_operable_on_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-operable-on-button",
- magic_wand_modifier_operable_off_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-operable-off-button",
- magic_wand_modifier_full_health_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-full-health-container",
- magic_wand_modifier_full_health_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-full-health-label",
- magic_wand_modifier_full_health_on_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-full-health-on-button",
- magic_wand_modifier_full_health_off_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-full-health-off-button",
- magic_wand_modifier_backer_name_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-backer-name-container",
- magic_wand_modifier_backer_name_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-backer-name-label",
- magic_wand_modifier_backer_name_textfield = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-backer-name-textfield",
- magic_wand_modifier_backer_name_separator = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-backer-name-separator",
- magic_wand_modifier_backer_name_apply_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-backer-name-apply-button",
- magic_wand_modifier_to_be_looted_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-to-be-looted-container",
- magic_wand_modifier_to_be_looted_label = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-to-be-looted-label",
- magic_wand_modifier_to_be_looted_on_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-to-be-looted-on-button",
- magic_wand_modifier_to_be_looted_off_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-to-be-looted-off-button",
- magic_wand_modifier_revive_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-revive-container",
- magic_wand_modifier_revive_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-revive-label",
- magic_wand_modifier_revive_apply_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-revive-apply-button",
- magic_wand_modifier_kill_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-kill-container",
- magic_wand_modifier_kill_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-kill-label",
- magic_wand_modifier_kill_apply_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-kill-apply-button",
- magic_wand_modifier_destroy_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-destroy-container",
- magic_wand_modifier_destroy_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-destroy-label",
- magic_wand_modifier_destroy_apply_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-destroy-apply-button",
- magic_wand_modifier_team_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-team-container",
- magic_wand_modifier_team_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-team-label",
- magic_wand_modifier_team_targets_drop_down_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-team-targets-drop-down-container",
- magic_wand_modifier_team_current_button = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-team-current-button",
- magic_wand_modifier_team_targets_scroll_pane = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-team-targets-scroll-pane",
- magic_wand_modifier_team_targets_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-team-targets-container",
- magic_wand_modifier_team_targets_inner_container = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-team-targets-inner-container",
- magic_wand_modifier_team_target_name_button_prefix = creative_mode_defines.name_prefix
- .. "magic-wand-modifier-team-target-name-button-",
- modding_menus_container = creative_mode_defines.name_prefix .. "modding-menu-container",
- modding_menus_frame = creative_mode_defines.name_prefix .. "modding-menu-frame",
- events_menu_button = creative_mode_defines.name_prefix .. "events-menu-button",
- interfaces_menu_button = creative_mode_defines.name_prefix .. "interfaces-menu-button",
- events_menu_frame = creative_mode_defines.name_prefix .. "events-menu-frame",
- events_menu_title_container = creative_mode_defines.name_prefix .. "events-menu-title-container",
- events_menu_title_label = creative_mode_defines.name_prefix .. "events-menu-title-label",
- events_menu_title_separator_1 = creative_mode_defines.name_prefix .. "events-menu-title-separator_1",
- events_menu_search_textfield = creative_mode_defines.name_prefix .. "events-menu-search-textfield",
- events_menu_search_textfield_placeholder_flow = creative_mode_defines.name_prefix
- .. "events-menu-search-textfield-placeholder-flow",
- events_menu_title_separator_2 = creative_mode_defines.name_prefix .. "events-menu-title-separator_2",
- events_menu_search_button = creative_mode_defines.name_prefix .. "events-menu-search-button",
- events_menu_label = creative_mode_defines.name_prefix .. "events-menu-label",
- events_scroll_pane = creative_mode_defines.name_prefix .. "events-scroll-pane",
- events_inner_container = creative_mode_defines.name_prefix .. "events-inner-container",
- event_container_prefix = creative_mode_defines.name_prefix .. "event-container-",
- event_toggle_checkbox_prefix = creative_mode_defines.name_prefix .. "event-toggle-checkbox-",
- events_all_button_container = creative_mode_defines.name_prefix .. "eventa-all-button-container",
- events_enable_all_button = creative_mode_defines.name_prefix .. "events-enable-all-button",
- events_disable_all_button = creative_mode_defines.name_prefix .. "events-disable-all-button",
- event_categories_and_options_container = creative_mode_defines.name_prefix
- .. "event-categories-and-options-container",
- event_categories_frame = creative_mode_defines.name_prefix .. "event-categories-frame",
- event_category_item_container = creative_mode_defines.name_prefix .. "event-category-item-container",
- event_category_item_label = creative_mode_defines.name_prefix .. "event-category-item-label",
- event_category_item_show_button = creative_mode_defines.name_prefix .. "event-category-item-show-button",
- event_category_item_hide_button = creative_mode_defines.name_prefix .. "event-category-item-hide-button",
- event_category_entity_container = creative_mode_defines.name_prefix .. "event-category-entity-container",
- event_category_entity_label = creative_mode_defines.name_prefix .. "event-category-entity-label",
- event_category_entity_show_button = creative_mode_defines.name_prefix .. "event-category-entity-show-button",
- event_category_entity_hide_button = creative_mode_defines.name_prefix .. "event-category-entity-hide-button",
- event_category_tile_container = creative_mode_defines.name_prefix .. "event-category-tile-container",
- event_category_tile_label = creative_mode_defines.name_prefix .. "event-category-tile-label",
- event_category_tile_show_button = creative_mode_defines.name_prefix .. "event-category-tile-show-button",
- event_category_tile_hide_button = creative_mode_defines.name_prefix .. "event-category-tile-hide-button",
- event_category_technology_container = creative_mode_defines.name_prefix .. "event-category-technology-container",
- event_category_technology_label = creative_mode_defines.name_prefix .. "event-category-technology-label",
- event_category_technology_show_button = creative_mode_defines.name_prefix
- .. "event-category-technology-show-button",
- event_category_technology_hide_button = creative_mode_defines.name_prefix
- .. "event-category-technology-hide-button",
- event_category_player_container = creative_mode_defines.name_prefix .. "event-category-player-container",
- event_category_player_label = creative_mode_defines.name_prefix .. "event-category-player-label",
- event_category_player_show_button = creative_mode_defines.name_prefix .. "event-category-player-show-button",
- event_category_player_hide_button = creative_mode_defines.name_prefix .. "event-category-player-hide-button",
- event_category_force_container = creative_mode_defines.name_prefix .. "event-category-force-container",
- event_category_force_label = creative_mode_defines.name_prefix .. "event-category-force-label",
- event_category_force_show_button = creative_mode_defines.name_prefix .. "event-category-force-show-button",
- event_category_force_hide_button = creative_mode_defines.name_prefix .. "event-category-force-hide-button",
- event_category_surface_container = creative_mode_defines.name_prefix .. "event-category-surface-container",
- event_category_surface_label = creative_mode_defines.name_prefix .. "event-category-surface-label",
- event_category_surface_show_button = creative_mode_defines.name_prefix .. "event-category-surface-show-button",
- event_category_surface_hide_button = creative_mode_defines.name_prefix .. "event-category-surface-hide-button",
- event_category_position_container = creative_mode_defines.name_prefix .. "event-category-position-container",
- event_category_position_label = creative_mode_defines.name_prefix .. "event-category-position-label",
- event_category_position_show_button = creative_mode_defines.name_prefix .. "event-category-position-show-button",
- event_category_position_hide_button = creative_mode_defines.name_prefix .. "event-category-position-hide-button",
- event_category_gui_container = creative_mode_defines.name_prefix .. "event-category-gui-container",
- event_category_gui_label = creative_mode_defines.name_prefix .. "event-category-gui-label",
- event_category_gui_show_button = creative_mode_defines.name_prefix .. "event-category-gui-show-button",
- event_category_gui_hide_button = creative_mode_defines.name_prefix .. "event-category-gui-hide-button",
- event_category_settings_container = creative_mode_defines.name_prefix .. "event-category-settings-container",
- event_category_settings_label = creative_mode_defines.name_prefix .. "event-category-settings-label",
- event_category_settings_show_button = creative_mode_defines.name_prefix .. "event-category-settings-show-button",
- event_category_settings_hide_button = creative_mode_defines.name_prefix .. "event-category-settings-hide-button",
- event_category_all_container = creative_mode_defines.name_prefix .. "event-category-all-container",
- event_category_all_label = creative_mode_defines.name_prefix .. "event-category-all-label",
- event_category_all_show_button = creative_mode_defines.name_prefix .. "event-category-all-show-button",
- event_category_all_hide_button = creative_mode_defines.name_prefix .. "event-category-all-hide-button",
- event_options_frame = creative_mode_defines.name_prefix .. "event-options-frame",
- event_options_container = creative_mode_defines.name_prefix .. "event-options-container",
- event_option_print_events_checkbox = creative_mode_defines.name_prefix .. "event-option-print-events-checkbox",
- event_option_print_parameters_checkbox = creative_mode_defines.name_prefix
- .. "event-option-print-parameters-checkbox",
- event_option_write_events_checkbox = creative_mode_defines.name_prefix .. "event-option-write-events-checkbox",
- event_option_write_parameters_checkbox = creative_mode_defines.name_prefix
- .. "event-option-write-parameters-checkbox",
- event_option_log_events_checkbox = creative_mode_defines.name_prefix .. "event-option-log-events-checkbox",
- event_option_log_parameters_checkbox = creative_mode_defines.name_prefix .. "event-option-log-parameters-checkbox",
- interfaces_menu_frame = creative_mode_defines.name_prefix .. "interfaces-menu-frame",
- interfaces_menu_label = creative_mode_defines.name_prefix .. "interfaces-menu-label",
- interfaces_scroll_pane = creative_mode_defines.name_prefix .. "interfaces-scroll-pane",
- interfaces_inner_container = creative_mode_defines.name_prefix .. "interfaces-inner-container",
- interface_button_prefix = creative_mode_defines.name_prefix .. "interface-button-",
- interface_contents_and_hints_container = creative_mode_defines.name_prefix
- .. "interface-contents-and-hints-container",
- interface_contents_frame = creative_mode_defines.name_prefix .. "interface-contents-frame",
- interface_contents_scroll_pane = creative_mode_defines.name_prefix .. "interface-contents-scroll-pane",
- interface_contents_container = creative_mode_defines.name_prefix .. "interface-contents-container",
- interface_contents_label_prefix = creative_mode_defines.name_prefix .. "interface-contents-label-",
- interface_contents_button_prefix = creative_mode_defines.name_prefix .. "interface-contents-button-",
- interface_hints_frame = creative_mode_defines.name_prefix .. "interface-hints-frame",
- interface_can_register_remote_function_label = creative_mode_defines.name_prefix
- .. "interface-can-register-remote-function-label",
- admin_menus_container = creative_mode_defines.name_prefix .. "admin-menus-container",
- access_right_frame = creative_mode_defines.name_prefix .. "access-right-frame",
- access_right_label = creative_mode_defines.name_prefix .. "access-right-label",
- access_rights_scroll_pane = creative_mode_defines.name_prefix .. "access-rights-scroll-pane",
- access_rights_container = creative_mode_defines.name_prefix .. "access-rights-container",
- disable_mode_frame = creative_mode_defines.name_prefix .. "disable-mode-frame",
- access_personal_cheat_container = creative_mode_defines.name_prefix .. "access-personal-cheat-container",
- access_personal_cheat_label = creative_mode_defines.name_prefix .. "access-personal-cheat-label",
- access_personal_cheat_inner_container = creative_mode_defines.name_prefix
- .. "access-personal-cheat-inner-container",
- access_personal_cheat_admin_only_button = creative_mode_defines.name_prefix
- .. "access-personal-cheat-admin-only-button",
- access_personal_cheat_free_button = creative_mode_defines.name_prefix .. "access-personal-cheat-free-button",
- access_team_cheat_container = creative_mode_defines.name_prefix .. "access-team-cheat-container",
- access_team_cheat_label = creative_mode_defines.name_prefix .. "access-team-cheat-label",
- access_team_cheat_inner_container = creative_mode_defines.name_prefix .. "access-team-cheat-inner-container",
- access_team_cheat_admin_only_button = creative_mode_defines.name_prefix .. "access-team-cheat-admin-only-button",
- access_team_cheat_own_team_button = creative_mode_defines.name_prefix .. "access-team-cheat-own-team-button",
- access_team_cheat_free_button = creative_mode_defines.name_prefix .. "access-team-cheat-free-button",
- access_surface_cheat_container = creative_mode_defines.name_prefix .. "access-surface-cheat-container",
- access_surface_cheat_label = creative_mode_defines.name_prefix .. "access-surface-cheat-label",
- access_surface_cheat_inner_container = creative_mode_defines.name_prefix .. "access-surface-cheat-inner-container",
- access_surface_cheat_admin_only_button = creative_mode_defines.name_prefix
- .. "access-surface-cheat-admin-only-button",
- access_surface_cheat_current_surface_button = creative_mode_defines.name_prefix
- .. "access-surface-cheat-current-surface-button",
- access_surface_cheat_free_button = creative_mode_defines.name_prefix .. "access-surface-cheat-free-button",
- access_global_cheat_container = creative_mode_defines.name_prefix .. "access-global-cheat-container",
- access_global_cheat_label = creative_mode_defines.name_prefix .. "access-global-cheat-label",
- access_global_cheat_inner_container = creative_mode_defines.name_prefix .. "access-global-cheat-inner-container",
- access_global_cheat_admin_only_button = creative_mode_defines.name_prefix
- .. "access-global-cheat-admin-only-button",
- access_global_cheat_free_button = creative_mode_defines.name_prefix .. "access-global-cheat-free-button",
- access_build_options_container = creative_mode_defines.name_prefix .. "access-build-options-container",
- access_build_options_label = creative_mode_defines.name_prefix .. "access-build-options-label",
- access_build_options_inner_container = creative_mode_defines.name_prefix .. "access-build-options-inner-container",
- access_build_options_admin_only_button = creative_mode_defines.name_prefix
- .. "access-build-options-admin-only-button",
- access_build_options_no_team_button = creative_mode_defines.name_prefix .. "access-build-options-no-team-button",
- access_build_options_free_button = creative_mode_defines.name_prefix .. "access-build-options-free-button",
- access_creator_magic_wand_container = creative_mode_defines.name_prefix .. "access-creator-magic-wand-container",
- access_creator_magic_wand_label = creative_mode_defines.name_prefix .. "access-creator-magic-wand-label",
- access_creator_magic_wand_inner_container = creative_mode_defines.name_prefix
- .. "access-creator-magic-wand-inner-container",
- access_creator_magic_wand_admin_only_button = creative_mode_defines.name_prefix
- .. "access-creator-magic-wand-admin-only-button",
- access_creator_magic_wand_free_button = creative_mode_defines.name_prefix
- .. "access-creator-magic-wand-free-button",
- access_healer_magic_wand_container = creative_mode_defines.name_prefix .. "access-healer-magic-wand-container",
- access_healer_magic_wand_label = creative_mode_defines.name_prefix .. "access-healer_magic_wand-label",
- access_healer_magic_wand_inner_container = creative_mode_defines.name_prefix
- .. "access-healer-magic-wand-inner-container",
- access_healer_magic_wand_admin_only_button = creative_mode_defines.name_prefix
- .. "access-healer-magic-wand-admin-only-button",
- access_healer_magic_wand_free_button = creative_mode_defines.name_prefix .. "access-healer-magic-wand-free-button",
- access_modifier_magic_wand_container = creative_mode_defines.name_prefix .. "access-modifier-magic-wand-container",
- access_modifier_magic_wand_label = creative_mode_defines.name_prefix .. "access-modifier-magic-wand-label",
- access_modifier_magic_wand_inner_container = creative_mode_defines.name_prefix
- .. "access-modifier-magic-wand-inner-container",
- access_modifier_magic_wand_admin_only_button = creative_mode_defines.name_prefix
- .. "access-modifier-magic-wand-admin-only-button",
- access_modifier_magic_wand_free_button = creative_mode_defines.name_prefix
- .. "access-modifier-magic-wand-free-button",
- access_modding_menu_container = creative_mode_defines.name_prefix .. "access-modding-menu-container",
- access_modding_menu_label = creative_mode_defines.name_prefix .. "access-modding-menu-label",
- access_modding_menu_inner_container = creative_mode_defines.name_prefix .. "access-modding-menu-inner-container",
- access_modding_menu_admin_only_button = creative_mode_defines.name_prefix
- .. "access-modding-menu-admin-only-button",
- access_modding_menu_free_button = creative_mode_defines.name_prefix .. "access-modding-menu-free-button",
- overall_access_rights_container = creative_mode_defines.name_prefix .. "overall-access-rights-container",
- overall_access_rights_label = creative_mode_defines.name_prefix .. "overall-access-rights-label",
- overall_access_rights_inner_container = creative_mode_defines.name_prefix
- .. "overall-access-rights-inner-container",
- overall_access_rights_admin_only_button = creative_mode_defines.name_prefix
- .. "overall-access-rights-admin-only-button",
- overall_access_rights_default_button = creative_mode_defines.name_prefix .. "overall-access-rights-default-button",
- disable_creative_mode_frame = creative_mode_defines.name_prefix .. "disable-creative-mode-frame",
- disable_creative_mode_button = creative_mode_defines.name_prefix .. "disable-creative-mode-button",
- disable_creative_mode_permanently_button = creative_mode_defines.name_prefix
- .. "disable-creative-mode-permanently-button",
- entity_gui_container = creative_mode_defines.name_prefix .. "entity-gui-container",
- entity_gui_button_container = creative_mode_defines.name_prefix .. "entity-gui-button-container",
- entity_gui_frame_container = creative_mode_defines.name_prefix .. "entity-gui-frame-container",
- entity_gui_frame = creative_mode_defines.name_prefix .. "entity-gui-frame",
- creative_chest_open_button = creative_mode_defines.name_prefix .. "creative-chest-open-button",
- creative_chest_item_group_container = creative_mode_defines.name_prefix .. "creative-chest-item-group-container",
- creative_chest_item_group_label = creative_mode_defines.name_prefix .. "creative-chest-item-group-label",
- creative_chest_item_group_number_label = creative_mode_defines.name_prefix
- .. "creative-chest-item-group-number-label",
- creative_chest_item_group_left_button = creative_mode_defines.name_prefix
- .. "creative-chest-item-group-left-button",
- creative_chest_item_group_right_button = creative_mode_defines.name_prefix
- .. "creative-chest-item-group-right-button",
- creative_chest_filter_container = creative_mode_defines.name_prefix .. "creative-chest-filter-container",
- creative_chest_filter_label = creative_mode_defines.name_prefix .. "creative-chest-filter-label",
- creative_chest_display_mode_button = creative_mode_defines.name_prefix .. "creative-chest-display-mode-button",
- creative_chest_toggle_all_button = creative_mode_defines.name_prefix .. "creative-chest-toggle-all-button",
- creative_chest_filter_scroll_pane = creative_mode_defines.name_prefix .. "creative-chest-filter-scroll-pane",
- creative_chest_filter_table = creative_mode_defines.name_prefix .. "creative-chest-filter-table",
- creative_chest_filter_slot_prefix = creative_mode_defines.name_prefix .. "creative-chest-filter-slot-",
- duplicating_chest_open_button = creative_mode_defines.name_prefix .. "duplicating-chest-open-button",
- duplicating_chest_lock_item_checkbox = creative_mode_defines.name_prefix .. "duplicating-chest-lock-item-checkbox",
- configurable_super_boiler_open_button = creative_mode_defines.name_prefix
- .. "configurable-super-boiler-open-button",
- configurable_super_boiler_set_temp_container = creative_mode_defines.name_prefix
- .. "configurable-super-boiler-set-temp-container",
- configurable_super_boiler_set_temp_label = creative_mode_defines.name_prefix
- .. "configurable-super-boiler-set-temp-label",
- configurable_super_boiler_set_temp_textfield = creative_mode_defines.name_prefix
- .. "configurable-super-boiler-set-temp-textfield",
- configurable_super_boiler_set_temp_button = creative_mode_defines.name_prefix
- .. "configurable-super-boiler-set-temp-button",
- item_source_open_button = creative_mode_defines.name_prefix .. "item-source-open-button",
- item_source_options_container = creative_mode_defines.name_prefix .. "item-source-options-container",
- item_source_can_insert_to_vehicle_checkbox = creative_mode_defines.name_prefix
- .. "item-source-can-insert-to-vehicle-checkbox",
- item_source_can_insert_to_player_checkbox = creative_mode_defines.name_prefix
- .. "item-source-can-insert-to-player-checkbox",
- item_source_can_drop_on_ground_checkbox = creative_mode_defines.name_prefix
- .. "item-source-can-drop-on-ground-checkbox",
- item_source_insert_to_player_frame = creative_mode_defines.name_prefix .. "item-source-insert-to-player-frame",
- item_source_insert_only_once_to_player_checkbox = creative_mode_defines.name_prefix
- .. "item-source-insert-only-once-to-player-checkbox",
- item_source_insert_once_to_player_frame = creative_mode_defines.name_prefix
- .. "item-source-insert-once-to-player-frame",
- item_source_insert_once_to_player_container = creative_mode_defines.name_prefix
- .. "item-source-insert-once-to-player-container",
- item_source_insert_once_to_player_amount_container = creative_mode_defines.name_prefix
- .. "item-source-insert-once-to-player-amount-container",
- item_source_insert_once_to_player_amount_label = creative_mode_defines.name_prefix
- .. "item-source-insert-once-to-player-amount-label",
- item_source_insert_once_to_player_amount_field = creative_mode_defines.name_prefix
- .. "item-source-insert-once-to-player-amount-field",
- item_source_insert_once_to_player_by_stack_checkbox = creative_mode_defines.name_prefix
- .. "item-source-insert-once-to-player-by-stack-checkbox",
- duplicator_open_button = creative_mode_defines.name_prefix .. "duplicator-open-button",
- duplicator_options_container = creative_mode_defines.name_prefix .. "duplicator-options_container",
- duplicator_can_duplicate_in_vehicle_checkbox = creative_mode_defines.name_prefix
- .. "duplicator-can-duplicate-in-vehicle-checkbox",
- duplicator_can_duplicate_in_player_checkbox = creative_mode_defines.name_prefix
- .. "duplicator-can-duplicate-in-player-checkbox",
- item_void_open_button = creative_mode_defines.name_prefix .. "item-void-open-button",
- item_void_options_container = creative_mode_defines.name_prefix .. "item-void-options-container",
- item_void_can_remove_from_vehicle_checkbox = creative_mode_defines.name_prefix
- .. "item-void-can-remove-from-vehicle-checkbox",
- item_void_can_remove_from_player_checkbox = creative_mode_defines.name_prefix
- .. "item-void-can-remove-from-player-checkbox",
- item_void_can_remove_from_ground_checkbox = creative_mode_defines.name_prefix
- .. "item-void-can-remove-from-ground-checkbox",
- -- Legacy GUI. Used for finding and destroying the legacy "more cheats" popup.
- cheats_table = creative_mode_defines.name_prefix .. "cheats-table",
+ popup = creative_mode_defines.name_prefix .. "popup",
+ popup_label = creative_mode_defines.name_prefix .. "popup-label",
+ popup_label2 = creative_mode_defines.name_prefix .. "popup-label2",
+ popup_buttons_container = creative_mode_defines.name_prefix .. "popup-buttons-container",
+ enable_creative_mode_yes = creative_mode_defines.name_prefix .. "enable-creative-mode_yes",
+ enable_creative_mode_yes_with_cheats = creative_mode_defines.name_prefix .. "enable-creative-mode_yes-with-cheats",
+ enable_creative_mode_no = creative_mode_defines.name_prefix .. "enable-creative-mode_no",
+ enable_creative_mode_no_permanently = creative_mode_defines.name_prefix .. "enable-creative-mode_no-permanently",
+ disable_creative_mode_yes = creative_mode_defines.name_prefix .. "disable-creative-mode_yes",
+ disable_creative_mode_no = creative_mode_defines.name_prefix .. "disable-creative-mode_no",
+ permanent_disable_creative_mode_yes = creative_mode_defines.name_prefix .. "permanent-disable-creative-mode_yes",
+ permanent_disable_creative_mode_no = creative_mode_defines.name_prefix .. "permanent-disable-creative-mode_no",
+ main_menu_open_button = creative_mode_defines.name_prefix .. "main-menu-open-button",
+ main_menu_container = creative_mode_defines.name_prefix .. "main-menu-container",
+ main_menu_frame = creative_mode_defines.name_prefix .. "main-menu-frame",
+ main_menu_open_cheats_button = creative_mode_defines.name_prefix .. "main-menu-open-cheats-button",
+ main_menu_open_build_options_button = creative_mode_defines.name_prefix .. "main-menu-open-build-options-button",
+ main_menu_open_magic_wand_button = creative_mode_defines.name_prefix .. "main-menu-open-magic-wand-button",
+ main_menu_open_modding_button = creative_mode_defines.name_prefix .. "main-menu-open-modding-button",
+ main_menu_open_admin_button = creative_mode_defines.name_prefix .. "main-menu-open-admin-button",
+ cheats_menus_container = creative_mode_defines.name_prefix .. "cheats-menus-container",
+ cheats_menu_frame = creative_mode_defines.name_prefix .. "cheats-menu-frame",
+ personal_cheats_menu_button = creative_mode_defines.name_prefix .. "personal-cheats-menu-button",
+ team_cheats_menu_button = creative_mode_defines.name_prefix .. "team-cheats-menu-button",
+ surface_cheats_menu_button = creative_mode_defines.name_prefix .. "surface-cheats-menu-button",
+ global_cheats_menu_button = creative_mode_defines.name_prefix .. "global-cheats-menu-button",
+ personal_cheats_menu_frame = creative_mode_defines.name_prefix .. "personal-cheats-menu-frame",
+ personal_cheats_outer_container = creative_mode_defines.name_prefix .. "personal-cheats-outer-container",
+ personal_cheats_targets_scroll_pane = creative_mode_defines.name_prefix .. "personal-cheats-targets-scroll-pane",
+ personal_cheats_targets_container = creative_mode_defines.name_prefix .. "personal-cheats-targets-container",
+ personal_cheats_targets_inner_container = creative_mode_defines.name_prefix
+ .. "personal-cheats-targets-inner-container",
+ personal_cheats_target_index_button_prefix = creative_mode_defines.name_prefix
+ .. "personal-cheats-target-index-button-",
+ personal_cheats_targets_select_all_button = creative_mode_defines.name_prefix
+ .. "personal-cheats-targets-select-all-button",
+ personal_cheats_cheats_scroll_pane = creative_mode_defines.name_prefix .. "personal-cheats-cheats-scroll-pane",
+ personal_cheats_cheats_container = creative_mode_defines.name_prefix .. "personal-cheats-cheats-container",
+ cheat_mode_container = creative_mode_defines.name_prefix .. "cheat-mode-container",
+ cheat_mode_label = creative_mode_defines.name_prefix .. "cheat-mode-label",
+ cheat_mode_on_button = creative_mode_defines.name_prefix .. "cheat-mode-on-button",
+ cheat_mode_off_button = creative_mode_defines.name_prefix .. "cheat-mode-off-button",
+ invincible_player_container = creative_mode_defines.name_prefix .. "invincible-player-container",
+ invincible_player_label = creative_mode_defines.name_prefix .. "invincible-player-label",
+ invincible_player_on_button = creative_mode_defines.name_prefix .. "invincible-player-on-button",
+ invincible_player_off_button = creative_mode_defines.name_prefix .. "invincible-player-off-button",
+ keep_last_item_container = creative_mode_defines.name_prefix .. "keep-last-item-container",
+ keep_last_item_label = creative_mode_defines.name_prefix .. "keep-last-item-label",
+ keep_last_item_on_button = creative_mode_defines.name_prefix .. "keep-last-item-on-button",
+ keep_last_item_off_button = creative_mode_defines.name_prefix .. "keep-last-item-off-button",
+ repair_mined_item_container = creative_mode_defines.name_prefix .. "repair-mined-item-container",
+ repair_mined_item_label = creative_mode_defines.name_prefix .. "repair-mined-item-label",
+ repair_mined_item_on_button = creative_mode_defines.name_prefix .. "repair-mined-item-on-button",
+ repair_mined_item_off_button = creative_mode_defines.name_prefix .. "repair-mined-item-off-button",
+ instant_request_container = creative_mode_defines.name_prefix .. "instant-request-container",
+ instant_request_label = creative_mode_defines.name_prefix .. "instant-request-label",
+ instant_request_on_button = creative_mode_defines.name_prefix .. "instant-request-on-button",
+ instant_request_off_button = creative_mode_defines.name_prefix .. "instant-request-off-button",
+ instant_trash_container = creative_mode_defines.name_prefix .. "instant-trash-container",
+ instant_trash_label = creative_mode_defines.name_prefix .. "instant-trash-label",
+ instant_trash_on_button = creative_mode_defines.name_prefix .. "instant-trash-on-button",
+ instant_trash_off_button = creative_mode_defines.name_prefix .. "instant-trash-off-button",
+ instant_blueprint_container = creative_mode_defines.name_prefix .. "instant-blueprint-container",
+ instant_blueprint_label = creative_mode_defines.name_prefix .. "instant-blueprint-label",
+ instant_blueprint_on_button = creative_mode_defines.name_prefix .. "instant-blueprint-on-button",
+ instant_blueprint_off_button = creative_mode_defines.name_prefix .. "instant-blueprint-off-button",
+ instant_deconstruction_container = creative_mode_defines.name_prefix .. "instant_deconstruction-container",
+ instant_deconstruction_label = creative_mode_defines.name_prefix .. "instant_deconstruction-label",
+ instant_deconstruction_on_button = creative_mode_defines.name_prefix .. "instant_deconstruction-on-button",
+ instant_deconstruction_off_button = creative_mode_defines.name_prefix .. "instant_deconstruction-off-button",
+ reach_distance_container = creative_mode_defines.name_prefix .. "reach-distance-container",
+ reach_distance_label = creative_mode_defines.name_prefix .. "reach-distance-label",
+ reach_distance_textfield = creative_mode_defines.name_prefix .. "reach-distance-textfield",
+ reach_distance_separator = creative_mode_defines.name_prefix .. "reach-distance-separator",
+ reach_distance_apply_button = creative_mode_defines.name_prefix .. "reach-distance-apply-button",
+ build_distance_container = creative_mode_defines.name_prefix .. "build-distance-container",
+ build_distance_label = creative_mode_defines.name_prefix .. "build-distance-label",
+ build_distance_textfield = creative_mode_defines.name_prefix .. "build-distance-textfield",
+ build_distance_separator = creative_mode_defines.name_prefix .. "build-distance-separator",
+ build_distance_apply_button = creative_mode_defines.name_prefix .. "build-distance-apply-button",
+ resource_reach_distance_container = creative_mode_defines.name_prefix .. "resource-reach-distance-container",
+ resource_reach_distance_label = creative_mode_defines.name_prefix .. "resource-reach-distance-label",
+ resource_reach_distance_textfield = creative_mode_defines.name_prefix .. "resource-reach-distance-textfield",
+ resource_reach_distance_separator = creative_mode_defines.name_prefix .. "resource-reach-distance-separator",
+ resource_reach_distance_apply_button = creative_mode_defines.name_prefix .. "resource-reach-distance-apply-button",
+ item_drop_distance_container = creative_mode_defines.name_prefix .. "item-drop-distance-container",
+ item_drop_distance_label = creative_mode_defines.name_prefix .. "item-drop-distance-label",
+ item_drop_distance_textfield = creative_mode_defines.name_prefix .. "item-drop-distance-textfield",
+ item_drop_distance_separator = creative_mode_defines.name_prefix .. "item-drop-distance-separator",
+ item_drop_distance_apply_button = creative_mode_defines.name_prefix .. "item-drop-distance-apply-button",
+ item_pickup_distance_container = creative_mode_defines.name_prefix .. "item-pickup-distance-container",
+ item_pickup_distance_label = creative_mode_defines.name_prefix .. "item-pickup-distance-label",
+ item_pickup_distance_textfield = creative_mode_defines.name_prefix .. "item-pickup-distance-textfield",
+ item_pickup_distance_separator = creative_mode_defines.name_prefix .. "item-pickup-distance-separator",
+ item_pickup_distance_apply_button = creative_mode_defines.name_prefix .. "item-pickup-distance-apply-button",
+ loot_pickup_distance_container = creative_mode_defines.name_prefix .. "loot-pickup-distance-container",
+ loot_pickup_distance_label = creative_mode_defines.name_prefix .. "loot-pickup-distance-label",
+ loot_pickup_distance_textfield = creative_mode_defines.name_prefix .. "loot-pickup-distance-textfield",
+ loot_pickup_distance_separator = creative_mode_defines.name_prefix .. "loot-pickup-distance-separator",
+ loot_pickup_distance_apply_button = creative_mode_defines.name_prefix .. "loot-pickup-distance-apply-button",
+ mining_speed_container = creative_mode_defines.name_prefix .. "mining-speed-container",
+ mining_speed_label = creative_mode_defines.name_prefix .. "mining-speed-label",
+ mining_speed_textfield = creative_mode_defines.name_prefix .. "mining-speed-textfield",
+ mining_speed_separator = creative_mode_defines.name_prefix .. "mining-speed-separator",
+ mining_speed_apply_button = creative_mode_defines.name_prefix .. "mining-speed-apply-button",
+ running_speed_container = creative_mode_defines.name_prefix .. "running-speed-container",
+ running_speed_label = creative_mode_defines.name_prefix .. "running-speed-label",
+ running_speed_textfield = creative_mode_defines.name_prefix .. "running-speed-textfield",
+ running_speed_separator = creative_mode_defines.name_prefix .. "running-speed-separator",
+ running_speed_apply_button = creative_mode_defines.name_prefix .. "running-speed-apply-button",
+ crafting_speed_container = creative_mode_defines.name_prefix .. "crafting-speed-container",
+ crafting_speed_label = creative_mode_defines.name_prefix .. "crafting-speed-label",
+ crafting_speed_textfield = creative_mode_defines.name_prefix .. "crafting-speed-textfield",
+ crafting_speed_separator = creative_mode_defines.name_prefix .. "crafting-speed-separator",
+ crafting_speed_apply_button = creative_mode_defines.name_prefix .. "crafting-speed-apply-button",
+ inventory_bonus_container = creative_mode_defines.name_prefix .. "inventory-bonus-container",
+ inventory_bonus_label = creative_mode_defines.name_prefix .. "inventory-bonus-label",
+ inventory_bonus_textfield = creative_mode_defines.name_prefix .. "inventory-bonus-textfield",
+ inventory_bonus_separator = creative_mode_defines.name_prefix .. "inventory-bonus-separator",
+ inventory_bonus_apply_button = creative_mode_defines.name_prefix .. "inventory-bonus-apply-button",
+ quickbar_bonus_container = creative_mode_defines.name_prefix .. "quickbar-bonus-container",
+ quickbar_bonus_label = creative_mode_defines.name_prefix .. "quickbar-bonus-label",
+ quickbar_bonus_textfield = creative_mode_defines.name_prefix .. "quickbar-bonus-textfield",
+ quickbar_bonus_separator = creative_mode_defines.name_prefix .. "quickbar-bonus-separator",
+ quickbar_bonus_apply_button = creative_mode_defines.name_prefix .. "quickbar-bonus-apply-button",
+ health_bonus_container = creative_mode_defines.name_prefix .. "health-bonus-container",
+ health_bonus_label = creative_mode_defines.name_prefix .. "health-bonus-label",
+ health_bonus_textfield = creative_mode_defines.name_prefix .. "health-bonus-textfield",
+ health_bonus_separator = creative_mode_defines.name_prefix .. "health-bonus-separator",
+ health_bonus_apply_button = creative_mode_defines.name_prefix .. "health-bonus-apply-button",
+ god_mode_container = creative_mode_defines.name_prefix .. "god-mode-container",
+ god_mode_label = creative_mode_defines.name_prefix .. "god-mode-label",
+ god_mode_on_button = creative_mode_defines.name_prefix .. "god-mode-on-button",
+ god_mode_off_button = creative_mode_defines.name_prefix .. "god-mode-off-button",
+ personal_cheats_all_button_container = creative_mode_defines.name_prefix .. "personal-cheats-all-button-container",
+ personal_cheats_enable_all_button = creative_mode_defines.name_prefix .. "personal-cheats-enable-all-button",
+ personal_cheats_disable_all_button = creative_mode_defines.name_prefix .. "personal-cheats-disable-all-button",
+ personal_cheats_not_included_in_enable_all_note = creative_mode_defines.name_prefix
+ .. "personal-cheats-not-included-in-enable-all-note",
+ team_cheats_menu_frame = creative_mode_defines.name_prefix .. "team-cheats-menu-frame",
+ team_cheats_outer_container = creative_mode_defines.name_prefix .. "team-cheats-outer-container",
+ team_cheats_targets_scroll_pane = creative_mode_defines.name_prefix .. "team-cheats-targets-scroll-pane",
+ team_cheats_targets_container = creative_mode_defines.name_prefix .. "team-cheats-targets-container",
+ team_cheats_targets_inner_container = creative_mode_defines.name_prefix .. "team-cheats-targets-inner-container",
+ team_cheats_target_name_button_prefix = creative_mode_defines.name_prefix .. "team-cheats-target-name-button-",
+ team_cheats_targets_select_all_button = creative_mode_defines.name_prefix .. "team-cheats-targets-select-all-button",
+ team_cheats_cheats_scroll_pane = creative_mode_defines.name_prefix .. "team-cheats-cheats-scroll-pane",
+ team_cheats_cheats_container = creative_mode_defines.name_prefix .. "team-cheats-cheats-container",
+ creative_tools_recipes_container = creative_mode_defines.name_prefix .. "creative-tools-recipes-container",
+ creative_tools_recipes_label = creative_mode_defines.name_prefix .. "creative-tools-recipes-label",
+ creative_tools_recipes_on_button = creative_mode_defines.name_prefix .. "creative-tools-recipes-on-button",
+ creative_tools_recipes_off_button = creative_mode_defines.name_prefix .. "creative-tools-recipes-off-button",
+ loaders_recipes_container = creative_mode_defines.name_prefix .. "loaders-recipes-container",
+ loaders_recipes_label = creative_mode_defines.name_prefix .. "loaders-recipes-label",
+ loaders_recipes_on_button = creative_mode_defines.name_prefix .. "loaders-recipes-on-button",
+ loaders_recipes_off_button = creative_mode_defines.name_prefix .. "loaders-recipes-off-button",
+ all_technologies_container = creative_mode_defines.name_prefix .. "all-technologies-container",
+ all_technologies_label = creative_mode_defines.name_prefix .. "all-technologies-label",
+ all_technologies_unlock_button = creative_mode_defines.name_prefix .. "all-technologies-unlock-button",
+ all_technologies_reset_button = creative_mode_defines.name_prefix .. "all-technologies-reset-button",
+ instant_research_container = creative_mode_defines.name_prefix .. "instant-research-container",
+ instant_research_label = creative_mode_defines.name_prefix .. "instant-research-label",
+ instant_research_on_button = creative_mode_defines.name_prefix .. "instant-research-on-button",
+ instant_research_off_button = creative_mode_defines.name_prefix .. "instant-research-off-button",
+ team_reach_distance_container = creative_mode_defines.name_prefix .. "team-reach-distance-container",
+ team_reach_distance_label = creative_mode_defines.name_prefix .. "team-reach-distance-label",
+ team_reach_distance_textfield = creative_mode_defines.name_prefix .. "team-reach-distance-textfield",
+ team_reach_distance_separator = creative_mode_defines.name_prefix .. "team-reach-distance-separator",
+ team_reach_distance_apply_button = creative_mode_defines.name_prefix .. "team-reach-distance-apply-button",
+ team_build_distance_container = creative_mode_defines.name_prefix .. "team-build-distance-container",
+ team_build_distance_label = creative_mode_defines.name_prefix .. "team-build-distance-label",
+ team_build_distance_textfield = creative_mode_defines.name_prefix .. "team-build-distance-textfield",
+ team_build_distance_separator = creative_mode_defines.name_prefix .. "team-build-distance-separator",
+ team_build_distance_apply_button = creative_mode_defines.name_prefix .. "team-build-distance-apply-button",
+ team_resource_reach_distance_container = creative_mode_defines.name_prefix
+ .. "team-resource-reach-distance-container",
+ team_resource_reach_distance_label = creative_mode_defines.name_prefix .. "team-resource-distance-label",
+ team_resource_reach_distance_textfield = creative_mode_defines.name_prefix .. "team-resource-distance-textfield",
+ team_resource_reach_distance_separator = creative_mode_defines.name_prefix .. "team-resource-distance-separator",
+ team_resource_reach_distance_apply_button = creative_mode_defines.name_prefix
+ .. "team-resource-distance-apply-button",
+ team_item_drop_distance_container = creative_mode_defines.name_prefix .. "team-item-drop-distance-container",
+ team_item_drop_distance_label = creative_mode_defines.name_prefix .. "team-item-drop-distance-label",
+ team_item_drop_distance_textfield = creative_mode_defines.name_prefix .. "team-item-drop-distance-textfield",
+ team_item_drop_distance_separator = creative_mode_defines.name_prefix .. "team-item-drop-distance-separator",
+ team_item_drop_distance_apply_button = creative_mode_defines.name_prefix .. "team-item-drop-distance-apply-button",
+ team_item_pickup_distance_container = creative_mode_defines.name_prefix .. "team-item-pickup-distance-container",
+ team_item_pickup_distance_label = creative_mode_defines.name_prefix .. "team-item-pickup-distance-label",
+ team_item_pickup_distance_textfield = creative_mode_defines.name_prefix .. "team-item-pickup-distance-textfield",
+ team_item_pickup_distance_separator = creative_mode_defines.name_prefix .. "team-item-pickup-distance-separator",
+ team_item_pickup_distance_apply_button = creative_mode_defines.name_prefix
+ .. "team-item-pickup-distance-apply-button",
+ team_loot_pickup_distance_container = creative_mode_defines.name_prefix .. "team-loot-pickup-distance-container",
+ team_loot_pickup_distance_label = creative_mode_defines.name_prefix .. "team-loot-pickup-distance-label",
+ team_loot_pickup_distance_textfield = creative_mode_defines.name_prefix .. "team-loot-pickup-distance-textfield",
+ team_loot_pickup_distance_separator = creative_mode_defines.name_prefix .. "team-loot-pickup-distance-separator",
+ team_loot_pickup_distance_apply_button = creative_mode_defines.name_prefix
+ .. "team-loot-pickup-distance-apply-button",
+ team_mining_speed_container = creative_mode_defines.name_prefix .. "team-mining-speed-container",
+ team_mining_speed_label = creative_mode_defines.name_prefix .. "team-mining-speed-label",
+ team_mining_speed_textfield = creative_mode_defines.name_prefix .. "team-mining-speed-textfield",
+ team_mining_speed_separator = creative_mode_defines.name_prefix .. "team-mining-speed-separator",
+ team_mining_speed_apply_button = creative_mode_defines.name_prefix .. "team-mining-speed-apply-button",
+ team_running_speed_container = creative_mode_defines.name_prefix .. "team-running-speed-container",
+ team_running_speed_label = creative_mode_defines.name_prefix .. "team-running-speed-label",
+ team_running_speed_textfield = creative_mode_defines.name_prefix .. "team-running-speed-textfield",
+ team_running_speed_separator = creative_mode_defines.name_prefix .. "team-running-speed-separator",
+ team_running_speed_apply_button = creative_mode_defines.name_prefix .. "team-running-speed-apply-button",
+ team_crafting_speed_container = creative_mode_defines.name_prefix .. "team-crafting-speed-container",
+ team_crafting_speed_label = creative_mode_defines.name_prefix .. "team-crafting-speed-label",
+ team_crafting_speed_textfield = creative_mode_defines.name_prefix .. "team-crafting-speed-textfield",
+ team_crafting_speed_separator = creative_mode_defines.name_prefix .. "team-crafting-speed-separator",
+ team_crafting_speed_apply_button = creative_mode_defines.name_prefix .. "team-crafting-speed-apply-button",
+ character_inventory_bonus_container = creative_mode_defines.name_prefix .. "character-inventory-bonus-container",
+ character_inventory_bonus_label = creative_mode_defines.name_prefix .. "character-inventory-bonus-label",
+ character_inventory_bonus_textfield = creative_mode_defines.name_prefix .. "character-inventory-bonus-textfield",
+ character_inventory_bonus_separator = creative_mode_defines.name_prefix .. "character-inventory-bonus-separator",
+ character_inventory_bonus_apply_button = creative_mode_defines.name_prefix
+ .. "character-inventory-bonus-apply-button",
+ quickbar_count_container = creative_mode_defines.name_prefix .. "quickbar-count-container",
+ quickbar_count_label = creative_mode_defines.name_prefix .. "quickbar-count-label",
+ quickbar_count_textfield = creative_mode_defines.name_prefix .. "quickbar-count-textfield",
+ quickbar_count_separator = creative_mode_defines.name_prefix .. "quickbar-count-separator",
+ quickbar_count_apply_button = creative_mode_defines.name_prefix .. "quickbar-count-apply-button",
+ character_health_bonus_container = creative_mode_defines.name_prefix .. "character-health-bonus-container",
+ character_health_bonus_label = creative_mode_defines.name_prefix .. "character-health-bonus-label",
+ character_health_bonus_textfield = creative_mode_defines.name_prefix .. "character-health-bonus-textfield",
+ character_health_bonus_separator = creative_mode_defines.name_prefix .. "character-health-bonus-separator",
+ character_health_bonus_apply_button = creative_mode_defines.name_prefix .. "character-health-bonus-apply-button",
+ inserter_capacity_bonus_container = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-container",
+ inserter_capacity_bonus_label = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-label",
+ inserter_capacity_bonus_textfield = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-textfield",
+ inserter_capacity_bonus_separator = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-separator",
+ inserter_capacity_bonus_apply_button = creative_mode_defines.name_prefix .. "inserter-capacity-bonus-apply-button",
+ bulk_inserter_capacity_bonus_container = creative_mode_defines.name_prefix
+ .. "bulk-inserter-capacity-bonus-container",
+ bulk_inserter_capacity_bonus_label = creative_mode_defines.name_prefix .. "bulk-inserter-capacity-bonus-label",
+ bulk_inserter_capacity_bonus_textfield = creative_mode_defines.name_prefix
+ .. "bulk-inserter-capacity-bonus-textfield",
+ bulk_inserter_capacity_bonus_separator = creative_mode_defines.name_prefix
+ .. "bulk-inserter-capacity-bonus-separator",
+ bulk_inserter_capacity_bonus_apply_button = creative_mode_defines.name_prefix
+ .. "bulk-inserter-capacity-bonus-apply-button",
+ evolution_factor_container = creative_mode_defines.name_prefix .. "evolution-factor-container",
+ evolution_factor_label = creative_mode_defines.name_prefix .. "evolution-factor-label",
+ evolution_factor_textfield = creative_mode_defines.name_prefix .. "evolution-factor-textfield",
+ evolution_factor_separator = creative_mode_defines.name_prefix .. "evolution-factor-separator",
+ evolution_factor_apply_button = creative_mode_defines.name_prefix .. "evolution-factor-apply-button",
+ chart_all_container = creative_mode_defines.name_prefix .. "chart-all-container",
+ chart_all_label = creative_mode_defines.name_prefix .. "chart-all-label",
+ chart_all_apply_button = creative_mode_defines.name_prefix .. "chart-all-apply-button",
+ kill_all_units_container = creative_mode_defines.name_prefix .. "kill-all-units-container",
+ kill_all_units_label = creative_mode_defines.name_prefix .. "kill-all-units-label",
+ kill_all_units_apply_button = creative_mode_defines.name_prefix .. "kill-all-units-apply-button",
+ team_cheats_all_button_container = creative_mode_defines.name_prefix .. "team-cheats-all-button-container",
+ team_cheats_enable_all_button = creative_mode_defines.name_prefix .. "team-cheats-enable-all-button",
+ team_cheats_disable_all_button = creative_mode_defines.name_prefix .. "team-cheats-disable-all-button",
+ team_cheats_not_included_in_enable_all_note = creative_mode_defines.name_prefix
+ .. "team-cheats-not-included-in-enable-all-note",
+ surface_cheats_menu_frame = creative_mode_defines.name_prefix .. "surface-cheats-menu-frame",
+ surface_cheats_outer_container = creative_mode_defines.name_prefix .. "surface-cheats-outer-container",
+ surface_cheats_targets_scroll_pane = creative_mode_defines.name_prefix .. "surface-cheats-targets-scroll-pane",
+ surface_cheats_targets_container = creative_mode_defines.name_prefix .. "surface-cheats-targets-container",
+ surface_cheats_targets_inner_container = creative_mode_defines.name_prefix
+ .. "surface-cheats-targets-inner-container",
+ surface_cheats_target_name_button_prefix = creative_mode_defines.name_prefix .. "surface-cheats-target-name-button-",
+ surface_cheats_targets_select_all_button = creative_mode_defines.name_prefix
+ .. "surface-cheats-targets-select-all-button",
+ surface_cheats_cheats_scroll_pane = creative_mode_defines.name_prefix .. "surface-cheats-cheats-scroll-pane",
+ surface_cheats_cheats_container = creative_mode_defines.name_prefix .. "surface-cheats-cheats-container",
+ freeze_daytime_container = creative_mode_defines.name_prefix .. "freeze-daytime-container",
+ freeze_daytime_label = creative_mode_defines.name_prefix .. "freeze-daytime-label",
+ freeze_daytime_on_button = creative_mode_defines.name_prefix .. "freeze-daytime-on-button",
+ freeze_daytime_off_button = creative_mode_defines.name_prefix .. "freeze-daytime-off-button",
+ daytime_container = creative_mode_defines.name_prefix .. "daytime-container",
+ daytime_label = creative_mode_defines.name_prefix .. "daytime-label",
+ daytime_textfield = creative_mode_defines.name_prefix .. "daytime-textfield",
+ daytime_separator = creative_mode_defines.name_prefix .. "daytime-separator",
+ daytime_apply_button = creative_mode_defines.name_prefix .. "daytime-apply-button",
+ daytime_selection_container = creative_mode_defines.name_prefix .. "daytime-selection-container",
+ daytime_selection_label = creative_mode_defines.name_prefix .. "daytime-selection-label",
+ daytime_selection_midday_button = creative_mode_defines.name_prefix .. "daytime-selection-midday-button",
+ daytime_selection_midnight_button = creative_mode_defines.name_prefix .. "daytime-selection-midnight-button",
+ peaceful_mode_container = creative_mode_defines.name_prefix .. "peaceful-mode-container",
+ peaceful_mode_label = creative_mode_defines.name_prefix .. "peaceful-mode-label",
+ peaceful_mode_on_button = creative_mode_defines.name_prefix .. "peaceful-mode-on-button",
+ peaceful_mode_off_button = creative_mode_defines.name_prefix .. "peaceful-mode-off-button",
+ destroy_all_enemies_container = creative_mode_defines.name_prefix .. "destroy-all-enemies-container",
+ destroy_all_enemies_label = creative_mode_defines.name_prefix .. "destroy-all-enemies-label",
+ destroy_all_enemies_apply_button = creative_mode_defines.name_prefix .. "destroy-all-enemies-apply-button",
+ remove_all_enemies_container = creative_mode_defines.name_prefix .. "remove-all-enemies-container",
+ remove_all_enemies_label = creative_mode_defines.name_prefix .. "remove-all-enemies-label",
+ remove_all_enemies_apply_button = creative_mode_defines.name_prefix .. "remove-all-enemies-apply-button",
+ dont_generate_enemy_container = creative_mode_defines.name_prefix .. "dont-generate-enemy-container",
+ dont_generate_enemy_label = creative_mode_defines.name_prefix .. "dont-generate-enemy-label",
+ dont_generate_enemy_on_button = creative_mode_defines.name_prefix .. "dont-generate-enemy-on-button",
+ dont_generate_enemy_off_button = creative_mode_defines.name_prefix .. "dont-generate-enemy-off-button",
+ surface_pressure_container = creative_mode_defines.name_prefix .. "surface-pressure-container",
+ surface_pressure_label = creative_mode_defines.name_prefix .. "surface-pressure-label",
+ surface_pressure_textfield = creative_mode_defines.name_prefix .. "surface-pressure-textfield",
+ surface_pressure_separator = creative_mode_defines.name_prefix .. "surface-pressure-separator",
+ surface_pressure_apply_button = creative_mode_defines.name_prefix .. "surface-pressure-apply-button",
+ surface_magnetic_field_container = creative_mode_defines.name_prefix .. "surface-magentic-field-container",
+ surface_magnetic_field_label = creative_mode_defines.name_prefix .. "surface-magentic-field-label",
+ surface_magnetic_field_textfield = creative_mode_defines.name_prefix .. "surface-magentic-field-textfield",
+ surface_magnetic_field_separator = creative_mode_defines.name_prefix .. "surface-magentic-field-separator",
+ surface_magnetic_field_apply_button = creative_mode_defines.name_prefix .. "surface-magentic-field-apply-button",
+ surface_gravity_container = creative_mode_defines.name_prefix .. "surface-gravity-container",
+ surface_gravity_label = creative_mode_defines.name_prefix .. "surface-gravity-label",
+ surface_gravity_textfield = creative_mode_defines.name_prefix .. "surface-gravity-textfield",
+ surface_gravity_separator = creative_mode_defines.name_prefix .. "surface-gravity-separator",
+ surface_gravity_apply_button = creative_mode_defines.name_prefix .. "surface-gravity-apply-button",
+ global_cheats_menu_frame = creative_mode_defines.name_prefix .. "global-cheats-menu-frame",
+ global_cheats_table = creative_mode_defines.name_prefix .. "global-cheats-table",
+ global_cheats_cheats_scroll_pane = creative_mode_defines.name_prefix .. "global-cheats-cheats-scroll-pane",
+ global_cheats_cheats_container = creative_mode_defines.name_prefix .. "global-cheats-cheats-container",
+ pollution_container = creative_mode_defines.name_prefix .. "pollution-container",
+ pollution_label = creative_mode_defines.name_prefix .. "pollution-label",
+ pollution_on_button = creative_mode_defines.name_prefix .. "pollution-on-button",
+ pollution_off_button = creative_mode_defines.name_prefix .. "pollution-off-button",
+ enemy_evolution_container = creative_mode_defines.name_prefix .. "enemy-evolution-container",
+ enemy_evolution_label = creative_mode_defines.name_prefix .. "enemy-evolution-label",
+ enemy_evolution_on_button = creative_mode_defines.name_prefix .. "enemy-evolution-on-button",
+ enemy_evolution_off_button = creative_mode_defines.name_prefix .. "enemy-evolution-off-button",
+ evolution_time_factor_container = creative_mode_defines.name_prefix .. "evolution-time-factor-container",
+ evolution_time_factor_label = creative_mode_defines.name_prefix .. "evolution-time-factor-label",
+ evolution_time_factor_textfield = creative_mode_defines.name_prefix .. "evolution-time-factor-textfield",
+ evolution_time_factor_separator = creative_mode_defines.name_prefix .. "evolution-time-factor-separator",
+ evolution_time_factor_apply_button = creative_mode_defines.name_prefix .. "evolution-time-factor-apply-button",
+ evolution_destroy_factor_container = creative_mode_defines.name_prefix .. "evolution-destroy-factor-container",
+ evolution_destroy_factor_label = creative_mode_defines.name_prefix .. "evolution-destroy-factor-label",
+ evolution_destroy_factor_textfield = creative_mode_defines.name_prefix .. "evolution-destroy-factor-textfield",
+ evolution_destroy_factor_separator = creative_mode_defines.name_prefix .. "evolution-destroy-factor-separator",
+ evolution_destroy_factor_apply_button = creative_mode_defines.name_prefix .. "evolution-destroy-factor-apply-button",
+ evolution_pollution_factor_container = creative_mode_defines.name_prefix .. "evolution-pollution-factor-container",
+ evolution_pollution_factor_label = creative_mode_defines.name_prefix .. "evolution-pollution-factor-label",
+ evolution_pollution_factor_textfield = creative_mode_defines.name_prefix .. "evolution-pollution-factor-textfield",
+ evolution_pollution_factor_separator = creative_mode_defines.name_prefix .. "evolution-pollution-factor-separator",
+ evolution_pollution_factor_apply_button = creative_mode_defines.name_prefix
+ .. "evolution-pollution-factor-apply-button",
+ enemy_expansion_container = creative_mode_defines.name_prefix .. "enemy-expansion-container",
+ enemy_expansion_label = creative_mode_defines.name_prefix .. "enemy-expansion-label",
+ enemy_expansion_on_button = creative_mode_defines.name_prefix .. "enemy-expansion-on-button",
+ enemy_expansion_off_button = creative_mode_defines.name_prefix .. "enemy-expansion-off-button",
+ enemy_expansion_min_cooldown_container = creative_mode_defines.name_prefix
+ .. "enemy-expansion-min-cooldown-container",
+ enemy_expansion_min_cooldown_label = creative_mode_defines.name_prefix .. "enemy-expansion-min-cooldown-label",
+ enemy_expansion_min_cooldown_textfield = creative_mode_defines.name_prefix
+ .. "enemy-expansion-min-cooldown-textfield",
+ enemy_expansion_min_cooldown_separator = creative_mode_defines.name_prefix
+ .. "enemy-expansion-min-cooldown-separator",
+ enemy_expansion_min_cooldown_apply_button = creative_mode_defines.name_prefix
+ .. "enemy-expansion-min-cooldown-apply-button",
+ enemy_expansion_max_cooldown_container = creative_mode_defines.name_prefix
+ .. "enemy-expansion-max-cooldown-container",
+ enemy_expansion_max_cooldown_label = creative_mode_defines.name_prefix .. "enemy-expansion-max-cooldown-label",
+ enemy_expansion_max_cooldown_textfield = creative_mode_defines.name_prefix
+ .. "enemy-expansion-max-cooldown-textfield",
+ enemy_expansion_max_cooldown_separator = creative_mode_defines.name_prefix
+ .. "enemy-expansion-max-cooldown-separator",
+ enemy_expansion_max_cooldown_apply_button = creative_mode_defines.name_prefix
+ .. "enemy-expansion-max-cooldown-apply-button",
+ game_speed_container = creative_mode_defines.name_prefix .. "game-speed-container",
+ game_speed_label = creative_mode_defines.name_prefix .. "game-speed-label",
+ game_speed_textfield = creative_mode_defines.name_prefix .. "game-speed-textfield",
+ game_speed_separator = creative_mode_defines.name_prefix .. "game-speed-separator",
+ game_speed_apply_button = creative_mode_defines.name_prefix .. "game-speed-apply-button",
+ build_options_menus_container = creative_mode_defines.name_prefix .. "build-options-menus_container",
+ build_options_frame = creative_mode_defines.name_prefix .. "build-options-frame",
+ build_options_outer_contianer = creative_mode_defines.name_prefix .. "build-options-outer-container",
+ build_options_targets_scroll_pane = creative_mode_defines.name_prefix .. "build-options-targets-scroll-pane",
+ build_options_targets_container = creative_mode_defines.name_prefix .. "build-options-targets-container",
+ build_options_targets_inner_container = creative_mode_defines.name_prefix .. "build-options-targets-inner-container",
+ build_options_target_index_button_prefix = creative_mode_defines.name_prefix .. "build-options-target-index-button-",
+ build_options_targets_select_all_button = creative_mode_defines.name_prefix
+ .. "build-options-targets-select-all-button",
+ build_options_cheats_scroll_pane = creative_mode_defines.name_prefix .. "build-options-cheats-scroll-pane",
+ build_options_cheats_container = creative_mode_defines.name_prefix .. "build-options-cheats-container",
+ build_active_container = creative_mode_defines.name_prefix .. "build-active-container",
+ build_active_label = creative_mode_defines.name_prefix .. "build-active-label",
+ build_active_on_button = creative_mode_defines.name_prefix .. "build-active-on-button",
+ build_active_off_button = creative_mode_defines.name_prefix .. "build-active-off-button",
+ build_destructible_container = creative_mode_defines.name_prefix .. "build-destructible-container",
+ build_destructible_label = creative_mode_defines.name_prefix .. "build-destructible-label",
+ build_destructible_on_button = creative_mode_defines.name_prefix .. "build-destructible-on-button",
+ build_destructible_off_button = creative_mode_defines.name_prefix .. "build-destructible-off-button",
+ build_minable_container = creative_mode_defines.name_prefix .. "build-minable-container",
+ build_minable_label = creative_mode_defines.name_prefix .. "build-minable-label",
+ build_minable_on_button = creative_mode_defines.name_prefix .. "build-minable-on-button",
+ build_minable_off_button = creative_mode_defines.name_prefix .. "build-minable-off-button",
+ build_rotatable_container = creative_mode_defines.name_prefix .. "build-rotatable-container",
+ build_rotatable_label = creative_mode_defines.name_prefix .. "build-rotatable-label",
+ build_rotatable_on_button = creative_mode_defines.name_prefix .. "build-rotatable-on-button",
+ build_rotatable_off_button = creative_mode_defines.name_prefix .. "build-rotatable-off-button",
+ build_operable_container = creative_mode_defines.name_prefix .. "build-operable-container",
+ build_operable_label = creative_mode_defines.name_prefix .. "build-operable-label",
+ build_operable_on_button = creative_mode_defines.name_prefix .. "build-operable-on-button",
+ build_operable_off_button = creative_mode_defines.name_prefix .. "build-operable-off-button",
+ build_full_health_container = creative_mode_defines.name_prefix .. "build-full-health-container",
+ build_full_health_label = creative_mode_defines.name_prefix .. "build-full-health-label",
+ build_full_health_on_button = creative_mode_defines.name_prefix .. "build-full-health-on-button",
+ build_full_health_off_button = creative_mode_defines.name_prefix .. "build-full-health-off-button",
+ build_team_container = creative_mode_defines.name_prefix .. "build-team-container",
+ build_team_label = creative_mode_defines.name_prefix .. "build-team-label",
+ build_team_targets_drop_down_container = creative_mode_defines.name_prefix
+ .. "build-team-targets-drop-down-container",
+ build_team_current_button = creative_mode_defines.name_prefix .. "build-team-current-button",
+ build_team_targets_scroll_pane = creative_mode_defines.name_prefix .. "build-team-targets-scroll-pane",
+ build_team_targets_container = creative_mode_defines.name_prefix .. "build-team-targets-container",
+ build_team_targets_inner_container = creative_mode_defines.name_prefix .. "build-team-targets-inner-container",
+ build_team_target_name_button_prefix = creative_mode_defines.name_prefix .. "build-team-target-name-button-",
+ magic_wand_menus_container = creative_mode_defines.name_prefix .. "magic-wand-menus-container",
+ magic_wand_frame = creative_mode_defines.name_prefix .. "magic-wand-frame",
+ magic_wand_creator_menu_button = creative_mode_defines.name_prefix .. "magic-wand-creator-menu-button",
+ magic_wand_healer_menu_button = creative_mode_defines.name_prefix .. "magic-wand-healer-menu-button",
+ magic_wand_modifier_menu_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-menu-button",
+ magic_wand_creator_frame = creative_mode_defines.name_prefix .. "magic-wand-creator-frame",
+ magic_wand_creator_frame_title_container = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-frame-title-container",
+ magic_wand_creator_frame_title = creative_mode_defines.name_prefix .. "magic-wand-creator-frame-title",
+ magic_wand_creator_get_item_button = creative_mode_defines.name_prefix .. "magic-wand-creator-get-item-button",
+ magic_wand_creator_scroll_pane = creative_mode_defines.name_prefix .. "magic-wand-creator-scroll-pane",
+ magic_wand_creator_container = creative_mode_defines.name_prefix .. "magic-wand-creator-container",
+ magic_wand_creator_select_mode_container = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-select-mode-container",
+ magic_wand_creator_select_mode_label = creative_mode_defines.name_prefix .. "magic-wand-creator-select-mode-label",
+ magic_wand_creator_alt_select_mode_container = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-alt-select-mode-container",
+ magic_wand_creator_alt_select_mode_label = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-alt-select-mode-label",
+ magic_wand_creator_correct_tiles_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-correct-tiles-checkbox",
+ magic_wand_creator_dont_kill_by_tiles_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-dont-kill-by-tiles-checkbox",
+ magic_wand_creator_tiles_table = creative_mode_defines.name_prefix .. "magic-wand-creator-tiles-table",
+ magic_wand_creator_tile_name_button_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-tile-name-button-",
+ magic_wand_creator_resources_table = creative_mode_defines.name_prefix .. "magic-wand-creator-resources-table",
+ magic_wand_creator_resource_name_button_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-name-button-",
+ magic_wand_creator_rsc_amt_slider_container = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-container",
+ magic_wand_creator_rsc_amt_slider_label = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-label",
+ magic_wand_creator_rsc_amt_slider_spacing_1 = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-spacing-1",
+ magic_wand_creator_rsc_amt_slider_button_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-button-",
+ magic_wand_creator_rsc_amt_slider_spacing_2 = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-spacing-2",
+ magic_wand_creator_rsc_amt_slider_textfield = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-textfield",
+ magic_wand_creator_use_pattern_container = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-use-pattern-container",
+ magic_wand_creator_use_pattern_label = creative_mode_defines.name_prefix .. "magic-wand-creator-use-pattern-label",
+ magic_wand_creator_use_pattern_drop_down = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-use-pattern-drop-down",
+ magic_wand_creator_tile_or_resource_2_container = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-tile-or-resource-2-container",
+ magic_wand_creator_tiles_table_2 = creative_mode_defines.name_prefix .. "magic-wand-creator-tiles-table-2",
+ magic_wand_creator_tile_name_button_2_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-tile-name-button-2-",
+ magic_wand_creator_resources_table_2 = creative_mode_defines.name_prefix .. "magic-wand-creator-resources-table-2",
+ magic_wand_creator_resource_name_button_2_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-name-button-2-",
+ magic_wand_creator_rsc_amt_slider_container_2 = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-container-2",
+ magic_wand_creator_rsc_amt_slider_label_2 = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-label-2",
+ magic_wand_creator_rsc_amt_slider_spacing_1_2 = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-spacing-1-2",
+ magic_wand_creator_rsc_amt_slider_button_2_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-button-2-",
+ magic_wand_creator_rsc_amt_slider_spacing_2_2 = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-spacing-2-2",
+ magic_wand_creator_rsc_amt_slider_textfield_2 = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-resource-amount-slider-textfield-2",
+ magic_wand_creator_also_remove_decoratives_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-also-remove-decoratives-checkbox",
+ magic_wand_creator_dont_remove_characters_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-dont-remove-characters-checkbox",
+ magic_wand_creator_dont_remove_tiles_with_entities_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-dont-remove-tiles-with-entities-checkbox",
+ magic_wand_creator_dont_kill_by_removing_tiles_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-dont-kill-by-removing-tiles-checkbox",
+ magic_wand_creator_alt_forces_label = creative_mode_defines.name_prefix .. "magic-wand-creator-alt-forces-label",
+ magic_wand_creator_alt_forces_table = creative_mode_defines.name_prefix .. "magic-wand-creator-alt-forces-table",
+ magic_wand_creator_alt_force_name_checkbox_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-alt-force-name-checkbox-",
+ magic_wand_creator_alt_forces_select_all_button = creative_mode_defines.name_prefix
+ .. "magic-wand-creator-alt-forces-select-all-button",
+ magic_wand_healer_frame = creative_mode_defines.name_prefix .. "magic-wand-healer-frame",
+ magic_wand_healer_frame_title_container = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-frame-title-container",
+ magic_wand_healer_frame_title = creative_mode_defines.name_prefix .. "magic-wand-healer-frame-title",
+ magic_wand_healer_get_item_button = creative_mode_defines.name_prefix .. "magic-wand-healer-get-item-button",
+ magic_wand_healer_scroll_pane = creative_mode_defines.name_prefix .. "magic-wand-healer-scroll-pane",
+ magic_wand_healer_container = creative_mode_defines.name_prefix .. "magic-wand-healer-container",
+ magic_wand_healer_select_mode_container = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-select-mode-container",
+ magic_wand_healer_select_mode_label = creative_mode_defines.name_prefix .. "magic-wand-healer-select-mode-label",
+ magic_wand_healer_alt_select_mode_container = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-select-mode-container",
+ magic_wand_healer_alt_select_mode_label = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-select-mode-label",
+ magic_wand_healer_revive_ghosts_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-revive-ghosts-checkbox",
+ magic_wand_healer_heal_forces_label = creative_mode_defines.name_prefix .. "magic-wand-healer-heal-forces-label",
+ magic_wand_healer_heal_forces_table = creative_mode_defines.name_prefix .. "magic-wand-healer-heal-forces-table",
+ magic_wand_healer_heal_force_name_checkbox_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-heal-force-name-checkbox-",
+ magic_wand_healer_heal_forces_select_all_button = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-heal-forces-select-all-button",
+ magic_wand_healer_alt_actions_container = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-actions-container",
+ magic_wand_healer_alt_set_hp_radiobutton = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-set-hp-radiobutton",
+ magic_wand_healer_alt_kill_radiobutton = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-kill-radiobutton",
+ magic_wand_healer_alt_dont_affect_characters_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-dont-affect-characters-checkbox",
+ magic_wand_healer_alt_dont_affect_indestructible_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-dont-affect-indestructible-checkbox",
+ magic_wand_healer_alt_forces_label = creative_mode_defines.name_prefix .. "magic-wand-healer-alt-forces-label",
+ magic_wand_healer_alt_forces_table = creative_mode_defines.name_prefix .. "magic-wand-healer-alt-forces-table",
+ magic_wand_healer_alt_force_name_checkbox_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-force-name-checkbox-",
+ magic_wand_healer_alt_forces_select_all_button = creative_mode_defines.name_prefix
+ .. "magic-wand-healer-alt-forces-select-all-button",
+ magic_wand_modifier_frame = creative_mode_defines.name_prefix .. "magic-wand-modifier-frame",
+ magic_wand_modifier_frame_title_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-frame-title-container",
+ magic_wand_modifier_frame_title = creative_mode_defines.name_prefix .. "magic-wand-modifier-frame-title",
+ magic_wand_modifier_get_item_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-get-item-button",
+ magic_wand_modifier_scroll_pane = creative_mode_defines.name_prefix .. "magic-wand-modifier-scroll-pane",
+ magic_wand_modifier_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-container",
+ magic_wand_modifier_select_mode_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-select-mode-container",
+ magic_wand_modifier_select_mode_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-select-mode-label",
+ magic_wand_modifier_alt_select_mode_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-alt-select-mode-container",
+ magic_wand_modifier_alt_select_mode_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-alt-select-mode-label",
+ magic_wand_modifier_std_ignore_characters_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-std-ignore-characters-checkbox",
+ magic_wand_modifier_std_ignore_healthless_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-std-ignore-healthless-checkbox",
+ magic_wand_modifier_std_ignore_indestructible_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-std-ignore-indestructible-checkbox",
+ magic_wand_modifier_std_forces_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-std-forces-label",
+ magic_wand_modifier_std_forces_table = creative_mode_defines.name_prefix .. "magic-wand-modifier-std-forces-table",
+ magic_wand_modifier_std_force_name_checkbox_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-std-force-name-checkbox-",
+ magic_wand_modifier_std_forces_select_all_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-std-forces-select-all-button",
+ magic_wand_modifier_alt_ignore_characters_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-alt-ignore-characters-checkbox",
+ magic_wand_modifier_alt_ignore_healthless_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-alt-ignore-healthless-checkbox",
+ magic_wand_modifier_alt_ignore_indestructible_checkbox = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-alt-ignore-indestructible-checkbox",
+ magic_wand_modifier_alt_forces_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-alt-forces-label",
+ magic_wand_modifier_alt_forces_table = creative_mode_defines.name_prefix .. "magic-wand-modifier-alt-forces-table",
+ magic_wand_modifier_alt_force_name_checkbox_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-alt-force-name-checkbox-",
+ magic_wand_modifier_alt_forces_select_all_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-alt-forces-select-all-button",
+ magic_wand_modifier_quick_actions_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-quick-actions-label",
+ magic_wand_modifier_quick_actions_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-quick-actions-container",
+ magic_wand_modifier_quick_action_container_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-quick-action-container-",
+ magic_wand_modifier_quick_action_remove_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-quick-action-remove-button",
+ magic_wand_modifier_quick_action_separator = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-quick-action-separator",
+ magic_wand_modifier_quick_action_name_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-quick-action-name-label",
+ magic_wand_modifier_quick_action_colon_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-quick-action-colon-label",
+ magic_wand_modifier_quick_action_value_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-quick-action-value-label",
+ magic_wand_modifier_remove_all_quick_actions_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-remove-all-quick-actions-button",
+ magic_wand_modifier_popup_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-popup-container",
+ magic_wand_modifier_popup_entities_frame = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-entities-frame",
+ magic_wand_modifier_popup_entities_frame_title_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-entities-frame-title-container",
+ magic_wand_modifier_popup_entities_frame_title_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-entities-frame-title-label",
+ magic_wand_modifier_popup_entities_frame_refresh_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-entities-frame-refresh-button",
+ magic_wand_modifier_popup_entities_sroll_pane = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-entities-scroll-pane",
+ magic_wand_modifier_popup_entities_table = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-entities-table",
+ magic_wand_modifier_popup_entity_name_slot_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-entity-slot-",
+ magic_wand_modifier_popup_item_on_ground_name_slot_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-item-on-ground-slot-",
+ magic_wand_modifier_popup_ghost_entity_name_slot_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-ghost-entity-slot-",
+ magic_wand_modifier_popup_ghost_tile_name_slot_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-ghost-tile-slot-",
+ magic_wand_modifier_popup_entity_count_label_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-entity-count-label-",
+ magic_wand_modifier_popup_item_on_ground_count_label_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-item-on-ground-count-label-",
+ magic_wand_modifier_popup_ghost_entity_count_label_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-ghost-entity-count-label-",
+ magic_wand_modifier_popup_ghost_tile_count_label_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-ghost-tile-count-label-",
+ magic_wand_modifier_popup_actions_frame = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-actions-frame",
+ magic_wand_modifier_popup_actions_frame_title_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-actions-frame-title-container",
+ magic_wand_modifier_popup_actions_frame_title_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-actions-frame-title-label",
+ magic_wand_modifier_popup_actions_frame_close_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-popup-actions-frame-close-button",
+ magic_wand_modifier_active_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-active-container",
+ magic_wand_modifier_active_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-active-label",
+ magic_wand_modifier_active_on_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-active-on-button",
+ magic_wand_modifier_active_off_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-active-off-button",
+ magic_wand_modifier_destructible_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-destructible-container",
+ magic_wand_modifier_destructible_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-destructible-label",
+ magic_wand_modifier_destructible_on_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-destructible-on-button",
+ magic_wand_modifier_destructible_off_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-destructible-off-button",
+ magic_wand_modifier_minable_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-minable-container",
+ magic_wand_modifier_minable_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-minable-label",
+ magic_wand_modifier_minable_on_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-minable-on-button",
+ magic_wand_modifier_minable_off_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-minable-off-button",
+ magic_wand_modifier_rotatable_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-rotatable-container",
+ magic_wand_modifier_rotatable_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-rotatable-label",
+ magic_wand_modifier_rotatable_on_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-rotatable-on-button",
+ magic_wand_modifier_rotatable_off_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-rotatable-off-button",
+ magic_wand_modifier_operable_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-operable-container",
+ magic_wand_modifier_operable_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-operable-label",
+ magic_wand_modifier_operable_on_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-operable-on-button",
+ magic_wand_modifier_operable_off_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-operable-off-button",
+ magic_wand_modifier_full_health_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-full-health-container",
+ magic_wand_modifier_full_health_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-full-health-label",
+ magic_wand_modifier_full_health_on_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-full-health-on-button",
+ magic_wand_modifier_full_health_off_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-full-health-off-button",
+ magic_wand_modifier_backer_name_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-backer-name-container",
+ magic_wand_modifier_backer_name_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-backer-name-label",
+ magic_wand_modifier_backer_name_textfield = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-backer-name-textfield",
+ magic_wand_modifier_backer_name_separator = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-backer-name-separator",
+ magic_wand_modifier_backer_name_apply_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-backer-name-apply-button",
+ magic_wand_modifier_to_be_looted_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-to-be-looted-container",
+ magic_wand_modifier_to_be_looted_label = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-to-be-looted-label",
+ magic_wand_modifier_to_be_looted_on_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-to-be-looted-on-button",
+ magic_wand_modifier_to_be_looted_off_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-to-be-looted-off-button",
+ magic_wand_modifier_revive_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-revive-container",
+ magic_wand_modifier_revive_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-revive-label",
+ magic_wand_modifier_revive_apply_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-revive-apply-button",
+ magic_wand_modifier_kill_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-kill-container",
+ magic_wand_modifier_kill_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-kill-label",
+ magic_wand_modifier_kill_apply_button = creative_mode_defines.name_prefix .. "magic-wand-modifier-kill-apply-button",
+ magic_wand_modifier_destroy_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-destroy-container",
+ magic_wand_modifier_destroy_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-destroy-label",
+ magic_wand_modifier_destroy_apply_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-destroy-apply-button",
+ magic_wand_modifier_team_container = creative_mode_defines.name_prefix .. "magic-wand-modifier-team-container",
+ magic_wand_modifier_team_label = creative_mode_defines.name_prefix .. "magic-wand-modifier-team-label",
+ magic_wand_modifier_team_targets_drop_down_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-team-targets-drop-down-container",
+ magic_wand_modifier_team_current_button = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-team-current-button",
+ magic_wand_modifier_team_targets_scroll_pane = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-team-targets-scroll-pane",
+ magic_wand_modifier_team_targets_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-team-targets-container",
+ magic_wand_modifier_team_targets_inner_container = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-team-targets-inner-container",
+ magic_wand_modifier_team_target_name_button_prefix = creative_mode_defines.name_prefix
+ .. "magic-wand-modifier-team-target-name-button-",
+ modding_menus_container = creative_mode_defines.name_prefix .. "modding-menu-container",
+ modding_menus_frame = creative_mode_defines.name_prefix .. "modding-menu-frame",
+ events_menu_button = creative_mode_defines.name_prefix .. "events-menu-button",
+ interfaces_menu_button = creative_mode_defines.name_prefix .. "interfaces-menu-button",
+ events_menu_frame = creative_mode_defines.name_prefix .. "events-menu-frame",
+ events_menu_title_container = creative_mode_defines.name_prefix .. "events-menu-title-container",
+ events_menu_title_label = creative_mode_defines.name_prefix .. "events-menu-title-label",
+ events_menu_title_separator_1 = creative_mode_defines.name_prefix .. "events-menu-title-separator_1",
+ events_menu_search_textfield = creative_mode_defines.name_prefix .. "events-menu-search-textfield",
+ events_menu_search_textfield_placeholder_flow = creative_mode_defines.name_prefix
+ .. "events-menu-search-textfield-placeholder-flow",
+ events_menu_title_separator_2 = creative_mode_defines.name_prefix .. "events-menu-title-separator_2",
+ events_menu_search_button = creative_mode_defines.name_prefix .. "events-menu-search-button",
+ events_menu_label = creative_mode_defines.name_prefix .. "events-menu-label",
+ events_scroll_pane = creative_mode_defines.name_prefix .. "events-scroll-pane",
+ events_inner_container = creative_mode_defines.name_prefix .. "events-inner-container",
+ event_container_prefix = creative_mode_defines.name_prefix .. "event-container-",
+ event_toggle_checkbox_prefix = creative_mode_defines.name_prefix .. "event-toggle-checkbox-",
+ events_all_button_container = creative_mode_defines.name_prefix .. "eventa-all-button-container",
+ events_enable_all_button = creative_mode_defines.name_prefix .. "events-enable-all-button",
+ events_disable_all_button = creative_mode_defines.name_prefix .. "events-disable-all-button",
+ event_categories_and_options_container = creative_mode_defines.name_prefix
+ .. "event-categories-and-options-container",
+ event_categories_frame = creative_mode_defines.name_prefix .. "event-categories-frame",
+ event_category_item_container = creative_mode_defines.name_prefix .. "event-category-item-container",
+ event_category_item_label = creative_mode_defines.name_prefix .. "event-category-item-label",
+ event_category_item_show_button = creative_mode_defines.name_prefix .. "event-category-item-show-button",
+ event_category_item_hide_button = creative_mode_defines.name_prefix .. "event-category-item-hide-button",
+ event_category_entity_container = creative_mode_defines.name_prefix .. "event-category-entity-container",
+ event_category_entity_label = creative_mode_defines.name_prefix .. "event-category-entity-label",
+ event_category_entity_show_button = creative_mode_defines.name_prefix .. "event-category-entity-show-button",
+ event_category_entity_hide_button = creative_mode_defines.name_prefix .. "event-category-entity-hide-button",
+ event_category_tile_container = creative_mode_defines.name_prefix .. "event-category-tile-container",
+ event_category_tile_label = creative_mode_defines.name_prefix .. "event-category-tile-label",
+ event_category_tile_show_button = creative_mode_defines.name_prefix .. "event-category-tile-show-button",
+ event_category_tile_hide_button = creative_mode_defines.name_prefix .. "event-category-tile-hide-button",
+ event_category_technology_container = creative_mode_defines.name_prefix .. "event-category-technology-container",
+ event_category_technology_label = creative_mode_defines.name_prefix .. "event-category-technology-label",
+ event_category_technology_show_button = creative_mode_defines.name_prefix .. "event-category-technology-show-button",
+ event_category_technology_hide_button = creative_mode_defines.name_prefix .. "event-category-technology-hide-button",
+ event_category_player_container = creative_mode_defines.name_prefix .. "event-category-player-container",
+ event_category_player_label = creative_mode_defines.name_prefix .. "event-category-player-label",
+ event_category_player_show_button = creative_mode_defines.name_prefix .. "event-category-player-show-button",
+ event_category_player_hide_button = creative_mode_defines.name_prefix .. "event-category-player-hide-button",
+ event_category_force_container = creative_mode_defines.name_prefix .. "event-category-force-container",
+ event_category_force_label = creative_mode_defines.name_prefix .. "event-category-force-label",
+ event_category_force_show_button = creative_mode_defines.name_prefix .. "event-category-force-show-button",
+ event_category_force_hide_button = creative_mode_defines.name_prefix .. "event-category-force-hide-button",
+ event_category_surface_container = creative_mode_defines.name_prefix .. "event-category-surface-container",
+ event_category_surface_label = creative_mode_defines.name_prefix .. "event-category-surface-label",
+ event_category_surface_show_button = creative_mode_defines.name_prefix .. "event-category-surface-show-button",
+ event_category_surface_hide_button = creative_mode_defines.name_prefix .. "event-category-surface-hide-button",
+ event_category_position_container = creative_mode_defines.name_prefix .. "event-category-position-container",
+ event_category_position_label = creative_mode_defines.name_prefix .. "event-category-position-label",
+ event_category_position_show_button = creative_mode_defines.name_prefix .. "event-category-position-show-button",
+ event_category_position_hide_button = creative_mode_defines.name_prefix .. "event-category-position-hide-button",
+ event_category_gui_container = creative_mode_defines.name_prefix .. "event-category-gui-container",
+ event_category_gui_label = creative_mode_defines.name_prefix .. "event-category-gui-label",
+ event_category_gui_show_button = creative_mode_defines.name_prefix .. "event-category-gui-show-button",
+ event_category_gui_hide_button = creative_mode_defines.name_prefix .. "event-category-gui-hide-button",
+ event_category_settings_container = creative_mode_defines.name_prefix .. "event-category-settings-container",
+ event_category_settings_label = creative_mode_defines.name_prefix .. "event-category-settings-label",
+ event_category_settings_show_button = creative_mode_defines.name_prefix .. "event-category-settings-show-button",
+ event_category_settings_hide_button = creative_mode_defines.name_prefix .. "event-category-settings-hide-button",
+ event_category_all_container = creative_mode_defines.name_prefix .. "event-category-all-container",
+ event_category_all_label = creative_mode_defines.name_prefix .. "event-category-all-label",
+ event_category_all_show_button = creative_mode_defines.name_prefix .. "event-category-all-show-button",
+ event_category_all_hide_button = creative_mode_defines.name_prefix .. "event-category-all-hide-button",
+ event_options_frame = creative_mode_defines.name_prefix .. "event-options-frame",
+ event_options_container = creative_mode_defines.name_prefix .. "event-options-container",
+ event_option_print_events_checkbox = creative_mode_defines.name_prefix .. "event-option-print-events-checkbox",
+ event_option_print_parameters_checkbox = creative_mode_defines.name_prefix
+ .. "event-option-print-parameters-checkbox",
+ event_option_write_events_checkbox = creative_mode_defines.name_prefix .. "event-option-write-events-checkbox",
+ event_option_write_parameters_checkbox = creative_mode_defines.name_prefix
+ .. "event-option-write-parameters-checkbox",
+ event_option_log_events_checkbox = creative_mode_defines.name_prefix .. "event-option-log-events-checkbox",
+ event_option_log_parameters_checkbox = creative_mode_defines.name_prefix .. "event-option-log-parameters-checkbox",
+ interfaces_menu_frame = creative_mode_defines.name_prefix .. "interfaces-menu-frame",
+ interfaces_menu_label = creative_mode_defines.name_prefix .. "interfaces-menu-label",
+ interfaces_scroll_pane = creative_mode_defines.name_prefix .. "interfaces-scroll-pane",
+ interfaces_inner_container = creative_mode_defines.name_prefix .. "interfaces-inner-container",
+ interface_button_prefix = creative_mode_defines.name_prefix .. "interface-button-",
+ interface_contents_and_hints_container = creative_mode_defines.name_prefix
+ .. "interface-contents-and-hints-container",
+ interface_contents_frame = creative_mode_defines.name_prefix .. "interface-contents-frame",
+ interface_contents_scroll_pane = creative_mode_defines.name_prefix .. "interface-contents-scroll-pane",
+ interface_contents_container = creative_mode_defines.name_prefix .. "interface-contents-container",
+ interface_contents_label_prefix = creative_mode_defines.name_prefix .. "interface-contents-label-",
+ interface_contents_button_prefix = creative_mode_defines.name_prefix .. "interface-contents-button-",
+ interface_hints_frame = creative_mode_defines.name_prefix .. "interface-hints-frame",
+ interface_can_register_remote_function_label = creative_mode_defines.name_prefix
+ .. "interface-can-register-remote-function-label",
+ admin_menus_container = creative_mode_defines.name_prefix .. "admin-menus-container",
+ access_right_frame = creative_mode_defines.name_prefix .. "access-right-frame",
+ access_right_label = creative_mode_defines.name_prefix .. "access-right-label",
+ access_rights_scroll_pane = creative_mode_defines.name_prefix .. "access-rights-scroll-pane",
+ access_rights_container = creative_mode_defines.name_prefix .. "access-rights-container",
+ disable_mode_frame = creative_mode_defines.name_prefix .. "disable-mode-frame",
+ access_personal_cheat_container = creative_mode_defines.name_prefix .. "access-personal-cheat-container",
+ access_personal_cheat_label = creative_mode_defines.name_prefix .. "access-personal-cheat-label",
+ access_personal_cheat_inner_container = creative_mode_defines.name_prefix .. "access-personal-cheat-inner-container",
+ access_personal_cheat_admin_only_button = creative_mode_defines.name_prefix
+ .. "access-personal-cheat-admin-only-button",
+ access_personal_cheat_free_button = creative_mode_defines.name_prefix .. "access-personal-cheat-free-button",
+ access_team_cheat_container = creative_mode_defines.name_prefix .. "access-team-cheat-container",
+ access_team_cheat_label = creative_mode_defines.name_prefix .. "access-team-cheat-label",
+ access_team_cheat_inner_container = creative_mode_defines.name_prefix .. "access-team-cheat-inner-container",
+ access_team_cheat_admin_only_button = creative_mode_defines.name_prefix .. "access-team-cheat-admin-only-button",
+ access_team_cheat_own_team_button = creative_mode_defines.name_prefix .. "access-team-cheat-own-team-button",
+ access_team_cheat_free_button = creative_mode_defines.name_prefix .. "access-team-cheat-free-button",
+ access_surface_cheat_container = creative_mode_defines.name_prefix .. "access-surface-cheat-container",
+ access_surface_cheat_label = creative_mode_defines.name_prefix .. "access-surface-cheat-label",
+ access_surface_cheat_inner_container = creative_mode_defines.name_prefix .. "access-surface-cheat-inner-container",
+ access_surface_cheat_admin_only_button = creative_mode_defines.name_prefix
+ .. "access-surface-cheat-admin-only-button",
+ access_surface_cheat_current_surface_button = creative_mode_defines.name_prefix
+ .. "access-surface-cheat-current-surface-button",
+ access_surface_cheat_free_button = creative_mode_defines.name_prefix .. "access-surface-cheat-free-button",
+ access_global_cheat_container = creative_mode_defines.name_prefix .. "access-global-cheat-container",
+ access_global_cheat_label = creative_mode_defines.name_prefix .. "access-global-cheat-label",
+ access_global_cheat_inner_container = creative_mode_defines.name_prefix .. "access-global-cheat-inner-container",
+ access_global_cheat_admin_only_button = creative_mode_defines.name_prefix .. "access-global-cheat-admin-only-button",
+ access_global_cheat_free_button = creative_mode_defines.name_prefix .. "access-global-cheat-free-button",
+ access_build_options_container = creative_mode_defines.name_prefix .. "access-build-options-container",
+ access_build_options_label = creative_mode_defines.name_prefix .. "access-build-options-label",
+ access_build_options_inner_container = creative_mode_defines.name_prefix .. "access-build-options-inner-container",
+ access_build_options_admin_only_button = creative_mode_defines.name_prefix
+ .. "access-build-options-admin-only-button",
+ access_build_options_no_team_button = creative_mode_defines.name_prefix .. "access-build-options-no-team-button",
+ access_build_options_free_button = creative_mode_defines.name_prefix .. "access-build-options-free-button",
+ access_creator_magic_wand_container = creative_mode_defines.name_prefix .. "access-creator-magic-wand-container",
+ access_creator_magic_wand_label = creative_mode_defines.name_prefix .. "access-creator-magic-wand-label",
+ access_creator_magic_wand_inner_container = creative_mode_defines.name_prefix
+ .. "access-creator-magic-wand-inner-container",
+ access_creator_magic_wand_admin_only_button = creative_mode_defines.name_prefix
+ .. "access-creator-magic-wand-admin-only-button",
+ access_creator_magic_wand_free_button = creative_mode_defines.name_prefix .. "access-creator-magic-wand-free-button",
+ access_healer_magic_wand_container = creative_mode_defines.name_prefix .. "access-healer-magic-wand-container",
+ access_healer_magic_wand_label = creative_mode_defines.name_prefix .. "access-healer_magic_wand-label",
+ access_healer_magic_wand_inner_container = creative_mode_defines.name_prefix
+ .. "access-healer-magic-wand-inner-container",
+ access_healer_magic_wand_admin_only_button = creative_mode_defines.name_prefix
+ .. "access-healer-magic-wand-admin-only-button",
+ access_healer_magic_wand_free_button = creative_mode_defines.name_prefix .. "access-healer-magic-wand-free-button",
+ access_modifier_magic_wand_container = creative_mode_defines.name_prefix .. "access-modifier-magic-wand-container",
+ access_modifier_magic_wand_label = creative_mode_defines.name_prefix .. "access-modifier-magic-wand-label",
+ access_modifier_magic_wand_inner_container = creative_mode_defines.name_prefix
+ .. "access-modifier-magic-wand-inner-container",
+ access_modifier_magic_wand_admin_only_button = creative_mode_defines.name_prefix
+ .. "access-modifier-magic-wand-admin-only-button",
+ access_modifier_magic_wand_free_button = creative_mode_defines.name_prefix
+ .. "access-modifier-magic-wand-free-button",
+ access_modding_menu_container = creative_mode_defines.name_prefix .. "access-modding-menu-container",
+ access_modding_menu_label = creative_mode_defines.name_prefix .. "access-modding-menu-label",
+ access_modding_menu_inner_container = creative_mode_defines.name_prefix .. "access-modding-menu-inner-container",
+ access_modding_menu_admin_only_button = creative_mode_defines.name_prefix .. "access-modding-menu-admin-only-button",
+ access_modding_menu_free_button = creative_mode_defines.name_prefix .. "access-modding-menu-free-button",
+ overall_access_rights_container = creative_mode_defines.name_prefix .. "overall-access-rights-container",
+ overall_access_rights_label = creative_mode_defines.name_prefix .. "overall-access-rights-label",
+ overall_access_rights_inner_container = creative_mode_defines.name_prefix .. "overall-access-rights-inner-container",
+ overall_access_rights_admin_only_button = creative_mode_defines.name_prefix
+ .. "overall-access-rights-admin-only-button",
+ overall_access_rights_default_button = creative_mode_defines.name_prefix .. "overall-access-rights-default-button",
+ disable_creative_mode_frame = creative_mode_defines.name_prefix .. "disable-creative-mode-frame",
+ disable_creative_mode_button = creative_mode_defines.name_prefix .. "disable-creative-mode-button",
+ disable_creative_mode_permanently_button = creative_mode_defines.name_prefix
+ .. "disable-creative-mode-permanently-button",
+ entity_gui_container = creative_mode_defines.name_prefix .. "entity-gui-container",
+ entity_gui_button_container = creative_mode_defines.name_prefix .. "entity-gui-button-container",
+ entity_gui_frame_container = creative_mode_defines.name_prefix .. "entity-gui-frame-container",
+ entity_gui_frame = creative_mode_defines.name_prefix .. "entity-gui-frame",
+ creative_chest_open_button = creative_mode_defines.name_prefix .. "creative-chest-open-button",
+ creative_chest_item_group_container = creative_mode_defines.name_prefix .. "creative-chest-item-group-container",
+ creative_chest_item_group_label = creative_mode_defines.name_prefix .. "creative-chest-item-group-label",
+ creative_chest_item_group_number_label = creative_mode_defines.name_prefix
+ .. "creative-chest-item-group-number-label",
+ creative_chest_item_group_left_button = creative_mode_defines.name_prefix .. "creative-chest-item-group-left-button",
+ creative_chest_item_group_right_button = creative_mode_defines.name_prefix
+ .. "creative-chest-item-group-right-button",
+ creative_chest_filter_container = creative_mode_defines.name_prefix .. "creative-chest-filter-container",
+ creative_chest_filter_label = creative_mode_defines.name_prefix .. "creative-chest-filter-label",
+ creative_chest_display_mode_button = creative_mode_defines.name_prefix .. "creative-chest-display-mode-button",
+ creative_chest_toggle_all_button = creative_mode_defines.name_prefix .. "creative-chest-toggle-all-button",
+ creative_chest_filter_scroll_pane = creative_mode_defines.name_prefix .. "creative-chest-filter-scroll-pane",
+ creative_chest_filter_table = creative_mode_defines.name_prefix .. "creative-chest-filter-table",
+ creative_chest_filter_slot_prefix = creative_mode_defines.name_prefix .. "creative-chest-filter-slot-",
+ duplicating_chest_open_button = creative_mode_defines.name_prefix .. "duplicating-chest-open-button",
+ duplicating_chest_lock_item_checkbox = creative_mode_defines.name_prefix .. "duplicating-chest-lock-item-checkbox",
+ configurable_super_boiler_open_button = creative_mode_defines.name_prefix .. "configurable-super-boiler-open-button",
+ configurable_super_boiler_set_temp_container = creative_mode_defines.name_prefix
+ .. "configurable-super-boiler-set-temp-container",
+ configurable_super_boiler_set_temp_label = creative_mode_defines.name_prefix
+ .. "configurable-super-boiler-set-temp-label",
+ configurable_super_boiler_set_temp_textfield = creative_mode_defines.name_prefix
+ .. "configurable-super-boiler-set-temp-textfield",
+ configurable_super_boiler_set_temp_button = creative_mode_defines.name_prefix
+ .. "configurable-super-boiler-set-temp-button",
+ item_source_open_button = creative_mode_defines.name_prefix .. "item-source-open-button",
+ item_source_options_container = creative_mode_defines.name_prefix .. "item-source-options-container",
+ item_source_can_insert_to_vehicle_checkbox = creative_mode_defines.name_prefix
+ .. "item-source-can-insert-to-vehicle-checkbox",
+ item_source_can_insert_to_player_checkbox = creative_mode_defines.name_prefix
+ .. "item-source-can-insert-to-player-checkbox",
+ item_source_can_drop_on_ground_checkbox = creative_mode_defines.name_prefix
+ .. "item-source-can-drop-on-ground-checkbox",
+ item_source_insert_to_player_frame = creative_mode_defines.name_prefix .. "item-source-insert-to-player-frame",
+ item_source_insert_only_once_to_player_checkbox = creative_mode_defines.name_prefix
+ .. "item-source-insert-only-once-to-player-checkbox",
+ item_source_insert_once_to_player_frame = creative_mode_defines.name_prefix
+ .. "item-source-insert-once-to-player-frame",
+ item_source_insert_once_to_player_container = creative_mode_defines.name_prefix
+ .. "item-source-insert-once-to-player-container",
+ item_source_insert_once_to_player_amount_container = creative_mode_defines.name_prefix
+ .. "item-source-insert-once-to-player-amount-container",
+ item_source_insert_once_to_player_amount_label = creative_mode_defines.name_prefix
+ .. "item-source-insert-once-to-player-amount-label",
+ item_source_insert_once_to_player_amount_field = creative_mode_defines.name_prefix
+ .. "item-source-insert-once-to-player-amount-field",
+ item_source_insert_once_to_player_by_stack_checkbox = creative_mode_defines.name_prefix
+ .. "item-source-insert-once-to-player-by-stack-checkbox",
+ duplicator_open_button = creative_mode_defines.name_prefix .. "duplicator-open-button",
+ duplicator_options_container = creative_mode_defines.name_prefix .. "duplicator-options_container",
+ duplicator_can_duplicate_in_vehicle_checkbox = creative_mode_defines.name_prefix
+ .. "duplicator-can-duplicate-in-vehicle-checkbox",
+ duplicator_can_duplicate_in_player_checkbox = creative_mode_defines.name_prefix
+ .. "duplicator-can-duplicate-in-player-checkbox",
+ item_void_open_button = creative_mode_defines.name_prefix .. "item-void-open-button",
+ item_void_options_container = creative_mode_defines.name_prefix .. "item-void-options-container",
+ item_void_can_remove_from_vehicle_checkbox = creative_mode_defines.name_prefix
+ .. "item-void-can-remove-from-vehicle-checkbox",
+ item_void_can_remove_from_player_checkbox = creative_mode_defines.name_prefix
+ .. "item-void-can-remove-from-player-checkbox",
+ item_void_can_remove_from_ground_checkbox = creative_mode_defines.name_prefix
+ .. "item-void-can-remove-from-ground-checkbox",
+ -- Legacy GUI. Used for finding and destroying the legacy "more cheats" popup.
+ cheats_table = creative_mode_defines.name_prefix .. "cheats-table",
}
-- GUI element captions.
creative_mode_defines.names.gui_captions = {
- yes = { "gui.creative-mode_yes" },
- no = { "gui.creative-mode_no" },
- on = { "gui.creative-mode_on" },
- off = { "gui.creative-mode_off" },
- ok = { "gui.creative-mode_ok" },
- unlock = { "gui.creative-mode_unlock" },
- reset = { "gui.reset" },
- show = { "gui.creative-mode_show" },
- hide = { "gui.creative-mode_hide" },
- enable_all = { "gui.creative-mode_enable-all" },
- disable_all = { "gui.creative-mode_disable-all" },
- select_all = { "gui.creative-mode_select-all" },
- remove_all = { "gui.creative-mode_remove-all" },
- creative_chest_display_mode_original = {
- "gui.creative-mode_switch-inventory-display-mode",
- { "gui.creative-mode_inventory-display-mode-original" },
- },
- creative_chest_display_mode_compact = {
- "gui.creative-mode_switch-inventory-display-mode",
- { "gui.creative-mode_inventory-display-mode-compact" },
- },
+ yes = { "gui.creative-mode_yes" },
+ no = { "gui.creative-mode_no" },
+ on = { "gui.creative-mode_on" },
+ off = { "gui.creative-mode_off" },
+ ok = { "gui.creative-mode_ok" },
+ unlock = { "gui.creative-mode_unlock" },
+ reset = { "gui.reset" },
+ show = { "gui.creative-mode_show" },
+ hide = { "gui.creative-mode_hide" },
+ enable_all = { "gui.creative-mode_enable-all" },
+ disable_all = { "gui.creative-mode_disable-all" },
+ select_all = { "gui.creative-mode_select-all" },
+ remove_all = { "gui.creative-mode_remove-all" },
+ creative_chest_display_mode_original = {
+ "gui.creative-mode_switch-inventory-display-mode",
+ { "gui.creative-mode_inventory-display-mode-original" },
+ },
+ creative_chest_display_mode_compact = {
+ "gui.creative-mode_switch-inventory-display-mode",
+ { "gui.creative-mode_inventory-display-mode-compact" },
+ },
}
-- GUI element styles.
creative_mode_defines.names.gui_styles = {
- resize_col_flow = "creative_mode_resize_col_flow_style",
- no_horizontal_spacing_flow = "creative_mode_no_horizontal_spacing_flow_style",
- no_horizontal_spacing_resize_col_flow = "creative_mode_no_horizontal_spacing_resize_col_flow_style",
- no_vertical_spacing_resize_row_flow = "creative_mode_no_vertical_spacing_resize_row_flow_style",
- frame_caption_label = "frame_caption_label",
- long_dialog_button = "creative_mode_long_dialog_button_style",
- small_default_bold_button = "creative_mode_small_default_bold_button_style",
- frame_caption_button = "frame_action_button",
- frame_search_textfield = "creative_mode_frame_search_textfield_style",
- frame_search_textfield_placeholder_flow = "creative_mode_frame_search_textfield_placeholder_flow_style",
- main_menu_open_button = "creative_mode_main_menu_open_button_style",
- main_menu_button = "creative_mode_main_menu_button_style",
- naked_small_orange_title_frame = "creative_mode_naked_small_orange_title_frame_style",
- small_orange_title_with_right_border_frame = "creative_mode_small_orange_title_with_right_border_frame_style",
- unscalable_no_spacing_table = "creative_mode_unscalable_no_spacing_table_style",
- slot_table = "slot_table",
- slot_button_label = "creative_mode_slot_button_label_style",
- slider_button_on = "creative_mode_slider_button_on_style",
- slider_button_off = "creative_mode_slider_button_off_style",
- slider_textfield = "creative_mode_slider_textfield_style",
- cheat_scroll_pane = "creative_mode_cheat_scroll_pane_style",
- cheat_target_selection_container_frame = "creative_mode_cheat_target_selection_container_frame_style",
- cheat_target_selected_button = "creative_mode_cheat_target_selected_button_style",
- cheat_target_unselected_button = "creative_mode_cheat_target_unselected_button_style",
- cheat_target_self_selected_button = "creative_mode_cheat_target_selected_self_button_style",
- cheat_target_self_unselected_button = "creative_mode_cheat_target_unselected_self_button_style",
- cheat_select_all_targets_button = "creative_mode_cheat_select_all_targets_button_style",
- cheat_table = "creative_mode_cheat_table_style",
- cheat_flow = "creative_mode_cheat_flow_style",
- cheat_name_label = "creative_mode_cheat_name_label_style",
- cheat_on_off_button_on = "creative_mode_cheat_on_off_button_on_style",
- cheat_on_off_button_off = "creative_mode_cheat_on_off_button_off_style",
- cheat_numeric_textfield = "creative_mode_cheat_numeric_textfield_style",
- cheat_textfield_and_button_separate_flow = "creative_mode_cheat_textfield_and_button_separate_flow_style",
- cheat_apply_button = "creative_mode_cheat_apply_button_style",
- cheat_with_one_button_name_label = "creative_mode_cheat_one_button_name_label_style",
- cheat_enable_disable_all_table = "creative_mode_cheat_enable_disable_all_table_style",
- cheat_enable_disable_all_button = "creative_mode_cheat_enable_disable_all_button_style",
- cheat_note_label = "creative_mode_cheat_note_label_style",
- cheat_value_drop_down_current_target_button = "creative_mode_cheat_value_drop_down_current_target_button_style",
- cheat_value_drop_down_scroll_pane = "creative_mode_cheat_value_drop_down_scroll_pane_style",
- cheat_value_drop_down_container_frame = "creative_mode_cheat_value_drop_down_container_frame_style",
- cheat_value_drop_down_selection_button = "creative_mode_cheat_value_drop_down_selection_button_style",
- magic_wand_frame_caption_label = "creative_mode_magic_wand_frame_caption_label_style",
- magic_wand_scroll_pane = "creative_mode_magic_wand_scroll_pane_style",
- magic_wand_select_mode_frame = "creative_mode_magic_wand_select_mode_frame_style",
- magic_wand_alt_select_mode_frame = "creative_mode_magic_wand_alt_select_mode_frame_style",
- magic_wand_label = "creative_mode_magic_wand_label_style",
- magic_wand_checkbox = "creative_mode_magic_wand_checkbox_style",
- magic_wand_radiobutton = "creative_mode_magic_wand_radiobutton_style",
- tile_slot_selected = "creative_mode_tile_slot_selected_style",
- tile_slot_deselected = "creative_mode_tile_slot_deselected_style",
- magic_wand_slider_label = "creative_mode_magic_wand_slider_label_style",
- magic_wand_drop_down_label = "creative_mode_magic_wand_drop_down_label",
- magic_wand_drop_down = "creative_mode_magic_wand_drop_down",
- magic_wand_select_all_button = "creative_mode_magic_wand_select_all_button_style",
- magic_wand_quick_action_remove_button = "creative_mode_magic_wand_quick_action_remove_button_style",
- magic_wand_popup_left_frame_caption_label = "creative_mode_magic_wand_popup_left_frame_caption_label_style",
- magic_wand_popup_right_frame_caption_label = "creative_mode_magic_wand_popup_right_frame_caption_label_style",
- magic_wand_popup_slot_scroll_pane = "creative_mode_magic_wand_popup_slot_scroll_pane_style",
- magic_wand_popup_slot_table = "creative_mode_magic_wand_popup_slot_table_style",
- magic_wand_popup_item_on_ground_slot_button = "creative_mode_magic_wand_popup_item_on_ground_slot_button_style",
- magic_wand_popup_ghost_slot_button = "creative_mode_magic_wand_popup_ghost_slot_button_style",
- events_menu_frame_caption_label = "creative_mode_events_menu_frame_caption_label_style",
- interfaces_scroll_pane = "creative_mode_interfaces_scroll_pane_style",
- interface_button = "creative_mode_interface_button_style",
- interface_contents_scroll_pane = "creative_mode_interface_scroll_pane_style",
- interface_content_button = "creative_mode_interface_content_button_style",
- access_right_on_off_button_on = "creative_mode_access_right_on_off_button_on_style",
- access_right_on_off_button_off = "creative_mode_access_right_on_off_button_off_style",
- disable_creative_mode_button = "creative_mode_disable_creative_mode_button_style",
- entity_open_button = "creative_mode_entity_open_button_style",
- creative_chest_item_group_label = "creative_mode_creative_chest_item_group_label_style",
- creative_chest_item_group_number_label = "creative_mode_creative_chest_item_group_number_label_style",
- creative_chest_item_group_left_right_button = "creative_mode_creative_chest_item_group_left_right_button_style",
- creative_chest_select_slot_label = "creative_mode_creative_chest_select_slot_label_style",
- creative_chest_display_mode_button_original = "creative_mode_creative_chest_original_display_mode_button_style",
- creative_chest_display_mode_button_compact = "creative_mode_creative_chest_compact_display_mode_button_style",
- inventory_toggle_all_button = "creative_mode_inventory_toggle_all_button_style",
- creative_chest_filter_slot_on = "creative_mode_filter_slot_on_style",
- creative_chest_filter_slot_off = "creative_mode_filter_slot_off_style",
- item_count_textfield = "creative_mode_item_count_textfield_style",
+ resize_col_flow = "creative_mode_resize_col_flow_style",
+ no_horizontal_spacing_flow = "creative_mode_no_horizontal_spacing_flow_style",
+ no_horizontal_spacing_resize_col_flow = "creative_mode_no_horizontal_spacing_resize_col_flow_style",
+ no_vertical_spacing_resize_row_flow = "creative_mode_no_vertical_spacing_resize_row_flow_style",
+ frame_caption_label = "frame_caption_label",
+ long_dialog_button = "creative_mode_long_dialog_button_style",
+ small_default_bold_button = "creative_mode_small_default_bold_button_style",
+ frame_caption_button = "frame_action_button",
+ frame_search_textfield = "creative_mode_frame_search_textfield_style",
+ frame_search_textfield_placeholder_flow = "creative_mode_frame_search_textfield_placeholder_flow_style",
+ main_menu_open_button = "creative_mode_main_menu_open_button_style",
+ main_menu_button = "creative_mode_main_menu_button_style",
+ naked_small_orange_title_frame = "creative_mode_naked_small_orange_title_frame_style",
+ small_orange_title_with_right_border_frame = "creative_mode_small_orange_title_with_right_border_frame_style",
+ unscalable_no_spacing_table = "creative_mode_unscalable_no_spacing_table_style",
+ slot_table = "slot_table",
+ slot_button_label = "creative_mode_slot_button_label_style",
+ slider_button_on = "creative_mode_slider_button_on_style",
+ slider_button_off = "creative_mode_slider_button_off_style",
+ slider_textfield = "creative_mode_slider_textfield_style",
+ cheat_scroll_pane = "creative_mode_cheat_scroll_pane_style",
+ cheat_target_selection_container_frame = "creative_mode_cheat_target_selection_container_frame_style",
+ cheat_target_selected_button = "creative_mode_cheat_target_selected_button_style",
+ cheat_target_unselected_button = "creative_mode_cheat_target_unselected_button_style",
+ cheat_target_self_selected_button = "creative_mode_cheat_target_selected_self_button_style",
+ cheat_target_self_unselected_button = "creative_mode_cheat_target_unselected_self_button_style",
+ cheat_select_all_targets_button = "creative_mode_cheat_select_all_targets_button_style",
+ cheat_table = "creative_mode_cheat_table_style",
+ cheat_flow = "creative_mode_cheat_flow_style",
+ cheat_name_label = "creative_mode_cheat_name_label_style",
+ cheat_on_off_button_on = "creative_mode_cheat_on_off_button_on_style",
+ cheat_on_off_button_off = "creative_mode_cheat_on_off_button_off_style",
+ cheat_numeric_textfield = "creative_mode_cheat_numeric_textfield_style",
+ cheat_textfield_and_button_separate_flow = "creative_mode_cheat_textfield_and_button_separate_flow_style",
+ cheat_apply_button = "creative_mode_cheat_apply_button_style",
+ cheat_with_one_button_name_label = "creative_mode_cheat_one_button_name_label_style",
+ cheat_enable_disable_all_table = "creative_mode_cheat_enable_disable_all_table_style",
+ cheat_enable_disable_all_button = "creative_mode_cheat_enable_disable_all_button_style",
+ cheat_note_label = "creative_mode_cheat_note_label_style",
+ cheat_value_drop_down_current_target_button = "creative_mode_cheat_value_drop_down_current_target_button_style",
+ cheat_value_drop_down_scroll_pane = "creative_mode_cheat_value_drop_down_scroll_pane_style",
+ cheat_value_drop_down_container_frame = "creative_mode_cheat_value_drop_down_container_frame_style",
+ cheat_value_drop_down_selection_button = "creative_mode_cheat_value_drop_down_selection_button_style",
+ magic_wand_frame_caption_label = "creative_mode_magic_wand_frame_caption_label_style",
+ magic_wand_scroll_pane = "creative_mode_magic_wand_scroll_pane_style",
+ magic_wand_select_mode_frame = "creative_mode_magic_wand_select_mode_frame_style",
+ magic_wand_alt_select_mode_frame = "creative_mode_magic_wand_alt_select_mode_frame_style",
+ magic_wand_label = "creative_mode_magic_wand_label_style",
+ magic_wand_checkbox = "creative_mode_magic_wand_checkbox_style",
+ magic_wand_radiobutton = "creative_mode_magic_wand_radiobutton_style",
+ tile_slot_selected = "creative_mode_tile_slot_selected_style",
+ tile_slot_deselected = "creative_mode_tile_slot_deselected_style",
+ magic_wand_slider_label = "creative_mode_magic_wand_slider_label_style",
+ magic_wand_drop_down_label = "creative_mode_magic_wand_drop_down_label",
+ magic_wand_drop_down = "creative_mode_magic_wand_drop_down",
+ magic_wand_select_all_button = "creative_mode_magic_wand_select_all_button_style",
+ magic_wand_quick_action_remove_button = "creative_mode_magic_wand_quick_action_remove_button_style",
+ magic_wand_popup_left_frame_caption_label = "creative_mode_magic_wand_popup_left_frame_caption_label_style",
+ magic_wand_popup_right_frame_caption_label = "creative_mode_magic_wand_popup_right_frame_caption_label_style",
+ magic_wand_popup_slot_scroll_pane = "creative_mode_magic_wand_popup_slot_scroll_pane_style",
+ magic_wand_popup_slot_table = "creative_mode_magic_wand_popup_slot_table_style",
+ magic_wand_popup_item_on_ground_slot_button = "creative_mode_magic_wand_popup_item_on_ground_slot_button_style",
+ magic_wand_popup_ghost_slot_button = "creative_mode_magic_wand_popup_ghost_slot_button_style",
+ events_menu_frame_caption_label = "creative_mode_events_menu_frame_caption_label_style",
+ interfaces_scroll_pane = "creative_mode_interfaces_scroll_pane_style",
+ interface_button = "creative_mode_interface_button_style",
+ interface_contents_scroll_pane = "creative_mode_interface_scroll_pane_style",
+ interface_content_button = "creative_mode_interface_content_button_style",
+ access_right_on_off_button_on = "creative_mode_access_right_on_off_button_on_style",
+ access_right_on_off_button_off = "creative_mode_access_right_on_off_button_off_style",
+ disable_creative_mode_button = "creative_mode_disable_creative_mode_button_style",
+ entity_open_button = "creative_mode_entity_open_button_style",
+ creative_chest_item_group_label = "creative_mode_creative_chest_item_group_label_style",
+ creative_chest_item_group_number_label = "creative_mode_creative_chest_item_group_number_label_style",
+ creative_chest_item_group_left_right_button = "creative_mode_creative_chest_item_group_left_right_button_style",
+ creative_chest_select_slot_label = "creative_mode_creative_chest_select_slot_label_style",
+ creative_chest_display_mode_button_original = "creative_mode_creative_chest_original_display_mode_button_style",
+ creative_chest_display_mode_button_compact = "creative_mode_creative_chest_compact_display_mode_button_style",
+ inventory_toggle_all_button = "creative_mode_inventory_toggle_all_button_style",
+ creative_chest_filter_slot_on = "creative_mode_filter_slot_on_style",
+ creative_chest_filter_slot_off = "creative_mode_filter_slot_off_style",
+ item_count_textfield = "creative_mode_item_count_textfield_style",
}
-- Sprites.
creative_mode_defines.names.sprites = {
- reset = creative_mode_defines.name_prefix .. "reset",
- cancel = creative_mode_defines.name_prefix .. "cancel",
- search = creative_mode_defines.name_prefix .. "search",
+ reset = creative_mode_defines.name_prefix .. "reset",
+ cancel = creative_mode_defines.name_prefix .. "cancel",
+ search = creative_mode_defines.name_prefix .. "search",
}
-- Prefix for the names of free fluid recipes.
@@ -1417,55 +1394,55 @@ creative_mode_defines.names.enemy_recipe_prefix = creative_mode_defines.name_pre
-- Patterns for matching strings.
creative_mode_defines.match_patterns = {}
creative_mode_defines.match_patterns.gui = {
- all = creative_mode_defines.name_prefix_pattern .. "(.+)",
- event_toggle_checkbox = creative_mode_defines.name_prefix_pattern .. "event%-toggle%-checkbox%-(%d+)",
- interface_button = creative_mode_defines.name_prefix_pattern .. "interface%-button%-(.+)",
- personal_cheats_target_index_button = creative_mode_defines.name_prefix_pattern
- .. "personal%-cheats%-target%-index%-button%-(%d+)",
- team_cheats_target_name_button = creative_mode_defines.name_prefix_pattern
- .. "team%-cheats%-target%-name%-button%-(.+)",
- surface_cheats_target_name_button = creative_mode_defines.name_prefix_pattern
- .. "surface%-cheats%-target%-name%-button%-(.+)",
- build_options_target_index_button = creative_mode_defines.name_prefix_pattern
- .. "build%-options%-target%-index%-button%-(%d+)",
- build_team_target_name_button = creative_mode_defines.name_prefix_pattern
- .. "build%-team%-target%-name%-button%-(.+)",
- magic_wand_creator_tile_name_button = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-creator%-tile%-name%-button%-(.+)",
- magic_wand_creator_resource_name_button = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-creator%-resource%-name%-button%-(.+)",
- magic_wand_creator_rsc_amt_slider_button = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-creator%-resource%-amount%-slider%-button%-(%d+)",
- magic_wand_creator_tile_name_button_2 = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-creator%-tile%-name%-button%-2%-(.+)",
- magic_wand_creator_resource_name_button_2 = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-creator%-resource%-name%-button%-2%-(.+)",
- magic_wand_creator_rsc_amt_slider_button_2 = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-creator%-resource%-amount%-slider%-button%-2%-(%d+)",
- magic_wand_creator_alt_force_name_checkbox = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-creator%-alt%-force%-name%-checkbox%-(.+)",
- magic_wand_healer_heal_force_name_checkbox = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-healer%-heal%-force%-name%-checkbox%-(.+)",
- magic_wand_healer_alt_force_name_checkbox = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-healer%-alt%-force%-name%-checkbox%-(.+)",
- magic_wand_modifier_std_force_name_checkbox = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-modifier%-std%-force%-name%-checkbox%-(.+)",
- magic_wand_modifier_alt_force_name_checkbox = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-modifier%-alt%-force%-name%-checkbox%-(.+)",
- magic_wand_modifier_quick_action_container = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-modifier%-quick%-action%-container%-(%d+)",
- magic_wand_modifier_popup_entity_name_slot = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-modifier%-popup%-entity%-slot%-(.+)",
- magic_wand_modifier_popup_item_on_ground_name_slot = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-modifier%-popup%-item%-on%-ground%-slot%-(.+)",
- magic_wand_modifier_popup_ghost_entity_name_slot = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-modifier%-popup%-ghost%-entity%-slot%-(.+)",
- magic_wand_modifier_popup_ghost_tile_name_slot = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-modifier%-popup%-ghost%-tile%-slot%-(.+)",
- magic_wand_modifier_team_target_name_button = creative_mode_defines.name_prefix_pattern
- .. "magic%-wand%-modifier%-team%-target%-name%-button%-(.+)",
- interface_contents_button = creative_mode_defines.name_prefix_pattern .. "interface%-contents%-button%-(.+)",
- creative_chest_filter_slot = creative_mode_defines.name_prefix_pattern .. "creative%-chest%-filter%-slot%-(%d+)",
+ all = creative_mode_defines.name_prefix_pattern .. "(.+)",
+ event_toggle_checkbox = creative_mode_defines.name_prefix_pattern .. "event%-toggle%-checkbox%-(%d+)",
+ interface_button = creative_mode_defines.name_prefix_pattern .. "interface%-button%-(.+)",
+ personal_cheats_target_index_button = creative_mode_defines.name_prefix_pattern
+ .. "personal%-cheats%-target%-index%-button%-(%d+)",
+ team_cheats_target_name_button = creative_mode_defines.name_prefix_pattern
+ .. "team%-cheats%-target%-name%-button%-(.+)",
+ surface_cheats_target_name_button = creative_mode_defines.name_prefix_pattern
+ .. "surface%-cheats%-target%-name%-button%-(.+)",
+ build_options_target_index_button = creative_mode_defines.name_prefix_pattern
+ .. "build%-options%-target%-index%-button%-(%d+)",
+ build_team_target_name_button = creative_mode_defines.name_prefix_pattern
+ .. "build%-team%-target%-name%-button%-(.+)",
+ magic_wand_creator_tile_name_button = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-creator%-tile%-name%-button%-(.+)",
+ magic_wand_creator_resource_name_button = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-creator%-resource%-name%-button%-(.+)",
+ magic_wand_creator_rsc_amt_slider_button = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-creator%-resource%-amount%-slider%-button%-(%d+)",
+ magic_wand_creator_tile_name_button_2 = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-creator%-tile%-name%-button%-2%-(.+)",
+ magic_wand_creator_resource_name_button_2 = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-creator%-resource%-name%-button%-2%-(.+)",
+ magic_wand_creator_rsc_amt_slider_button_2 = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-creator%-resource%-amount%-slider%-button%-2%-(%d+)",
+ magic_wand_creator_alt_force_name_checkbox = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-creator%-alt%-force%-name%-checkbox%-(.+)",
+ magic_wand_healer_heal_force_name_checkbox = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-healer%-heal%-force%-name%-checkbox%-(.+)",
+ magic_wand_healer_alt_force_name_checkbox = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-healer%-alt%-force%-name%-checkbox%-(.+)",
+ magic_wand_modifier_std_force_name_checkbox = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-modifier%-std%-force%-name%-checkbox%-(.+)",
+ magic_wand_modifier_alt_force_name_checkbox = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-modifier%-alt%-force%-name%-checkbox%-(.+)",
+ magic_wand_modifier_quick_action_container = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-modifier%-quick%-action%-container%-(%d+)",
+ magic_wand_modifier_popup_entity_name_slot = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-modifier%-popup%-entity%-slot%-(.+)",
+ magic_wand_modifier_popup_item_on_ground_name_slot = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-modifier%-popup%-item%-on%-ground%-slot%-(.+)",
+ magic_wand_modifier_popup_ghost_entity_name_slot = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-modifier%-popup%-ghost%-entity%-slot%-(.+)",
+ magic_wand_modifier_popup_ghost_tile_name_slot = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-modifier%-popup%-ghost%-tile%-slot%-(.+)",
+ magic_wand_modifier_team_target_name_button = creative_mode_defines.name_prefix_pattern
+ .. "magic%-wand%-modifier%-team%-target%-name%-button%-(.+)",
+ interface_contents_button = creative_mode_defines.name_prefix_pattern .. "interface%-contents%-button%-(.+)",
+ creative_chest_filter_slot = creative_mode_defines.name_prefix_pattern .. "creative%-chest%-filter%-slot%-(%d+)",
}
-- The additional (hidden) items that should be contained in the creative provider chest
@@ -1475,223 +1452,223 @@ table.insert(creative_mode_defines.values.creative_provider_chest_additional_con
table.insert(creative_mode_defines.values.creative_provider_chest_additional_content_names, "express-loader")
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.creative_chest
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.creative_chest
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.creative_provider_chest
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.creative_provider_chest
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.autofill_requester_chest
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.autofill_requester_chest
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.duplicating_chest
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.duplicating_chest
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.duplicating_provider_chest
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.duplicating_provider_chest
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.void_requester_chest
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.void_requester_chest
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.void_chest
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.void_chest
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.void_storage_chest
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.void_storage_chest
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_loader
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_loader
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.creative_cargo_wagon
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.creative_cargo_wagon
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.duplicating_cargo_wagon
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.duplicating_cargo_wagon
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.void_cargo_wagon
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.void_cargo_wagon
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_logistic_robot
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_logistic_robot
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_construction_robot
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_construction_robot
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_roboport
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_roboport
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.fluid_source
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.fluid_source
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.fluid_void
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.fluid_void
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_boiler
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_boiler
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_cooler
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_cooler
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.configurable_super_boiler
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.configurable_super_boiler
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.heat_source
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.heat_source
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.heat_void
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.heat_void
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.item_source
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.item_source
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.duplicator
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.duplicator
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.item_void
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.item_void
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.random_item_source
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.random_item_source
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.creative_lab
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.creative_lab
)
-- table.insert(creative_mode_defines.values.creative_provider_chest_additional_content_names, creative_mode_defines.names.items.active_electric_energy_interface_output)
-- table.insert(creative_mode_defines.values.creative_provider_chest_additional_content_names, creative_mode_defines.names.items.passive_electric_energy_interface)
-- table.insert(creative_mode_defines.values.creative_provider_chest_additional_content_names, creative_mode_defines.names.items.active_electric_energy_interface_input)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.energy_source
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.energy_source
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.passive_energy_source
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.passive_energy_source
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.energy_void
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.energy_void
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.passive_energy_void
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.passive_energy_void
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_electric_pole
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_electric_pole
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_substation
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_substation
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.magic_wand_creator
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.magic_wand_creator
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.magic_wand_healer
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.magic_wand_healer
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.magic_wand_modifier
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.magic_wand_modifier
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_radar
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_radar
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_radar_2
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_radar_2
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.alien_attractor_small
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.alien_attractor_small
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.alien_attractor_medium
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.alien_attractor_medium
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.alien_attractor_large
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.alien_attractor_large
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_beacon
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_beacon
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_speed_module
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_speed_module
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_effectivity_module
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_effectivity_module
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_productivity_module
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_productivity_module
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_clean_module
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_clean_module
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_slow_module
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_slow_module
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_consumption_module
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_consumption_module
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_pollution_module
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_pollution_module
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.belt_immunity_equipment
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.belt_immunity_equipment
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_fusion_reactor_equipment
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_fusion_reactor_equipment
)
table.insert(
- creative_mode_defines.values.creative_provider_chest_additional_content_names,
- creative_mode_defines.names.items.super_personal_roboport_equipment
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ creative_mode_defines.names.items.super_personal_roboport_equipment
)
-- The names of the loader recipes.
diff --git a/migrations/creative-mode_0.3.2.lua b/migrations/creative-mode_0.3.2.lua
index 6b7e702..a009dc9 100644
--- a/migrations/creative-mode_0.3.2.lua
+++ b/migrations/creative-mode_0.3.2.lua
@@ -1,3 +1,3 @@
for _, force in pairs(game.forces) do
- force.reset_recipes()
+ force.reset_recipes()
end
diff --git a/prototypes/entity.lua b/prototypes/entity.lua
index 46ba4e7..86c9245 100644
--- a/prototypes/entity.lua
+++ b/prototypes/entity.lua
@@ -2,2638 +2,2905 @@ require("scripts/creative-chest-util")
require("circuit-connector-sprites")
local function flying_robot(volume)
- return {
- sound = { {
- filename = "__base__/sound/construction-robot-11.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-12.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-13.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-14.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-15.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-16.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-17.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-18.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-19.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/flying-robot-1.ogg",
- volume = 0.43
- }, {
- filename = "__base__/sound/flying-robot-2.ogg",
- volume = 0.43
- }, {
- filename = "__base__/sound/flying-robot-3.ogg",
- volume = 0.43
- }, {
- filename = "__base__/sound/flying-robot-4.ogg",
- volume = 0.43
- }, {
- filename = "__base__/sound/flying-robot-5.ogg",
- volume = 0.43
- } },
- max_sounds_per_type = 20,
- audible_distance_modifier = 1,
- fade_in_ticks = 8,
- fade_out_ticks = 10,
- probability = 1 / (10 * 60) -- average pause between the sound is 10 seconds
- -- average pause between the sound is 10 seconds
- -- average pause between the sound is 10 seconds
- -- average pause between the sound is 10 seconds
- }
+ return {
+ sound = {
+ {
+ filename = "__base__/sound/construction-robot-11.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-12.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-13.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-14.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-15.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-16.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-17.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-18.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-19.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/flying-robot-1.ogg",
+ volume = 0.43,
+ },
+ {
+ filename = "__base__/sound/flying-robot-2.ogg",
+ volume = 0.43,
+ },
+ {
+ filename = "__base__/sound/flying-robot-3.ogg",
+ volume = 0.43,
+ },
+ {
+ filename = "__base__/sound/flying-robot-4.ogg",
+ volume = 0.43,
+ },
+ {
+ filename = "__base__/sound/flying-robot-5.ogg",
+ volume = 0.43,
+ },
+ },
+ max_sounds_per_type = 20,
+ audible_distance_modifier = 1,
+ fade_in_ticks = 8,
+ fade_out_ticks = 10,
+ probability = 1 / (10 * 60), -- average pause between the sound is 10 seconds
+ -- average pause between the sound is 10 seconds
+ -- average pause between the sound is 10 seconds
+ -- average pause between the sound is 10 seconds
+ }
end
local function construction_robot(volume)
- return {
- sound = { {
- filename = "__base__/sound/construction-robot-1.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-2.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-3.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-4.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-5.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-6.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-7.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-8.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/construction-robot-9.ogg",
- volume = volume
- }, {
- filename = "__base__/sound/flying-robot-1.ogg",
- volume = 0.43
- }, {
- filename = "__base__/sound/flying-robot-2.ogg",
- volume = 0.43
- }, {
- filename = "__base__/sound/flying-robot-3.ogg",
- volume = 0.43
- }, {
- filename = "__base__/sound/flying-robot-4.ogg",
- volume = 0.43
- }, {
- filename = "__base__/sound/flying-robot-5.ogg",
- volume = 0.43
- } },
- max_sounds_per_type = 20,
- audible_distance_modifier = 1,
- fade_in_ticks = 8,
- fade_out_ticks = 8,
- probability = 1 / (10 * 60) -- average pause between the sound is 10 seconds
- -- average pause between the sound is 10 seconds
- -- average pause between the sound is 10 seconds
- -- average pause between the sound is 10 seconds
- }
+ return {
+ sound = {
+ {
+ filename = "__base__/sound/construction-robot-1.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-2.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-3.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-4.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-5.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-6.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-7.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-8.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/construction-robot-9.ogg",
+ volume = volume,
+ },
+ {
+ filename = "__base__/sound/flying-robot-1.ogg",
+ volume = 0.43,
+ },
+ {
+ filename = "__base__/sound/flying-robot-2.ogg",
+ volume = 0.43,
+ },
+ {
+ filename = "__base__/sound/flying-robot-3.ogg",
+ volume = 0.43,
+ },
+ {
+ filename = "__base__/sound/flying-robot-4.ogg",
+ volume = 0.43,
+ },
+ {
+ filename = "__base__/sound/flying-robot-5.ogg",
+ volume = 0.43,
+ },
+ },
+ max_sounds_per_type = 20,
+ audible_distance_modifier = 1,
+ fade_in_ticks = 8,
+ fade_out_ticks = 8,
+ probability = 1 / (10 * 60), -- average pause between the sound is 10 seconds
+ -- average pause between the sound is 10 seconds
+ -- average pause between the sound is 10 seconds
+ -- average pause between the sound is 10 seconds
+ }
end
local function def_CC_table(main_offset, shadow_offset, variation)
- return {
- variation = variation,
- main_offset = main_offset,
- shadow_offset = shadow_offset,
- show_shadow = shadow_offset ~= nil
- }
+ return {
+ variation = variation,
+ main_offset = main_offset,
+ shadow_offset = shadow_offset,
+ show_shadow = shadow_offset ~= nil,
+ }
end
-- Generates data for container according to the given data.
local function container(entity_name, item_name, icon_name, picture_name, additional_pastable_entities, inventory_size)
- circuit_connector_definitions[entity_name] = circuit_connector_definitions.create_vector(
- universal_connector_template,
- { def_CC_table({ 0.1875, 0.15625 }, nil, 18) })
+ circuit_connector_definitions[entity_name] = circuit_connector_definitions.create_vector(
+ universal_connector_template,
+ { def_CC_table({ 0.1875, 0.15625 }, nil, 18) }
+ )
- return {
- type = "container",
- name = entity_name,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = item_name
- },
- max_health = 150,
- corpse = "small-remnants",
- fast_replaceable_group = "container",
- additional_pastable_entities = additional_pastable_entities,
- collision_box = { { -0.35, -0.35 }, { 0.35, 0.35 } },
- selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- inventory_size = inventory_size,
- open_sound = {
- filename = "__base__/sound/metallic-chest-open.ogg",
- volume = 0.65
- },
- close_sound = {
- filename = "__base__/sound/metallic-chest-close.ogg",
- volume = 0.7
- },
- picture = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. picture_name,
- priority = "extra-high",
- width = 48,
- height = 34,
- shift = { 0.1875, 0 }
- },
- circuit_wire_connection_point = {
- shadow = {
- red = { 0.734375, 0.453125 },
- green = { 0.609375, 0.515625 }
- },
- wire = {
- red = { 0.40625, 0.21875 },
- green = { 0.40625, 0.375 }
- }
- },
- circuit_wire_max_distance = 1000,
- circuit_connector_sprites = circuit_connector_definitions[entity_name].sprites,
- se_allow_in_space = true
- }
+ return {
+ type = "container",
+ name = entity_name,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = item_name,
+ },
+ max_health = 150,
+ corpse = "small-remnants",
+ fast_replaceable_group = "container",
+ additional_pastable_entities = additional_pastable_entities,
+ collision_box = { { -0.35, -0.35 }, { 0.35, 0.35 } },
+ selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ inventory_size = inventory_size,
+ open_sound = {
+ filename = "__base__/sound/metallic-chest-open.ogg",
+ volume = 0.65,
+ },
+ close_sound = {
+ filename = "__base__/sound/metallic-chest-close.ogg",
+ volume = 0.7,
+ },
+ picture = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. picture_name,
+ priority = "extra-high",
+ width = 48,
+ height = 34,
+ shift = { 0.1875, 0 },
+ },
+ circuit_wire_connection_point = {
+ shadow = {
+ red = { 0.734375, 0.453125 },
+ green = { 0.609375, 0.515625 },
+ },
+ wire = {
+ red = { 0.40625, 0.21875 },
+ green = { 0.40625, 0.375 },
+ },
+ },
+ circuit_wire_max_distance = 1000,
+ circuit_connector_sprites = circuit_connector_definitions[entity_name].sprites,
+ se_allow_in_space = true,
+ }
end
-- Generates data for infinity container according to the given data.
-local function infcontainer(entity_name, item_name, icon_name, picture_name, additional_pastable_entities, inventory_size,
- logistic_mode)
- local newchest = table.deepcopy(data.raw["infinity-container"]["infinity-chest"])
- newchest.type = "infinity-container"
- newchest.name = entity_name
- newchest.icon_size = 32
- newchest.icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name
- newchest.flags = { "placeable-player", "player-creation" }
- newchest.minable = {
- mining_time = 0.5,
- result = item_name
- }
- newchest.max_health = 150
- newchest.fast_replaceable_group = "container"
- newchest.gui_mode = "none"
- newchest.additional_pastable_entities = additional_pastable_entities
- newchest.inventory_size = inventory_size
- newchest.erase_contents_when_mined = true
- newchest.logistic_mode = logistic_mode
- newchest.max_logistic_slots = (logistic_mode == "storage" and 1) or 12
- newchest.picture = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. picture_name,
- priority = "extra-high",
- width = 38,
- height = 32,
- shift = { 0, 0 }
- }
- newchest.circuit_wire_max_distance = 1000
- newchest.localised_name = nil
- newchest.localised_description = nil
- newchest.se_allow_in_space = true
- return newchest
+local function infcontainer(
+ entity_name,
+ item_name,
+ icon_name,
+ picture_name,
+ additional_pastable_entities,
+ inventory_size,
+ logistic_mode
+)
+ local newchest = table.deepcopy(data.raw["infinity-container"]["infinity-chest"])
+ newchest.type = "infinity-container"
+ newchest.name = entity_name
+ newchest.icon_size = 32
+ newchest.icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name
+ newchest.flags = { "placeable-player", "player-creation" }
+ newchest.minable = {
+ mining_time = 0.5,
+ result = item_name,
+ }
+ newchest.max_health = 150
+ newchest.fast_replaceable_group = "container"
+ newchest.gui_mode = "none"
+ newchest.additional_pastable_entities = additional_pastable_entities
+ newchest.inventory_size = inventory_size
+ newchest.erase_contents_when_mined = true
+ newchest.logistic_mode = logistic_mode
+ newchest.max_logistic_slots = (logistic_mode == "storage" and 1) or 12
+ newchest.picture = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. picture_name,
+ priority = "extra-high",
+ width = 38,
+ height = 32,
+ shift = { 0, 0 },
+ }
+ newchest.circuit_wire_max_distance = 1000
+ newchest.localised_name = nil
+ newchest.localised_description = nil
+ newchest.se_allow_in_space = true
+ return newchest
end
-- Generates data for infinity container according to the given data.
local function infchest(entity_name, item_name, tint, additional_pastable_entities, inventory_size, logistic_mode)
- local newchest = table.deepcopy(data.raw["infinity-container"]["infinity-chest"])
- newchest.type = "infinity-container"
- newchest.name = entity_name
- newchest.icons = {
- {
- icon = "__base__/graphics/icons/infinity-chest.png",
- icon_mipmaps = 4,
- icon_size = 64,
- tint = tint
- }
- }
- newchest.flags = { "placeable-player", "player-creation" }
- newchest.minable = {
- mining_time = 0.5,
- result = item_name
- }
- newchest.max_health = 150
- newchest.fast_replaceable_group = "container"
- newchest.gui_mode = settings.startup[creative_mode_defines.names.settings.infinity_chest_control].value
- newchest.additional_pastable_entities = additional_pastable_entities
- newchest.inventory_size = inventory_size
- newchest.erase_contents_when_mined = true
- newchest.logistic_mode = logistic_mode
- newchest.max_logistic_slots = (logistic_mode == "storage" and 1) or 12
- newchest.picture = {
- layers = {
- {
- filename = "__base__/graphics/entity/infinity-chest/infinity-chest.png",
- priority = "extra-high",
- shift = util.by_pixel(0, -3),
- tint = tint,
- scale = 0.5,
- height = 84,
- width = 68
- },
- {
- draw_as_shadow = true,
- filename = "__base__/graphics/entity/infinity-chest/infinity-chest-shadow.png",
- scale = 0.5,
- priority = "extra-high",
- shift = util.by_pixel(12, 6),
- height = 48,
- width = 116
- }
- }
- }
- newchest.circuit_wire_max_distance = 1000
- newchest.se_allow_in_space = true
+ local newchest = table.deepcopy(data.raw["infinity-container"]["infinity-chest"])
+ newchest.type = "infinity-container"
+ newchest.name = entity_name
+ newchest.icons = {
+ {
+ icon = "__base__/graphics/icons/infinity-chest.png",
+ icon_mipmaps = 4,
+ icon_size = 64,
+ tint = tint,
+ },
+ }
+ newchest.flags = { "placeable-player", "player-creation" }
+ newchest.minable = {
+ mining_time = 0.5,
+ result = item_name,
+ }
+ newchest.max_health = 150
+ newchest.fast_replaceable_group = "container"
+ newchest.gui_mode = settings.startup[creative_mode_defines.names.settings.infinity_chest_control].value
+ newchest.additional_pastable_entities = additional_pastable_entities
+ newchest.inventory_size = inventory_size
+ newchest.erase_contents_when_mined = true
+ newchest.logistic_mode = logistic_mode
+ newchest.max_logistic_slots = (logistic_mode == "storage" and 1) or 12
+ newchest.picture = {
+ layers = {
+ {
+ filename = "__base__/graphics/entity/infinity-chest/infinity-chest.png",
+ priority = "extra-high",
+ shift = util.by_pixel(0, -3),
+ tint = tint,
+ scale = 0.5,
+ height = 84,
+ width = 68,
+ },
+ {
+ draw_as_shadow = true,
+ filename = "__base__/graphics/entity/infinity-chest/infinity-chest-shadow.png",
+ scale = 0.5,
+ priority = "extra-high",
+ shift = util.by_pixel(12, 6),
+ height = 48,
+ width = 116,
+ },
+ },
+ }
+ newchest.circuit_wire_max_distance = 1000
+ newchest.se_allow_in_space = true
- return newchest
+ return newchest
end
-- Generates data for logistic container according to the given data.
-local function logistic_container(entity_name, item_name, icon_name, picture_name, additional_pastable_entities,
- inventory_size, logistic_mode)
- circuit_connector_definitions[entity_name] = circuit_connector_definitions.create_vector(
- universal_connector_template,
- { def_CC_table({ 0.1875, 0.15625 }, nil, 18) })
+local function logistic_container(
+ entity_name,
+ item_name,
+ icon_name,
+ picture_name,
+ additional_pastable_entities,
+ inventory_size,
+ logistic_mode
+)
+ circuit_connector_definitions[entity_name] = circuit_connector_definitions.create_vector(
+ universal_connector_template,
+ { def_CC_table({ 0.1875, 0.15625 }, nil, 18) }
+ )
- return {
- type = "logistic-container",
- name = entity_name,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = item_name
- },
- max_health = 150,
- corpse = "small-remnants",
- fast_replaceable_group = "container",
- additional_pastable_entities = additional_pastable_entities,
- collision_box = { { -0.35, -0.35 }, { 0.35, 0.35 } },
- selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- inventory_size = inventory_size,
- logistic_mode = logistic_mode,
- max_logistic_slots = (logistic_mode == "storage" and 1) or 12,
- open_sound = {
- filename = "__base__/sound/metallic-chest-open.ogg",
- volume = 0.65
- },
- close_sound = {
- filename = "__base__/sound/metallic-chest-close.ogg",
- volume = 0.7
- },
- picture = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. picture_name,
- priority = "extra-high",
- width = 38,
- height = 32,
- shift = { 0.09375, 0 }
- },
- circuit_wire_connection_point = {
- shadow = {
- red = { 0.734375, 0.453125 },
- green = { 0.609375, 0.515625 }
- },
- wire = {
- red = { 0.40625, 0.21875 },
- green = { 0.40625, 0.375 }
- }
- },
- circuit_wire_max_distance = 1000,
- circuit_connector_sprites = circuit_connector_definitions[entity_name].sprites,
- se_allow_in_space = true
- }
+ return {
+ type = "logistic-container",
+ name = entity_name,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = item_name,
+ },
+ max_health = 150,
+ corpse = "small-remnants",
+ fast_replaceable_group = "container",
+ additional_pastable_entities = additional_pastable_entities,
+ collision_box = { { -0.35, -0.35 }, { 0.35, 0.35 } },
+ selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ inventory_size = inventory_size,
+ logistic_mode = logistic_mode,
+ max_logistic_slots = (logistic_mode == "storage" and 1) or 12,
+ open_sound = {
+ filename = "__base__/sound/metallic-chest-open.ogg",
+ volume = 0.65,
+ },
+ close_sound = {
+ filename = "__base__/sound/metallic-chest-close.ogg",
+ volume = 0.7,
+ },
+ picture = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. picture_name,
+ priority = "extra-high",
+ width = 38,
+ height = 32,
+ shift = { 0.09375, 0 },
+ },
+ circuit_wire_connection_point = {
+ shadow = {
+ red = { 0.734375, 0.453125 },
+ green = { 0.609375, 0.515625 },
+ },
+ wire = {
+ red = { 0.40625, 0.21875 },
+ green = { 0.40625, 0.375 },
+ },
+ },
+ circuit_wire_max_distance = 1000,
+ circuit_connector_sprites = circuit_connector_definitions[entity_name].sprites,
+ se_allow_in_space = true,
+ }
end
-- Makes a new linked chest
local function linkedchest(entity_name, item_name, inventory_size)
- --We make minimal changes to this, we just want it to be our own entity in case anything messes with the vanilla one.
- local newchest = table.deepcopy(data.raw["linked-container"]["linked-chest"])
- newchest.type = "linked-container"
- newchest.name = entity_name
- newchest.flags = { "placeable-player", "player-creation" }
- newchest.minable = {
- mining_time = 0.5,
- result = item_name
- }
- newchest.max_health = 150
- newchest.fast_replaceable_group = "container"
- newchest.gui_mode = "admins"
- newchest.additional_pastable_entities = additional_pastable_entities
- if inventory_size then
- newchest.inventory_size = inventory_size
- end
- newchest.erase_contents_when_mined = true
- newchest.circuit_wire_max_distance = 1000
- newchest.localised_name = { "entity-name.linked-chest" }
- newchest.se_allow_in_space = true
- return newchest
+ --We make minimal changes to this, we just want it to be our own entity in case anything messes with the vanilla one.
+ local newchest = table.deepcopy(data.raw["linked-container"]["linked-chest"])
+ newchest.type = "linked-container"
+ newchest.name = entity_name
+ newchest.flags = { "placeable-player", "player-creation" }
+ newchest.minable = {
+ mining_time = 0.5,
+ result = item_name,
+ }
+ newchest.max_health = 150
+ newchest.fast_replaceable_group = "container"
+ newchest.gui_mode = "admins"
+ newchest.additional_pastable_entities = additional_pastable_entities
+ if inventory_size then
+ newchest.inventory_size = inventory_size
+ end
+ newchest.erase_contents_when_mined = true
+ newchest.circuit_wire_max_distance = 1000
+ newchest.localised_name = { "entity-name.linked-chest" }
+ newchest.se_allow_in_space = true
+ return newchest
end
-- Makes a new linked belt
local function linkedbelt(entity_name, item_name)
- local newbelt = table.deepcopy(data.raw["linked-belt"]["linked-belt"])
- newbelt.type = "linked-belt"
- newbelt.name = entity_name
- newbelt.flags = { "placeable-player", "player-creation" }
- newbelt.minable = {
- mining_time = 0.5,
- result = item_name
- }
- newbelt.max_health = 150
- newbelt.fast_replaceable_group = "container"
- newbelt.gui_mode = "admins"
- newbelt.additional_pastable_entities = additional_pastable_entities
- newbelt.circuit_wire_max_distance = 1000
- newbelt.localised_name = { "entity-name.linked-belt" }
- newbelt.allow_copy_paste = true
- newbelt.additional_pastable_entities = { entity_name }
- newbelt.speed = 1
- newbelt.se_allow_in_space = true
+ local newbelt = table.deepcopy(data.raw["linked-belt"]["linked-belt"])
+ newbelt.type = "linked-belt"
+ newbelt.name = entity_name
+ newbelt.flags = { "placeable-player", "player-creation" }
+ newbelt.minable = {
+ mining_time = 0.5,
+ result = item_name,
+ }
+ newbelt.max_health = 150
+ newbelt.fast_replaceable_group = "container"
+ newbelt.gui_mode = "admins"
+ newbelt.additional_pastable_entities = additional_pastable_entities
+ newbelt.circuit_wire_max_distance = 1000
+ newbelt.localised_name = { "entity-name.linked-belt" }
+ newbelt.allow_copy_paste = true
+ newbelt.additional_pastable_entities = { entity_name }
+ newbelt.speed = 1
+ newbelt.se_allow_in_space = true
- return newbelt
+ return newbelt
end
local drive_over_tie = function()
- return
- {
- type = "play-sound",
- sound = sound_variations("__base__/sound/train-tie", 6, 0.4,
- { volume_multiplier("main-menu", 2.4), volume_multiplier("driving", 1.3) })
- }
+ return {
+ type = "play-sound",
+ sound = sound_variations(
+ "__base__/sound/train-tie",
+ 6,
+ 0.4,
+ { volume_multiplier("main-menu", 2.4), volume_multiplier("driving", 1.3) }
+ ),
+ }
end
local rolling_stock_back_light = function()
- return
+ return {
{
- {
- minimum_darkness = 0.3,
- color = { 1, 0.1, 0.05, 0 },
- shift = { -0.6, 3.5 },
- size = 2,
- intensity = 0.6,
- add_perspective = true
- },
- {
- minimum_darkness = 0.3,
- color = { 1, 0.1, 0.05, 0 },
- shift = { 0.6, 3.5 },
- size = 2,
- intensity = 0.6,
- add_perspective = true
- }
- }
+ minimum_darkness = 0.3,
+ color = { 1, 0.1, 0.05, 0 },
+ shift = { -0.6, 3.5 },
+ size = 2,
+ intensity = 0.6,
+ add_perspective = true,
+ },
+ {
+ minimum_darkness = 0.3,
+ color = { 1, 0.1, 0.05, 0 },
+ shift = { 0.6, 3.5 },
+ size = 2,
+ intensity = 0.6,
+ add_perspective = true,
+ },
+ }
end
local rolling_stock_stand_by_light = function()
- return
+ return {
{
- {
- minimum_darkness = 0.3,
- color = { 0.05, 0.2, 1, 0 },
- shift = { -0.6, -3.5 },
- size = 2,
- intensity = 0.5,
- add_perspective = true
- },
- {
- minimum_darkness = 0.3,
- color = { 0.05, 0.2, 1, 0 },
- shift = { 0.6, -3.5 },
- size = 2,
- intensity = 0.5,
- add_perspective = true
- }
- }
+ minimum_darkness = 0.3,
+ color = { 0.05, 0.2, 1, 0 },
+ shift = { -0.6, -3.5 },
+ size = 2,
+ intensity = 0.5,
+ add_perspective = true,
+ },
+ {
+ minimum_darkness = 0.3,
+ color = { 0.05, 0.2, 1, 0 },
+ shift = { 0.6, -3.5 },
+ size = 2,
+ intensity = 0.5,
+ add_perspective = true,
+ },
+ }
end
-- Generates data for cargo wagon according to the given data.
local function cargo_wagon(entity_name, item_name, tint, additional_pastable_entities, inventory_size)
- return {
- type = "cargo-wagon",
- name = entity_name,
- icon_size = 64,
- icons = { {
- icon = "__base__/graphics/icons/cargo-wagon.png",
- tint = tint
- } },
- flags = { "player-creation", "placeable-off-grid", "not-on-map" },
- additional_pastable_entities = additional_pastable_entities,
- inventory_size = inventory_size,
- minable = {
- mining_time = 1,
- result = item_name
- },
- mined_sound = {
- filename = "__core__/sound/deconstruct-medium.ogg"
- },
- max_health = 600,
- corpse = "medium-remnants",
- dying_explosion = "medium-explosion",
- collision_box = { { -0.6, -2.4 }, { 0.6, 2.4 } },
- selection_box = { { -1, -2.703125 }, { 1, 3.296875 } },
- vertical_selection_shift = -0.796875,
- weight = 1000,
- max_speed = 1.5,
- braking_force = 3,
- friction_force = 0.50,
- air_resistance = 0.01,
- connection_distance = 3,
- joint_distance = 4,
- energy_per_hit_point = 5,
- resistances = { {
- type = "fire",
- decrease = 15,
- percent = 50
- }, {
- type = "physical",
- decrease = 15,
- percent = 30
- }, {
- type = "impact",
- decrease = 50,
- percent = 60
- }, {
- type = "explosion",
- decrease = 15,
- percent = 30
- }, {
- type = "acid",
- decrease = 10,
- percent = 20
- } },
- back_light = rolling_stock_back_light(),
- stand_by_light = rolling_stock_stand_by_light(),
- color = {
- r = 0.43,
- g = 0.23,
- b = 0,
- a = 0.5
- },
- pictures = {
- rotated =
- {
- layers =
- {
- util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon",
- {
- dice = 4,
- priority = "very-low",
- allow_low_quality_rotation = true,
- back_equals_front = true,
- direction_count = 128,
- tint = tint,
- scale = 0.5
- }
- ),
- util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-mask",
- {
- dice = 4,
- priority = "very-low",
- allow_low_quality_rotation = true,
- back_equals_front = true,
- flags = { "mask" },
- apply_runtime_tint = true,
- tint_as_overlay = true,
- direction_count = 128,
- scale = 0.5
- }
- ),
- util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-shadow",
- {
- dice = 4,
- priority = "very-low",
- allow_low_quality_rotation = true,
- back_equals_front = true,
- draw_as_shadow = true,
- direction_count = 128,
- scale = 0.5
- }
- )
- }
- }
- },
- horizontal_doors =
- {
- layers =
- {
- util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-door-horizontal",
- {
- frame_count = 8,
- tint = tint,
- scale = 0.5
- }
- ),
- util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-door-horizontal-mask",
- {
- apply_runtime_tint = true,
- tint_as_overlay = true,
- flags = { "mask" },
- frame_count = 8,
- scale = 0.5
- }
- )
- }
- },
- vertical_doors =
- {
- layers =
- {
- util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-door-vertical",
- {
- frame_count = 8,
- tint = tint,
- scale = 0.5
- }
- ),
- util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-door-vertical-mask",
- {
- apply_runtime_tint = true,
- tint_as_overlay = true,
- flags = { "mask" },
- frame_count = 8,
- scale = 0.5
- }
- )
- }
- },
- wheels = standard_train_wheels,
- rail_category = "regular",
- drive_over_tie_trigger = drive_over_tie(),
- tie_distance = 50,
- working_sound = {
- sound = {
- filename = "__base__/sound/train-wheels.ogg",
- volume = 0.6
- },
- match_volume_to_activity = true
- },
- crash_trigger = crash_trigger(),
- open_sound = {
- filename = "__base__/sound/machine-open.ogg",
- volume = 0.85
- },
- close_sound = {
- filename = "__base__/sound/machine-close.ogg",
- volume = 0.75
- },
- sound_minimum_speed = 0.5,
- vehicle_impact_sound = {
- filename = "__base__/sound/car-wood-impact.ogg",
- volume = 1.0
+ return {
+ type = "cargo-wagon",
+ name = entity_name,
+ icon_size = 64,
+ icons = { {
+ icon = "__base__/graphics/icons/cargo-wagon.png",
+ tint = tint,
+ } },
+ flags = { "player-creation", "placeable-off-grid", "not-on-map" },
+ additional_pastable_entities = additional_pastable_entities,
+ inventory_size = inventory_size,
+ minable = {
+ mining_time = 1,
+ result = item_name,
+ },
+ mined_sound = {
+ filename = "__core__/sound/deconstruct-medium.ogg",
+ },
+ max_health = 600,
+ corpse = "medium-remnants",
+ dying_explosion = "medium-explosion",
+ collision_box = { { -0.6, -2.4 }, { 0.6, 2.4 } },
+ selection_box = { { -1, -2.703125 }, { 1, 3.296875 } },
+ vertical_selection_shift = -0.796875,
+ weight = 1000,
+ max_speed = 1.5,
+ braking_force = 3,
+ friction_force = 0.50,
+ air_resistance = 0.01,
+ connection_distance = 3,
+ joint_distance = 4,
+ energy_per_hit_point = 5,
+ resistances = {
+ {
+ type = "fire",
+ decrease = 15,
+ percent = 50,
+ },
+ {
+ type = "physical",
+ decrease = 15,
+ percent = 30,
+ },
+ {
+ type = "impact",
+ decrease = 50,
+ percent = 60,
+ },
+ {
+ type = "explosion",
+ decrease = 15,
+ percent = 30,
+ },
+ {
+ type = "acid",
+ decrease = 10,
+ percent = 20,
+ },
+ },
+ back_light = rolling_stock_back_light(),
+ stand_by_light = rolling_stock_stand_by_light(),
+ color = {
+ r = 0.43,
+ g = 0.23,
+ b = 0,
+ a = 0.5,
+ },
+ pictures = {
+ rotated = {
+ layers = {
+ util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon", {
+ dice = 4,
+ priority = "very-low",
+ allow_low_quality_rotation = true,
+ back_equals_front = true,
+ direction_count = 128,
+ tint = tint,
+ scale = 0.5,
+ }),
+ util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-mask", {
+ dice = 4,
+ priority = "very-low",
+ allow_low_quality_rotation = true,
+ back_equals_front = true,
+ flags = { "mask" },
+ apply_runtime_tint = true,
+ tint_as_overlay = true,
+ direction_count = 128,
+ scale = 0.5,
+ }),
+ util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-shadow", {
+ dice = 4,
+ priority = "very-low",
+ allow_low_quality_rotation = true,
+ back_equals_front = true,
+ draw_as_shadow = true,
+ direction_count = 128,
+ scale = 0.5,
+ }),
},
- se_allow_in_space = true
- }
+ },
+ },
+ horizontal_doors = {
+ layers = {
+ util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-door-horizontal", {
+ frame_count = 8,
+ tint = tint,
+ scale = 0.5,
+ }),
+ util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-door-horizontal-mask", {
+ apply_runtime_tint = true,
+ tint_as_overlay = true,
+ flags = { "mask" },
+ frame_count = 8,
+ scale = 0.5,
+ }),
+ },
+ },
+ vertical_doors = {
+ layers = {
+ util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-door-vertical", {
+ frame_count = 8,
+ tint = tint,
+ scale = 0.5,
+ }),
+ util.sprite_load("__base__/graphics/entity/cargo-wagon/cargo-wagon-door-vertical-mask", {
+ apply_runtime_tint = true,
+ tint_as_overlay = true,
+ flags = { "mask" },
+ frame_count = 8,
+ scale = 0.5,
+ }),
+ },
+ },
+ wheels = standard_train_wheels,
+ rail_category = "regular",
+ drive_over_tie_trigger = drive_over_tie(),
+ tie_distance = 50,
+ working_sound = {
+ sound = {
+ filename = "__base__/sound/train-wheels.ogg",
+ volume = 0.6,
+ },
+ match_volume_to_activity = true,
+ },
+ crash_trigger = crash_trigger(),
+ open_sound = {
+ filename = "__base__/sound/machine-open.ogg",
+ volume = 0.85,
+ },
+ close_sound = {
+ filename = "__base__/sound/machine-close.ogg",
+ volume = 0.75,
+ },
+ sound_minimum_speed = 0.5,
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-wood-impact.ogg",
+ volume = 1.0,
+ },
+ se_allow_in_space = true,
+ }
end
-- Returns the charging offsets for the super roboport.
local function get_super_roboport_charging_offsets()
- local charging_offsets = {}
- for i = -1.5, 1.5, 0.2 do
- table.insert(charging_offsets, { i, -0.5 })
- end
- for i = -0.5, 1.5, 0.2 do
- table.insert(charging_offsets, { 1.5, i })
- end
- for i = 1.5, -1.5, -0.2 do
- table.insert(charging_offsets, { i, 1.5 })
- end
- for i = 1.5, -0.5, -0.2 do
- table.insert(charging_offsets, { -1.5, i })
- end
- return charging_offsets
+ local charging_offsets = {}
+ for i = -1.5, 1.5, 0.2 do
+ table.insert(charging_offsets, { i, -0.5 })
+ end
+ for i = -0.5, 1.5, 0.2 do
+ table.insert(charging_offsets, { 1.5, i })
+ end
+ for i = 1.5, -1.5, -0.2 do
+ table.insert(charging_offsets, { i, 1.5 })
+ end
+ for i = 1.5, -0.5, -0.2 do
+ table.insert(charging_offsets, { -1.5, i })
+ end
+ return charging_offsets
end
-- Generates data for super boiler according to the given data.
local function super_boiler(entity_name, item_name, icon_name, picture_name, additional_pastable_entities)
- circuit_connector_definitions[entity_name] = circuit_connector_definitions.create_vector(
- universal_connector_template,
- { def_CC_table({ -0.1875, -0.375 }, nil, 7),
- def_CC_table({ 0.375, -0.53125 }, nil, 1),
- def_CC_table({ -0.1875, -0.375 }, nil, 7),
- def_CC_table({ 0.375, -0.53125 }, nil, 1) })
+ circuit_connector_definitions[entity_name] =
+ circuit_connector_definitions.create_vector(universal_connector_template, {
+ def_CC_table({ -0.1875, -0.375 }, nil, 7),
+ def_CC_table({ 0.375, -0.53125 }, nil, 1),
+ def_CC_table({ -0.1875, -0.375 }, nil, 7),
+ def_CC_table({ 0.375, -0.53125 }, nil, 1),
+ })
- return {
- type = "storage-tank",
- name = entity_name,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = item_name
+ return {
+ type = "storage-tank",
+ name = entity_name,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = item_name,
+ },
+ additional_pastable_entities = additional_pastable_entities,
+ max_health = 100,
+ corpse = "small-remnants",
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ resistances = {
+ {
+ type = "fire",
+ percent = 90,
+ },
+ {
+ type = "explosion",
+ percent = 30,
+ },
+ {
+ type = "impact",
+ percent = 30,
+ },
+ },
+ fast_replaceable_group = "pipe",
+ collision_box = { { -0.29, -0.29 }, { 0.29, 0.29 } },
+ selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
+ fluid_box = {
+ volume = 200,
+ base_area = 1,
+ pipe_covers = pipecoverspictures(),
+ pipe_connections = {
+ {
+ direction = defines.direction.south,
+ position = { 0, 0.289 },
},
- additional_pastable_entities = additional_pastable_entities,
- max_health = 100,
- corpse = "small-remnants",
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
+ {
+ direction = defines.direction.north,
+ position = { 0, -0.289 },
},
- resistances = { {
- type = "fire",
- percent = 90
- }, {
- type = "explosion",
- percent = 30
- }, {
- type = "impact",
- percent = 30
- } },
- fast_replaceable_group = "pipe",
- collision_box = { { -0.29, -0.29 }, { 0.29, 0.29 } },
- selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
- fluid_box = {
- volume = 200,
- base_area = 1,
- pipe_covers = pipecoverspictures(),
- pipe_connections = { {
- direction = defines.direction.south,
- position = { 0, 0.289 }
- }, {
- direction = defines.direction.north,
- position = { 0, -0.289 }
- } },
- production_type = "input-output"
+ },
+ production_type = "input-output",
+ },
+ two_direction_only = false,
+ window_bounding_box = { { 0, 0 }, { 0, 0 } },
+ working_sound = {
+ sound = {
+ filename = "__base__/sound/boiler.ogg",
+ volume = 0.8,
+ },
+ max_sounds_per_type = 3,
+ },
+ pictures = {
+ picture = {
+ sheet = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. picture_name,
+ priority = "extra-high",
+ frames = 4,
+ width = 66,
+ height = 72,
},
- two_direction_only = false,
- window_bounding_box = { { 0, 0 }, { 0, 0 } },
- working_sound = {
- sound = {
- filename = "__base__/sound/boiler.ogg",
- volume = 0.8
- },
- max_sounds_per_type = 3
+ },
+ fluid_background = creative_mode_defines.empty_png.data,
+ window_background = creative_mode_defines.empty_png.data,
+ flow_sprite = creative_mode_defines.empty_png.data,
+ gas_flow = creative_mode_defines.empty_animation,
+ },
+ flow_length_in_ticks = 360,
+ circuit_wire_connection_points = {
+ {
+ shadow = {
+ red = { 2.35938, 0.890625 },
+ green = { 2.29688, 0.953125 },
},
- pictures = {
- picture = {
- sheet = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. picture_name,
- priority = "extra-high",
- frames = 4,
- width = 66,
- height = 72
- }
- },
- fluid_background = creative_mode_defines.empty_png.data,
- window_background = creative_mode_defines.empty_png.data,
- flow_sprite = creative_mode_defines.empty_png.data,
- gas_flow = creative_mode_defines.empty_animation
+ wire = {
+ red = { -0.40625, -0.375 },
+ green = { -0.53125, -0.46875 },
},
- flow_length_in_ticks = 360,
- circuit_wire_connection_points = { {
- shadow = {
- red = { 2.35938, 0.890625 },
- green = { 2.29688, 0.953125 }
- },
- wire = {
- red = { -0.40625, -0.375 },
- green = { -0.53125, -0.46875 }
- }
- }, {
- shadow = {
- red = { 2.35938, 0.890625 },
- green = { 2.29688, 0.953125 }
- },
- wire = {
- red = { 0.46875, -0.53125 },
- green = { 0.375, -0.4375 }
- }
- }, {
- shadow = {
- red = { 2.35938, 0.890625 },
- green = { 2.29688, 0.953125 }
- },
- wire = {
- red = { -0.40625, -0.375 },
- green = { -0.53125, -0.46875 }
- }
- }, {
- shadow = {
- red = { 2.35938, 0.890625 },
- green = { 2.29688, 0.953125 }
- },
- wire = {
- red = { 0.46875, -0.53125 },
- green = { 0.375, -0.4375 }
- }
- } },
- circuit_connector_sprites = circuit_connector_definitions[entity_name].sprites,
- circuit_wire_max_distance = 1000,
- se_allow_in_space = true
- }
+ },
+ {
+ shadow = {
+ red = { 2.35938, 0.890625 },
+ green = { 2.29688, 0.953125 },
+ },
+ wire = {
+ red = { 0.46875, -0.53125 },
+ green = { 0.375, -0.4375 },
+ },
+ },
+ {
+ shadow = {
+ red = { 2.35938, 0.890625 },
+ green = { 2.29688, 0.953125 },
+ },
+ wire = {
+ red = { -0.40625, -0.375 },
+ green = { -0.53125, -0.46875 },
+ },
+ },
+ {
+ shadow = {
+ red = { 2.35938, 0.890625 },
+ green = { 2.29688, 0.953125 },
+ },
+ wire = {
+ red = { 0.46875, -0.53125 },
+ green = { 0.375, -0.4375 },
+ },
+ },
+ },
+ circuit_connector_sprites = circuit_connector_definitions[entity_name].sprites,
+ circuit_wire_max_distance = 1000,
+ se_allow_in_space = true,
+ }
end
-- Generates data for heat pipe according to the given data.
local function heat_pipe(entity_name, item_name, tint, use_heated_pictures, max_temperature)
- local heat_pipe = table.deepcopy(data.raw["heat-interface"]["heat-interface"])
- heat_pipe.name = entity_name
- heat_pipe.icon_size = 64
- heat_pipe.icons = { {
- icon = heat_pipe.icon,
- tint = tint
- } }
- heat_pipe.icon = nil
- heat_pipe.flags = { "placeable-player", "player-creation" }
- heat_pipe.minable = {
- mining_time = 0.5,
- result = item_name
- }
- heat_pipe.heat_buffer.max_temperature = max_temperature
- heat_pipe.picture = { layers = {} } -- We want a picture with an empty layers so we can add the pipe graphics instead of the bland heat interface one.
- if use_heated_pictures then -- This is a heat source, use the hot pipe pictures.
- heat_pipe.picture = table.deepcopy(data.raw["heat-pipe"]["heat-pipe"].heat_glow_sprites.cross[1])
- for _, layer in ipairs(heat_pipe.picture.layers) do
- layer.tint = table.deepcopy(tint)
- end
+ local heat_pipe = table.deepcopy(data.raw["heat-interface"]["heat-interface"])
+ heat_pipe.name = entity_name
+ heat_pipe.icon_size = 64
+ heat_pipe.icons = { {
+ icon = heat_pipe.icon,
+ tint = tint,
+ } }
+ heat_pipe.icon = nil
+ heat_pipe.flags = { "placeable-player", "player-creation" }
+ heat_pipe.minable = {
+ mining_time = 0.5,
+ result = item_name,
+ }
+ heat_pipe.heat_buffer.max_temperature = max_temperature
+ heat_pipe.picture = { layers = {} } -- We want a picture with an empty layers so we can add the pipe graphics instead of the bland heat interface one.
+ if use_heated_pictures then -- This is a heat source, use the hot pipe pictures.
+ heat_pipe.picture = table.deepcopy(data.raw["heat-pipe"]["heat-pipe"].heat_glow_sprites.cross[1])
+ for _, layer in ipairs(heat_pipe.picture.layers) do
+ layer.tint = table.deepcopy(tint)
end
- -- Always use the basic four way picture - tint it and insert it into the layers
- regpipe = table.deepcopy(data.raw["heat-pipe"]["heat-pipe"].connection_sprites.cross[1])
- regpipe.tint = table.deepcopy(tint)
- table.insert(heat_pipe.picture.layers, regpipe)
- --log(serpent.block(heat_pipe.picture))
- heat_pipe.fast_replaceable_group = heat_pipe.fast_replaceable_group or
- creative_mode_defines.names.fast_replaceable_groups.heat_source_void
- heat_pipe.gui_mode = "none"
- heat_pipe.type = "heat-interface"
- heat_pipe.se_allow_in_space = true
- return heat_pipe
+ end
+ -- Always use the basic four way picture - tint it and insert it into the layers
+ regpipe = table.deepcopy(data.raw["heat-pipe"]["heat-pipe"].connection_sprites.cross[1])
+ regpipe.tint = table.deepcopy(tint)
+ table.insert(heat_pipe.picture.layers, regpipe)
+ --log(serpent.block(heat_pipe.picture))
+ heat_pipe.fast_replaceable_group = heat_pipe.fast_replaceable_group
+ or creative_mode_defines.names.fast_replaceable_groups.heat_source_void
+ heat_pipe.gui_mode = "none"
+ heat_pipe.type = "heat-interface"
+ heat_pipe.se_allow_in_space = true
+ return heat_pipe
end
-- Generates data for inserter according to the given data.
-local function inserter(entity_name, item_name, icon_name, platform_sheet_name, additional_pastable_entities,
- fast_replaceable_group, pickup_position, insert_position, filter_count)
- -- circuit_connector_definitions[entity_name] = circuit_connector_definitions.create_vector
- -- (
- -- universal_connector_template,
- -- {
- -- def_CC_table({0, -0.125}, nil, 6),
- -- }
- -- )
+local function inserter(
+ entity_name,
+ item_name,
+ icon_name,
+ platform_sheet_name,
+ additional_pastable_entities,
+ fast_replaceable_group,
+ pickup_position,
+ insert_position,
+ filter_count
+)
+ -- circuit_connector_definitions[entity_name] = circuit_connector_definitions.create_vector
+ -- (
+ -- universal_connector_template,
+ -- {
+ -- def_CC_table({0, -0.125}, nil, 6),
+ -- }
+ -- )
- return {
- type = "inserter",
- name = entity_name,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = item_name
- },
- max_health = 150,
- corpse = "small-remnants",
- additional_pastable_entities = additional_pastable_entities,
- fast_replaceable_group = fast_replaceable_group,
- collision_box = { { -0.35, -0.35 }, { 0.35, 0.35 } },
- selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
- open_sound = {
- filename = "__base__/sound/metallic-chest-open.ogg",
- volume = 0.65
- },
- close_sound = {
- filename = "__base__/sound/metallic-chest-close.ogg",
- volume = 0.7
- },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- energy_per_movement = "1J",
- energy_per_rotation = "1J",
- energy_source = creative_mode_defines.non_electric_energy_source,
- pickup_position = pickup_position,
- insert_position = insert_position,
- extension_speed = 0,
- rotation_speed = 0,
- filter_count = filter_count,
- platform_picture = {
- sheet = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. platform_sheet_name,
- priority = "extra-high",
- width = 79,
- height = 63,
- shift = { 0.140625, 0.140625 }
- }
- },
- hand_base_picture = creative_mode_defines.empty_png.data,
- hand_closed_picture = creative_mode_defines.empty_png.data,
- hand_open_picture = creative_mode_defines.empty_png.data,
- hand_base_shadow = creative_mode_defines.empty_png.data,
- hand_closed_shadow = creative_mode_defines.empty_png.data,
- hand_open_shadow = creative_mode_defines.empty_png.data,
- circuit_wire_connection_point = {
- shadow = {
- red = { 0.890625, 0.390625 },
- green = { 0.890625, 0.265625 }
- },
- wire = {
- red = { -0.28125, -0.25 },
- green = { -0.28125, -0.375 }
- }
- },
- circuit_connector_sprites = circuit_connector_definitions["inserter"].sprites,
- circuit_wire_max_distance = 1000,
- se_allow_in_space = true
- }
+ return {
+ type = "inserter",
+ name = entity_name,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = item_name,
+ },
+ max_health = 150,
+ corpse = "small-remnants",
+ additional_pastable_entities = additional_pastable_entities,
+ fast_replaceable_group = fast_replaceable_group,
+ collision_box = { { -0.35, -0.35 }, { 0.35, 0.35 } },
+ selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
+ open_sound = {
+ filename = "__base__/sound/metallic-chest-open.ogg",
+ volume = 0.65,
+ },
+ close_sound = {
+ filename = "__base__/sound/metallic-chest-close.ogg",
+ volume = 0.7,
+ },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ energy_per_movement = "1J",
+ energy_per_rotation = "1J",
+ energy_source = creative_mode_defines.non_electric_energy_source,
+ pickup_position = pickup_position,
+ insert_position = insert_position,
+ extension_speed = 0,
+ rotation_speed = 0,
+ filter_count = filter_count,
+ platform_picture = {
+ sheet = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. platform_sheet_name,
+ priority = "extra-high",
+ width = 79,
+ height = 63,
+ shift = { 0.140625, 0.140625 },
+ },
+ },
+ hand_base_picture = creative_mode_defines.empty_png.data,
+ hand_closed_picture = creative_mode_defines.empty_png.data,
+ hand_open_picture = creative_mode_defines.empty_png.data,
+ hand_base_shadow = creative_mode_defines.empty_png.data,
+ hand_closed_shadow = creative_mode_defines.empty_png.data,
+ hand_open_shadow = creative_mode_defines.empty_png.data,
+ circuit_wire_connection_point = {
+ shadow = {
+ red = { 0.890625, 0.390625 },
+ green = { 0.890625, 0.265625 },
+ },
+ wire = {
+ red = { -0.28125, -0.25 },
+ green = { -0.28125, -0.375 },
+ },
+ },
+ circuit_connector_sprites = circuit_connector_definitions["inserter"].sprites,
+ circuit_wire_max_distance = 1000,
+ se_allow_in_space = true,
+ }
end
-- Generates data for lab.
local function lab(entity_name, item_name, icon_name, on_animation_filename, off_animation_filename)
- local lab = table.deepcopy(data.raw["lab"]["lab"])
- lab.name = entity_name
- lab.next_upgrade = ""
- lab.icon_size = 32
- lab.icon_mipmaps = 1
- lab.icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name
- lab.minable = {
- mining_time = 0.5,
- result = item_name
- }
- lab.on_animation.filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. on_animation_filename
- lab.off_animation.filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. off_animation_filename
- lab.energy_source = creative_mode_defines.non_electric_energy_source
- lab.module_slots = 7
- lab.se_allow_in_space = true
- return lab
+ local lab = table.deepcopy(data.raw["lab"]["lab"])
+ lab.name = entity_name
+ lab.next_upgrade = ""
+ lab.icon_size = 32
+ lab.icon_mipmaps = 1
+ lab.icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name
+ lab.minable = {
+ mining_time = 0.5,
+ result = item_name,
+ }
+ lab.on_animation.filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. on_animation_filename
+ lab.off_animation.filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. off_animation_filename
+ lab.energy_source = creative_mode_defines.non_electric_energy_source
+ lab.module_slots = 7
+ lab.se_allow_in_space = true
+ return lab
end
local function void_lab()
- local lab = table.deepcopy(data.raw["lab"]["lab"])
- lab.name = creative_mode_defines.names.entities.void_lab
- lab.icons = { {
- icon = "__base__/graphics/icons/lab.png",
- icon_size = 64,
- tint = {
- r = 50,
- g = 50,
- b = 50
- }
- } }
- lab.on_animation.layers[1].tint = {
- r = 50,
- g = 50,
- b = 50
- }
- lab.off_animation.layers[1].tint = {
+ local lab = table.deepcopy(data.raw["lab"]["lab"])
+ lab.name = creative_mode_defines.names.entities.void_lab
+ lab.icons = {
+ {
+ icon = "__base__/graphics/icons/lab.png",
+ icon_size = 64,
+ tint = {
r = 50,
g = 50,
- b = 50
- }
+ b = 50,
+ },
+ },
+ }
+ lab.on_animation.layers[1].tint = {
+ r = 50,
+ g = 50,
+ b = 50,
+ }
+ lab.off_animation.layers[1].tint = {
+ r = 50,
+ g = 50,
+ b = 50,
+ }
- lab.se_allow_in_space = true
- return lab
+ lab.se_allow_in_space = true
+ return lab
end
-- Generates data for electric energy interface.
-local function electric_energy_interface(entity_name, item_name, icon_name, animation_filename, usage_priority,
- default_input_flow, default_output_flow, default_production, default_usage,
- additional_pastable_entities)
- return {
- type = "electric-energy-interface",
- name = entity_name,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = item_name
- },
- max_health = 200,
- corpse = "big-remnants",
- collision_box = { { -1.2, -1.2 }, { 1.2, 1.2 } },
- selection_box = { { -1.5, -1.5 }, { 1.5, 1.5 } },
- enable_gui = true,
- allow_copy_paste = true,
- energy_source = {
- type = "electric",
- buffer_capacity = "10GJ",
- usage_priority = usage_priority,
- input_flow_limit = default_input_flow,
- output_flow_limit = default_output_flow
- },
- energy_production = default_production,
- energy_usage = default_usage,
- animation = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. animation_filename,
- width = 176,
- height = 186,
- frame_count = 32,
- line_length = 6,
- shift = { 1.2, 0.5 },
- animation_speed = 1 / 3
- },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- working_sound = {
- sound = {
- filename = "__base__/sound/accumulator-working.ogg",
- volume = 1
- },
- idle_sound = {
- filename = "__base__/sound/accumulator-idle.ogg",
- volume = 0.4
- },
- max_sounds_per_type = 5
- },
- additional_pastable_entities = additional_pastable_entities,
- fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.electric_energy_interface,
- se_allow_in_space = true
- }
+local function electric_energy_interface(
+ entity_name,
+ item_name,
+ icon_name,
+ animation_filename,
+ usage_priority,
+ default_input_flow,
+ default_output_flow,
+ default_production,
+ default_usage,
+ additional_pastable_entities
+)
+ return {
+ type = "electric-energy-interface",
+ name = entity_name,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = item_name,
+ },
+ max_health = 200,
+ corpse = "big-remnants",
+ collision_box = { { -1.2, -1.2 }, { 1.2, 1.2 } },
+ selection_box = { { -1.5, -1.5 }, { 1.5, 1.5 } },
+ enable_gui = true,
+ allow_copy_paste = true,
+ energy_source = {
+ type = "electric",
+ buffer_capacity = "10GJ",
+ usage_priority = usage_priority,
+ input_flow_limit = default_input_flow,
+ output_flow_limit = default_output_flow,
+ },
+ energy_production = default_production,
+ energy_usage = default_usage,
+ animation = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. animation_filename,
+ width = 176,
+ height = 186,
+ frame_count = 32,
+ line_length = 6,
+ shift = { 1.2, 0.5 },
+ animation_speed = 1 / 3,
+ },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ working_sound = {
+ sound = {
+ filename = "__base__/sound/accumulator-working.ogg",
+ volume = 1,
+ },
+ idle_sound = {
+ filename = "__base__/sound/accumulator-idle.ogg",
+ volume = 0.4,
+ },
+ max_sounds_per_type = 5,
+ },
+ additional_pastable_entities = additional_pastable_entities,
+ fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.electric_energy_interface,
+ se_allow_in_space = true,
+ }
end
-- Generates data for the smoke of magic wands.
local function magic_wand_smoke(entity_name, color)
- return {
- affected_by_wind = false,
- animation = {
- animation_speed = 60 / 40,
- axially_symmetrical = false,
- direction_count = 1,
- filename = "__base__/graphics/entity/smoke/smoke.png",
- flags = { "smoke" },
- frame_count = 60,
- height = 120,
- line_length = 5,
- priority = "high",
- shift = { -0.53125, -0.4375 },
- width = 152
- },
- color = color,
- cyclic = true,
- duration = 40,
- end_scale = 3.0,
- fade_away_duration = 40,
- fade_in_duration = 0,
- flags = { "not-on-map" },
- name = entity_name,
- spread_duration = 40,
- start_scale = 0.5,
- type = "trivial-smoke"
- }
+ return {
+ affected_by_wind = false,
+ animation = {
+ animation_speed = 60 / 40,
+ axially_symmetrical = false,
+ direction_count = 1,
+ filename = "__base__/graphics/entity/smoke/smoke.png",
+ flags = { "smoke" },
+ frame_count = 60,
+ height = 120,
+ line_length = 5,
+ priority = "high",
+ shift = { -0.53125, -0.4375 },
+ width = 152,
+ },
+ color = color,
+ cyclic = true,
+ duration = 40,
+ end_scale = 3.0,
+ fade_away_duration = 40,
+ fade_in_duration = 0,
+ flags = { "not-on-map" },
+ name = entity_name,
+ spread_duration = 40,
+ start_scale = 0.5,
+ type = "trivial-smoke",
+ }
end
-- Generates data for radar.
local function radar(entity_name, item_name, icon_name, pictures_name, scan_distance)
- return {
- type = "radar",
- name = entity_name,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = item_name
- },
- max_health = 150,
- corpse = "big-remnants",
- resistances = { {
- type = "fire",
- percent = 70
- } },
- collision_box = { { -1.4, -1.4 }, { 1.4, 1.4 } },
- selection_box = { { -1.5, -1.5 }, { 1.5, 1.5 } },
- energy_per_sector = "1MJ", -- Make the frequency of scanning each sector to be very low.
- max_distance_of_sector_revealed = scan_distance, -- Scan area
- max_distance_of_nearby_sector_revealed = scan_distance, -- Always revealed area
- energy_per_nearby_scan = "1kJ",
- energy_source = creative_mode_defines.non_electric_energy_source,
- energy_usage = "1kW",
- pictures = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. pictures_name,
- priority = "low",
- width = 153,
- height = 131,
- apply_projection = false,
- direction_count = 64,
- line_length = 8,
- shift = { 0.875, -0.34375 }
- },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- working_sound = {
- sound = { {
- filename = "__base__/sound/radar.ogg"
- } },
- apparent_volume = 2
- },
- se_allow_in_space = true
- }
+ return {
+ type = "radar",
+ name = entity_name,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/" .. icon_name,
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = item_name,
+ },
+ max_health = 150,
+ corpse = "big-remnants",
+ resistances = { {
+ type = "fire",
+ percent = 70,
+ } },
+ collision_box = { { -1.4, -1.4 }, { 1.4, 1.4 } },
+ selection_box = { { -1.5, -1.5 }, { 1.5, 1.5 } },
+ energy_per_sector = "1MJ", -- Make the frequency of scanning each sector to be very low.
+ max_distance_of_sector_revealed = scan_distance, -- Scan area
+ max_distance_of_nearby_sector_revealed = scan_distance, -- Always revealed area
+ energy_per_nearby_scan = "1kJ",
+ energy_source = creative_mode_defines.non_electric_energy_source,
+ energy_usage = "1kW",
+ pictures = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/" .. pictures_name,
+ priority = "low",
+ width = 153,
+ height = 131,
+ apply_projection = false,
+ direction_count = 64,
+ line_length = 8,
+ shift = { 0.875, -0.34375 },
+ },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ working_sound = {
+ sound = { {
+ filename = "__base__/sound/radar.ogg",
+ } },
+ apparent_volume = 2,
+ },
+ se_allow_in_space = true,
+ }
end
-- Generates data for the alien attractor proxy.
local function alien_attractor_proxy(entity_name, mark_scale)
- return {
- type = "smoke-with-trigger",
- name = entity_name,
- flags = { "not-on-map", "placeable-off-grid", "not-blueprintable", "not-deconstructable" },
- show_when_smoke_off = true,
- animation = {
- filename = "__core__/graphics/shoot-cursor-red.png",
- priority = "low",
- width = 258,
- height = 183,
- frame_count = 1,
- animation_speed = 1,
- line_length = 1,
- shift = { 0, 1 },
- scale = mark_scale
- },
- movement_slow_down_factor = 0,
- affected_by_wind = false,
- cyclic = true,
- duration = 60 * 3,
- fade_away_duration = 60 * 3,
- spread_duration = 0,
- color = {
- r = 1,
- g = 1,
- b = 1
- }
- }
+ return {
+ type = "smoke-with-trigger",
+ name = entity_name,
+ flags = { "not-on-map", "placeable-off-grid", "not-blueprintable", "not-deconstructable" },
+ show_when_smoke_off = true,
+ animation = {
+ filename = "__core__/graphics/shoot-cursor-red.png",
+ priority = "low",
+ width = 258,
+ height = 183,
+ frame_count = 1,
+ animation_speed = 1,
+ line_length = 1,
+ shift = { 0, 1 },
+ scale = mark_scale,
+ },
+ movement_slow_down_factor = 0,
+ affected_by_wind = false,
+ cyclic = true,
+ duration = 60 * 3,
+ fade_away_duration = 60 * 3,
+ spread_duration = 0,
+ color = {
+ r = 1,
+ g = 1,
+ b = 1,
+ },
+ }
end
circuit_connector_definitions[creative_mode_defines.names.entities.super_roboport] =
- circuit_connector_definitions.create_vector(universal_connector_template, { def_CC_table({ 0.59375, 1.3125 }, nil, 18) })
+ circuit_connector_definitions.create_vector(
+ universal_connector_template,
+ { def_CC_table({ 0.59375, 1.3125 }, nil, 18) }
+ )
circuit_connector_definitions[creative_mode_defines.names.entities.fluid_void] =
- circuit_connector_definitions.create_vector(universal_connector_template,
- { def_CC_table({ -0.1875, -0.375 }, nil, 7), def_CC_table({ 0.375, -0.53125 }, nil, 1),
- def_CC_table({ -0.1875, -0.375 }, nil, 7), def_CC_table({ 0.375, -0.53125 }, nil, 1) })
+ circuit_connector_definitions.create_vector(universal_connector_template, {
+ def_CC_table({ -0.1875, -0.375 }, nil, 7),
+ def_CC_table({ 0.375, -0.53125 }, nil, 1),
+ def_CC_table({ -0.1875, -0.375 }, nil, 7),
+ def_CC_table({ 0.375, -0.53125 }, nil, 1),
+ })
circuit_connector_definitions[creative_mode_defines.names.entities.passive_energy_source] =
- circuit_connector_definitions.create_vector(universal_connector_template,
- { def_CC_table({ 0.46875, 0.5 }, { 0.46875, 0.8125 }, 26) })
+ circuit_connector_definitions.create_vector(
+ universal_connector_template,
+ { def_CC_table({ 0.46875, 0.5 }, { 0.46875, 0.8125 }, 26) }
+ )
circuit_connector_definitions[creative_mode_defines.names.entities.passive_energy_void] =
- circuit_connector_definitions.create_vector(universal_connector_template,
- { def_CC_table({ 0.46875, 0.5 }, { 0.46875, 0.8125 }, 26) })
+ circuit_connector_definitions.create_vector(
+ universal_connector_template,
+ { def_CC_table({ 0.46875, 0.5 }, { 0.46875, 0.8125 }, 26) }
+ )
data:extend({
- -- Infinity Requester Chest
- infchest(creative_mode_defines.names.entities.inf_requester_chest,
- creative_mode_defines.names.items.inf_requester_chest, { a = 1, b = .9 },
- { creative_mode_defines.names.entities.creative_provider_chest },
- settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1, "requester"),
- -- Infinity Provider Chest
- infchest(creative_mode_defines.names.entities.inf_provider_chest,
- creative_mode_defines.names.items.inf_provider_chest, { a = 1, r = 0.7 },
- { creative_mode_defines.names.entities.creative_provider_chest },
- settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1, "passive-provider"),
- -- Creative Chest
- container(creative_mode_defines.names.entities.creative_chest,
- creative_mode_defines.names.items.creative_chest, "creative-chest.png", "creative-chest.png",
- { creative_mode_defines.names.entities.creative_provider_chest },
- settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1),
- -- Creative provider chest
- logistic_container(creative_mode_defines.names.entities.creative_provider_chest,
- creative_mode_defines.names.items.creative_provider_chest, "creative-provider-chest.png",
- "creative-provider-chest.png", { creative_mode_defines.names.entities.creative_chest },
- settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1, "passive-provider"),
- -- Autofill requester chest
- logistic_container(creative_mode_defines.names.entities.autofill_requester_chest,
- creative_mode_defines.names.items.autofill_requester_chest, "autofill-requester-chest.png",
- "autofill-requester-chest.png", nil, settings.startup[creative_mode_defines.names.settings
- .autofill_requester_chest_size].value, "requester"),
- -- New Creative Chest
- infcontainer(creative_mode_defines.names.entities.new_creative_chest,
- creative_mode_defines.names.items.creative_chest, "creative-chest.png", "creative-chest.png",
- { creative_mode_defines.names.entities.creative_provider_chest },
- settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1),
- -- New Creative provider chest
- infcontainer(creative_mode_defines.names.entities.new_creative_provider_chest,
- creative_mode_defines.names.items.creative_provider_chest, "creative-provider-chest.png",
- "creative-provider-chest.png", { creative_mode_defines.names.entities.creative_chest },
- settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1, "passive-provider"),
- -- New Autofill requester chest
- infcontainer(creative_mode_defines.names.entities.new_autofill_requester_chest,
- creative_mode_defines.names.items.autofill_requester_chest, "autofill-requester-chest.png",
- "autofill-requester-chest.png", nil, settings.startup[creative_mode_defines.names.settings
- .autofill_requester_chest_size].value, "requester"),
- -- Duplicating chest
- container(creative_mode_defines.names.entities.duplicating_chest,
- creative_mode_defines.names.items.duplicating_chest, "duplicating-chest.png", "duplicating-chest.png",
- { creative_mode_defines.names.entities.duplicating_provider_chest,
- creative_mode_defines.names.entities.duplicating_cargo_wagon },
- settings.startup[creative_mode_defines.names.settings.duplicating_chest_size].value),
- -- Duplicating provider chest
- logistic_container(creative_mode_defines.names.entities.duplicating_provider_chest,
- creative_mode_defines.names.items.duplicating_provider_chest, "duplicating-provider-chest.png",
- "duplicating-provider-chest.png", { creative_mode_defines.names.entities.duplicating_chest,
- creative_mode_defines.names.entities.duplicating_cargo_wagon },
- settings.startup[creative_mode_defines.names.settings.duplicating_chest_size].value, "passive-provider"),
- -- Void requester chest
- infcontainer(creative_mode_defines.names.entities.void_requester_chest,
- creative_mode_defines.names.items.void_requester_chest, "void-requester-chest.png", "void-requester-chest.png",
- nil,
- settings.startup[creative_mode_defines.names.settings.void_requester_chest_size].value, "requester"),
- -- Void chest
- infcontainer(creative_mode_defines.names.entities.void_chest, creative_mode_defines.names.items.void_chest,
- "void-chest.png", "void-chest.png", nil,
- settings.startup[creative_mode_defines.names.settings.void_chest_size].value),
- -- Void storage chest
- infcontainer(creative_mode_defines.names.entities.void_storage_chest,
- creative_mode_defines.names.items.void_storage_chest, "void-storage-chest.png", "void-storage-chest.png", nil,
- settings.startup[creative_mode_defines.names.settings.void_storage_chest_size].value, "storage"),
- -- Super loader
+ -- Infinity Requester Chest
+ infchest(
+ creative_mode_defines.names.entities.inf_requester_chest,
+ creative_mode_defines.names.items.inf_requester_chest,
+ { a = 1, b = 0.9 },
+ { creative_mode_defines.names.entities.creative_provider_chest },
+ settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1,
+ "requester"
+ ),
+ -- Infinity Provider Chest
+ infchest(
+ creative_mode_defines.names.entities.inf_provider_chest,
+ creative_mode_defines.names.items.inf_provider_chest,
+ { a = 1, r = 0.7 },
+ { creative_mode_defines.names.entities.creative_provider_chest },
+ settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1,
+ "passive-provider"
+ ),
+ -- Creative Chest
+ container(
+ creative_mode_defines.names.entities.creative_chest,
+ creative_mode_defines.names.items.creative_chest,
+ "creative-chest.png",
+ "creative-chest.png",
+ { creative_mode_defines.names.entities.creative_provider_chest },
+ settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1
+ ),
+ -- Creative provider chest
+ logistic_container(
+ creative_mode_defines.names.entities.creative_provider_chest,
+ creative_mode_defines.names.items.creative_provider_chest,
+ "creative-provider-chest.png",
+ "creative-provider-chest.png",
+ { creative_mode_defines.names.entities.creative_chest },
+ settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1,
+ "passive-provider"
+ ),
+ -- Autofill requester chest
+ logistic_container(
+ creative_mode_defines.names.entities.autofill_requester_chest,
+ creative_mode_defines.names.items.autofill_requester_chest,
+ "autofill-requester-chest.png",
+ "autofill-requester-chest.png",
+ nil,
+ settings.startup[creative_mode_defines.names.settings.autofill_requester_chest_size].value,
+ "requester"
+ ),
+ -- New Creative Chest
+ infcontainer(
+ creative_mode_defines.names.entities.new_creative_chest,
+ creative_mode_defines.names.items.creative_chest,
+ "creative-chest.png",
+ "creative-chest.png",
+ { creative_mode_defines.names.entities.creative_provider_chest },
+ settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1
+ ),
+ -- New Creative provider chest
+ infcontainer(
+ creative_mode_defines.names.entities.new_creative_provider_chest,
+ creative_mode_defines.names.items.creative_provider_chest,
+ "creative-provider-chest.png",
+ "creative-provider-chest.png",
+ { creative_mode_defines.names.entities.creative_chest },
+ settings.startup[creative_mode_defines.names.settings.creative_chest_size].value + 1,
+ "passive-provider"
+ ),
+ -- New Autofill requester chest
+ infcontainer(
+ creative_mode_defines.names.entities.new_autofill_requester_chest,
+ creative_mode_defines.names.items.autofill_requester_chest,
+ "autofill-requester-chest.png",
+ "autofill-requester-chest.png",
+ nil,
+ settings.startup[creative_mode_defines.names.settings.autofill_requester_chest_size].value,
+ "requester"
+ ),
+ -- Duplicating chest
+ container(
+ creative_mode_defines.names.entities.duplicating_chest,
+ creative_mode_defines.names.items.duplicating_chest,
+ "duplicating-chest.png",
+ "duplicating-chest.png",
{
- type = "loader",
- name = creative_mode_defines.names.entities.super_loader,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.super_loader
- },
- max_health = 70,
- filter_count = 5,
- corpse = "small-remnants",
- resistances = { {
- type = "fire",
- percent = 60
- } },
- collision_box = { { -0.4, -0.9 }, { 0.4, 0.9 } },
- selection_box = { { -0.5, -1 }, { 0.5, 1 } },
- animation_speed_coefficient = 32,
- belt_animation_set = basic_belt_animation_set,
- fast_replaceable_group = "loader",
- speed = 1,
- structure_render_layer = "lower-object",
- structure = {
- direction_in = {
- sheet = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-loader-structure.png",
- priority = "extra-high",
- width = 64,
- height = 64
- }
- },
- direction_out = {
- sheet = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-loader-structure.png",
- priority = "extra-high",
- width = 64,
- height = 64,
- y = 64
- }
- }
- },
- ending_patch = ending_patch_prototype,
- se_allow_in_space = true
+ creative_mode_defines.names.entities.duplicating_provider_chest,
+ creative_mode_defines.names.entities.duplicating_cargo_wagon,
},
- -- Super loader 2
- {
- type = "loader-1x1",
- name = creative_mode_defines.names.entities.super_loader2,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.super_loader2
- },
- max_health = 70,
- filter_count = 5,
- corpse = "small-remnants",
- container_distance = 1,
- resistances = { {
- type = "fire",
- percent = 60
- } },
- collision_box = { { -0.4, -0.4 }, { 0.4, 0.4 } },
- selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
- animation_speed_coefficient = 32,
- belt_animation_set = {
- animation_set = {
- direction_count = 20,
- filename = "__base__/graphics/entity/transport-belt/transport-belt.png",
- frame_count = 16,
- size = 128,
- scale = 0.5,
- priority = "extra-high",
- }
- },
- speed = 1,
- structure = {
- direction_in = {
- sheet = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-loader-structure-1.png",
- priority = "extra-high",
- width = 64,
- height = 64,
- scale = 0.5
- }
- },
- direction_out = {
- sheet = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-loader-structure-1.png",
- priority = "extra-high",
- width = 64,
- height = 64,
- scale = 0.5,
- y = 64
- }
- }
- },
- ending_patch = ending_patch_prototype,
- se_allow_in_space = true
- },
- -- Linked Chest
- linkedchest(creative_mode_defines.names.entities.linked_chest, creative_mode_defines.names.items.linked_chest),
- -- Linked Belt
- linkedbelt(creative_mode_defines.names.entities.linked_belt, creative_mode_defines.names.items.linked_belt),
- -- Creative Cargo Wagon
- cargo_wagon(creative_mode_defines.names.entities.creative_cargo_wagon,
- creative_mode_defines.names.items.creative_cargo_wagon, {
- r = 1,
- g = 0.3,
- b = 0.3
- }, -- Because the cargo wagon images are too large, we only use tint here to reduce the overall mod size.
- nil, settings.startup[creative_mode_defines.names.settings.creative_cargo_wagon_size].value + 1),
- -- Duplicating cargo wagon
- cargo_wagon(creative_mode_defines.names.entities.duplicating_cargo_wagon,
- creative_mode_defines.names.items.duplicating_cargo_wagon, {
- r = 0.35,
- g = 0.3,
- b = 1
- }, { creative_mode_defines.names.entities.duplicating_chest,
- creative_mode_defines.names.entities.duplicating_provider_chest },
- settings.startup[creative_mode_defines.names.settings.duplicating_cargo_wagon_size].value),
- -- Void cargo wagon
- cargo_wagon(creative_mode_defines.names.entities.void_cargo_wagon,
- creative_mode_defines.names.items.void_cargo_wagon, {
- r = 0.4,
- g = 0.4,
- b = 0.4
- }, nil, settings.startup[creative_mode_defines.names.settings.void_cargo_wagon_size].value),
- -- Super Logistics Robot
+ settings.startup[creative_mode_defines.names.settings.duplicating_chest_size].value
+ ),
+ -- Duplicating provider chest
+ logistic_container(
+ creative_mode_defines.names.entities.duplicating_provider_chest,
+ creative_mode_defines.names.items.duplicating_provider_chest,
+ "duplicating-provider-chest.png",
+ "duplicating-provider-chest.png",
{
- type = "logistic-robot",
- name = creative_mode_defines.names.entities.super_logistic_robot,
- icon_size = 64,
- icons = { {
- icon = "__base__/graphics/icons/logistic-robot.png",
- tint = {
- r = 1,
- g = 0.3,
- b = 0.3
- }
- } },
- flags = { "placeable-player", "player-creation", "placeable-off-grid", "not-on-map" },
- minable = {
- hardness = 0.1,
- mining_time = 0.1,
- result = creative_mode_defines.names.items.super_logistic_robot
- },
- resistances = {},
- max_health = 100,
- collision_box = { { 0, 0 }, { 0, 0 } },
- selection_box = { { -0.5, -1.5 }, { 0.5, -0.5 } },
- max_payload_size = 1000,
- speed = 100,
- transfer_distance = 0.5,
- max_energy = "0kJ",
- energy_per_tick = "0kJ",
- speed_multiplier_when_out_of_energy = 1,
- energy_per_move = "0kJ",
- min_to_charge = 0,
- max_to_charge = 0,
- idle = {
- filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
- priority = "high",
- line_length = 16,
- width = 80,
- height = 84,
- shift = util.by_pixel(0, -3),
- direction_count = 16,
- y = 84,
- scale = 0.5,
- tint = {
- r = 1,
- g = 0.3,
- b = 0.3
- }
- },
- idle_with_cargo = {
- filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
- priority = "high",
- line_length = 16,
- width = 80,
- height = 84,
- shift = util.by_pixel(0, -3),
- direction_count = 16,
- scale = 0.5,
- tint = {
- r = 1,
- g = 0.3,
- b = 0.3
- }
- },
- in_motion = {
- filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
- priority = "high",
- line_length = 16,
- width = 80,
- height = 84,
- scale = 0.5,
- y = 252,
- shift = util.by_pixel(0, -3),
- direction_count = 16,
- tint = {
- r = 1,
- g = 0.3,
- b = 0.3
- }
- },
- in_motion_with_cargo = {
- filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
- priority = "high",
- line_length = 16,
- width = 80,
- height = 84,
- scale = 0.5,
- y = 168,
- shift = util.by_pixel(0, -3),
- direction_count = 16,
- tint = {
- r = 1,
- g = 0.3,
- b = 0.3
- }
- },
- shadow_idle = {
- filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
- priority = "high",
- line_length = 16,
- width = 115,
- height = 57,
- scale = 0.5,
- y = 57,
- shift = util.by_pixel(31.75, 19,75),
- direction_count = 16,
- draw_as_shadow = true
+ creative_mode_defines.names.entities.duplicating_chest,
+ creative_mode_defines.names.entities.duplicating_cargo_wagon,
+ },
+ settings.startup[creative_mode_defines.names.settings.duplicating_chest_size].value,
+ "passive-provider"
+ ),
+ -- Void requester chest
+ infcontainer(
+ creative_mode_defines.names.entities.void_requester_chest,
+ creative_mode_defines.names.items.void_requester_chest,
+ "void-requester-chest.png",
+ "void-requester-chest.png",
+ nil,
+ settings.startup[creative_mode_defines.names.settings.void_requester_chest_size].value,
+ "requester"
+ ),
+ -- Void chest
+ infcontainer(
+ creative_mode_defines.names.entities.void_chest,
+ creative_mode_defines.names.items.void_chest,
+ "void-chest.png",
+ "void-chest.png",
+ nil,
+ settings.startup[creative_mode_defines.names.settings.void_chest_size].value
+ ),
+ -- Void storage chest
+ infcontainer(
+ creative_mode_defines.names.entities.void_storage_chest,
+ creative_mode_defines.names.items.void_storage_chest,
+ "void-storage-chest.png",
+ "void-storage-chest.png",
+ nil,
+ settings.startup[creative_mode_defines.names.settings.void_storage_chest_size].value,
+ "storage"
+ ),
+ -- Super loader
+ {
+ type = "loader",
+ name = creative_mode_defines.names.entities.super_loader,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.super_loader,
+ },
+ max_health = 70,
+ filter_count = 5,
+ corpse = "small-remnants",
+ resistances = { {
+ type = "fire",
+ percent = 60,
+ } },
+ collision_box = { { -0.4, -0.9 }, { 0.4, 0.9 } },
+ selection_box = { { -0.5, -1 }, { 0.5, 1 } },
+ animation_speed_coefficient = 32,
+ belt_animation_set = basic_belt_animation_set,
+ fast_replaceable_group = "loader",
+ speed = 1,
+ structure_render_layer = "lower-object",
+ structure = {
+ direction_in = {
+ sheet = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-loader-structure.png",
+ priority = "extra-high",
+ width = 64,
+ height = 64,
},
- shadow_idle_with_cargo = {
- filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
- priority = "high",
- line_length = 16,
- width = 115,
- height = 57,
- scale = 0.5,
- shift = util.by_pixel(31.75, 19,75),
- direction_count = 16,
- draw_as_shadow = true
+ },
+ direction_out = {
+ sheet = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-loader-structure.png",
+ priority = "extra-high",
+ width = 64,
+ height = 64,
+ y = 64,
},
- shadow_in_motion = {
- filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
- priority = "high",
- line_length = 16,
- width = 115,
- height = 57,
- scale = 0.5,
- y = 57*3,
- shift = util.by_pixel(31.75, 19,75),
- direction_count = 16,
- draw_as_shadow = true
+ },
+ },
+ ending_patch = ending_patch_prototype,
+ se_allow_in_space = true,
+ },
+ -- Super loader 2
+ {
+ type = "loader-1x1",
+ name = creative_mode_defines.names.entities.super_loader2,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.super_loader2,
+ },
+ max_health = 70,
+ filter_count = 5,
+ corpse = "small-remnants",
+ container_distance = 1,
+ resistances = { {
+ type = "fire",
+ percent = 60,
+ } },
+ collision_box = { { -0.4, -0.4 }, { 0.4, 0.4 } },
+ selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
+ animation_speed_coefficient = 32,
+ belt_animation_set = {
+ animation_set = {
+ direction_count = 20,
+ filename = "__base__/graphics/entity/transport-belt/transport-belt.png",
+ frame_count = 16,
+ size = 128,
+ scale = 0.5,
+ priority = "extra-high",
+ },
+ },
+ speed = 1,
+ structure = {
+ direction_in = {
+ sheet = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-loader-structure-1.png",
+ priority = "extra-high",
+ width = 64,
+ height = 64,
+ scale = 0.5,
},
- shadow_in_motion_with_cargo = {
- filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
- priority = "high",
- line_length = 16,
- width = 115,
- height = 57,
- scale = 0.5,
- y = 114,
- shift = util.by_pixel(31.75, 19,75),
- direction_count = 16,
- draw_as_shadow = true
+ },
+ direction_out = {
+ sheet = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-loader-structure-1.png",
+ priority = "extra-high",
+ width = 64,
+ height = 64,
+ scale = 0.5,
+ y = 64,
},
- working_sound = flying_robot(0.48),
- cargo_centered = { 0.0, 0.2 }
+ },
},
- -- Super Construction Robot
+ ending_patch = ending_patch_prototype,
+ se_allow_in_space = true,
+ },
+ -- Linked Chest
+ linkedchest(creative_mode_defines.names.entities.linked_chest, creative_mode_defines.names.items.linked_chest),
+ -- Linked Belt
+ linkedbelt(creative_mode_defines.names.entities.linked_belt, creative_mode_defines.names.items.linked_belt),
+ -- Creative Cargo Wagon
+ cargo_wagon(
+ creative_mode_defines.names.entities.creative_cargo_wagon,
+ creative_mode_defines.names.items.creative_cargo_wagon,
{
- type = "construction-robot",
- name = creative_mode_defines.names.entities.super_construction_robot,
- icon_size = 64,
- icons = { {
- icon = "__base__/graphics/icons/construction-robot.png",
- tint = {
- r = 0.3,
- g = 0.3,
- b = 1
- }
- } },
- flags = { "placeable-player", "player-creation", "placeable-off-grid", "not-on-map" },
- minable = {
- hardness = 0.1,
- mining_time = 0.1,
- result = creative_mode_defines.names.items.super_construction_robot
- },
- resistances = {},
- max_health = 100,
- collision_box = { { 0, 0 }, { 0, 0 } },
- selection_box = { { -0.5, -1.5 }, { 0.5, -0.5 } },
- max_payload_size = 1,
- speed = 100,
- transfer_distance = 0.5,
- max_energy = "0kJ",
- energy_per_tick = "0kJ",
- speed_multiplier_when_out_of_energy = 1,
- energy_per_move = "0kJ",
- min_to_charge = 0,
- max_to_charge = 0,
- working_light = {
- intensity = 0.8,
- size = 3
- },
- idle =
- {
- filename = "__base__/graphics/entity/construction-robot/construction-robot.png",
- priority = "high",
- line_length = 16,
- width = 66,
- height = 76,
- shift = util.by_pixel(0,-4.5),
- direction_count = 16,
- tint = {
- r = 0.3,
- g = 0.3,
- b = 1
- },
- scale = 0.5
- },
- in_motion =
- {
- filename = "__base__/graphics/entity/construction-robot/construction-robot.png",
- priority = "high",
- line_length = 16,
- width = 66,
- height = 76,
- shift = util.by_pixel(0, -4.5),
- direction_count = 16,
- tint = {
- r = 0.3,
- g = 0.3,
- b = 1
- },
- y = 76,
- scale = 0.5
- },
- shadow_idle =
- {
- filename = "__base__/graphics/entity/construction-robot/construction-robot-shadow.png",
- priority = "high",
- line_length = 16,
- width = 104,
- height = 49,
- shift = util.by_pixel(33.5, 18.75),
- direction_count = 16,
- scale = 0.5,
- draw_as_shadow = true
+ r = 1,
+ g = 0.3,
+ b = 0.3,
+ }, -- Because the cargo wagon images are too large, we only use tint here to reduce the overall mod size.
+ nil,
+ settings.startup[creative_mode_defines.names.settings.creative_cargo_wagon_size].value + 1
+ ),
+ -- Duplicating cargo wagon
+ cargo_wagon(
+ creative_mode_defines.names.entities.duplicating_cargo_wagon,
+ creative_mode_defines.names.items.duplicating_cargo_wagon,
+ {
+ r = 0.35,
+ g = 0.3,
+ b = 1,
+ },
+ {
+ creative_mode_defines.names.entities.duplicating_chest,
+ creative_mode_defines.names.entities.duplicating_provider_chest,
+ },
+ settings.startup[creative_mode_defines.names.settings.duplicating_cargo_wagon_size].value
+ ),
+ -- Void cargo wagon
+ cargo_wagon(
+ creative_mode_defines.names.entities.void_cargo_wagon,
+ creative_mode_defines.names.items.void_cargo_wagon,
+ {
+ r = 0.4,
+ g = 0.4,
+ b = 0.4,
+ },
+ nil,
+ settings.startup[creative_mode_defines.names.settings.void_cargo_wagon_size].value
+ ),
+ -- Super Logistics Robot
+ {
+ type = "logistic-robot",
+ name = creative_mode_defines.names.entities.super_logistic_robot,
+ icon_size = 64,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/logistic-robot.png",
+ tint = {
+ r = 1,
+ g = 0.3,
+ b = 0.3,
},
- shadow_in_motion =
- {
- filename = "__base__/graphics/entity/construction-robot/construction-robot-shadow.png",
- priority = "high",
- line_length = 16,
- width = 104,
- height = 49,
- shift = util.by_pixel(33.5, 18.75),
- direction_count = 16,
- scale = 0.5,
- draw_as_shadow = true
+ },
+ },
+ flags = { "placeable-player", "player-creation", "placeable-off-grid", "not-on-map" },
+ minable = {
+ hardness = 0.1,
+ mining_time = 0.1,
+ result = creative_mode_defines.names.items.super_logistic_robot,
+ },
+ resistances = {},
+ max_health = 100,
+ collision_box = { { 0, 0 }, { 0, 0 } },
+ selection_box = { { -0.5, -1.5 }, { 0.5, -0.5 } },
+ max_payload_size = 1000,
+ speed = 100,
+ transfer_distance = 0.5,
+ max_energy = "0kJ",
+ energy_per_tick = "0kJ",
+ speed_multiplier_when_out_of_energy = 1,
+ energy_per_move = "0kJ",
+ min_to_charge = 0,
+ max_to_charge = 0,
+ idle = {
+ filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
+ priority = "high",
+ line_length = 16,
+ width = 80,
+ height = 84,
+ shift = util.by_pixel(0, -3),
+ direction_count = 16,
+ y = 84,
+ scale = 0.5,
+ tint = {
+ r = 1,
+ g = 0.3,
+ b = 0.3,
+ },
+ },
+ idle_with_cargo = {
+ filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
+ priority = "high",
+ line_length = 16,
+ width = 80,
+ height = 84,
+ shift = util.by_pixel(0, -3),
+ direction_count = 16,
+ scale = 0.5,
+ tint = {
+ r = 1,
+ g = 0.3,
+ b = 0.3,
+ },
+ },
+ in_motion = {
+ filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
+ priority = "high",
+ line_length = 16,
+ width = 80,
+ height = 84,
+ scale = 0.5,
+ y = 252,
+ shift = util.by_pixel(0, -3),
+ direction_count = 16,
+ tint = {
+ r = 1,
+ g = 0.3,
+ b = 0.3,
+ },
+ },
+ in_motion_with_cargo = {
+ filename = "__base__/graphics/entity/logistic-robot/logistic-robot.png",
+ priority = "high",
+ line_length = 16,
+ width = 80,
+ height = 84,
+ scale = 0.5,
+ y = 168,
+ shift = util.by_pixel(0, -3),
+ direction_count = 16,
+ tint = {
+ r = 1,
+ g = 0.3,
+ b = 0.3,
+ },
+ },
+ shadow_idle = {
+ filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
+ priority = "high",
+ line_length = 16,
+ width = 115,
+ height = 57,
+ scale = 0.5,
+ y = 57,
+ shift = util.by_pixel(31.75, 19, 75),
+ direction_count = 16,
+ draw_as_shadow = true,
+ },
+ shadow_idle_with_cargo = {
+ filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
+ priority = "high",
+ line_length = 16,
+ width = 115,
+ height = 57,
+ scale = 0.5,
+ shift = util.by_pixel(31.75, 19, 75),
+ direction_count = 16,
+ draw_as_shadow = true,
+ },
+ shadow_in_motion = {
+ filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
+ priority = "high",
+ line_length = 16,
+ width = 115,
+ height = 57,
+ scale = 0.5,
+ y = 57 * 3,
+ shift = util.by_pixel(31.75, 19, 75),
+ direction_count = 16,
+ draw_as_shadow = true,
+ },
+ shadow_in_motion_with_cargo = {
+ filename = "__base__/graphics/entity/logistic-robot/logistic-robot-shadow.png",
+ priority = "high",
+ line_length = 16,
+ width = 115,
+ height = 57,
+ scale = 0.5,
+ y = 114,
+ shift = util.by_pixel(31.75, 19, 75),
+ direction_count = 16,
+ draw_as_shadow = true,
+ },
+ working_sound = flying_robot(0.48),
+ cargo_centered = { 0.0, 0.2 },
+ },
+ -- Super Construction Robot
+ {
+ type = "construction-robot",
+ name = creative_mode_defines.names.entities.super_construction_robot,
+ icon_size = 64,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/construction-robot.png",
+ tint = {
+ r = 0.3,
+ g = 0.3,
+ b = 1,
},
- working =
+ },
+ },
+ flags = { "placeable-player", "player-creation", "placeable-off-grid", "not-on-map" },
+ minable = {
+ hardness = 0.1,
+ mining_time = 0.1,
+ result = creative_mode_defines.names.items.super_construction_robot,
+ },
+ resistances = {},
+ max_health = 100,
+ collision_box = { { 0, 0 }, { 0, 0 } },
+ selection_box = { { -0.5, -1.5 }, { 0.5, -0.5 } },
+ max_payload_size = 1,
+ speed = 100,
+ transfer_distance = 0.5,
+ max_energy = "0kJ",
+ energy_per_tick = "0kJ",
+ speed_multiplier_when_out_of_energy = 1,
+ energy_per_move = "0kJ",
+ min_to_charge = 0,
+ max_to_charge = 0,
+ working_light = {
+ intensity = 0.8,
+ size = 3,
+ },
+ idle = {
+ filename = "__base__/graphics/entity/construction-robot/construction-robot.png",
+ priority = "high",
+ line_length = 16,
+ width = 66,
+ height = 76,
+ shift = util.by_pixel(0, -4.5),
+ direction_count = 16,
+ tint = {
+ r = 0.3,
+ g = 0.3,
+ b = 1,
+ },
+ scale = 0.5,
+ },
+ in_motion = {
+ filename = "__base__/graphics/entity/construction-robot/construction-robot.png",
+ priority = "high",
+ line_length = 16,
+ width = 66,
+ height = 76,
+ shift = util.by_pixel(0, -4.5),
+ direction_count = 16,
+ tint = {
+ r = 0.3,
+ g = 0.3,
+ b = 1,
+ },
+ y = 76,
+ scale = 0.5,
+ },
+ shadow_idle = {
+ filename = "__base__/graphics/entity/construction-robot/construction-robot-shadow.png",
+ priority = "high",
+ line_length = 16,
+ width = 104,
+ height = 49,
+ shift = util.by_pixel(33.5, 18.75),
+ direction_count = 16,
+ scale = 0.5,
+ draw_as_shadow = true,
+ },
+ shadow_in_motion = {
+ filename = "__base__/graphics/entity/construction-robot/construction-robot-shadow.png",
+ priority = "high",
+ line_length = 16,
+ width = 104,
+ height = 49,
+ shift = util.by_pixel(33.5, 18.75),
+ direction_count = 16,
+ scale = 0.5,
+ draw_as_shadow = true,
+ },
+ working = {
+ filename = "__base__/graphics/entity/construction-robot/construction-robot-working.png",
+ priority = "high",
+ line_length = 2,
+ width = 57,
+ height = 74,
+ frame_count = 2,
+ shift = util.by_pixel(-0.25, -5),
+ direction_count = 16,
+ animation_speed = 0.3,
+ tint = {
+ r = 0.3,
+ g = 0.3,
+ b = 1,
+ },
+ scale = 0.5,
+ },
+ shadow_working = {
+ filename = "__base__/graphics/entity/construction-robot/construction-robot-shadow.png",
+ priority = "high",
+ line_length = 16,
+ width = 104,
+ height = 49,
+ repeat_count = 2,
+ shift = util.by_pixel(33.5, 18.75),
+ direction_count = 16,
+ scale = 0.5,
+ draw_as_shadow = true,
+ },
+ smoke = {
+ filename = "__base__/graphics/entity/smoke-construction/smoke-01.png",
+ width = 39,
+ height = 32,
+ frame_count = 19,
+ line_length = 19,
+ shift = { 0.078125, -0.15625 },
+ animation_speed = 0.3,
+ },
+ sparks = {
+ filename = "__base__/graphics/entity/sparks/sparks-01.png",
+ width = 39,
+ height = 34,
+ frame_count = 19,
+ line_length = 19,
+ shift = { -0.109375, 0.3125 },
+ tint = {
+ r = 1.0,
+ g = 0.9,
+ b = 0.0,
+ a = 1.0,
+ },
+ animation_speed = 0.3,
+ },
+ {
+ filename = "__base__/graphics/entity/sparks/sparks-02.png",
+ width = 36,
+ height = 32,
+ frame_count = 19,
+ line_length = 19,
+ shift = { 0.03125, 0.125 },
+ tint = {
+ r = 1.0,
+ g = 0.9,
+ b = 0.0,
+ a = 1.0,
+ },
+ animation_speed = 0.3,
+ },
+ {
+ filename = "__base__/graphics/entity/sparks/sparks-03.png",
+ width = 42,
+ height = 29,
+ frame_count = 19,
+ line_length = 19,
+ shift = { -0.0625, 0.203125 },
+ tint = {
+ r = 1.0,
+ g = 0.9,
+ b = 0.0,
+ a = 1.0,
+ },
+ animation_speed = 0.3,
+ },
+ {
+ filename = "__base__/graphics/entity/sparks/sparks-04.png",
+ width = 40,
+ height = 35,
+ frame_count = 19,
+ line_length = 19,
+ shift = { -0.0625, 0.234375 },
+ tint = {
+ r = 1.0,
+ g = 0.9,
+ b = 0.0,
+ a = 1.0,
+ },
+ animation_speed = 0.3,
+ },
+ {
+ filename = "__base__/graphics/entity/sparks/sparks-05.png",
+ width = 39,
+ height = 29,
+ frame_count = 19,
+ line_length = 19,
+ shift = { -0.109375, 0.171875 },
+ tint = {
+ r = 1.0,
+ g = 0.9,
+ b = 0.0,
+ a = 1.0,
+ },
+ animation_speed = 0.3,
+ },
+ {
+ filename = "__base__/graphics/entity/sparks/sparks-06.png",
+ width = 44,
+ height = 36,
+ frame_count = 19,
+ line_length = 19,
+ shift = { 0.03125, 0.3125 },
+ tint = {
+ r = 1.0,
+ g = 0.9,
+ b = 0.0,
+ a = 1.0,
+ },
+ animation_speed = 0.3,
+ },
+ repairing_sound = {
+ {
+ filename = "__base__/sound/robot-repair-1.ogg",
+ },
+ {
+ filename = "__base__/sound/robot-repair-2.ogg",
+ },
+ {
+ filename = "__base__/sound/robot-repair-3.ogg",
+ },
+ {
+ filename = "__base__/sound/robot-repair-4.ogg",
+ },
+ {
+ filename = "__base__/sound/robot-repair-5.ogg",
+ },
+ },
+ working_sound = construction_robot(0.47),
+ cargo_centered = { 0.0, 0.2 },
+ construction_vector = { 0.30, 0.22 },
+ },
+ -- Super Roboport
+ {
+ type = "roboport",
+ name = creative_mode_defines.names.entities.super_roboport,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-roboport.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.super_roboport,
+ },
+ max_health = 500,
+ corpse = "big-remnants",
+ collision_box = { { -1.7, -1.7 }, { 1.7, 1.7 } },
+ selection_box = { { -2, -2 }, { 2, 2 } },
+ dying_explosion = "medium-explosion",
+ energy_source = creative_mode_defines.non_electric_energy_source,
+ recharge_minimum = "40MJ",
+ energy_usage = "1W",
+ -- per one charge slot
+ charging_energy = "1000MW",
+ logistics_radius = 100,
+ construction_radius = 200,
+ charge_approach_distance = 5,
+ robot_slots_count = 7,
+ material_slots_count = 7,
+ stationing_offset = { 0, 0 },
+ charging_offsets = get_super_roboport_charging_offsets(),
+ base = {
+ layers = {
{
- filename = "__base__/graphics/entity/construction-robot/construction-robot-working.png",
- priority = "high",
- line_length = 2,
- width = 57,
- height = 74,
- frame_count = 2,
- shift = util.by_pixel(-0.25, -5),
- direction_count = 16,
- animation_speed = 0.3,
- tint = {
- r = 0.3,
- g = 0.3,
- b = 1
- },
- scale = 0.5
+ filename = "__base__/graphics/entity/roboport/roboport-base.png",
+ width = 228,
+ height = 277,
+ shift = util.by_pixel(2, -2.25),
+ tint = {
+ r = 0.7,
+ g = 0.3,
+ b = 1,
+ },
+ scale = 0.5,
},
- shadow_working =
{
- filename = "__base__/graphics/entity/construction-robot/construction-robot-shadow.png",
- priority = "high",
- line_length = 16,
- width = 104,
- height = 49,
- repeat_count = 2,
- shift = util.by_pixel(33.5, 18.75),
- direction_count = 16,
- scale = 0.5,
- draw_as_shadow = true
- },
- smoke = {
- filename = "__base__/graphics/entity/smoke-construction/smoke-01.png",
- width = 39,
- height = 32,
- frame_count = 19,
- line_length = 19,
- shift = { 0.078125, -0.15625 },
- animation_speed = 0.3
+ filename = "__base__/graphics/entity/roboport/roboport-shadow.png",
+ width = 294,
+ height = 201,
+ draw_as_shadow = true,
+ shift = util.by_pixel(28.5, 9.25),
+ scale = 0.5,
},
- sparks = {
- filename = "__base__/graphics/entity/sparks/sparks-01.png",
- width = 39,
- height = 34,
- frame_count = 19,
- line_length = 19,
- shift = { -0.109375, 0.3125 },
- tint = {
- r = 1.0,
- g = 0.9,
- b = 0.0,
- a = 1.0
- },
- animation_speed = 0.3
- }, {
- filename = "__base__/graphics/entity/sparks/sparks-02.png",
- width = 36,
- height = 32,
- frame_count = 19,
- line_length = 19,
- shift = { 0.03125, 0.125 },
- tint = {
- r = 1.0,
- g = 0.9,
- b = 0.0,
- a = 1.0
- },
- animation_speed = 0.3
- }, {
- filename = "__base__/graphics/entity/sparks/sparks-03.png",
- width = 42,
- height = 29,
- frame_count = 19,
- line_length = 19,
- shift = { -0.0625, 0.203125 },
- tint = {
- r = 1.0,
- g = 0.9,
- b = 0.0,
- a = 1.0
- },
- animation_speed = 0.3
- }, {
- filename = "__base__/graphics/entity/sparks/sparks-04.png",
- width = 40,
- height = 35,
- frame_count = 19,
- line_length = 19,
- shift = { -0.0625, 0.234375 },
- tint = {
- r = 1.0,
- g = 0.9,
- b = 0.0,
- a = 1.0
- },
- animation_speed = 0.3
- }, {
- filename = "__base__/graphics/entity/sparks/sparks-05.png",
- width = 39,
- height = 29,
- frame_count = 19,
- line_length = 19,
- shift = { -0.109375, 0.171875 },
- tint = {
- r = 1.0,
- g = 0.9,
- b = 0.0,
- a = 1.0
- },
- animation_speed = 0.3
- }, {
- filename = "__base__/graphics/entity/sparks/sparks-06.png",
- width = 44,
- height = 36,
- frame_count = 19,
- line_length = 19,
- shift = { 0.03125, 0.3125 },
- tint = {
- r = 1.0,
- g = 0.9,
- b = 0.0,
- a = 1.0
- },
- animation_speed = 0.3
+ },
+ },
+ base_patch = {
+ filename = "__base__/graphics/entity/roboport/roboport-base-patch.png",
+ priority = "medium",
+ width = 138,
+ height = 100,
+ shift = util.by_pixel(1.5, -5),
+ tint = {
+ r = 0.7,
+ g = 0.3,
+ b = 1,
+ },
+ scale = 0.5,
+ },
+ base_animation = {
+ filename = "__base__/graphics/entity/roboport/roboport-base-animation.png",
+ priority = "medium",
+ width = 83,
+ height = 59,
+ frame_count = 8,
+ animation_speed = 0.5,
+ shift = util.by_pixel(-17.75, -71.25),
+ tint = {
+ r = 0.7,
+ g = 0.3,
+ b = 1,
+ },
+ scale = 0.5,
+ },
+ door_animation_up = {
+ filename = "__base__/graphics/entity/roboport/roboport-door-up.png",
+ priority = "medium",
+ width = 97,
+ height = 38,
+ frame_count = 16,
+ shift = util.by_pixel(-0.25, -39.5),
+ tint = {
+ r = 0.7,
+ g = 0.3,
+ b = 1,
+ },
+ scale = 0.5,
+ },
+ door_animation_down = {
+ filename = "__base__/graphics/entity/roboport/roboport-door-down.png",
+ priority = "medium",
+ width = 97,
+ height = 41,
+ frame_count = 16,
+ shift = util.by_pixel(-0.25, -19.75),
+ tint = {
+ r = 0.7,
+ g = 0.3,
+ b = 1,
+ },
+ scale = 0.5,
+ },
+ recharging_animation = {
+ filename = "__base__/graphics/entity/roboport/roboport-recharging.png",
+ priority = "high",
+ width = 37,
+ height = 35,
+ frame_count = 16,
+ scale = 1.5,
+ animation_speed = 0.5,
+ },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ working_sound = {
+ sound = {
+ filename = "__base__/sound/roboport-working.ogg",
+ volume = 0.6,
+ },
+ max_sounds_per_type = 3,
+ audible_distance_modifier = 0.5,
+ probability = 1 / (5 * 60), -- average pause between the sound is 5 seconds
+ -- average pause between the sound is 5 seconds
+ -- average pause between the sound is 5 seconds
+ -- average pause between the sound is 5 seconds
+ },
+ recharging_light = {
+ intensity = 0.4,
+ size = 5,
+ },
+ request_to_open_door_timeout = 15,
+ spawn_and_station_height = -0.1,
+ draw_logistic_radius_visualization = true,
+ draw_construction_radius_visualization = true,
+ open_door_trigger_effect = {
+ {
+ type = "play-sound",
+ sound = {
+ filename = "__base__/sound/roboport-door.ogg",
+ volume = 1.2,
},
- repairing_sound = { {
- filename = "__base__/sound/robot-repair-1.ogg"
- }, {
- filename = "__base__/sound/robot-repair-2.ogg"
- }, {
- filename = "__base__/sound/robot-repair-3.ogg"
- }, {
- filename = "__base__/sound/robot-repair-4.ogg"
- }, {
- filename = "__base__/sound/robot-repair-5.ogg"
- } },
- working_sound = construction_robot(0.47),
- cargo_centered = { 0.0, 0.2 },
- construction_vector = { 0.30, 0.22 }
- },
- -- Super Roboport
- {
- type = "roboport",
- name = creative_mode_defines.names.entities.super_roboport,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-roboport.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.super_roboport
+ },
+ },
+ close_door_trigger_effect = {
+ {
+ type = "play-sound",
+ sound = {
+ filename = "__base__/sound/roboport-door.ogg",
+ volume = 0.75,
},
- max_health = 500,
- corpse = "big-remnants",
- collision_box = { { -1.7, -1.7 }, { 1.7, 1.7 } },
- selection_box = { { -2, -2 }, { 2, 2 } },
- dying_explosion = "medium-explosion",
- energy_source = creative_mode_defines.non_electric_energy_source,
- recharge_minimum = "40MJ",
- energy_usage = "1W",
- -- per one charge slot
- charging_energy = "1000MW",
- logistics_radius = 100,
- construction_radius = 200,
- charge_approach_distance = 5,
- robot_slots_count = 7,
- material_slots_count = 7,
- stationing_offset = { 0, 0 },
- charging_offsets = get_super_roboport_charging_offsets(),
- base =
- {
- layers =
- {
- {
- filename = "__base__/graphics/entity/roboport/roboport-base.png",
- width = 228,
- height = 277,
- shift = util.by_pixel(2, -2.25),
- tint = {
- r = 0.7,
- g = 0.3,
- b = 1
- },
- scale = 0.5
- },
- {
- filename = "__base__/graphics/entity/roboport/roboport-shadow.png",
- width = 294,
- height = 201,
- draw_as_shadow = true,
- shift = util.by_pixel(28.5, 9.25),
- scale = 0.5
- }
- }
+ },
+ },
+ circuit_connector = circuit_connector_definitions[creative_mode_defines.names.entities.super_roboport],
+ circuit_wire_max_distance = 1000,
+ default_available_logistic_output_signal = {
+ type = "virtual",
+ name = "signal-X",
+ },
+ default_total_logistic_output_signal = {
+ type = "virtual",
+ name = "signal-Y",
+ },
+ default_available_construction_output_signal = {
+ type = "virtual",
+ name = "signal-Z",
+ },
+ default_total_construction_output_signal = {
+ type = "virtual",
+ name = "signal-T",
+ },
+ se_allow_in_space = true,
+ },
+ -- Fluid source
+ {
+ type = "assembling-machine",
+ name = creative_mode_defines.names.entities.fluid_source,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/fluid-source.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.fluid_source,
+ },
+ max_health = 150,
+ corpse = "small-remnants",
+ fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.fluid_source_void,
+ collision_box = { { -0.29, -0.29 }, { 0.29, 0.29 } },
+ selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ fluid_boxes = {
+ {
+ volume = 200,
+ production_type = "output",
+ pipe_covers = pipecoverspictures(),
+ base_area = 10,
+ base_level = 1,
+ pipe_connections = {
+ {
+ flow_direction = "output",
+ direction = defines.direction.north,
+ position = { 0, -0.289 },
+ },
},
- base_patch =
- {
- filename = "__base__/graphics/entity/roboport/roboport-base-patch.png",
- priority = "medium",
- width = 138,
- height = 100,
- shift = util.by_pixel(1.5, -5),
- tint = {
- r = 0.7,
- g = 0.3,
- b = 1
- },
- scale = 0.5
+ },
+ },
+ graphics_set = {
+ animation = {
+ north = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/fluid-source-up.png",
+ width = 46,
+ height = 56,
+ frame_count = 8,
+ shift = { 0.09375, 0.03125 },
+ animation_speed = 0.5,
+ },
+ east = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/fluid-source-right.png",
+ width = 51 + 6,
+ height = 56,
+ frame_count = 8,
+ shift = { 0.265625 - 6 / 2 / 32, -0.21875 },
+ animation_speed = 0.5,
+ },
+ south = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/fluid-source-down.png",
+ width = 61,
+ height = 58,
+ frame_count = 8,
+ shift = { 0.421875, -0.125 },
+ animation_speed = 0.5,
+ },
+ west = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/fluid-source-left.png",
+ width = 56,
+ height = 44,
+ frame_count = 8,
+ shift = { 0.3125, 0.0625 },
+ animation_speed = 0.5,
},
- base_animation =
+ },
+ },
+ energy_source = creative_mode_defines.non_electric_energy_source,
+ energy_usage = "1W", -- Need to be at least 1W or the no energy signal will keep blinking
+ crafting_speed = 1,
+ ingredient_count = 0,
+ crafting_categories = { creative_mode_defines.names.recipe_categories.free_fluids },
+ module_specification = {
+ module_slots = 0,
+ },
+ allowed_effects = { "pollution" },
+ se_allow_in_space = true,
+ },
+ -- New Fluid void
+ {
+ type = "infinity-pipe",
+ name = creative_mode_defines.names.entities.new_fluid_void,
+ icon_size = data.raw["infinity-pipe"]["infinity-pipe"].icon_size,
+ icons = data.raw["infinity-pipe"]["infinity-pipe"].icons,
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.fluid_void,
+ },
+ max_health = 150,
+ corpse = "small-remnants",
+ resistances = {
+ {
+ type = "fire",
+ percent = 80,
+ },
+ {
+ type = "impact",
+ percent = 40,
+ },
+ },
+ fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.fluid_source_void,
+ collision_box = { { -0.29, -0.29 }, { 0.29, 0.29 } },
+ selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
+ vehicle_impact_sound = data.raw["infinity-pipe"]["infinity-pipe"].vehicle_impact_sound,
+ fluid_box = {
+ volume = 200,
+ pipe_connections = {
{
- filename = "__base__/graphics/entity/roboport/roboport-base-animation.png",
- priority = "medium",
- width = 83,
- height = 59,
- frame_count = 8,
- animation_speed = 0.5,
- shift = util.by_pixel(-17.75, -71.25),
- tint = {
- r = 0.7,
- g = 0.3,
- b = 1
- },
- scale = 0.5
+ flow_direction = "input-output",
+ direction = defines.direction.north,
+ position = {
+ 0,
+ -0.289,
+ },
},
- door_animation_up =
{
- filename = "__base__/graphics/entity/roboport/roboport-door-up.png",
- priority = "medium",
- width = 97,
- height = 38,
- frame_count = 16,
- shift = util.by_pixel(-0.25, -39.5),
- tint = {
- r = 0.7,
- g = 0.3,
- b = 1
- },
- scale = 0.5
+ flow_direction = "input-output",
+ direction = defines.direction.east,
+ position = {
+ 0.289,
+ 0,
+ },
},
- door_animation_down =
{
- filename = "__base__/graphics/entity/roboport/roboport-door-down.png",
- priority = "medium",
- width = 97,
- height = 41,
- frame_count = 16,
- shift = util.by_pixel(-0.25, -19.75),
- tint = {
- r = 0.7,
- g = 0.3,
- b = 1
- },
- scale = 0.5
- },
- recharging_animation = {
- filename = "__base__/graphics/entity/roboport/roboport-recharging.png",
- priority = "high",
- width = 37,
- height = 35,
- frame_count = 16,
- scale = 1.5,
- animation_speed = 0.5
- },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- working_sound = {
- sound = {
- filename = "__base__/sound/roboport-working.ogg",
- volume = 0.6
- },
- max_sounds_per_type = 3,
- audible_distance_modifier = 0.5,
- probability = 1 / (5 * 60) -- average pause between the sound is 5 seconds
- -- average pause between the sound is 5 seconds
- -- average pause between the sound is 5 seconds
- -- average pause between the sound is 5 seconds
- },
- recharging_light = {
- intensity = 0.4,
- size = 5
- },
- request_to_open_door_timeout = 15,
- spawn_and_station_height = -0.1,
- draw_logistic_radius_visualization = true,
- draw_construction_radius_visualization = true,
- open_door_trigger_effect = { {
- type = "play-sound",
- sound = {
- filename = "__base__/sound/roboport-door.ogg",
- volume = 1.2
- }
- } },
- close_door_trigger_effect = { {
- type = "play-sound",
- sound = {
- filename = "__base__/sound/roboport-door.ogg",
- volume = 0.75
- }
- } },
- circuit_connector = circuit_connector_definitions[creative_mode_defines.names.entities.super_roboport],
- circuit_wire_max_distance = 1000,
- default_available_logistic_output_signal = {
- type = "virtual",
- name = "signal-X"
- },
- default_total_logistic_output_signal = {
- type = "virtual",
- name = "signal-Y"
- },
- default_available_construction_output_signal = {
- type = "virtual",
- name = "signal-Z"
+ flow_direction = "input-output",
+ direction = defines.direction.south,
+ position = {
+ 0,
+ 0.289,
+ },
},
- default_total_construction_output_signal = {
- type = "virtual",
- name = "signal-T"
- },
- se_allow_in_space = true
- },
- -- Fluid source
- {
- type = "assembling-machine",
- name = creative_mode_defines.names.entities.fluid_source,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/fluid-source.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.fluid_source
- },
- max_health = 150,
- corpse = "small-remnants",
- fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.fluid_source_void,
- collision_box = { { -0.29, -0.29 }, { 0.29, 0.29 } },
- selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- fluid_boxes = { {
- volume = 200,
- production_type = "output",
- pipe_covers = pipecoverspictures(),
- base_area = 10,
- base_level = 1,
- pipe_connections = { {
- flow_direction = "output",
- direction = defines.direction.north,
- position = { 0, -0.289 }
- } }
- } },
- graphics_set =
{
- animation = {
- north = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/fluid-source-up.png",
- width = 46,
- height = 56,
- frame_count = 8,
- shift = { 0.09375, 0.03125 },
- animation_speed = 0.5
- },
- east = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/fluid-source-right.png",
- width = 51 + 6,
- height = 56,
- frame_count = 8,
- shift = { 0.265625 - 6 / 2 / 32, -0.21875 },
- animation_speed = 0.5
- },
- south = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/fluid-source-down.png",
- width = 61,
- height = 58,
- frame_count = 8,
- shift = { 0.421875, -0.125 },
- animation_speed = 0.5
- },
- west = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/fluid-source-left.png",
- width = 56,
- height = 44,
- frame_count = 8,
- shift = { 0.3125, 0.0625 },
- animation_speed = 0.5
- }
- }},
- energy_source = creative_mode_defines.non_electric_energy_source,
- energy_usage = "1W", -- Need to be at least 1W or the no energy signal will keep blinking
- crafting_speed = 1,
- ingredient_count = 0,
- crafting_categories = { creative_mode_defines.names.recipe_categories.free_fluids },
- module_specification = {
- module_slots = 0
+ flow_direction = "input-output",
+ direction = defines.direction.west,
+ position = {
+ -0.289,
+ 0,
+ },
},
- allowed_effects = { "pollution" },
- se_allow_in_space = true
+ },
+ base_area = 10000,
+ base_level = -1,
},
- -- New Fluid void
- {
- type = "infinity-pipe",
- name = creative_mode_defines.names.entities.new_fluid_void,
- icon_size = data.raw["infinity-pipe"]["infinity-pipe"].icon_size,
- icons = data.raw["infinity-pipe"]["infinity-pipe"].icons,
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.fluid_void
- },
- max_health = 150,
- corpse = "small-remnants",
- resistances = { {
- type = "fire",
- percent = 80
- }, {
- type = "impact",
- percent = 40
- } },
- fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.fluid_source_void,
- collision_box = { { -0.29, -0.29 }, { 0.29, 0.29 } },
- selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
- vehicle_impact_sound = data.raw["infinity-pipe"]["infinity-pipe"].vehicle_impact_sound,
- fluid_box = {
- volume = 200,
- pipe_connections = {
- {
- flow_direction = "input-output",
- direction = defines.direction.north,
- position = {
- 0,
- -0.289
- }
- },
- {
- flow_direction = "input-output",
- direction = defines.direction.east,
- position = {
- 0.289,
- 0
- }
- },
- {
- flow_direction = "input-output",
- direction = defines.direction.south,
- position = {
- 0,
- 0.289
- }
- },
- {
- flow_direction = "input-output",
- direction = defines.direction.west,
- position = {
- -0.289,
- 0
- }
- }
- },
- base_area = 10000,
- base_level = -1
- },
- working_sound = data.raw["infinity-pipe"]["infinity-pipe"].working_sound,
- pictures = data.raw["infinity-pipe"]["infinity-pipe"].pictures,
- horizontal_window_bounding_box = data.raw["infinity-pipe"]["infinity-pipe"].horizontal_window_bounding_box,
- vertical_window_bounding_box = data.raw["infinity-pipe"]["infinity-pipe"].vertical_window_bounding_box,
- flow_length_in_ticks = 10000,
- localised_name = { "entity-name." .. creative_mode_defines.names.entities.fluid_void },
- localised_description = { "entity-description." .. creative_mode_defines.names.entities.fluid_void },
- gui_mode = "none",
- se_allow_in_space = true
- },
- -- Super boiler
- super_boiler(creative_mode_defines.names.entities.super_boiler,
- creative_mode_defines.names.items.super_boiler, "super-boiler.png", "super-boiler.png", nil),
- -- Super cooler
- super_boiler(creative_mode_defines.names.entities.super_cooler,
- creative_mode_defines.names.items.super_cooler, "super-cooler.png", "super-cooler.png", nil),
- -- Configurable super boiler
- super_boiler(creative_mode_defines.names.entities.configurable_super_boiler,
- creative_mode_defines.names.items.configurable_super_boiler, "configurable-super-boiler.png",
- "configurable-super-boiler.png", { creative_mode_defines.names.entities.configurable_super_boiler }), -- This is needed because boiler does not support copy-and-paste by default.
- -- Heat source
- heat_pipe(creative_mode_defines.names.entities.heat_source, creative_mode_defines.names.items.heat_source,
- {
- r = 1,
- g = 0.3,
- b = 0.3
- }, true, 1000),
- -- Heat void
- heat_pipe(creative_mode_defines.names.entities.heat_void, creative_mode_defines.names.items.heat_void, {
- r = 0.2,
- g = 0.2,
- b = 0.2
- }, false, 1000),
- -----------------------------------------------------------------------------
+ working_sound = data.raw["infinity-pipe"]["infinity-pipe"].working_sound,
+ pictures = data.raw["infinity-pipe"]["infinity-pipe"].pictures,
+ horizontal_window_bounding_box = data.raw["infinity-pipe"]["infinity-pipe"].horizontal_window_bounding_box,
+ vertical_window_bounding_box = data.raw["infinity-pipe"]["infinity-pipe"].vertical_window_bounding_box,
+ flow_length_in_ticks = 10000,
+ localised_name = { "entity-name." .. creative_mode_defines.names.entities.fluid_void },
+ localised_description = { "entity-description." .. creative_mode_defines.names.entities.fluid_void },
+ gui_mode = "none",
+ se_allow_in_space = true,
+ },
+ -- Super boiler
+ super_boiler(
+ creative_mode_defines.names.entities.super_boiler,
+ creative_mode_defines.names.items.super_boiler,
+ "super-boiler.png",
+ "super-boiler.png",
+ nil
+ ),
+ -- Super cooler
+ super_boiler(
+ creative_mode_defines.names.entities.super_cooler,
+ creative_mode_defines.names.items.super_cooler,
+ "super-cooler.png",
+ "super-cooler.png",
+ nil
+ ),
+ -- Configurable super boiler
+ super_boiler(
+ creative_mode_defines.names.entities.configurable_super_boiler,
+ creative_mode_defines.names.items.configurable_super_boiler,
+ "configurable-super-boiler.png",
+ "configurable-super-boiler.png",
+ { creative_mode_defines.names.entities.configurable_super_boiler }
+ ), -- This is needed because boiler does not support copy-and-paste by default.
+ -- Heat source
+ heat_pipe(creative_mode_defines.names.entities.heat_source, creative_mode_defines.names.items.heat_source, {
+ r = 1,
+ g = 0.3,
+ b = 0.3,
+ }, true, 1000),
+ -- Heat void
+ heat_pipe(creative_mode_defines.names.entities.heat_void, creative_mode_defines.names.items.heat_void, {
+ r = 0.2,
+ g = 0.2,
+ b = 0.2,
+ }, false, 1000),
+ -----------------------------------------------------------------------------
- -- Matter source
- inserter(creative_mode_defines.names.entities.item_source, creative_mode_defines.names.items.item_source,
- "item-source.png", "item-source.png", nil,
- creative_mode_defines.names.fast_replaceable_groups.item_source_void_duplicator, { 0, 0.8 }, { 0, 1 }, 2),
- -- Matter duplicator
- inserter(creative_mode_defines.names.entities.duplicator, creative_mode_defines.names.items.duplicator,
- "duplicator.png", "duplicator.png", nil,
- creative_mode_defines.names.fast_replaceable_groups.item_source_void_duplicator, { 0, 0.8 }, { 0, 1 }, 1),
- -- Matter void
- inserter(creative_mode_defines.names.entities.item_void, creative_mode_defines.names.items.item_void,
- "item-void.png", "item-void.png", nil,
- creative_mode_defines.names.fast_replaceable_groups.item_source_void_duplicator, { 0, -1 }, { 0, -0.9 }, 1),
- -- Random item source
- inserter(creative_mode_defines.names.entities.random_item_source,
- creative_mode_defines.names.items.random_item_source, "random-item-source.png", "random-item-source.png", nil,
- creative_mode_defines.names.fast_replaceable_groups.item_source_void_duplicator, { 0, 0.8 }, { 0, 1 }, 0),
- -- Creative lab
- lab(creative_mode_defines.names.entities.creative_lab, creative_mode_defines.names.items.creative_lab,
- "creative-lab.png", "creative-lab.png", "creative-lab.png"),
+ -- Matter source
+ inserter(
+ creative_mode_defines.names.entities.item_source,
+ creative_mode_defines.names.items.item_source,
+ "item-source.png",
+ "item-source.png",
+ nil,
+ creative_mode_defines.names.fast_replaceable_groups.item_source_void_duplicator,
+ { 0, 0.8 },
+ { 0, 1 },
+ 2
+ ),
+ -- Matter duplicator
+ inserter(
+ creative_mode_defines.names.entities.duplicator,
+ creative_mode_defines.names.items.duplicator,
+ "duplicator.png",
+ "duplicator.png",
+ nil,
+ creative_mode_defines.names.fast_replaceable_groups.item_source_void_duplicator,
+ { 0, 0.8 },
+ { 0, 1 },
+ 1
+ ),
+ -- Matter void
+ inserter(
+ creative_mode_defines.names.entities.item_void,
+ creative_mode_defines.names.items.item_void,
+ "item-void.png",
+ "item-void.png",
+ nil,
+ creative_mode_defines.names.fast_replaceable_groups.item_source_void_duplicator,
+ { 0, -1 },
+ { 0, -0.9 },
+ 1
+ ),
+ -- Random item source
+ inserter(
+ creative_mode_defines.names.entities.random_item_source,
+ creative_mode_defines.names.items.random_item_source,
+ "random-item-source.png",
+ "random-item-source.png",
+ nil,
+ creative_mode_defines.names.fast_replaceable_groups.item_source_void_duplicator,
+ { 0, 0.8 },
+ { 0, 1 },
+ 0
+ ),
+ -- Creative lab
+ lab(
+ creative_mode_defines.names.entities.creative_lab,
+ creative_mode_defines.names.items.creative_lab,
+ "creative-lab.png",
+ "creative-lab.png",
+ "creative-lab.png"
+ ),
- -- Void Lab
- void_lab(),
- -----------------------------------------------------------------------------
+ -- Void Lab
+ void_lab(),
+ -----------------------------------------------------------------------------
- -- Active electric energy interface (output)
- electric_energy_interface(creative_mode_defines.names.entities.active_electric_energy_interface_output,
- creative_mode_defines.names.items.active_electric_energy_interface_output,
- "active-electric-energy-interface-output.png", "active-electric-energy-interface-output.png", "primary-output",
- "0kW", -- Default input flow
- "500GW", -- Default output flow
- "500GW", -- Default production
- "0kW", -- Default usage
- { creative_mode_defines.names.entities.passive_electric_energy_interface,
- creative_mode_defines.names.entities.active_electric_energy_interface_input }),
- -- Passive electric energy interface
- electric_energy_interface(creative_mode_defines.names.entities.passive_electric_energy_interface,
- creative_mode_defines.names.items.passive_electric_energy_interface, "passive-electric-energy-interface.png",
- "passive-electric-energy-interface.png", "tertiary", "500GW", "0kW", "0kW", "500GW",
- { creative_mode_defines.names.entities.active_electric_energy_interface_output,
- creative_mode_defines.names.entities.active_electric_energy_interface_input }),
- -- Active electric energy interface (input)
- electric_energy_interface(creative_mode_defines.names.entities.active_electric_energy_interface_input,
- creative_mode_defines.names.items.active_electric_energy_interface_input,
- "active-electric-energy-interface-input.png", "active-electric-energy-interface-input.png", "primary-input",
- "500GW", "0kW", "0kW", "500GW", { creative_mode_defines.names.entities.active_electric_energy_interface_output,
- creative_mode_defines.names.entities.passive_electric_energy_interface }),
- -- Energy Source
+ -- Active electric energy interface (output)
+ electric_energy_interface(
+ creative_mode_defines.names.entities.active_electric_energy_interface_output,
+ creative_mode_defines.names.items.active_electric_energy_interface_output,
+ "active-electric-energy-interface-output.png",
+ "active-electric-energy-interface-output.png",
+ "primary-output",
+ "0kW", -- Default input flow
+ "500GW", -- Default output flow
+ "500GW", -- Default production
+ "0kW", -- Default usage
{
- type = "electric-energy-interface",
- enable_gui = true,
- name = creative_mode_defines.names.entities.energy_source,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-source.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.energy_source
- },
- max_health = 150,
- corpse = "medium-remnants",
- fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.energy_source_void,
- collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
- selection_box = { { -1, -1 }, { 1, 1 } },
- energy_source = {
- type = "electric",
- buffer_capacity = "5.4PW",
- usage_priority = "primary-output",
- input_flow_limit = "0W",
- output_flow_limit = "5.4PW"
- },
- energy_production = "5.4PW",
- picture = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/energy-source.png",
- priority = "extra-high",
- width = 124,
- height = 103,
- frame_count = 1,
- line_length = 1,
- shift = { 0.6875, -0.203125 }
- },
- charge_animation = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/energy-source.png",
- width = 124,
- height = 103,
- frame_count = 1,
- line_length = 1,
- shift = { 0.6875, -0.203125 },
- animation_speed = 0.5
- },
- charge_cooldown = 30,
- charge_light = {
- intensity = 0.3,
- size = 7
- },
- discharge_animation = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/energy-source.png",
- width = 124,
- height = 103,
- frame_count = 1,
- line_length = 1,
- shift = { 0.6875, -0.203125 },
- animation_speed = 0.5
- },
- discharge_cooldown = 60,
- discharge_light = {
- intensity = 0.7,
- size = 7
- },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- working_sound = {
- sound = {
- filename = "__base__/sound/accumulator-working.ogg",
- volume = 1
- },
- idle_sound = {
- filename = "__base__/sound/accumulator-idle.ogg",
- volume = 0.4
- },
- max_sounds_per_type = 5
- },
- se_allow_in_space = true
- },
- -- Passive energy source
+ creative_mode_defines.names.entities.passive_electric_energy_interface,
+ creative_mode_defines.names.entities.active_electric_energy_interface_input,
+ }
+ ),
+ -- Passive electric energy interface
+ electric_energy_interface(
+ creative_mode_defines.names.entities.passive_electric_energy_interface,
+ creative_mode_defines.names.items.passive_electric_energy_interface,
+ "passive-electric-energy-interface.png",
+ "passive-electric-energy-interface.png",
+ "tertiary",
+ "500GW",
+ "0kW",
+ "0kW",
+ "500GW",
{
- type = "electric-energy-interface",
- name = creative_mode_defines.names.entities.passive_energy_source,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-energy-source.png",
- flags = { "placeable-neutral", "player-creation" },
- minable = {
- hardness = 0.2,
- mining_time = 0.5,
- result = creative_mode_defines.names.items.passive_energy_source
- },
- max_health = 150,
- corpse = "medium-remnants",
- fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.energy_source_void,
- collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
- selection_box = { { -1, -1 }, { 1, 1 } },
- energy_source = {
- type = "electric",
- buffer_capacity = "5.4PW",
- usage_priority = "tertiary",
- input_flow_limit = "0W",
- output_flow_limit = "5.4PW"
- },
- energy_production = "5.4PW",
- gui_mode = "none",
- picture = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/passive-energy-source.png",
- priority = "extra-high",
- width = 124,
- height = 103,
- shift = { 0.6875, -0.203125 }
- },
- charge_animation = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/passive-energy-source-working.png",
- width = 147,
- height = 128,
- line_length = 8,
- frame_count = 24,
- shift = { 0.390625, -0.53125 },
- animation_speed = 0.5
- },
- charge_cooldown = 30,
- charge_light = {
- intensity = 0.3,
- size = 7
- },
- discharge_animation = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/passive-energy-source-working.png",
- width = 147,
- height = 128,
- line_length = 8,
- frame_count = 24,
- shift = { 0.390625, -0.53125 },
- animation_speed = 0.5
- },
- discharge_cooldown = 60,
- discharge_light = {
- intensity = 0.7,
- size = 7
- },
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- working_sound = {
- sound = {
- filename = "__base__/sound/accumulator-working.ogg",
- volume = 1
- },
- idle_sound = {
- filename = "__base__/sound/accumulator-idle.ogg",
- volume = 0.4
- },
- max_sounds_per_type = 5
- },
- se_allow_in_space = true
- },
- -- Energy void
+ creative_mode_defines.names.entities.active_electric_energy_interface_output,
+ creative_mode_defines.names.entities.active_electric_energy_interface_input,
+ }
+ ),
+ -- Active electric energy interface (input)
+ electric_energy_interface(
+ creative_mode_defines.names.entities.active_electric_energy_interface_input,
+ creative_mode_defines.names.items.active_electric_energy_interface_input,
+ "active-electric-energy-interface-input.png",
+ "active-electric-energy-interface-input.png",
+ "primary-input",
+ "500GW",
+ "0kW",
+ "0kW",
+ "500GW",
{
- type = "assembling-machine",
- name = creative_mode_defines.names.entities.energy_void,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-void.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.energy_void
+ creative_mode_defines.names.entities.active_electric_energy_interface_output,
+ creative_mode_defines.names.entities.passive_electric_energy_interface,
+ }
+ ),
+ -- Energy Source
+ {
+ type = "electric-energy-interface",
+ enable_gui = true,
+ name = creative_mode_defines.names.entities.energy_source,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-source.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.energy_source,
+ },
+ max_health = 150,
+ corpse = "medium-remnants",
+ fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.energy_source_void,
+ collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
+ selection_box = { { -1, -1 }, { 1, 1 } },
+ energy_source = {
+ type = "electric",
+ buffer_capacity = "5.4PW",
+ usage_priority = "primary-output",
+ input_flow_limit = "0W",
+ output_flow_limit = "5.4PW",
+ },
+ energy_production = "5.4PW",
+ picture = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/energy-source.png",
+ priority = "extra-high",
+ width = 124,
+ height = 103,
+ frame_count = 1,
+ line_length = 1,
+ shift = { 0.6875, -0.203125 },
+ },
+ charge_animation = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/energy-source.png",
+ width = 124,
+ height = 103,
+ frame_count = 1,
+ line_length = 1,
+ shift = { 0.6875, -0.203125 },
+ animation_speed = 0.5,
+ },
+ charge_cooldown = 30,
+ charge_light = {
+ intensity = 0.3,
+ size = 7,
+ },
+ discharge_animation = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/energy-source.png",
+ width = 124,
+ height = 103,
+ frame_count = 1,
+ line_length = 1,
+ shift = { 0.6875, -0.203125 },
+ animation_speed = 0.5,
+ },
+ discharge_cooldown = 60,
+ discharge_light = {
+ intensity = 0.7,
+ size = 7,
+ },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ working_sound = {
+ sound = {
+ filename = "__base__/sound/accumulator-working.ogg",
+ volume = 1,
+ },
+ idle_sound = {
+ filename = "__base__/sound/accumulator-idle.ogg",
+ volume = 0.4,
+ },
+ max_sounds_per_type = 5,
+ },
+ se_allow_in_space = true,
+ },
+ -- Passive energy source
+ {
+ type = "electric-energy-interface",
+ name = creative_mode_defines.names.entities.passive_energy_source,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-energy-source.png",
+ flags = { "placeable-neutral", "player-creation" },
+ minable = {
+ hardness = 0.2,
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.passive_energy_source,
+ },
+ max_health = 150,
+ corpse = "medium-remnants",
+ fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.energy_source_void,
+ collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
+ selection_box = { { -1, -1 }, { 1, 1 } },
+ energy_source = {
+ type = "electric",
+ buffer_capacity = "5.4PW",
+ usage_priority = "tertiary",
+ input_flow_limit = "0W",
+ output_flow_limit = "5.4PW",
+ },
+ energy_production = "5.4PW",
+ gui_mode = "none",
+ picture = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/passive-energy-source.png",
+ priority = "extra-high",
+ width = 124,
+ height = 103,
+ shift = { 0.6875, -0.203125 },
+ },
+ charge_animation = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/passive-energy-source-working.png",
+ width = 147,
+ height = 128,
+ line_length = 8,
+ frame_count = 24,
+ shift = { 0.390625, -0.53125 },
+ animation_speed = 0.5,
+ },
+ charge_cooldown = 30,
+ charge_light = {
+ intensity = 0.3,
+ size = 7,
+ },
+ discharge_animation = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/passive-energy-source-working.png",
+ width = 147,
+ height = 128,
+ line_length = 8,
+ frame_count = 24,
+ shift = { 0.390625, -0.53125 },
+ animation_speed = 0.5,
+ },
+ discharge_cooldown = 60,
+ discharge_light = {
+ intensity = 0.7,
+ size = 7,
+ },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ working_sound = {
+ sound = {
+ filename = "__base__/sound/accumulator-working.ogg",
+ volume = 1,
+ },
+ idle_sound = {
+ filename = "__base__/sound/accumulator-idle.ogg",
+ volume = 0.4,
+ },
+ max_sounds_per_type = 5,
+ },
+ se_allow_in_space = true,
+ },
+ -- Energy void
+ {
+ type = "assembling-machine",
+ name = creative_mode_defines.names.entities.energy_void,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-void.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.energy_void,
+ },
+ max_health = 150,
+ corpse = "medium-remnants",
+ fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.energy_source_void,
+ collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
+ selection_box = { { -1, -1 }, { 1, 1 } },
+ fluid_boxes = {},
+ animation = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/energy-void.png",
+ priority = "high",
+ width = 124,
+ height = 103,
+ frame_count = 1,
+ line_length = 1,
+ shift = { 0.6875, -0.203125 },
+ },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ open_sound = {
+ filename = "__base__/sound/machine-open.ogg",
+ volume = 0.85,
+ },
+ close_sound = {
+ filename = "__base__/sound/machine-close.ogg",
+ volume = 0.75,
+ },
+ working_sound = {
+ sound = {
+ filename = "__base__/sound/accumulator-working.ogg",
+ volume = 1,
+ },
+ idle_sound = {
+ filename = "__base__/sound/accumulator-idle.ogg",
+ volume = 0.4,
+ },
+ apparent_volume = 1.5,
+ },
+ crafting_categories = { creative_mode_defines.names.recipe_categories.energy_absorption },
+ fixed_recipe = creative_mode_defines.names.recipes.energy_absorption,
+ show_recipe_icon = false,
+ show_recipe_icon_on_map = false,
+ crafting_speed = 0.01,
+ energy_source = {
+ type = "electric",
+ usage_priority = "secondary-input",
+ emissions_per_minute = { pollution = 0 },
+ },
+ energy_usage = "5.4PW",
+ ingredient_count = 0,
+ module_specification = {},
+ allowed_effects = { "pollution" },
+ se_allow_in_space = true,
+ },
+ -- Passive energy void
+ {
+ type = "assembling-machine",
+ name = creative_mode_defines.names.entities.passive_energy_void,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-energy-void.png",
+ flags = { "placeable-neutral", "player-creation" },
+ minable = {
+ hardness = 0.2,
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.passive_energy_void,
+ },
+ max_health = 150,
+ corpse = "medium-remnants",
+ fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.energy_source_void,
+ collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
+ selection_box = { { -1, -1 }, { 1, 1 } },
+ fluid_boxes = {},
+ animation = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/passive-energy-void-working.png",
+ width = 147,
+ height = 128,
+ line_length = 8,
+ frame_count = 24,
+ shift = { 0.390625, -0.53125 },
+ animation_speed = 0.5,
+ },
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ open_sound = {
+ filename = "__base__/sound/machine-open.ogg",
+ volume = 0.85,
+ },
+ close_sound = {
+ filename = "__base__/sound/machine-close.ogg",
+ volume = 0.75,
+ },
+ working_sound = {
+ sound = {
+ filename = "__base__/sound/accumulator-working.ogg",
+ volume = 1,
+ },
+ idle_sound = {
+ filename = "__base__/sound/accumulator-idle.ogg",
+ volume = 0.4,
+ },
+ apparent_volume = 1.5,
+ },
+ crafting_categories = { creative_mode_defines.names.recipe_categories.energy_absorption },
+ fixed_recipe = creative_mode_defines.names.recipes.energy_absorption,
+ show_recipe_icon = false,
+ show_recipe_icon_on_map = false,
+ crafting_speed = 0.01,
+ energy_source = {
+ type = "electric",
+ usage_priority = "tertiary",
+ emissions_per_minute = { pollution = 0 },
+ },
+ energy_usage = "5.4PW",
+ ingredient_count = 0,
+ module_specification = {},
+ allowed_effects = { "pollution" },
+ se_allow_in_space = true,
+ },
+ -- Super electric pole
+ {
+ type = "electric-pole",
+ name = creative_mode_defines.names.entities.super_electric_pole,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-electric-pole.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.super_electric_pole,
+ },
+ max_health = 150,
+ corpse = "medium-remnants",
+ resistances = { {
+ type = "fire",
+ percent = 100,
+ } },
+ collision_box = { { -0.65, -0.65 }, { 0.65, 0.65 } },
+ selection_box = { { -1, -1 }, { 1, 1 } },
+ drawing_box = { { -1, -3 }, { 1, 0.5 } },
+ maximum_wire_distance = 64,
+ supply_area_distance = 2,
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ pictures = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-electric-pole.png",
+ priority = "high",
+ width = 168,
+ height = 165,
+ direction_count = 4,
+ shift = { 1.6, -1.1 },
+ },
+ connection_points = {
+ {
+ shadow = {
+ copper = { 2.7, 0 },
+ green = { 1.8, 0 },
+ red = { 3.6, 0 },
+ },
+ wire = {
+ copper = { 0, -3.125 },
+ green = { -0.59375, -3.125 },
+ red = { 0.625, -3.125 },
},
- max_health = 150,
- corpse = "medium-remnants",
- fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.energy_source_void,
- collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
- selection_box = { { -1, -1 }, { 1, 1 } },
- fluid_boxes = {},
- animation = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/energy-void.png",
- priority = "high",
- width = 124,
- height = 103,
- frame_count = 1,
- line_length = 1,
- shift = { 0.6875, -0.203125 }
+ },
+ {
+ shadow = {
+ copper = { 3.1, 0.2 },
+ green = { 2.3, -0.3 },
+ red = { 3.8, 0.6 },
},
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
+ wire = {
+ copper = { -0.0625, -3.125 },
+ green = { -0.5, -3.4375 },
+ red = { 0.34375, -2.8125 },
},
- open_sound = {
- filename = "__base__/sound/machine-open.ogg",
- volume = 0.85
+ },
+ {
+ shadow = {
+ copper = { 2.9, 0.06 },
+ green = { 3.0, -0.6 },
+ red = { 3.0, 0.8 },
},
- close_sound = {
- filename = "__base__/sound/machine-close.ogg",
- volume = 0.75
+ wire = {
+ copper = { -0.09375, -3.09375 },
+ green = { -0.09375, -3.53125 },
+ red = { -0.09375, -2.65625 },
},
- working_sound = {
- sound = {
- filename = "__base__/sound/accumulator-working.ogg",
- volume = 1
- },
- idle_sound = {
- filename = "__base__/sound/accumulator-idle.ogg",
- volume = 0.4
- },
- apparent_volume = 1.5
+ },
+ {
+ shadow = {
+ copper = { 3.1, 0.2 },
+ green = { 3.8, -0.3 },
+ red = { 2.35, 0.6 },
},
- crafting_categories = { creative_mode_defines.names.recipe_categories.energy_absorption },
- fixed_recipe = creative_mode_defines.names.recipes.energy_absorption,
- show_recipe_icon = false,
- show_recipe_icon_on_map = false,
- crafting_speed = 0.01,
- energy_source = {
- type = "electric",
- usage_priority = "secondary-input",
- emissions_per_minute = { pollution = 0 }
+ wire = {
+ copper = { -0.0625, -3.1875 },
+ green = { 0.375, -3.5 },
+ red = { -0.46875, -2.90625 },
},
- energy_usage = "5.4PW",
- ingredient_count = 0,
- module_specification = {},
- allowed_effects = { "pollution" },
- se_allow_in_space = true
+ },
},
- -- Passive energy void
- {
- type = "assembling-machine",
- name = creative_mode_defines.names.entities.passive_energy_void,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-energy-void.png",
- flags = { "placeable-neutral", "player-creation" },
- minable = {
- hardness = 0.2,
- mining_time = 0.5,
- result = creative_mode_defines.names.items.passive_energy_void
+ radius_visualisation_picture = {
+ filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png",
+ width = 12,
+ height = 12,
+ priority = "extra-high-no-scale",
+ },
+ se_allow_in_space = true,
+ },
+ -- Super substation
+ {
+ type = "electric-pole",
+ name = creative_mode_defines.names.entities.super_substation,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-substation.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.super_substation,
+ },
+ max_health = 200,
+ corpse = "medium-remnants",
+ track_coverage_during_build_by_moving = true,
+ resistances = { {
+ type = "fire",
+ percent = 90,
+ } },
+ collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
+ selection_box = { { -1, -1 }, { 1, 1 } },
+ drawing_box = { { -1, -3 }, { 1, 1 } },
+ maximum_wire_distance = 64,
+ supply_area_distance = 64,
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ pictures = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-substation.png",
+ priority = "high",
+ width = 132,
+ height = 144,
+ direction_count = 4,
+ shift = { 0.9, -1 },
+ },
+ connection_points = {
+ {
+ shadow = {
+ copper = { 1.9, -0.6 },
+ green = { 1.3, -0.6 },
+ red = { 2.65, -0.6 },
+ },
+ wire = {
+ copper = { -0.25, -2.71875 },
+ green = { -0.84375, -2.71875 },
+ red = { 0.34375, -2.71875 },
},
- max_health = 150,
- corpse = "medium-remnants",
- fast_replaceable_group = creative_mode_defines.names.fast_replaceable_groups.energy_source_void,
- collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
- selection_box = { { -1, -1 }, { 1, 1 } },
- fluid_boxes = {},
- animation = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/passive-energy-void-working.png",
- width = 147,
- height = 128,
- line_length = 8,
- frame_count = 24,
- shift = { 0.390625, -0.53125 },
- animation_speed = 0.5
+ },
+ {
+ shadow = {
+ copper = { 1.9, -0.6 },
+ green = { 1.2, -0.8 },
+ red = { 2.5, -0.35 },
},
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
+ wire = {
+ copper = { -0.21875, -2.71875 },
+ green = { -0.65625, -3.03125 },
+ red = { 0.1875, -2.4375 },
},
- open_sound = {
- filename = "__base__/sound/machine-open.ogg",
- volume = 0.85
+ },
+ {
+ shadow = {
+ copper = { 1.9, -0.6 },
+ green = { 1.9, -0.9 },
+ red = { 1.9, -0.3 },
},
- close_sound = {
- filename = "__base__/sound/machine-close.ogg",
- volume = 0.75
+ wire = {
+ copper = { -0.21875, -2.71875 },
+ green = { -0.21875, -3.15625 },
+ red = { -0.21875, -2.34375 },
},
- working_sound = {
- sound = {
- filename = "__base__/sound/accumulator-working.ogg",
- volume = 1
- },
- idle_sound = {
- filename = "__base__/sound/accumulator-idle.ogg",
- volume = 0.4
- },
- apparent_volume = 1.5
+ },
+ {
+ shadow = {
+ copper = { 1.8, -0.7 },
+ green = { 1.3, -0.6 },
+ red = { 2.4, -1.15 },
},
- crafting_categories = { creative_mode_defines.names.recipe_categories.energy_absorption },
- fixed_recipe = creative_mode_defines.names.recipes.energy_absorption,
- show_recipe_icon = false,
- show_recipe_icon_on_map = false,
- crafting_speed = 0.01,
- energy_source = {
- type = "electric",
- usage_priority = "tertiary",
- emissions_per_minute = { pollution = 0 }
+ wire = {
+ copper = { -0.21875, -2.75 },
+ green = { -0.65625, -2.4375 },
+ red = { 0.1875, -3.03125 },
},
- energy_usage = "5.4PW",
- ingredient_count = 0,
- module_specification = {},
- allowed_effects = { "pollution" },
- se_allow_in_space = true
+ },
},
- -- Super electric pole
- {
- type = "electric-pole",
- name = creative_mode_defines.names.entities.super_electric_pole,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-electric-pole.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.super_electric_pole
- },
- max_health = 150,
- corpse = "medium-remnants",
- resistances = { {
- type = "fire",
- percent = 100
- } },
- collision_box = { { -0.65, -0.65 }, { 0.65, 0.65 } },
- selection_box = { { -1, -1 }, { 1, 1 } },
- drawing_box = { { -1, -3 }, { 1, 0.5 } },
- maximum_wire_distance = 64,
- supply_area_distance = 2,
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- pictures = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-electric-pole.png",
- priority = "high",
- width = 168,
- height = 165,
- direction_count = 4,
- shift = { 1.6, -1.1 }
- },
- connection_points = { {
- shadow = {
- copper = { 2.7, 0 },
- green = { 1.8, 0 },
- red = { 3.6, 0 }
- },
- wire = {
- copper = { 0, -3.125 },
- green = { -0.59375, -3.125 },
- red = { 0.625, -3.125 }
- }
- }, {
- shadow = {
- copper = { 3.1, 0.2 },
- green = { 2.3, -0.3 },
- red = { 3.8, 0.6 }
- },
- wire = {
- copper = { -0.0625, -3.125 },
- green = { -0.5, -3.4375 },
- red = { 0.34375, -2.8125 }
- }
- }, {
- shadow = {
- copper = { 2.9, 0.06 },
- green = { 3.0, -0.6 },
- red = { 3.0, 0.8 }
- },
- wire = {
- copper = { -0.09375, -3.09375 },
- green = { -0.09375, -3.53125 },
- red = { -0.09375, -2.65625 }
- }
- }, {
- shadow = {
- copper = { 3.1, 0.2 },
- green = { 3.8, -0.3 },
- red = { 2.35, 0.6 }
- },
- wire = {
- copper = { -0.0625, -3.1875 },
- green = { 0.375, -3.5 },
- red = { -0.46875, -2.90625 }
- }
- } },
- radius_visualisation_picture = {
- filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png",
- width = 12,
- height = 12,
- priority = "extra-high-no-scale"
- },
- se_allow_in_space = true
+ radius_visualisation_picture = {
+ filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png",
+ width = 12,
+ height = 12,
+ priority = "extra-high-no-scale",
},
- -- Super substation
- {
- type = "electric-pole",
- name = creative_mode_defines.names.entities.super_substation,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-substation.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.super_substation
- },
- max_health = 200,
- corpse = "medium-remnants",
- track_coverage_during_build_by_moving = true,
- resistances = { {
- type = "fire",
- percent = 90
- } },
- collision_box = { { -0.9, -0.9 }, { 0.9, 0.9 } },
- selection_box = { { -1, -1 }, { 1, 1 } },
- drawing_box = { { -1, -3 }, { 1, 1 } },
- maximum_wire_distance = 64,
- supply_area_distance = 64,
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- pictures = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-substation.png",
- priority = "high",
- width = 132,
- height = 144,
- direction_count = 4,
- shift = { 0.9, -1 }
- },
- connection_points = { {
- shadow = {
- copper = { 1.9, -0.6 },
- green = { 1.3, -0.6 },
- red = { 2.65, -0.6 }
- },
- wire = {
- copper = { -0.25, -2.71875 },
- green = { -0.84375, -2.71875 },
- red = { 0.34375, -2.71875 }
- }
- }, {
- shadow = {
- copper = { 1.9, -0.6 },
- green = { 1.2, -0.8 },
- red = { 2.5, -0.35 }
- },
- wire = {
- copper = { -0.21875, -2.71875 },
- green = { -0.65625, -3.03125 },
- red = { 0.1875, -2.4375 }
- }
- }, {
- shadow = {
- copper = { 1.9, -0.6 },
- green = { 1.9, -0.9 },
- red = { 1.9, -0.3 }
- },
- wire = {
- copper = { -0.21875, -2.71875 },
- green = { -0.21875, -3.15625 },
- red = { -0.21875, -2.34375 }
- }
- }, {
- shadow = {
- copper = { 1.8, -0.7 },
- green = { 1.3, -0.6 },
- red = { 2.4, -1.15 }
- },
- wire = {
- copper = { -0.21875, -2.75 },
- green = { -0.65625, -2.4375 },
- red = { 0.1875, -3.03125 }
- }
- } },
- radius_visualisation_picture = {
- filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png",
- width = 12,
- height = 12,
- priority = "extra-high-no-scale"
- },
- se_allow_in_space = true
- }, magic_wand_smoke(creative_mode_defines.names.entities.magic_wand_smoke_creator, {
+ se_allow_in_space = true,
+ },
+ magic_wand_smoke(creative_mode_defines.names.entities.magic_wand_smoke_creator, {
r = 1,
g = 0,
b = 0,
- a = 0.4
-}), magic_wand_smoke(creative_mode_defines.names.entities.magic_wand_smoke_healer, {
+ a = 0.4,
+ }),
+ magic_wand_smoke(creative_mode_defines.names.entities.magic_wand_smoke_healer, {
r = 0,
g = 1,
b = 0,
- a = 0.4
-}), magic_wand_smoke(creative_mode_defines.names.entities.magic_wand_smoke_modifier, {
+ a = 0.4,
+ }),
+ magic_wand_smoke(creative_mode_defines.names.entities.magic_wand_smoke_modifier, {
r = 0.5,
g = 0,
b = 1,
- a = 0.4
-}),
- -- Super radar
- radar(creative_mode_defines.names.entities.super_radar, creative_mode_defines.names.items.super_radar,
- "super-radar.png", "super-radar.png", 14),
- -- Super radar MK2
- radar(creative_mode_defines.names.entities.super_radar_2, creative_mode_defines.names.items.super_radar_2,
- "super-radar-2.png", "super-radar-2.png", 50),
- -- Alien attractor proxy - small
- alien_attractor_proxy(creative_mode_defines.names.entities.alien_attractor_proxy_small, 0.1),
- -- Alien attractor proxy - medium
- alien_attractor_proxy(creative_mode_defines.names.entities.alien_attractor_proxy_medium, 0.25),
- -- Alien attractor proxy - large
- alien_attractor_proxy(creative_mode_defines.names.entities.alien_attractor_proxy_large, 0.5),
- -- Super Beacon
- {
- type = "beacon",
- name = creative_mode_defines.names.entities.super_beacon,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-beacon.png",
- flags = { "placeable-player", "player-creation" },
- minable = {
- mining_time = 0.5,
- result = creative_mode_defines.names.items.super_beacon
- },
- max_health = 200,
- corpse = "big-remnants",
- dying_explosion = "medium-explosion",
- collision_box = { { -1.2, -1.2 }, { 1.2, 1.2 } },
- selection_box = { { -1.5, -1.5 }, { 1.5, 1.5 } },
- allowed_effects = { "consumption", "speed", "pollution", "productivity" },
- base_picture = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-beacon-base.png",
- width = 116,
- height = 93,
- shift = { 0.34375, 0.046875 }
- },
- animation = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-beacon-antenna.png",
- width = 54,
- height = 50,
- line_length = 8,
- frame_count = 32,
- shift = { -0.03125, -1.71875 },
- animation_speed = 0.5
- },
- animation_shadow = {
- filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-beacon-antenna-shadow.png",
- width = 63,
- height = 49,
- line_length = 8,
- frame_count = 32,
- shift = { 3.140625, 0.484375 },
- animation_speed = 0.5
- },
- radius_visualisation_picture = {
- filename = "__base__/graphics/entity/beacon/beacon-radius-visualization.png",
- priority = "extra-high-no-scale",
- width = 10,
- height = 10
- },
- supply_area_distance = 64,
- energy_source = creative_mode_defines.non_electric_energy_source,
- energy_usage = "1kW",
- vehicle_impact_sound = {
- filename = "__base__/sound/car-metal-impact.ogg",
- volume = 0.65
- },
- distribution_effectivity = 0.5,
- module_slots = 7,
- module_info_icon_shift = { 0, 0.5 },
- module_info_multi_row_initial_height_modifier = -0.3,
- se_allow_in_space = true
- }
-
+ a = 0.4,
+ }),
+ -- Super radar
+ radar(
+ creative_mode_defines.names.entities.super_radar,
+ creative_mode_defines.names.items.super_radar,
+ "super-radar.png",
+ "super-radar.png",
+ 14
+ ),
+ -- Super radar MK2
+ radar(
+ creative_mode_defines.names.entities.super_radar_2,
+ creative_mode_defines.names.items.super_radar_2,
+ "super-radar-2.png",
+ "super-radar-2.png",
+ 50
+ ),
+ -- Alien attractor proxy - small
+ alien_attractor_proxy(creative_mode_defines.names.entities.alien_attractor_proxy_small, 0.1),
+ -- Alien attractor proxy - medium
+ alien_attractor_proxy(creative_mode_defines.names.entities.alien_attractor_proxy_medium, 0.25),
+ -- Alien attractor proxy - large
+ alien_attractor_proxy(creative_mode_defines.names.entities.alien_attractor_proxy_large, 0.5),
+ -- Super Beacon
+ {
+ type = "beacon",
+ name = creative_mode_defines.names.entities.super_beacon,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-beacon.png",
+ flags = { "placeable-player", "player-creation" },
+ minable = {
+ mining_time = 0.5,
+ result = creative_mode_defines.names.items.super_beacon,
+ },
+ max_health = 200,
+ corpse = "big-remnants",
+ dying_explosion = "medium-explosion",
+ collision_box = { { -1.2, -1.2 }, { 1.2, 1.2 } },
+ selection_box = { { -1.5, -1.5 }, { 1.5, 1.5 } },
+ allowed_effects = { "consumption", "speed", "pollution", "productivity" },
+ base_picture = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-beacon-base.png",
+ width = 116,
+ height = 93,
+ shift = { 0.34375, 0.046875 },
+ },
+ animation = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-beacon-antenna.png",
+ width = 54,
+ height = 50,
+ line_length = 8,
+ frame_count = 32,
+ shift = { -0.03125, -1.71875 },
+ animation_speed = 0.5,
+ },
+ animation_shadow = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/entity/super-beacon-antenna-shadow.png",
+ width = 63,
+ height = 49,
+ line_length = 8,
+ frame_count = 32,
+ shift = { 3.140625, 0.484375 },
+ animation_speed = 0.5,
+ },
+ radius_visualisation_picture = {
+ filename = "__base__/graphics/entity/beacon/beacon-radius-visualization.png",
+ priority = "extra-high-no-scale",
+ width = 10,
+ height = 10,
+ },
+ supply_area_distance = 64,
+ energy_source = creative_mode_defines.non_electric_energy_source,
+ energy_usage = "1kW",
+ vehicle_impact_sound = {
+ filename = "__base__/sound/car-metal-impact.ogg",
+ volume = 0.65,
+ },
+ distribution_effectivity = 0.5,
+ module_slots = 7,
+ module_info_icon_shift = { 0, 0.5 },
+ module_info_multi_row_initial_height_modifier = -0.3,
+ se_allow_in_space = true,
+ },
})
-
-- Vanilla infinity chest already exists but has no description, so we add one.
data.raw["infinity-container"]["infinity-chest"].localised_description = { "entity-description.infinity-chest" }
-- It also needs it's gui mode set to match our setting.
-data.raw["infinity-container"]["infinity-chest"].gui_mode = settings.startup
-[creative_mode_defines.names.settings.infinity_chest_control].value
+data.raw["infinity-container"]["infinity-chest"].gui_mode =
+ settings.startup[creative_mode_defines.names.settings.infinity_chest_control].value
diff --git a/prototypes/equipment.lua b/prototypes/equipment.lua
index 57fdfc0..9dbd5ec 100644
--- a/prototypes/equipment.lua
+++ b/prototypes/equipment.lua
@@ -1,67 +1,67 @@
-data:extend {
- {
- -- Super fusion reactor requipment
- type = "generator-equipment",
- name = creative_mode_defines.names.equipments.super_fusion_reactor_equipment,
- sprite = {
- filename = creative_mode_defines.mod_directory .. "/graphics/equipment/super-fusion-reactor-equipment.png",
- width = 32,
- height = 32,
- priority = "medium"
- },
- shape = {
- width = 1,
- height = 1,
- type = "full"
- },
- energy_source = {
- type = "electric",
- usage_priority = "primary-output"
- },
- power = "5.4PW",
- categories = {"armor"}
- },
- {
- -- Super personal roboport equipment
- type = "roboport-equipment",
- name = creative_mode_defines.names.equipments.super_personal_roboport_equipment,
- sprite = {
- filename = creative_mode_defines.mod_directory .. "/graphics/equipment/super-personal-roboport-equipment.png",
- width = 32,
- height = 32,
- priority = "medium"
- },
- shape = {
- width = 1,
- height = 1,
- type = "full"
- },
- energy_source = {
- type = "electric",
- buffer_capacity = "100PJ",
- usage_priority = "secondary-input"
- },
- charging_energy = "40MJ",
- energy_consumption = "1W",
- robot_limit = 1000,
- construction_radius = 200,
- spawn_and_station_height = 0.4,
- charge_approach_distance = 2.6,
- recharging_animation = {
- filename = "__base__/graphics/entity/roboport/roboport-recharging.png",
- priority = "high",
- width = 37,
- height = 35,
- frame_count = 16,
- scale = 1.5,
- animation_speed = 0.5
- },
- recharging_light = {intensity = 0.4, size = 5},
- stationing_offset = {0, -0.6},
- charging_station_shift = {0, 0.5},
- charging_station_count = 1000,
- charging_distance = 1.6,
- charging_threshold_distance = 5,
- categories = {"armor"}
- }
-}
+data:extend({
+ {
+ -- Super fusion reactor requipment
+ type = "generator-equipment",
+ name = creative_mode_defines.names.equipments.super_fusion_reactor_equipment,
+ sprite = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/equipment/super-fusion-reactor-equipment.png",
+ width = 32,
+ height = 32,
+ priority = "medium",
+ },
+ shape = {
+ width = 1,
+ height = 1,
+ type = "full",
+ },
+ energy_source = {
+ type = "electric",
+ usage_priority = "primary-output",
+ },
+ power = "5.4PW",
+ categories = { "armor" },
+ },
+ {
+ -- Super personal roboport equipment
+ type = "roboport-equipment",
+ name = creative_mode_defines.names.equipments.super_personal_roboport_equipment,
+ sprite = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/equipment/super-personal-roboport-equipment.png",
+ width = 32,
+ height = 32,
+ priority = "medium",
+ },
+ shape = {
+ width = 1,
+ height = 1,
+ type = "full",
+ },
+ energy_source = {
+ type = "electric",
+ buffer_capacity = "100PJ",
+ usage_priority = "secondary-input",
+ },
+ charging_energy = "40MJ",
+ energy_consumption = "1W",
+ robot_limit = 1000,
+ construction_radius = 200,
+ spawn_and_station_height = 0.4,
+ charge_approach_distance = 2.6,
+ recharging_animation = {
+ filename = "__base__/graphics/entity/roboport/roboport-recharging.png",
+ priority = "high",
+ width = 37,
+ height = 35,
+ frame_count = 16,
+ scale = 1.5,
+ animation_speed = 0.5,
+ },
+ recharging_light = { intensity = 0.4, size = 5 },
+ stationing_offset = { 0, -0.6 },
+ charging_station_shift = { 0, 0.5 },
+ charging_station_count = 1000,
+ charging_distance = 1.6,
+ charging_threshold_distance = 5,
+ categories = { "armor" },
+ },
+})
diff --git a/prototypes/item-group.lua b/prototypes/item-group.lua
index 9266da9..288ad4b 100644
--- a/prototypes/item-group.lua
+++ b/prototypes/item-group.lua
@@ -1,82 +1,80 @@
-data:extend(
- {
- {
- -- Creative tools
- type = "item-group",
- name = creative_mode_defines.names.item_groups.creative_tools,
- order = "zzz",
- icon = creative_mode_defines.mod_directory .. "/graphics/item-group/creative-tools.png",
- icon_size = 64
- },
- {
- -- Creative tools / Items
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.items,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "a"
- },
- {
- -- Creative tools / Vehicles
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.vehicles,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "b"
- },
- {
- -- Creative tools / Fluids
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.fluids,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "c"
- },
- {
- -- Creative tools / Advanced
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.advanced,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "d"
- },
- {
- -- Creative tools / Energy
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.energy,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "e"
- },
- {
- -- Creative tools / Magic wands
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.magic_wands,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "f"
- },
- {
- -- Creative tools / Enemies
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.enemies,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "g"
- },
- {
- -- Creative tools / Modules
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.modules,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "h"
- },
- {
- -- Creative tools / Equipments
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.equipments,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "i"
- },
- {
- -- Creative tools / Free fluids
- type = "item-subgroup",
- name = creative_mode_defines.names.item_subgroups.free_fluids,
- group = creative_mode_defines.names.item_groups.creative_tools,
- order = "j"
- }
- }
-)
+data:extend({
+ {
+ -- Creative tools
+ type = "item-group",
+ name = creative_mode_defines.names.item_groups.creative_tools,
+ order = "zzz",
+ icon = creative_mode_defines.mod_directory .. "/graphics/item-group/creative-tools.png",
+ icon_size = 64,
+ },
+ {
+ -- Creative tools / Items
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.items,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "a",
+ },
+ {
+ -- Creative tools / Vehicles
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.vehicles,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "b",
+ },
+ {
+ -- Creative tools / Fluids
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.fluids,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "c",
+ },
+ {
+ -- Creative tools / Advanced
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.advanced,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "d",
+ },
+ {
+ -- Creative tools / Energy
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.energy,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "e",
+ },
+ {
+ -- Creative tools / Magic wands
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.magic_wands,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "f",
+ },
+ {
+ -- Creative tools / Enemies
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.enemies,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "g",
+ },
+ {
+ -- Creative tools / Modules
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.modules,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "h",
+ },
+ {
+ -- Creative tools / Equipments
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.equipments,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "i",
+ },
+ {
+ -- Creative tools / Free fluids
+ type = "item-subgroup",
+ name = creative_mode_defines.names.item_subgroups.free_fluids,
+ group = creative_mode_defines.names.item_groups.creative_tools,
+ order = "j",
+ },
+})
diff --git a/prototypes/item.lua b/prototypes/item.lua
index 66eaa2b..3058894 100644
--- a/prototypes/item.lua
+++ b/prototypes/item.lua
@@ -1,863 +1,861 @@
hidden = false
if not settings.startup[creative_mode_defines.names.settings.unhide_items].value then
- hidden = true
+ hidden = true
end
-data:extend(
- {
- -- The items are hidden so they are not shown on the logistic slots when Creative Mode is not enabled.
- -- Currently there is no way to unhide them.
- {
- -- Creative chest
- type = "item",
- name = creative_mode_defines.names.items.creative_chest,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/creative-chest.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "a3",
- place_result = creative_mode_defines.names.entities.new_creative_chest,
- stack_size = 50
- },
- {
- -- Creative provider chest
- type = "item",
- name = creative_mode_defines.names.items.creative_provider_chest,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/creative-provider-chest.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "b",
- place_result = creative_mode_defines.names.entities.new_creative_provider_chest,
- stack_size = 50
- },
- {
- -- Autofill requester chest
- type = "item",
- name = creative_mode_defines.names.items.autofill_requester_chest,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/autofill-requester-chest.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "c",
- place_result = creative_mode_defines.names.entities.new_autofill_requester_chest,
- stack_size = 50
- },
- {
- -- Infinity Requester Chest
- type = "item",
- name = creative_mode_defines.names.items.inf_requester_chest,
- icons= {
- {
- icon = "__base__/graphics/icons/infinity-chest.png",
- icon_mipmaps = 4,
- icon_size = 64,
- tint = {a=1,b=.9}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "a1",
- place_result = creative_mode_defines.names.entities.inf_requester_chest,
- stack_size = 50
- },
- {
- -- Infinity Provider Chest
- type = "item",
- name = creative_mode_defines.names.items.inf_provider_chest,
- icons= {
- {
- icon = "__base__/graphics/icons/infinity-chest.png",
- icon_mipmaps = 4,
- icon_size = 64,
- tint = {a=1,r=0.7}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "a2",
- place_result = creative_mode_defines.names.entities.inf_provider_chest,
- stack_size = 50
- },
- {
- -- Duplicating chest
- type = "item",
- name = creative_mode_defines.names.items.duplicating_chest,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/duplicating-chest.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "d",
- place_result = creative_mode_defines.names.entities.duplicating_chest,
- stack_size = 50
- },
- {
- -- Duplicating provider chest
- type = "item",
- name = creative_mode_defines.names.items.duplicating_provider_chest,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/duplicating-provider-chest.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "e",
- place_result = creative_mode_defines.names.entities.duplicating_provider_chest,
- stack_size = 50
- },
- {
- -- Void chest
- type = "item",
- name = creative_mode_defines.names.items.void_chest,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/void-chest.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "f",
- place_result = creative_mode_defines.names.entities.void_chest,
- stack_size = 50
- },
- {
- -- Void requester chest
- type = "item",
- name = creative_mode_defines.names.items.void_requester_chest,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/void-requester-chest.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "g",
- place_result = creative_mode_defines.names.entities.void_requester_chest,
- stack_size = 50
- },
- {
- -- Void storage chest
- type = "item",
- name = creative_mode_defines.names.items.void_storage_chest,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/void-storage-chest.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "h",
- place_result = creative_mode_defines.names.entities.void_storage_chest,
- stack_size = 50
- },
- {
- -- Super loader
- type = "item",
- name = creative_mode_defines.names.items.super_loader,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "i",
- place_result = creative_mode_defines.names.entities.super_loader,
- stack_size = 50
- },
- {
- -- Super loader 2
- type = "item",
- name = creative_mode_defines.names.items.super_loader2,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "i1",
- place_result = creative_mode_defines.names.entities.super_loader2,
- stack_size = 50
- },
- {
- -- Linked Chest
- type = "item",
- name = creative_mode_defines.names.items.linked_chest,
- icon_size = data.raw.item["linked-chest"].icon_size,
- icon = data.raw.item["linked-chest"].icon,
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "a5",
- place_result = creative_mode_defines.names.entities.linked_chest,
- stack_size = 50
- },
- {
- -- Linked Belt
- type = "item",
- name = creative_mode_defines.names.items.linked_belt,
- icon_size = data.raw.item["linked-belt"].icon_size,
- icon = data.raw.item["linked-belt"].icon,
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- order = "i2",
- place_result = creative_mode_defines.names.entities.linked_belt,
- stack_size = 50
- },
- -----------------------------------------------------------------------------
+data:extend({
+ -- The items are hidden so they are not shown on the logistic slots when Creative Mode is not enabled.
+ -- Currently there is no way to unhide them.
+ {
+ -- Creative chest
+ type = "item",
+ name = creative_mode_defines.names.items.creative_chest,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/creative-chest.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "a3",
+ place_result = creative_mode_defines.names.entities.new_creative_chest,
+ stack_size = 50,
+ },
+ {
+ -- Creative provider chest
+ type = "item",
+ name = creative_mode_defines.names.items.creative_provider_chest,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/creative-provider-chest.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "b",
+ place_result = creative_mode_defines.names.entities.new_creative_provider_chest,
+ stack_size = 50,
+ },
+ {
+ -- Autofill requester chest
+ type = "item",
+ name = creative_mode_defines.names.items.autofill_requester_chest,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/autofill-requester-chest.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "c",
+ place_result = creative_mode_defines.names.entities.new_autofill_requester_chest,
+ stack_size = 50,
+ },
+ {
+ -- Infinity Requester Chest
+ type = "item",
+ name = creative_mode_defines.names.items.inf_requester_chest,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/infinity-chest.png",
+ icon_mipmaps = 4,
+ icon_size = 64,
+ tint = { a = 1, b = 0.9 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "a1",
+ place_result = creative_mode_defines.names.entities.inf_requester_chest,
+ stack_size = 50,
+ },
+ {
+ -- Infinity Provider Chest
+ type = "item",
+ name = creative_mode_defines.names.items.inf_provider_chest,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/infinity-chest.png",
+ icon_mipmaps = 4,
+ icon_size = 64,
+ tint = { a = 1, r = 0.7 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "a2",
+ place_result = creative_mode_defines.names.entities.inf_provider_chest,
+ stack_size = 50,
+ },
+ {
+ -- Duplicating chest
+ type = "item",
+ name = creative_mode_defines.names.items.duplicating_chest,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/duplicating-chest.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "d",
+ place_result = creative_mode_defines.names.entities.duplicating_chest,
+ stack_size = 50,
+ },
+ {
+ -- Duplicating provider chest
+ type = "item",
+ name = creative_mode_defines.names.items.duplicating_provider_chest,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/duplicating-provider-chest.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "e",
+ place_result = creative_mode_defines.names.entities.duplicating_provider_chest,
+ stack_size = 50,
+ },
+ {
+ -- Void chest
+ type = "item",
+ name = creative_mode_defines.names.items.void_chest,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/void-chest.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "f",
+ place_result = creative_mode_defines.names.entities.void_chest,
+ stack_size = 50,
+ },
+ {
+ -- Void requester chest
+ type = "item",
+ name = creative_mode_defines.names.items.void_requester_chest,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/void-requester-chest.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "g",
+ place_result = creative_mode_defines.names.entities.void_requester_chest,
+ stack_size = 50,
+ },
+ {
+ -- Void storage chest
+ type = "item",
+ name = creative_mode_defines.names.items.void_storage_chest,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/void-storage-chest.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "h",
+ place_result = creative_mode_defines.names.entities.void_storage_chest,
+ stack_size = 50,
+ },
+ {
+ -- Super loader
+ type = "item",
+ name = creative_mode_defines.names.items.super_loader,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "i",
+ place_result = creative_mode_defines.names.entities.super_loader,
+ stack_size = 50,
+ },
+ {
+ -- Super loader 2
+ type = "item",
+ name = creative_mode_defines.names.items.super_loader2,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-loader.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "i1",
+ place_result = creative_mode_defines.names.entities.super_loader2,
+ stack_size = 50,
+ },
+ {
+ -- Linked Chest
+ type = "item",
+ name = creative_mode_defines.names.items.linked_chest,
+ icon_size = data.raw.item["linked-chest"].icon_size,
+ icon = data.raw.item["linked-chest"].icon,
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "a5",
+ place_result = creative_mode_defines.names.entities.linked_chest,
+ stack_size = 50,
+ },
+ {
+ -- Linked Belt
+ type = "item",
+ name = creative_mode_defines.names.items.linked_belt,
+ icon_size = data.raw.item["linked-belt"].icon_size,
+ icon = data.raw.item["linked-belt"].icon,
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ order = "i2",
+ place_result = creative_mode_defines.names.entities.linked_belt,
+ stack_size = 50,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Creative cargo wagon
- type = "item",
- name = creative_mode_defines.names.items.creative_cargo_wagon,
- icon_size = 64,
- icon_mipmaps = 4,
- icons = {
- {
- icon = "__base__/graphics/icons/cargo-wagon.png",
- tint = {r = 1, g = 0.3, b = 0.3}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.vehicles,
- order = "a",
- place_result = creative_mode_defines.names.entities.creative_cargo_wagon,
- stack_size = 50
- },
- {
- -- Duplicating cargo wagon
- type = "item",
- name = creative_mode_defines.names.items.duplicating_cargo_wagon,
- icon_size = 64,
- icon_mipmaps = 4,
- icons = {
- {
- icon = "__base__/graphics/icons/cargo-wagon.png",
- tint = {r = 0.35, g = 0.3, b = 1}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.vehicles,
- order = "b",
- place_result = creative_mode_defines.names.entities.duplicating_cargo_wagon,
- stack_size = 50
- },
- {
- -- Void cargo wagon
- type = "item",
- name = creative_mode_defines.names.items.void_cargo_wagon,
- icon_size = 64,
- icon_mipmaps = 4,
- icons = {
- {
- icon = "__base__/graphics/icons/cargo-wagon.png",
- tint = {r = 0.4, g = 0.4, b = 0.4}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.vehicles,
- order = "c",
- place_result = creative_mode_defines.names.entities.void_cargo_wagon,
- stack_size = 50
- },
- {
- -- Super logistic robot.
- type = "item",
- name = creative_mode_defines.names.items.super_logistic_robot,
- icon_size = 64,
- icon_mipmaps = 4,
- icons = {
- {
- icon = "__base__/graphics/icons/logistic-robot.png",
- tint = {r = 1, g = 0.3, b = 0.3}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.vehicles,
- order = "d",
- place_result = creative_mode_defines.names.entities.super_logistic_robot,
- stack_size = 1000
- },
- {
- -- Super construction robot.
- type = "item",
- name = creative_mode_defines.names.items.super_construction_robot,
- icon_size = 64,
- icon_mipmaps = 4,
- icons = {
- {
- icon = "__base__/graphics/icons/construction-robot.png",
- tint = {r = 0.3, g = 0.3, b = 1}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.vehicles,
- order = "e",
- place_result = creative_mode_defines.names.entities.super_construction_robot,
- stack_size = 1000
- },
- {
- -- Super roboport
- type = "item",
- name = creative_mode_defines.names.items.super_roboport,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-roboport.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.vehicles,
- order = "f",
- place_result = creative_mode_defines.names.entities.super_roboport,
- stack_size = 50
- },
- -----------------------------------------------------------------------------
+ {
+ -- Creative cargo wagon
+ type = "item",
+ name = creative_mode_defines.names.items.creative_cargo_wagon,
+ icon_size = 64,
+ icon_mipmaps = 4,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/cargo-wagon.png",
+ tint = { r = 1, g = 0.3, b = 0.3 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.vehicles,
+ order = "a",
+ place_result = creative_mode_defines.names.entities.creative_cargo_wagon,
+ stack_size = 50,
+ },
+ {
+ -- Duplicating cargo wagon
+ type = "item",
+ name = creative_mode_defines.names.items.duplicating_cargo_wagon,
+ icon_size = 64,
+ icon_mipmaps = 4,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/cargo-wagon.png",
+ tint = { r = 0.35, g = 0.3, b = 1 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.vehicles,
+ order = "b",
+ place_result = creative_mode_defines.names.entities.duplicating_cargo_wagon,
+ stack_size = 50,
+ },
+ {
+ -- Void cargo wagon
+ type = "item",
+ name = creative_mode_defines.names.items.void_cargo_wagon,
+ icon_size = 64,
+ icon_mipmaps = 4,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/cargo-wagon.png",
+ tint = { r = 0.4, g = 0.4, b = 0.4 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.vehicles,
+ order = "c",
+ place_result = creative_mode_defines.names.entities.void_cargo_wagon,
+ stack_size = 50,
+ },
+ {
+ -- Super logistic robot.
+ type = "item",
+ name = creative_mode_defines.names.items.super_logistic_robot,
+ icon_size = 64,
+ icon_mipmaps = 4,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/logistic-robot.png",
+ tint = { r = 1, g = 0.3, b = 0.3 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.vehicles,
+ order = "d",
+ place_result = creative_mode_defines.names.entities.super_logistic_robot,
+ stack_size = 1000,
+ },
+ {
+ -- Super construction robot.
+ type = "item",
+ name = creative_mode_defines.names.items.super_construction_robot,
+ icon_size = 64,
+ icon_mipmaps = 4,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/construction-robot.png",
+ tint = { r = 0.3, g = 0.3, b = 1 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.vehicles,
+ order = "e",
+ place_result = creative_mode_defines.names.entities.super_construction_robot,
+ stack_size = 1000,
+ },
+ {
+ -- Super roboport
+ type = "item",
+ name = creative_mode_defines.names.items.super_roboport,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-roboport.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.vehicles,
+ order = "f",
+ place_result = creative_mode_defines.names.entities.super_roboport,
+ stack_size = 50,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Fluid source
- type = "item",
- name = creative_mode_defines.names.items.fluid_source,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/fluid-source.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.fluids,
- order = "a",
- place_result = creative_mode_defines.names.entities.fluid_source,
- stack_size = 50
- },
- {
- -- Fluid void
- type = "item",
- name = creative_mode_defines.names.items.fluid_void,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/fluid-void.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.fluids,
- order = "b",
- place_result = creative_mode_defines.names.entities.new_fluid_void,
- stack_size = 50
- },
- {
- -- Super boiler
- type = "item",
- name = creative_mode_defines.names.items.super_boiler,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-boiler.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.fluids,
- order = "c",
- place_result = creative_mode_defines.names.entities.super_boiler,
- stack_size = 50
- },
- {
- -- Super cooler
- type = "item",
- name = creative_mode_defines.names.items.super_cooler,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-cooler.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.fluids,
- order = "d",
- place_result = creative_mode_defines.names.entities.super_cooler,
- stack_size = 50
- },
- {
- -- Configurable super boiler
- type = "item",
- name = creative_mode_defines.names.items.configurable_super_boiler,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/configurable-super-boiler.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.fluids,
- order = "e",
- place_result = creative_mode_defines.names.entities.configurable_super_boiler,
- stack_size = 50
- },
- {
- -- Heat source
- type = "item",
- name = creative_mode_defines.names.items.heat_source,
- icon_size = 64,
- icon_mipmaps = 4,
- icons = {
- {
- icon = "__base__/graphics/icons/heat-pipe.png",
- tint = {r = 1, g = 0.3, b = 0.3}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.fluids,
- order = "f",
- place_result = creative_mode_defines.names.entities.heat_source,
- stack_size = 50
- },
- {
- -- Heat void
- type = "item",
- name = creative_mode_defines.names.items.heat_void,
- icon_size = 64,
- icon_mipmaps = 4,
- icons = {
- {
- icon = "__base__/graphics/icons/heat-pipe.png",
- tint = {r = 0.2, g = 0.2, b = 0.2}
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.fluids,
- order = "g",
- place_result = creative_mode_defines.names.entities.heat_void,
- stack_size = 50
- },
- -----------------------------------------------------------------------------
+ {
+ -- Fluid source
+ type = "item",
+ name = creative_mode_defines.names.items.fluid_source,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/fluid-source.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.fluids,
+ order = "a",
+ place_result = creative_mode_defines.names.entities.fluid_source,
+ stack_size = 50,
+ },
+ {
+ -- Fluid void
+ type = "item",
+ name = creative_mode_defines.names.items.fluid_void,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/fluid-void.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.fluids,
+ order = "b",
+ place_result = creative_mode_defines.names.entities.new_fluid_void,
+ stack_size = 50,
+ },
+ {
+ -- Super boiler
+ type = "item",
+ name = creative_mode_defines.names.items.super_boiler,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-boiler.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.fluids,
+ order = "c",
+ place_result = creative_mode_defines.names.entities.super_boiler,
+ stack_size = 50,
+ },
+ {
+ -- Super cooler
+ type = "item",
+ name = creative_mode_defines.names.items.super_cooler,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-cooler.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.fluids,
+ order = "d",
+ place_result = creative_mode_defines.names.entities.super_cooler,
+ stack_size = 50,
+ },
+ {
+ -- Configurable super boiler
+ type = "item",
+ name = creative_mode_defines.names.items.configurable_super_boiler,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/configurable-super-boiler.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.fluids,
+ order = "e",
+ place_result = creative_mode_defines.names.entities.configurable_super_boiler,
+ stack_size = 50,
+ },
+ {
+ -- Heat source
+ type = "item",
+ name = creative_mode_defines.names.items.heat_source,
+ icon_size = 64,
+ icon_mipmaps = 4,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/heat-pipe.png",
+ tint = { r = 1, g = 0.3, b = 0.3 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.fluids,
+ order = "f",
+ place_result = creative_mode_defines.names.entities.heat_source,
+ stack_size = 50,
+ },
+ {
+ -- Heat void
+ type = "item",
+ name = creative_mode_defines.names.items.heat_void,
+ icon_size = 64,
+ icon_mipmaps = 4,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/heat-pipe.png",
+ tint = { r = 0.2, g = 0.2, b = 0.2 },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.fluids,
+ order = "g",
+ place_result = creative_mode_defines.names.entities.heat_void,
+ stack_size = 50,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Matter source
- type = "item",
- name = creative_mode_defines.names.items.item_source,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/item-source.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.advanced,
- order = "a",
- place_result = creative_mode_defines.names.entities.item_source,
- stack_size = 50
- },
- {
- -- Matter duplicator
- type = "item",
- name = creative_mode_defines.names.items.duplicator,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/duplicator.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.advanced,
- order = "b",
- place_result = creative_mode_defines.names.entities.duplicator,
- stack_size = 50
- },
- {
- -- Matter void
- type = "item",
- name = creative_mode_defines.names.items.item_void,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/item-void.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.advanced,
- order = "c",
- place_result = creative_mode_defines.names.entities.item_void,
- stack_size = 50
- },
- {
- -- Random item source
- type = "item",
- name = creative_mode_defines.names.items.random_item_source,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/random-item-source.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.advanced,
- order = "d",
- place_result = creative_mode_defines.names.entities.random_item_source,
- stack_size = 50
- },
- {
- -- Creative lab
- type = "item",
- name = creative_mode_defines.names.items.creative_lab,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/creative-lab.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.advanced,
- order = "e",
- place_result = creative_mode_defines.names.entities.creative_lab,
- stack_size = 50
- },
- {
- -- Void lab
- type = "item",
- name = creative_mode_defines.names.items.void_lab,
- icon_size = 64,
- icons = {
- {
- icon = "__base__/graphics/icons/lab.png",
- tint = {
- r = 50,
- g = 50,
- b = 50
- }
- }
- },
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.advanced,
- order = "f",
- place_result = creative_mode_defines.names.entities.void_lab,
- stack_size = 50
- },
- -----------------------------------------------------------------------------
+ {
+ -- Matter source
+ type = "item",
+ name = creative_mode_defines.names.items.item_source,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/item-source.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.advanced,
+ order = "a",
+ place_result = creative_mode_defines.names.entities.item_source,
+ stack_size = 50,
+ },
+ {
+ -- Matter duplicator
+ type = "item",
+ name = creative_mode_defines.names.items.duplicator,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/duplicator.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.advanced,
+ order = "b",
+ place_result = creative_mode_defines.names.entities.duplicator,
+ stack_size = 50,
+ },
+ {
+ -- Matter void
+ type = "item",
+ name = creative_mode_defines.names.items.item_void,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/item-void.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.advanced,
+ order = "c",
+ place_result = creative_mode_defines.names.entities.item_void,
+ stack_size = 50,
+ },
+ {
+ -- Random item source
+ type = "item",
+ name = creative_mode_defines.names.items.random_item_source,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/random-item-source.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.advanced,
+ order = "d",
+ place_result = creative_mode_defines.names.entities.random_item_source,
+ stack_size = 50,
+ },
+ {
+ -- Creative lab
+ type = "item",
+ name = creative_mode_defines.names.items.creative_lab,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/creative-lab.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.advanced,
+ order = "e",
+ place_result = creative_mode_defines.names.entities.creative_lab,
+ stack_size = 50,
+ },
+ {
+ -- Void lab
+ type = "item",
+ name = creative_mode_defines.names.items.void_lab,
+ icon_size = 64,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/lab.png",
+ tint = {
+ r = 50,
+ g = 50,
+ b = 50,
+ },
+ },
+ },
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.advanced,
+ order = "f",
+ place_result = creative_mode_defines.names.entities.void_lab,
+ stack_size = 50,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Active electric energy interface (output)
- type = "item",
- name = creative_mode_defines.names.items.active_electric_energy_interface_output,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/active-electric-energy-interface-output.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "a",
- place_result = creative_mode_defines.names.entities.active_electric_energy_interface_output,
- stack_size = 50
- },
- {
- -- Passive electric energy interface
- type = "item",
- name = creative_mode_defines.names.items.passive_electric_energy_interface,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-electric-energy-interface.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "b",
- place_result = creative_mode_defines.names.entities.passive_electric_energy_interface,
- stack_size = 50
- },
- {
- -- Active electric energy interface (input)
- type = "item",
- name = creative_mode_defines.names.items.active_electric_energy_interface_input,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/active-electric-energy-interface-input.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "c",
- place_result = creative_mode_defines.names.entities.active_electric_energy_interface_input,
- stack_size = 50
- },
- {
- -- Active energy source
- type = "item",
- name = creative_mode_defines.names.items.energy_source,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-source.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "d",
- place_result = creative_mode_defines.names.entities.energy_source,
- stack_size = 50
- },
- {
- -- Passive energy source
- type = "item",
- name = creative_mode_defines.names.items.passive_energy_source,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-energy-source.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "e",
- place_result = creative_mode_defines.names.entities.passive_energy_source,
- stack_size = 50
- },
- {
- -- Active energy void
- type = "item",
- name = creative_mode_defines.names.items.energy_void,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-void.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "f",
- place_result = creative_mode_defines.names.entities.energy_void,
- stack_size = 50
- },
- {
- -- Dummy item for energy void to absorb energy.
- type = "item",
- name = creative_mode_defines.names.items.energy_absorption,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-absorption.png",
- flags = {},
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "z",
- stack_size = 50
- },
- {
- -- Passive energy void
- type = "item",
- name = creative_mode_defines.names.items.passive_energy_void,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-energy-void.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "g",
- place_result = creative_mode_defines.names.entities.passive_energy_void,
- stack_size = 50
- },
- {
- -- Super electric pole
- type = "item",
- name = creative_mode_defines.names.items.super_electric_pole,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-electric-pole.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "h",
- place_result = creative_mode_defines.names.entities.super_electric_pole,
- stack_size = 50
- },
- {
- -- Super substation
- type = "item",
- name = creative_mode_defines.names.items.super_substation,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-substation.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.energy,
- order = "i",
- place_result = creative_mode_defines.names.entities.super_substation,
- stack_size = 50
- },
- -----------------------------------------------------------------------------
+ {
+ -- Active electric energy interface (output)
+ type = "item",
+ name = creative_mode_defines.names.items.active_electric_energy_interface_output,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/active-electric-energy-interface-output.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "a",
+ place_result = creative_mode_defines.names.entities.active_electric_energy_interface_output,
+ stack_size = 50,
+ },
+ {
+ -- Passive electric energy interface
+ type = "item",
+ name = creative_mode_defines.names.items.passive_electric_energy_interface,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-electric-energy-interface.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "b",
+ place_result = creative_mode_defines.names.entities.passive_electric_energy_interface,
+ stack_size = 50,
+ },
+ {
+ -- Active electric energy interface (input)
+ type = "item",
+ name = creative_mode_defines.names.items.active_electric_energy_interface_input,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/active-electric-energy-interface-input.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "c",
+ place_result = creative_mode_defines.names.entities.active_electric_energy_interface_input,
+ stack_size = 50,
+ },
+ {
+ -- Active energy source
+ type = "item",
+ name = creative_mode_defines.names.items.energy_source,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-source.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "d",
+ place_result = creative_mode_defines.names.entities.energy_source,
+ stack_size = 50,
+ },
+ {
+ -- Passive energy source
+ type = "item",
+ name = creative_mode_defines.names.items.passive_energy_source,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-energy-source.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "e",
+ place_result = creative_mode_defines.names.entities.passive_energy_source,
+ stack_size = 50,
+ },
+ {
+ -- Active energy void
+ type = "item",
+ name = creative_mode_defines.names.items.energy_void,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-void.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "f",
+ place_result = creative_mode_defines.names.entities.energy_void,
+ stack_size = 50,
+ },
+ {
+ -- Dummy item for energy void to absorb energy.
+ type = "item",
+ name = creative_mode_defines.names.items.energy_absorption,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-absorption.png",
+ flags = {},
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "z",
+ stack_size = 50,
+ },
+ {
+ -- Passive energy void
+ type = "item",
+ name = creative_mode_defines.names.items.passive_energy_void,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/passive-energy-void.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "g",
+ place_result = creative_mode_defines.names.entities.passive_energy_void,
+ stack_size = 50,
+ },
+ {
+ -- Super electric pole
+ type = "item",
+ name = creative_mode_defines.names.items.super_electric_pole,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-electric-pole.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "h",
+ place_result = creative_mode_defines.names.entities.super_electric_pole,
+ stack_size = 50,
+ },
+ {
+ -- Super substation
+ type = "item",
+ name = creative_mode_defines.names.items.super_substation,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-substation.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.energy,
+ order = "i",
+ place_result = creative_mode_defines.names.entities.super_substation,
+ stack_size = 50,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Magic wand - creator
- type = "selection-tool",
- name = creative_mode_defines.names.items.magic_wand_creator,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/magic-wand-creator.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.magic_wands,
- order = "a",
- stack_size = 1,
- select = {
- border_color = {r = 0, g = 1, b = 0},
- mode = {"any-tile"},
- cursor_box_type = "entity",
- },
- alt_select = {
- border_color = {r = 1, g = 0, b = 0},
- mode = {"any-entity", "deconstruct"},
- cursor_box_type = "not-allowed",
- },
- always_include_tiles = true
- },
- {
- -- Magic wand - healer
- type = "selection-tool",
- name = creative_mode_defines.names.items.magic_wand_healer,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/magic-wand-healer.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.magic_wands,
- order = "b",
- stack_size = 1,
- select = {
- border_color = {r = 0, g = 1, b = 0},
- mode = {"any-entity"},
- cursor_box_type = "copy",
- },
- alt_select = {
- border_color = {r = 1, g = 0.5, b = 0},
- mode = {"any-entity"},
- cursor_box_type = "not-allowed"
- },
- },
- {
- -- Magic wand - modifier
- type = "selection-tool",
- name = creative_mode_defines.names.items.magic_wand_modifier,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/magic-wand-modifier.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.magic_wands,
- order = "c",
- stack_size = 1,
- select = {
- border_color = {r = 0.5, g = 0, b = 1},
- mode = {"any-entity"},
- cursor_box_type = "electricity",
- },
- alt_select = {
- border_color = {r = 0.5, g = 1, b = 1},
- mode = {"any-entity"},
- cursor_box_type = "electricity"
- },
- },
- -----------------------------------------------------------------------------
+ {
+ -- Magic wand - creator
+ type = "selection-tool",
+ name = creative_mode_defines.names.items.magic_wand_creator,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/magic-wand-creator.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.magic_wands,
+ order = "a",
+ stack_size = 1,
+ select = {
+ border_color = { r = 0, g = 1, b = 0 },
+ mode = { "any-tile" },
+ cursor_box_type = "entity",
+ },
+ alt_select = {
+ border_color = { r = 1, g = 0, b = 0 },
+ mode = { "any-entity", "deconstruct" },
+ cursor_box_type = "not-allowed",
+ },
+ always_include_tiles = true,
+ },
+ {
+ -- Magic wand - healer
+ type = "selection-tool",
+ name = creative_mode_defines.names.items.magic_wand_healer,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/magic-wand-healer.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.magic_wands,
+ order = "b",
+ stack_size = 1,
+ select = {
+ border_color = { r = 0, g = 1, b = 0 },
+ mode = { "any-entity" },
+ cursor_box_type = "copy",
+ },
+ alt_select = {
+ border_color = { r = 1, g = 0.5, b = 0 },
+ mode = { "any-entity" },
+ cursor_box_type = "not-allowed",
+ },
+ },
+ {
+ -- Magic wand - modifier
+ type = "selection-tool",
+ name = creative_mode_defines.names.items.magic_wand_modifier,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/magic-wand-modifier.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.magic_wands,
+ order = "c",
+ stack_size = 1,
+ select = {
+ border_color = { r = 0.5, g = 0, b = 1 },
+ mode = { "any-entity" },
+ cursor_box_type = "electricity",
+ },
+ alt_select = {
+ border_color = { r = 0.5, g = 1, b = 1 },
+ mode = { "any-entity" },
+ cursor_box_type = "electricity",
+ },
+ },
+ -----------------------------------------------------------------------------
- {
- -- Super radar
- type = "item",
- name = creative_mode_defines.names.items.super_radar,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-radar.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.enemies,
- order = "za",
- place_result = creative_mode_defines.names.entities.super_radar,
- stack_size = 50
- },
- {
- -- Super radar MK2
- type = "item",
- name = creative_mode_defines.names.items.super_radar_2,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-radar-2.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.enemies,
- order = "zb",
- place_result = creative_mode_defines.names.entities.super_radar_2,
- stack_size = 50
- },
- {
- -- Alien attractor - small
- type = "item",
- name = creative_mode_defines.names.items.alien_attractor_small,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/alien-attractor-small.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.enemies,
- order = "zc",
- place_result = creative_mode_defines.names.entities.alien_attractor_proxy_small,
- stack_size = 100
- },
- {
- -- Alien attractor - medium
- type = "item",
- name = creative_mode_defines.names.items.alien_attractor_medium,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/alien-attractor-medium.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.enemies,
- order = "zd",
- place_result = creative_mode_defines.names.entities.alien_attractor_proxy_medium,
- stack_size = 100
- },
- {
- -- Alien attractor - large
- type = "item",
- name = creative_mode_defines.names.items.alien_attractor_large,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/alien-attractor-large.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.enemies,
- order = "ze",
- place_result = creative_mode_defines.names.entities.alien_attractor_proxy_large,
- stack_size = 100
- },
- -----------------------------------------------------------------------------
+ {
+ -- Super radar
+ type = "item",
+ name = creative_mode_defines.names.items.super_radar,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-radar.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.enemies,
+ order = "za",
+ place_result = creative_mode_defines.names.entities.super_radar,
+ stack_size = 50,
+ },
+ {
+ -- Super radar MK2
+ type = "item",
+ name = creative_mode_defines.names.items.super_radar_2,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-radar-2.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.enemies,
+ order = "zb",
+ place_result = creative_mode_defines.names.entities.super_radar_2,
+ stack_size = 50,
+ },
+ {
+ -- Alien attractor - small
+ type = "item",
+ name = creative_mode_defines.names.items.alien_attractor_small,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/alien-attractor-small.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.enemies,
+ order = "zc",
+ place_result = creative_mode_defines.names.entities.alien_attractor_proxy_small,
+ stack_size = 100,
+ },
+ {
+ -- Alien attractor - medium
+ type = "item",
+ name = creative_mode_defines.names.items.alien_attractor_medium,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/alien-attractor-medium.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.enemies,
+ order = "zd",
+ place_result = creative_mode_defines.names.entities.alien_attractor_proxy_medium,
+ stack_size = 100,
+ },
+ {
+ -- Alien attractor - large
+ type = "item",
+ name = creative_mode_defines.names.items.alien_attractor_large,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/alien-attractor-large.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.enemies,
+ order = "ze",
+ place_result = creative_mode_defines.names.entities.alien_attractor_proxy_large,
+ stack_size = 100,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Super beacon
- type = "item",
- name = creative_mode_defines.names.items.super_beacon,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-beacon.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.modules,
- order = "a",
- place_result = creative_mode_defines.names.entities.super_beacon,
- stack_size = 50
- },
- {
- -- Super speed module.
- type = "module",
- name = creative_mode_defines.names.recipes.super_speed_module,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-speed-module.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.modules,
- category = "speed",
- tier = 50,
- order = "b",
- stack_size = 50,
- effect = {speed = 2.5}
- },
- {
- -- Super effectivity module.
- type = "module",
- name = creative_mode_defines.names.recipes.super_effectivity_module,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-effectivity-module.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.modules,
- category = "efficiency",
- tier = 50,
- order = "c",
- stack_size = 50,
- effect = {consumption = -2.5} -- 80% limit
- },
- {
- -- Super productivity module
- type = "module",
- name = creative_mode_defines.names.recipes.super_productivity_module,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-productivity-module.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.modules,
- category = "productivity",
- tier = 50,
- order = "d",
- stack_size = 50,
- effect = {productivity = 2.5}
- },
- {
- -- Super clean module
- type = "module",
- name = creative_mode_defines.names.recipes.super_clean_module,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-clean-module.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.modules,
- category = "efficiency",
- tier = 50,
- order = "e",
- stack_size = 50,
- effect = {pollution = -2.5} -- 80% limit
- },
- {
- -- Super slow module.
- type = "module",
- name = creative_mode_defines.names.recipes.super_slow_module,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-slow-module.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.modules,
- category = "speed",
- tier = 50,
- order = "f",
- stack_size = 50,
- effect = {speed = -2.5} -- 80% limit
- },
- {
- -- Super consumption module.
- type = "module",
- name = creative_mode_defines.names.recipes.super_consumption_module,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-consumption-module.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.modules,
- category = "efficiency",
- tier = 50,
- order = "g",
- stack_size = 50,
- effect = {consumption = 2.5}
- },
- {
- -- Super pollution module
- type = "module",
- name = creative_mode_defines.names.recipes.super_pollution_module,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-pollution-module.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.modules,
- category = "efficiency",
- tier = 50,
- order = "h",
- stack_size = 50,
- effect = {pollution = 2.5}
- },
- -----------------------------------------------------------------------------
+ {
+ -- Super beacon
+ type = "item",
+ name = creative_mode_defines.names.items.super_beacon,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-beacon.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.modules,
+ order = "a",
+ place_result = creative_mode_defines.names.entities.super_beacon,
+ stack_size = 50,
+ },
+ {
+ -- Super speed module.
+ type = "module",
+ name = creative_mode_defines.names.recipes.super_speed_module,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-speed-module.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.modules,
+ category = "speed",
+ tier = 50,
+ order = "b",
+ stack_size = 50,
+ effect = { speed = 2.5 },
+ },
+ {
+ -- Super effectivity module.
+ type = "module",
+ name = creative_mode_defines.names.recipes.super_effectivity_module,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-effectivity-module.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.modules,
+ category = "efficiency",
+ tier = 50,
+ order = "c",
+ stack_size = 50,
+ effect = { consumption = -2.5 }, -- 80% limit
+ },
+ {
+ -- Super productivity module
+ type = "module",
+ name = creative_mode_defines.names.recipes.super_productivity_module,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-productivity-module.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.modules,
+ category = "productivity",
+ tier = 50,
+ order = "d",
+ stack_size = 50,
+ effect = { productivity = 2.5 },
+ },
+ {
+ -- Super clean module
+ type = "module",
+ name = creative_mode_defines.names.recipes.super_clean_module,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-clean-module.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.modules,
+ category = "efficiency",
+ tier = 50,
+ order = "e",
+ stack_size = 50,
+ effect = { pollution = -2.5 }, -- 80% limit
+ },
+ {
+ -- Super slow module.
+ type = "module",
+ name = creative_mode_defines.names.recipes.super_slow_module,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-slow-module.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.modules,
+ category = "speed",
+ tier = 50,
+ order = "f",
+ stack_size = 50,
+ effect = { speed = -2.5 }, -- 80% limit
+ },
+ {
+ -- Super consumption module.
+ type = "module",
+ name = creative_mode_defines.names.recipes.super_consumption_module,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-consumption-module.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.modules,
+ category = "efficiency",
+ tier = 50,
+ order = "g",
+ stack_size = 50,
+ effect = { consumption = 2.5 },
+ },
+ {
+ -- Super pollution module
+ type = "module",
+ name = creative_mode_defines.names.recipes.super_pollution_module,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-pollution-module.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.modules,
+ category = "efficiency",
+ tier = 50,
+ order = "h",
+ stack_size = 50,
+ effect = { pollution = 2.5 },
+ },
+ -----------------------------------------------------------------------------
- {
- -- Super fusion reactor equipment
- type = "item",
- name = creative_mode_defines.names.equipments.super_fusion_reactor_equipment,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-fusion-reactor-equipment.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.equipments,
- order = "b",
- place_as_equipment_result = creative_mode_defines.names.equipments.super_fusion_reactor_equipment,
- stack_size = 50
- },
- {
- -- Super personal roboport
- type = "item",
- name = creative_mode_defines.names.equipments.super_personal_roboport_equipment,
- icon_size = 32,
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-personal-roboport-equipment.png",
- hidden = hidden,
- subgroup = creative_mode_defines.names.item_subgroups.equipments,
- order = "c",
- place_as_equipment_result = creative_mode_defines.names.equipments.super_personal_roboport_equipment,
- stack_size = 50
- }
- }
-)
+ {
+ -- Super fusion reactor equipment
+ type = "item",
+ name = creative_mode_defines.names.equipments.super_fusion_reactor_equipment,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-fusion-reactor-equipment.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.equipments,
+ order = "b",
+ place_as_equipment_result = creative_mode_defines.names.equipments.super_fusion_reactor_equipment,
+ stack_size = 50,
+ },
+ {
+ -- Super personal roboport
+ type = "item",
+ name = creative_mode_defines.names.equipments.super_personal_roboport_equipment,
+ icon_size = 32,
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/super-personal-roboport-equipment.png",
+ hidden = hidden,
+ subgroup = creative_mode_defines.names.item_subgroups.equipments,
+ order = "c",
+ place_as_equipment_result = creative_mode_defines.names.equipments.super_personal_roboport_equipment,
+ stack_size = 50,
+ },
+})
diff --git a/prototypes/recipe-category.lua b/prototypes/recipe-category.lua
index 88b2df2..570b818 100644
--- a/prototypes/recipe-category.lua
+++ b/prototypes/recipe-category.lua
@@ -1,14 +1,12 @@
-data:extend(
- {
- {
- -- Free fluids
- type = "recipe-category",
- name = creative_mode_defines.names.recipe_categories.free_fluids
- },
- {
- -- Energy absorption
- type = "recipe-category",
- name = creative_mode_defines.names.recipe_categories.energy_absorption
- }
- }
-)
+data:extend({
+ {
+ -- Free fluids
+ type = "recipe-category",
+ name = creative_mode_defines.names.recipe_categories.free_fluids,
+ },
+ {
+ -- Energy absorption
+ type = "recipe-category",
+ name = creative_mode_defines.names.recipe_categories.energy_absorption,
+ },
+})
diff --git a/prototypes/recipe.lua b/prototypes/recipe.lua
index 7ef234b..c2427ea 100644
--- a/prototypes/recipe.lua
+++ b/prototypes/recipe.lua
@@ -1,540 +1,546 @@
-data:extend(
- {
- {
- -- Creative chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.creative_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.creative_chest, amount = 1}},
- enabled = false
- },
- {
- -- Vanilla infinity chest.
- type = "recipe",
- name = creative_mode_defines.names.recipes.new_creative_chest,
- ingredients = {},
- results = {{ type="item", name= "infinity-chest", amount = 1}},
- enabled = false,
- order = "a",
- subgroup = creative_mode_defines.names.item_subgroups.items
- },
- {
- -- Infinity Requester Chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.inf_requester_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.recipes.inf_requester_chest, amount = 1}},
- enabled = false,
- order = "a1",
- subgroup = creative_mode_defines.names.item_subgroups.items
- },
- {
- -- Infinity Provider Chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.inf_provider_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.recipes.inf_provider_chest, amount = 1}},
- enabled = false,
- order = "a2",
- subgroup = creative_mode_defines.names.item_subgroups.items
- },
- {
- -- Creative provider chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.creative_provider_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.creative_provider_chest, amount = 1}},
- enabled = false
- },
- {
- -- Autofill requester chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.autofill_requester_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.autofill_requester_chest, amount = 1}},
- enabled = false
- },
- {
- -- Duplicating chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.duplicating_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.duplicating_chest, amount = 1}},
- enabled = false
- },
- {
- -- Duplicating provider chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.duplicating_provider_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.duplicating_provider_chest, amount = 1}},
- enabled = false
- },
- {
- -- Void requester chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.void_requester_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.void_requester_chest, amount = 1}},
- enabled = false
- },
- {
- -- Void chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.void_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.void_chest, amount = 1}},
- enabled = false
- },
- {
- -- Void storage chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.void_storage_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.void_storage_chest, amount = 1}},
- enabled = false
- },
- {
- -- Super loader
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_loader,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_loader, amount = 1}},
- enabled = false
- },
- {
- -- Super loader2
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_loader2,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_loader2, amount = 1}},
- enabled = false
- },
- {
- -- Linked Chest
- type = "recipe",
- name = creative_mode_defines.names.recipes.linked_chest,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.linked_chest, amount = 1}},
- enabled = false
- },
- {
- -- Linked Belt
- type = "recipe",
- name = creative_mode_defines.names.recipes.linked_belt,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.linked_belt, amount = 1}},
- enabled = false
- },
- -----------------------------------------------------------------------------
+data:extend({
+ {
+ -- Creative chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.creative_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.creative_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Vanilla infinity chest.
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.new_creative_chest,
+ ingredients = {},
+ results = { { type = "item", name = "infinity-chest", amount = 1 } },
+ enabled = false,
+ order = "a",
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ },
+ {
+ -- Infinity Requester Chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.inf_requester_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.recipes.inf_requester_chest, amount = 1 } },
+ enabled = false,
+ order = "a1",
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ },
+ {
+ -- Infinity Provider Chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.inf_provider_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.recipes.inf_provider_chest, amount = 1 } },
+ enabled = false,
+ order = "a2",
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ },
+ {
+ -- Creative provider chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.creative_provider_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.creative_provider_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Autofill requester chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.autofill_requester_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.autofill_requester_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Duplicating chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.duplicating_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.duplicating_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Duplicating provider chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.duplicating_provider_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.duplicating_provider_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Void requester chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.void_requester_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.void_requester_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Void chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.void_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.void_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Void storage chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.void_storage_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.void_storage_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super loader
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_loader,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_loader, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super loader2
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_loader2,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_loader2, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Linked Chest
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.linked_chest,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.linked_chest, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Linked Belt
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.linked_belt,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.linked_belt, amount = 1 } },
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Creative cargo wagon
- type = "recipe",
- name = creative_mode_defines.names.recipes.creative_cargo_wagon,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.creative_cargo_wagon, amount = 1}},
- enabled = false
- },
- {
- -- Duplicating cargo wagon
- type = "recipe",
- name = creative_mode_defines.names.recipes.duplicating_cargo_wagon,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.duplicating_cargo_wagon, amount = 1}},
- enabled = false
- },
- {
- -- Void cargo wagon
- type = "recipe",
- name = creative_mode_defines.names.recipes.void_cargo_wagon,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.void_cargo_wagon, amount = 1}},
- enabled = false
- },
- {
- -- Super logistic robot
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_logistic_robot,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_logistic_robot, amount = 1}},
- enabled = false
- },
- {
- -- Super construction robot
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_construction_robot,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_construction_robot, amount = 1}},
- enabled = false
- },
- {
- -- Super roboport
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_roboport,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_roboport, amount = 1}},
- enabled = false
- },
- -----------------------------------------------------------------------------
+ {
+ -- Creative cargo wagon
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.creative_cargo_wagon,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.creative_cargo_wagon, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Duplicating cargo wagon
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.duplicating_cargo_wagon,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.duplicating_cargo_wagon, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Void cargo wagon
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.void_cargo_wagon,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.void_cargo_wagon, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super logistic robot
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_logistic_robot,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_logistic_robot, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super construction robot
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_construction_robot,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_construction_robot, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super roboport
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_roboport,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_roboport, amount = 1 } },
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Fluid source
- type = "recipe",
- name = creative_mode_defines.names.recipes.fluid_source,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.fluid_source, amount = 1}},
- enabled = false
- },
- {
- -- Fluid void
- type = "recipe",
- name = creative_mode_defines.names.recipes.fluid_void,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.fluid_void, amount = 1}},
- enabled = false
- },
- {
- -- Super boiler
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_boiler,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_boiler, amount = 1}},
- enabled = false
- },
- {
- -- Super cooler
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_cooler,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_cooler, amount = 1}},
- enabled = false
- },
- {
- -- Configurable super boiler
- type = "recipe",
- name = creative_mode_defines.names.recipes.configurable_super_boiler,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.configurable_super_boiler, amount = 1}},
- enabled = false
- },
- {
- -- Heat source
- type = "recipe",
- name = creative_mode_defines.names.recipes.heat_source,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.heat_source, amount = 1}},
- enabled = false
- },
- {
- -- Heat void
- type = "recipe",
- name = creative_mode_defines.names.recipes.heat_void,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.heat_void, amount = 1}},
- enabled = false
- },
- -----------------------------------------------------------------------------
+ {
+ -- Fluid source
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.fluid_source,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.fluid_source, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Fluid void
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.fluid_void,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.fluid_void, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super boiler
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_boiler,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_boiler, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super cooler
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_cooler,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_cooler, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Configurable super boiler
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.configurable_super_boiler,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.configurable_super_boiler, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Heat source
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.heat_source,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.heat_source, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Heat void
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.heat_void,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.heat_void, amount = 1 } },
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Matter source
- type = "recipe",
- name = creative_mode_defines.names.recipes.item_source,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.item_source, amount = 1}},
- enabled = false
- },
- {
- -- Matter duplicator
- type = "recipe",
- name = creative_mode_defines.names.recipes.duplicator,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.duplicator, amount = 1}},
- enabled = false
- },
- {
- -- Matter void
- type = "recipe",
- name = creative_mode_defines.names.recipes.item_void,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.item_void, amount = 1}},
- enabled = false
- },
- {
- -- Random item source
- type = "recipe",
- name = creative_mode_defines.names.recipes.random_item_source,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.random_item_source, amount = 1}},
- enabled = false
- },
- {
- -- Creative lab
- type = "recipe",
- name = creative_mode_defines.names.recipes.creative_lab,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.creative_lab, amount = 1}},
- enabled = false
- },
- {
- -- Void lab
- type = "recipe",
- name = creative_mode_defines.names.recipes.void_lab,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.void_lab, amount = 1}},
- enabled = false
- },
- -----------------------------------------------------------------------------
+ {
+ -- Matter source
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.item_source,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.item_source, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Matter duplicator
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.duplicator,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.duplicator, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Matter void
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.item_void,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.item_void, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Random item source
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.random_item_source,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.random_item_source, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Creative lab
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.creative_lab,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.creative_lab, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Void lab
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.void_lab,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.void_lab, amount = 1 } },
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Active electric energy interface (output)
- type = "recipe",
- name = creative_mode_defines.names.recipes.active_electric_energy_interface_output,
- hidden = true,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.active_electric_energy_interface_output, amount = 1}},
- enabled = false
- },
- {
- -- Passive electric energy interface
- type = "recipe",
- name = creative_mode_defines.names.recipes.passive_electric_energy_interface,
- hidden = true,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.passive_electric_energy_interface, amount = 1}},
- enabled = false
- },
- {
- -- Active electric energy interface (input)
- type = "recipe",
- name = creative_mode_defines.names.recipes.active_electric_energy_interface_input,
- hidden = true,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.active_electric_energy_interface_input, amount = 1}},
- enabled = false
- },
- {
- -- Active energy source
- type = "recipe",
- name = creative_mode_defines.names.recipes.energy_source,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.energy_source, amount = 1}},
- enabled = false
- },
- {
- -- Passive energy source
- type = "recipe",
- name = creative_mode_defines.names.recipes.passive_energy_source,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.passive_energy_source, amount = 1}},
- enabled = false
- },
- {
- -- Active energy void
- type = "recipe",
- name = creative_mode_defines.names.recipes.energy_void,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.energy_void, amount = 1}},
- enabled = false
- },
- {
- -- Passive energy void
- type = "recipe",
- name = creative_mode_defines.names.recipes.passive_energy_void,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.passive_energy_void, amount = 1}},
- enabled = false
- },
- {
- -- Super electric pole
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_electric_pole,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_electric_pole, amount = 1}},
- enabled = false
- },
- {
- -- Super substation
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_substation,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_substation, amount = 1}},
- enabled = false
- },
- -----------------------------------------------------------------------------
+ {
+ -- Active electric energy interface (output)
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.active_electric_energy_interface_output,
+ hidden = true,
+ ingredients = {},
+ results = {
+ { type = "item", name = creative_mode_defines.names.items.active_electric_energy_interface_output, amount = 1 },
+ },
+ enabled = false,
+ },
+ {
+ -- Passive electric energy interface
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.passive_electric_energy_interface,
+ hidden = true,
+ ingredients = {},
+ results = {
+ { type = "item", name = creative_mode_defines.names.items.passive_electric_energy_interface, amount = 1 },
+ },
+ enabled = false,
+ },
+ {
+ -- Active electric energy interface (input)
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.active_electric_energy_interface_input,
+ hidden = true,
+ ingredients = {},
+ results = {
+ { type = "item", name = creative_mode_defines.names.items.active_electric_energy_interface_input, amount = 1 },
+ },
+ enabled = false,
+ },
+ {
+ -- Active energy source
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.energy_source,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.energy_source, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Passive energy source
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.passive_energy_source,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.passive_energy_source, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Active energy void
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.energy_void,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.energy_void, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Passive energy void
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.passive_energy_void,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.passive_energy_void, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super electric pole
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_electric_pole,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_electric_pole, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super substation
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_substation,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_substation, amount = 1 } },
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Fixed recipe for energy void to absorb energy
- type = "recipe",
- name = creative_mode_defines.names.recipes.energy_absorption,
- ingredients = {},
- results = {},
- icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-void.png",
- icon_size = 32,
- category = creative_mode_defines.names.recipe_categories.energy_absorption,
- subgroup = creative_mode_defines.names.item_subgroups.items,
- hidden = true,
- enabled = false
- },
- -----------------------------------------------------------------------------
+ {
+ -- Fixed recipe for energy void to absorb energy
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.energy_absorption,
+ ingredients = {},
+ results = {},
+ icon = creative_mode_defines.mod_directory .. "/graphics/icons/energy-void.png",
+ icon_size = 32,
+ category = creative_mode_defines.names.recipe_categories.energy_absorption,
+ subgroup = creative_mode_defines.names.item_subgroups.items,
+ hidden = true,
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Magic wand - creator
- type = "recipe",
- name = creative_mode_defines.names.recipes.magic_wand_creator,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.magic_wand_creator, amount = 1}},
- enabled = false
- },
- {
- -- Magic wand - healer
- type = "recipe",
- name = creative_mode_defines.names.recipes.magic_wand_healer,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.magic_wand_healer, amount = 1}},
- enabled = false
- },
- {
- -- Magic wand - modifier
- type = "recipe",
- name = creative_mode_defines.names.recipes.magic_wand_modifier,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.magic_wand_modifier, amount = 1}},
- enabled = false
- },
- -----------------------------------------------------------------------------
+ {
+ -- Magic wand - creator
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.magic_wand_creator,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.magic_wand_creator, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Magic wand - healer
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.magic_wand_healer,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.magic_wand_healer, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Magic wand - modifier
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.magic_wand_modifier,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.magic_wand_modifier, amount = 1 } },
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Super radar
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_radar,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_radar, amount = 1}},
- enabled = false
- },
- {
- -- Super radar MK2
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_radar_2,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_radar_2, amount = 1}},
- enabled = false
- },
- {
- -- Alien attractor - small
- type = "recipe",
- name = creative_mode_defines.names.recipes.alien_attractor_small,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.alien_attractor_small, amount = 1}},
- enabled = false
- },
- {
- -- Alien attractor - medium
- type = "recipe",
- name = creative_mode_defines.names.recipes.alien_attractor_medium,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.alien_attractor_medium, amount = 1}},
- enabled = false
- },
- {
- -- Alien attractor - large
- type = "recipe",
- name = creative_mode_defines.names.recipes.alien_attractor_large,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.alien_attractor_large, amount = 1}},
- enabled = false
- },
- -----------------------------------------------------------------------------
+ {
+ -- Super radar
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_radar,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_radar, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super radar MK2
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_radar_2,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_radar_2, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Alien attractor - small
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.alien_attractor_small,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.alien_attractor_small, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Alien attractor - medium
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.alien_attractor_medium,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.alien_attractor_medium, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Alien attractor - large
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.alien_attractor_large,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.alien_attractor_large, amount = 1 } },
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Super beacon
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_beacon,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_beacon, amount = 1}},
- enabled = false
- },
- {
- -- Super speed module
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_speed_module,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_speed_module, amount = 1}},
- enabled = false
- },
- {
- -- Super effectivity module
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_effectivity_module,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_effectivity_module, amount = 1}},
- enabled = false
- },
- {
- -- Super productivity module
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_productivity_module,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_productivity_module, amount = 1}},
- enabled = false
- },
- {
- -- Super clean module
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_clean_module,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_clean_module, amount = 1}},
- enabled = false
- },
- {
- -- Super slow module
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_slow_module,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_slow_module, amount = 1}},
- enabled = false
- },
- {
- -- Super consumption module
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_consumption_module,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_consumption_module, amount = 1}},
- enabled = false
- },
- {
- -- Super pollution module
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_pollution_module,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_pollution_module, amount = 1}},
- enabled = false
- },
- -----------------------------------------------------------------------------
+ {
+ -- Super beacon
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_beacon,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_beacon, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super speed module
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_speed_module,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_speed_module, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super effectivity module
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_effectivity_module,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_effectivity_module, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super productivity module
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_productivity_module,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_productivity_module, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super clean module
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_clean_module,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_clean_module, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super slow module
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_slow_module,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_slow_module, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super consumption module
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_consumption_module,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_consumption_module, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super pollution module
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_pollution_module,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_pollution_module, amount = 1 } },
+ enabled = false,
+ },
+ -----------------------------------------------------------------------------
- {
- -- Infinity Chest (the item already exists, we just need to create the recipe)
- type = "recipe",
- name = "infinity-chest",
- ingredients = {},
- results = {{ type="item", name= "infinity-chest", amount = 1}},
- enabled = false
- },
- {
- -- Super fusion reactor equipment
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_fusion_reactor_equipment,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_fusion_reactor_equipment, amount = 1}},
- enabled = false
- },
- {
- -- Super fusion reactor equipment
- type = "recipe",
- name = creative_mode_defines.names.recipes.super_personal_roboport_equipment,
- ingredients = {},
- results = {{ type="item", name= creative_mode_defines.names.items.super_personal_roboport_equipment, amount = 1}},
- enabled = false
- }
- }
-)
+ {
+ -- Infinity Chest (the item already exists, we just need to create the recipe)
+ type = "recipe",
+ name = "infinity-chest",
+ ingredients = {},
+ results = { { type = "item", name = "infinity-chest", amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super fusion reactor equipment
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_fusion_reactor_equipment,
+ ingredients = {},
+ results = { { type = "item", name = creative_mode_defines.names.items.super_fusion_reactor_equipment, amount = 1 } },
+ enabled = false,
+ },
+ {
+ -- Super fusion reactor equipment
+ type = "recipe",
+ name = creative_mode_defines.names.recipes.super_personal_roboport_equipment,
+ ingredients = {},
+ results = {
+ { type = "item", name = creative_mode_defines.names.items.super_personal_roboport_equipment, amount = 1 },
+ },
+ enabled = false,
+ },
+})
diff --git a/prototypes/sprite.lua b/prototypes/sprite.lua
index 122bae6..caa06b6 100644
--- a/prototypes/sprite.lua
+++ b/prototypes/sprite.lua
@@ -1,28 +1,26 @@
-data:extend(
- {
- {
- type = "sprite",
- name = creative_mode_defines.names.sprites.reset,
- filename = creative_mode_defines.mod_directory .. "/graphics/sprites/reset.png",
- width = 32,
- height = 32,
- scale = 1
- },
- {
- type = "sprite",
- name = creative_mode_defines.names.sprites.cancel,
- filename = creative_mode_defines.mod_directory .. "/graphics/sprites/cancel.png",
- width = 32,
- height = 32,
- scale = 1
- },
- {
- type = "sprite",
- name = creative_mode_defines.names.sprites.search,
- filename = creative_mode_defines.mod_directory .. "/graphics/sprites/search.png",
- width = 32,
- height = 32,
- scale = 1
- }
- }
-)
+data:extend({
+ {
+ type = "sprite",
+ name = creative_mode_defines.names.sprites.reset,
+ filename = creative_mode_defines.mod_directory .. "/graphics/sprites/reset.png",
+ width = 32,
+ height = 32,
+ scale = 1,
+ },
+ {
+ type = "sprite",
+ name = creative_mode_defines.names.sprites.cancel,
+ filename = creative_mode_defines.mod_directory .. "/graphics/sprites/cancel.png",
+ width = 32,
+ height = 32,
+ scale = 1,
+ },
+ {
+ type = "sprite",
+ name = creative_mode_defines.names.sprites.search,
+ filename = creative_mode_defines.mod_directory .. "/graphics/sprites/search.png",
+ width = 32,
+ height = 32,
+ scale = 1,
+ },
+})
diff --git a/prototypes/style.lua b/prototypes/style.lua
index 4ecb9a6..0eb96e6 100644
--- a/prototypes/style.lua
+++ b/prototypes/style.lua
@@ -1,12 +1,12 @@
-- Makes and returns a graphical set according to the given properties.
local function extract_monolith(file_name, x, y, width, height)
- return {
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. file_name,
- position = {x, y},
- size = {width, height},
- scale = 1,
- border = 1
- }
+ return {
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. file_name,
+ position = { x, y },
+ size = { width, height },
+ scale = 1,
+ border = 1,
+ }
end
-- Create styles.
local default_style = data.raw["gui-style"].default
@@ -34,993 +34,998 @@ local quick_action_remove_button_width = 18
local magic_wand_popup_left_frame_caption_width = magic_wand_popup_slot_table_width - frame_caption_button_width
local magic_wand_popup_right_frame_caption_width = cheat_width - frame_caption_button_width
local events_menu_frame_width = cheat_width + 15 + 8
-local events_menu_frame_caption_label_width =
- events_menu_frame_width - default_horizontal_spacing - search_textfield_width - default_horizontal_spacing -
- frame_caption_button_width
+local events_menu_frame_caption_label_width = events_menu_frame_width
+ - default_horizontal_spacing
+ - search_textfield_width
+ - default_horizontal_spacing
+ - frame_caption_button_width
local creative_chest_item_group_left_right_button_width = 20
local creative_chest_item_group_number_label_width = 60
-- Flow style with resize to row height.
default_style[creative_mode_defines.names.gui_styles.resize_col_flow] = {
- type = "horizontal_flow_style",
- parent = "horizontal_flow",
- resize_to_row_height = true
+ type = "horizontal_flow_style",
+ parent = "horizontal_flow",
+ resize_to_row_height = true,
}
-- Flow style with no horizontal spacing.
default_style[creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow] = {
- type = "horizontal_flow_style",
- parent = "horizontal_flow",
- horizontal_spacing = 0
+ type = "horizontal_flow_style",
+ parent = "horizontal_flow",
+ horizontal_spacing = 0,
}
-- Flow style with no horizontal spacing and resize to row height.
default_style[creative_mode_defines.names.gui_styles.no_horizontal_spacing_resize_col_flow] = {
- type = "horizontal_flow_style",
- parent = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- resize_to_row_height = true
+ type = "horizontal_flow_style",
+ parent = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ resize_to_row_height = true,
}
-- Flow style with no vertical spacing and resize row to width.
default_style[creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow] = {
- type = "vertical_flow_style",
- parent = "vertical_flow",
- vertical_spacing = 0,
- resize_row_to_width = true
+ type = "vertical_flow_style",
+ parent = "vertical_flow",
+ vertical_spacing = 0,
+ resize_row_to_width = true,
}
--------------------------------------------------------------------
-- Longer dialog button, but still shorter than menu button.
default_style[creative_mode_defines.names.gui_styles.long_dialog_button] = {
- type = "button_style",
- parent = "dialog_button",
- minimal_width = 200
+ type = "button_style",
+ parent = "dialog_button",
+ minimal_width = 200,
}
-- Single-lined height, no fixed width button style with default-bold font.
default_style[creative_mode_defines.names.gui_styles.small_default_bold_button] = {
- type = "button_style",
- parent = "button",
- font = "default-bold",
- height = cheat_on_off_button_height,
- top_padding = 0,
- bottom_padding = 0,
- left_click_sound = {
- {
- filename = "__core__/sound/gui-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ font = "default-bold",
+ height = cheat_on_off_button_height,
+ top_padding = 0,
+ bottom_padding = 0,
+ left_click_sound = {
+ {
+ filename = "__core__/sound/gui-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The style for the search textfield besides the frame title.
default_style[creative_mode_defines.names.gui_styles.frame_search_textfield] = {
- type = "textbox_style",
- parent = "textbox",
- width = search_textfield_width,
- scalable = false
+ type = "textbox_style",
+ parent = "textbox",
+ width = search_textfield_width,
+ scalable = false,
}
-- The style for the placeholder flow when search textfield is not visible.
default_style[creative_mode_defines.names.gui_styles.frame_search_textfield_placeholder_flow] = {
- type = "horizontal_flow_style",
- parent = "horizontal_flow",
- width = search_textfield_width,
- scalable = false
+ type = "horizontal_flow_style",
+ parent = "horizontal_flow",
+ width = search_textfield_width,
+ scalable = false,
}
--------------------------------------------------------------------
-- The main menu open button style.
default_style[creative_mode_defines.names.gui_styles.main_menu_open_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.entity_open_button,
- default_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 0,
- big_button_width_height * 0,
- big_button_width_height,
- big_button_width_height
- ),
- hovered_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 1,
- big_button_width_height * 0,
- big_button_width_height,
- big_button_width_height
- ),
- clicked_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 2,
- big_button_width_height * 0,
- big_button_width_height,
- big_button_width_height
- ),
- disabled_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 3,
- big_button_width_height * 0,
- big_button_width_height,
- big_button_width_height
- )
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.entity_open_button,
+ default_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 0,
+ big_button_width_height * 0,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ hovered_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 1,
+ big_button_width_height * 0,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ clicked_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 2,
+ big_button_width_height * 0,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ disabled_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 3,
+ big_button_width_height * 0,
+ big_button_width_height,
+ big_button_width_height
+ ),
}
-- The style for main menu buttons.
default_style[creative_mode_defines.names.gui_styles.main_menu_button] = {
- type = "button_style",
- parent = "button",
- width = 150,
- left_click_sound = {
- {
- filename = "__core__/sound/gui-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ width = 150,
+ left_click_sound = {
+ {
+ filename = "__core__/sound/gui-click.ogg",
+ volume = 1,
+ },
+ },
}
--------------------------------------------------------------------
-- Frame style without graphic set and with a small, orange title.
default_style[creative_mode_defines.names.gui_styles.naked_small_orange_title_frame] = {
- type = "frame_style",
- parent = "frame",
- font = "default-bold",
- font_color = default_orange_color
+ type = "frame_style",
+ parent = "frame",
+ font = "default-bold",
+ font_color = default_orange_color,
}
-- Frame style with just a white line at the right and a small, orange title.
default_style[creative_mode_defines.names.gui_styles.small_orange_title_with_right_border_frame] = {
- type = "frame_style",
- parent = creative_mode_defines.names.gui_styles.naked_small_orange_title_frame,
- right_padding = 1,
- graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/right-border.png",
- priority = "extra-high-no-scale",
- corner_size = {1, 1},
- position = {0, 0}
- }
+ type = "frame_style",
+ parent = creative_mode_defines.names.gui_styles.naked_small_orange_title_frame,
+ right_padding = 1,
+ graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/right-border.png",
+ priority = "extra-high-no-scale",
+ corner_size = { 1, 1 },
+ position = { 0, 0 },
+ },
}
--------------------------------------------------------------------
-- Table style with scalable equal to false and no horizontal or vertical spacing.
default_style[creative_mode_defines.names.gui_styles.unscalable_no_spacing_table] = {
- type = "table_style",
- parent = "table",
- horizontal_spacing = 0,
- vertical_spacing = 0,
- scalable = false
+ type = "table_style",
+ parent = "table",
+ horizontal_spacing = 0,
+ vertical_spacing = 0,
+ scalable = false,
}
-- Style for the label in slot button.
-- Note: it is impossible to replicate the vanilla item count label, as the label will block raycast.
default_style[creative_mode_defines.names.gui_styles.slot_button_label] = {
- type = "label_style",
- parent = "label",
- font = "default-small-bold",
- align = "left",
- width = inventory_slot_width,
- height = inventory_slot_width
+ type = "label_style",
+ parent = "label",
+ font = "default-small-bold",
+ align = "left",
+ width = inventory_slot_width,
+ height = inventory_slot_width,
}
--------------------------------------------------------------------
-- Style for turned-on slider buttons.
default_style[creative_mode_defines.names.gui_styles.slider_button_on] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.slider_button_off,
- default_graphical_set = {
- type = "composition",
- filename = "__core__/graphics/gui.png",
- priority = "extra-high-no-scale",
- corner_size = {3, 3},
- position = {0, 8}
- }
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.slider_button_off,
+ default_graphical_set = {
+ type = "composition",
+ filename = "__core__/graphics/gui.png",
+ priority = "extra-high-no-scale",
+ corner_size = { 3, 3 },
+ position = { 0, 8 },
+ },
}
-- Style for turned-off slider buttons.
default_style[creative_mode_defines.names.gui_styles.slider_button_off] = {
- type = "button_style",
- parent = "button",
- scalable = false,
- top_padding = 0,
- right_padding = 0,
- bottom_padding = 0,
- left_padding = 0,
- width = slider_button_width,
- height = slider_button_height,
- left_click_sound = {
- {
- filename = "__core__/sound/list-box-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ scalable = false,
+ top_padding = 0,
+ right_padding = 0,
+ bottom_padding = 0,
+ left_padding = 0,
+ width = slider_button_width,
+ height = slider_button_height,
+ left_click_sound = {
+ {
+ filename = "__core__/sound/list-box-click.ogg",
+ volume = 1,
+ },
+ },
}
-- Style for slider textfields.
default_style[creative_mode_defines.names.gui_styles.slider_textfield] = {
- type = "textbox_style",
- parent = "slider_value_textfield",
- width = slider_textfield_width,
- scalable = false
+ type = "textbox_style",
+ parent = "slider_value_textfield",
+ width = slider_textfield_width,
+ scalable = false,
}
--------------------------------------------------------------------
-- The style for cheat scoll pane.
default_style[creative_mode_defines.names.gui_styles.cheat_scroll_pane] = {
- type = "scroll_pane_style",
- parent = "scroll_pane",
- maximal_height = cheat_all_height,
- scalable = false,
- vertical_scroll_bar_spacing = 0
+ type = "scroll_pane_style",
+ parent = "scroll_pane",
+ maximal_height = cheat_all_height,
+ scalable = false,
+ vertical_scroll_bar_spacing = 0,
}
-- The style for cheat target selection frame that contains all cheat target options.
default_style[creative_mode_defines.names.gui_styles.cheat_target_selection_container_frame] = {
- type = "frame_style",
- parent = "frame",
- top_padding = 0,
- right_padding = 0,
- bottom_padding = 0,
- left_padding = 0,
- minimal_height = cheat_selection_min_height,
- scalable = false,
- graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "black.png",
- priority = "extra-high-no-scale",
- corner_size = 1,
- position = {0, 0}
- }
+ type = "frame_style",
+ parent = "frame",
+ top_padding = 0,
+ right_padding = 0,
+ bottom_padding = 0,
+ left_padding = 0,
+ minimal_height = cheat_selection_min_height,
+ scalable = false,
+ graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "black.png",
+ priority = "extra-high-no-scale",
+ corner_size = 1,
+ position = { 0, 0 },
+ },
}
-- The style for selected cheat target (not self) button.
default_style[creative_mode_defines.names.gui_styles.cheat_target_selected_button] = {
- type = "button_style",
- parent = "button",
- align = "left",
- top_padding = 0,
- bottom_padding = 0,
- left_padding = 0,
- right_padding = 0,
- width = cheat_selection_width,
- height = cheat_selection_button_height,
- scalable = false,
- default_font_color = {r = 1, g = 1, b = 1},
- default_graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
- priority = "extra-high-no-scale",
- corner_size = 1,
- position = {0, 0}
- },
- hovered_font_color = {r = 1, g = 1, b = 1},
- hovered_graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
- priority = "extra-high-no-scale",
- corner_size = 1,
- position = {0, 0}
- },
- clicked_font_color = {r = 1, g = 1, b = 1},
- clicked_graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
- priority = "extra-high-no-scale",
- corner_size = 1,
- position = {0, 0}
- },
- disabled_font_color = {r = 0.5, g = 0.5, b = 0.5},
- disabled_graphical_set = {
- type = "none"
- },
- left_click_sound = {
- {
- filename = "__core__/sound/list-box-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ align = "left",
+ top_padding = 0,
+ bottom_padding = 0,
+ left_padding = 0,
+ right_padding = 0,
+ width = cheat_selection_width,
+ height = cheat_selection_button_height,
+ scalable = false,
+ default_font_color = { r = 1, g = 1, b = 1 },
+ default_graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
+ priority = "extra-high-no-scale",
+ corner_size = 1,
+ position = { 0, 0 },
+ },
+ hovered_font_color = { r = 1, g = 1, b = 1 },
+ hovered_graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
+ priority = "extra-high-no-scale",
+ corner_size = 1,
+ position = { 0, 0 },
+ },
+ clicked_font_color = { r = 1, g = 1, b = 1 },
+ clicked_graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
+ priority = "extra-high-no-scale",
+ corner_size = 1,
+ position = { 0, 0 },
+ },
+ disabled_font_color = { r = 0.5, g = 0.5, b = 0.5 },
+ disabled_graphical_set = {
+ type = "none",
+ },
+ left_click_sound = {
+ {
+ filename = "__core__/sound/list-box-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The style for unselected cheat target (not self) button.
default_style[creative_mode_defines.names.gui_styles.cheat_target_unselected_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.cheat_target_selected_button,
- default_graphical_set = {
- type = "none"
- },
- clicked_graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "grey.png",
- priority = "extra-high-no-scale",
- corner_size = 1,
- position = {0, 0}
- },
- hovered_graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "grey.png",
- priority = "extra-high-no-scale",
- corner_size = 1,
- position = {0, 0}
- }
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_target_selected_button,
+ default_graphical_set = {
+ type = "none",
+ },
+ clicked_graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "grey.png",
+ priority = "extra-high-no-scale",
+ corner_size = 1,
+ position = { 0, 0 },
+ },
+ hovered_graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "grey.png",
+ priority = "extra-high-no-scale",
+ corner_size = 1,
+ position = { 0, 0 },
+ },
}
-- The style for selected cheat target (self) button.
default_style[creative_mode_defines.names.gui_styles.cheat_target_self_selected_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.cheat_target_selected_button,
- default_font_color = {r = 0, g = 0, b = 1},
- hovered_font_color = {r = 0, g = 0, b = 1},
- clicked_font_color = {r = 0, g = 0, b = 1},
- disabled_font_color = {r = 0, g = 0, b = 0.5}
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_target_selected_button,
+ default_font_color = { r = 0, g = 0, b = 1 },
+ hovered_font_color = { r = 0, g = 0, b = 1 },
+ clicked_font_color = { r = 0, g = 0, b = 1 },
+ disabled_font_color = { r = 0, g = 0, b = 0.5 },
}
-- The style for unselected cheat target (self) button.
default_style[creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.cheat_target_unselected_button,
- default_font_color = {r = 0, g = 0, b = 1},
- hovered_font_color = {r = 0, g = 0, b = 1},
- clicked_font_color = {r = 0, g = 0, b = 1},
- disabled_font_color = {r = 0, g = 0, b = 0.5}
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_target_unselected_button,
+ default_font_color = { r = 0, g = 0, b = 1 },
+ hovered_font_color = { r = 0, g = 0, b = 1 },
+ clicked_font_color = { r = 0, g = 0, b = 1 },
+ disabled_font_color = { r = 0, g = 0, b = 0.5 },
}
-- The style for the select all targets button.
default_style[creative_mode_defines.names.gui_styles.cheat_select_all_targets_button] = {
- type = "button_style",
- parent = "button",
- width = cheat_selection_width,
- scalable = false,
- left_click_sound = {
- {
- filename = "__core__/sound/gui-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ width = cheat_selection_width,
+ scalable = false,
+ left_click_sound = {
+ {
+ filename = "__core__/sound/gui-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The style for the table that contains each individual cheat option.
default_style[creative_mode_defines.names.gui_styles.cheat_table] = {
- type = "table_style",
- parent = "table",
- horizontal_spacing = 0,
- width = cheat_width,
- scalable = false
+ type = "table_style",
+ parent = "table",
+ horizontal_spacing = 0,
+ width = cheat_width,
+ scalable = false,
}
-- The style for the flow that contains each individual cheat option.
default_style[creative_mode_defines.names.gui_styles.cheat_flow] = {
- type = "horizontal_flow_style",
- parent = "horizontal_flow",
- horizontal_spacing = 0,
- width = cheat_width,
- scalable = false
+ type = "horizontal_flow_style",
+ parent = "horizontal_flow",
+ horizontal_spacing = 0,
+ width = cheat_width,
+ scalable = false,
}
-- The cheat name label style.
default_style[creative_mode_defines.names.gui_styles.cheat_name_label] = {
- type = "label_style",
- parent = "label",
- width = cheat_label_width,
- scalable = false
+ type = "label_style",
+ parent = "label",
+ width = cheat_label_width,
+ scalable = false,
}
-- The cheat on/off button with off state style.
default_style[creative_mode_defines.names.gui_styles.cheat_on_off_button_off] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.small_default_bold_button,
- width = cheat_on_off_button_width,
- scalable = false
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.small_default_bold_button,
+ width = cheat_on_off_button_width,
+ scalable = false,
}
-- The cheat on/off button with on state style.
default_style[creative_mode_defines.names.gui_styles.cheat_on_off_button_on] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
- default_graphical_set = {
- type = "composition",
- filename = "__core__/graphics/gui.png",
- priority = "extra-high-no-scale",
- corner_size = {3, 3},
- position = {0, 8}
- }
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
+ default_graphical_set = {
+ type = "composition",
+ filename = "__core__/graphics/gui.png",
+ priority = "extra-high-no-scale",
+ corner_size = { 3, 3 },
+ position = { 0, 8 },
+ },
}
-- The cheat numeric textfield style.
default_style[creative_mode_defines.names.gui_styles.cheat_numeric_textfield] = {
- type = "textbox_style",
- parent = "long_number_textfield",
- width = math.floor((cheat_width - cheat_label_width - 8) * 0.625),
- scalable = false
+ type = "textbox_style",
+ parent = "long_number_textfield",
+ width = math.floor((cheat_width - cheat_label_width - 8) * 0.625),
+ scalable = false,
}
-- The flow style for separating the cheat numeric textfield and apply button.
default_style[creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow] = {
- type = "horizontal_flow_style",
- parent = "horizontal_flow",
- width = default_horizontal_spacing,
- scalable = false
+ type = "horizontal_flow_style",
+ parent = "horizontal_flow",
+ width = default_horizontal_spacing,
+ scalable = false,
}
-- The cheat apply button style.
default_style[creative_mode_defines.names.gui_styles.cheat_apply_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.small_default_bold_button,
- width = math.floor((cheat_width - cheat_label_width - 8) * 0.375),
- scalable = false
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.small_default_bold_button,
+ width = math.floor((cheat_width - cheat_label_width - 8) * 0.375),
+ scalable = false,
}
-- The cheat name label style for cheats that have only one button.
default_style[creative_mode_defines.names.gui_styles.cheat_with_one_button_name_label] = {
- type = "label_style",
- parent = creative_mode_defines.names.gui_styles.cheat_name_label,
- width = cheat_label_width + cheat_on_off_button_width,
- scalable = false
+ type = "label_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_name_label,
+ width = cheat_label_width + cheat_on_off_button_width,
+ scalable = false,
}
-- The style for the enable all/disable all buttons table container.
default_style[creative_mode_defines.names.gui_styles.cheat_enable_disable_all_table] = {
- type = "table_style",
- parent = creative_mode_defines.names.gui_styles.cheat_table,
- top_padding = 15
+ type = "table_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_table,
+ top_padding = 15,
}
-- The cheat enable/disable all button style.
default_style[creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.small_default_bold_button,
- width = cheat_width / 2,
- scalable = false
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.small_default_bold_button,
+ width = cheat_width / 2,
+ scalable = false,
}
-- The style for note label under the cheat enable/disable all buttons.
default_style[creative_mode_defines.names.gui_styles.cheat_note_label] = {
- type = "label_style",
- parent = "label",
- font = "default-small",
- width = cheat_width,
- scalable = false
+ type = "label_style",
+ parent = "label",
+ font = "default-small",
+ width = cheat_width,
+ scalable = false,
}
-- The style for cheat value target selection drop down (e.g. team selection) - current selection button.
default_style[creative_mode_defines.names.gui_styles.cheat_value_drop_down_current_target_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
- font = "default",
- align = "left",
- width = cheat_on_off_button_width * 2,
- scalable = false,
- right_padding = 4,
- left_padding = 4,
- bottom_padding = 2,
- default_graphical_set = {
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "cheat-dropdown.png",
- top_border = 3,
- right_border = 14,
- bottom_border = 3,
- left_border = 3,
- width = 150,
- height = 25
- },
- hovered_graphical_set = {
- top_border = 3,
- right_border = 14,
- bottom_border = 3,
- left_border = 3,
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "cheat-dropdown.png",
- width = 150,
- height = 25
- },
- clicked_graphical_set = {
- top_border = 3,
- right_border = 14,
- bottom_border = 3,
- left_border = 3,
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "cheat-dropdown.png",
- width = 150,
- height = 25
- },
- disabled_graphical_set = {
- top_border = 3,
- right_border = 14,
- bottom_border = 3,
- left_border = 3,
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "cheat-dropdown.png",
- width = 150,
- height = 25
- }
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
+ font = "default",
+ align = "left",
+ width = cheat_on_off_button_width * 2,
+ scalable = false,
+ right_padding = 4,
+ left_padding = 4,
+ bottom_padding = 2,
+ default_graphical_set = {
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "cheat-dropdown.png",
+ top_border = 3,
+ right_border = 14,
+ bottom_border = 3,
+ left_border = 3,
+ width = 150,
+ height = 25,
+ },
+ hovered_graphical_set = {
+ top_border = 3,
+ right_border = 14,
+ bottom_border = 3,
+ left_border = 3,
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "cheat-dropdown.png",
+ width = 150,
+ height = 25,
+ },
+ clicked_graphical_set = {
+ top_border = 3,
+ right_border = 14,
+ bottom_border = 3,
+ left_border = 3,
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "cheat-dropdown.png",
+ width = 150,
+ height = 25,
+ },
+ disabled_graphical_set = {
+ top_border = 3,
+ right_border = 14,
+ bottom_border = 3,
+ left_border = 3,
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "cheat-dropdown.png",
+ width = 150,
+ height = 25,
+ },
}
-- The style for cheat value target selection drop down (e.g. team selection) - scroll pane.
default_style[creative_mode_defines.names.gui_styles.cheat_value_drop_down_scroll_pane] = {
- type = "scroll_pane_style",
- parent = creative_mode_defines.names.gui_styles.cheat_scroll_pane,
- maximal_height = cheat_value_drop_down_height
+ type = "scroll_pane_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_scroll_pane,
+ maximal_height = cheat_value_drop_down_height,
}
-- The style for cheat value target selection drop down (e.g. team selection) - frame.
default_style[creative_mode_defines.names.gui_styles.cheat_value_drop_down_container_frame] = {
- type = "frame_style",
- parent = creative_mode_defines.names.gui_styles.cheat_target_selection_container_frame,
- minimal_height = cheat_value_drop_down_height
+ type = "frame_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_target_selection_container_frame,
+ minimal_height = cheat_value_drop_down_height,
}
-- The style for cheat value target selection drop down (e.g. team selection) - selection button.
default_style[creative_mode_defines.names.gui_styles.cheat_value_drop_down_selection_button] = {
- type = "button_style",
- parent = "button",
- font = "default",
- align = "left",
- top_padding = 0,
- bottom_padding = 0,
- left_padding = 0,
- right_padding = 0,
- width = cheat_on_off_button_width * 2,
- height = cheat_on_off_button_height,
- scalable = false,
- default_font_color = {r = 1, g = 1, b = 1},
- default_graphical_set = {
- type = "none"
- },
- hovered_font_color = {r = 1, g = 1, b = 1},
- hovered_graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
- priority = "extra-high-no-scale",
- corner_size = 1,
- position = {0, 0}
- },
- clicked_font_color = {r = 1, g = 1, b = 1},
- clicked_graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
- priority = "extra-high-no-scale",
- corner_size = 1,
- position = {0, 0}
- },
- disabled_font_color = {r = 0.5, g = 0.5, b = 0.5},
- disabled_graphical_set = {
- type = "none"
- },
- left_click_sound = {
- {
- filename = "__core__/sound/list-box-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ font = "default",
+ align = "left",
+ top_padding = 0,
+ bottom_padding = 0,
+ left_padding = 0,
+ right_padding = 0,
+ width = cheat_on_off_button_width * 2,
+ height = cheat_on_off_button_height,
+ scalable = false,
+ default_font_color = { r = 1, g = 1, b = 1 },
+ default_graphical_set = {
+ type = "none",
+ },
+ hovered_font_color = { r = 1, g = 1, b = 1 },
+ hovered_graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
+ priority = "extra-high-no-scale",
+ corner_size = 1,
+ position = { 0, 0 },
+ },
+ clicked_font_color = { r = 1, g = 1, b = 1 },
+ clicked_graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/" .. "orange.png",
+ priority = "extra-high-no-scale",
+ corner_size = 1,
+ position = { 0, 0 },
+ },
+ disabled_font_color = { r = 0.5, g = 0.5, b = 0.5 },
+ disabled_graphical_set = {
+ type = "none",
+ },
+ left_click_sound = {
+ {
+ filename = "__core__/sound/list-box-click.ogg",
+ volume = 1,
+ },
+ },
}
--------------------------------------------------------------------
-- The style for magic wand frame title label.
default_style[creative_mode_defines.names.gui_styles.magic_wand_frame_caption_label] = {
- type = "label_style",
- -- parent = creative_mode_defines.names.gui_styles.frame_caption_label,
- width = cheat_width * 2 - inventory_slot_width,
- scalable = false
+ type = "label_style",
+ -- parent = creative_mode_defines.names.gui_styles.frame_caption_label,
+ width = cheat_width * 2 - inventory_slot_width,
+ scalable = false,
}
-- The style for magic wand scroll pane.
default_style[creative_mode_defines.names.gui_styles.magic_wand_scroll_pane] = {
- type = "scroll_pane_style",
- parent = "scroll_pane",
- maximal_height = cheat_all_height,
- scalable = false
+ type = "scroll_pane_style",
+ parent = "scroll_pane",
+ maximal_height = cheat_all_height,
+ scalable = false,
}
-- The style for magic wand select mode frame.
default_style[creative_mode_defines.names.gui_styles.magic_wand_select_mode_frame] = {
- type = "frame_style",
- parent = creative_mode_defines.names.gui_styles.small_orange_title_with_right_border_frame,
- width = cheat_width + 3,
- scalable = false
+ type = "frame_style",
+ parent = creative_mode_defines.names.gui_styles.small_orange_title_with_right_border_frame,
+ width = cheat_width + 3,
+ scalable = false,
}
-- The style for magic wand alt-select mode frame.
default_style[creative_mode_defines.names.gui_styles.magic_wand_alt_select_mode_frame] = {
- type = "frame_style",
- parent = creative_mode_defines.names.gui_styles.naked_small_orange_title_frame,
- width = cheat_width,
- scalable = false
+ type = "frame_style",
+ parent = creative_mode_defines.names.gui_styles.naked_small_orange_title_frame,
+ width = cheat_width,
+ scalable = false,
}
-- The style for labels in magic wand select mode or alt-select mode frames.
default_style[creative_mode_defines.names.gui_styles.magic_wand_label] = {
- type = "label_style",
- parent = "label",
- width = cheat_width,
- scalable = false
+ type = "label_style",
+ parent = "label",
+ width = cheat_width,
+ scalable = false,
}
-- The style for checkboxes in magic wand select mode or alt-select mode frames.
default_style[creative_mode_defines.names.gui_styles.magic_wand_checkbox] = {
- type = "checkbox_style",
- parent = "checkbox",
- width = cheat_width,
- scalable = false
+ type = "checkbox_style",
+ parent = "checkbox",
+ width = cheat_width,
+ scalable = false,
}
-- The style for radiobuttons in magic wand select mode or alt-select mode frames.
default_style[creative_mode_defines.names.gui_styles.magic_wand_radiobutton] = {
- type = "radiobutton_style",
- parent = "radiobutton",
- width = cheat_width,
- scalable = false
+ type = "radiobutton_style",
+ parent = "radiobutton",
+ width = cheat_width,
+ scalable = false,
}
-- The filter slot on button style.
default_style[creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on] = {
- type = "button_style",
- parent = "slot_button",
- left_click_sound = {
- {
- filename = "__core__/sound/list-box-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "slot_button",
+ left_click_sound = {
+ {
+ filename = "__core__/sound/list-box-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The filter slot off button style.
default_style[creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off] = {
- type = "button_style",
- parent = "red_slot_button",
- left_click_sound = {
- {
- filename = "__core__/sound/list-box-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "red_slot_button",
+ left_click_sound = {
+ {
+ filename = "__core__/sound/list-box-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The tile slot selected button style.
default_style[creative_mode_defines.names.gui_styles.tile_slot_selected] = {
- type = "button_style",
- parent = "button",
- left_click_sound = {
- {
- filename = "__core__/sound/list-box-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ left_click_sound = {
+ {
+ filename = "__core__/sound/list-box-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The tile slot deselected button style.
default_style[creative_mode_defines.names.gui_styles.tile_slot_deselected] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on,
}
-- The style for labels of sliders in magic wand select mode or alt-select mode frames.
default_style[creative_mode_defines.names.gui_styles.magic_wand_slider_label] = {
- type = "label_style",
- parent = "label",
- width = cheat_width - default_horizontal_spacing - (slider_button_width * 13) - default_horizontal_spacing -
- slider_textfield_width -
- default_horizontal_spacing,
- scalable = false
+ type = "label_style",
+ parent = "label",
+ width = cheat_width
+ - default_horizontal_spacing
+ - (slider_button_width * 13)
+ - default_horizontal_spacing
+ - slider_textfield_width
+ - default_horizontal_spacing,
+ scalable = false,
}
-- The style for the labels before the drop-downs in magic wand select mode or alt-select mode frames.
default_style[creative_mode_defines.names.gui_styles.magic_wand_drop_down_label] = {
- type = "label_style",
- parent = "label",
- width = cheat_width * 0.5 - default_horizontal_spacing,
- scalable = false
+ type = "label_style",
+ parent = "label",
+ width = cheat_width * 0.5 - default_horizontal_spacing,
+ scalable = false,
}
-- The style for drop-downs in magic wand select mode or alt-select mode frames.
default_style[creative_mode_defines.names.gui_styles.magic_wand_drop_down] = {
- type = "dropdown_style",
- parent = "dropdown",
- width = cheat_width * 0.5 - default_horizontal_spacing,
- scalable = false
+ type = "dropdown_style",
+ parent = "dropdown",
+ width = cheat_width * 0.5 - default_horizontal_spacing,
+ scalable = false,
}
-- The style for magic wand select all (forces) button.
default_style[creative_mode_defines.names.gui_styles.magic_wand_select_all_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.small_default_bold_button,
- width = cheat_width,
- scalable = false
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.small_default_bold_button,
+ width = cheat_width,
+ scalable = false,
}
-- The style for magic wand quick action remove button.
default_style[creative_mode_defines.names.gui_styles.magic_wand_quick_action_remove_button] = {
- type = "button_style",
- parent = "slot_button",
- width = quick_action_remove_button_width,
- height = quick_action_remove_button_width,
- scalable = false,
- left_click_sound = {
- {
- filename = "__core__/sound/gui-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "slot_button",
+ width = quick_action_remove_button_width,
+ height = quick_action_remove_button_width,
+ scalable = false,
+ left_click_sound = {
+ {
+ filename = "__core__/sound/gui-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The style for magic wand popup left frame caption label.
default_style[creative_mode_defines.names.gui_styles.magic_wand_popup_left_frame_caption_label] = {
- type = "label_style",
- -- parent = creative_mode_defines.names.gui_styles.frame_caption_label,
- width = magic_wand_popup_left_frame_caption_width,
- scalable = false
+ type = "label_style",
+ -- parent = creative_mode_defines.names.gui_styles.frame_caption_label,
+ width = magic_wand_popup_left_frame_caption_width,
+ scalable = false,
}
-- The style for magic wand popup right frame caption label.
default_style[creative_mode_defines.names.gui_styles.magic_wand_popup_right_frame_caption_label] = {
- type = "label_style",
- -- parent = creative_mode_defines.names.gui_styles.frame_caption_label,
- width = magic_wand_popup_right_frame_caption_width,
- scalable = false
+ type = "label_style",
+ -- parent = creative_mode_defines.names.gui_styles.frame_caption_label,
+ width = magic_wand_popup_right_frame_caption_width,
+ scalable = false,
}
-- The style for magic wand popup frame.
default_style[creative_mode_defines.names.gui_styles.magic_wand_popup_slot_scroll_pane] = {
- type = "scroll_pane_style",
- parent = "scroll_pane",
- height = magic_wand_popup_height,
- scalable = false
+ type = "scroll_pane_style",
+ parent = "scroll_pane",
+ height = magic_wand_popup_height,
+ scalable = false,
}
-- The style for magic wand popup slot table.
default_style[creative_mode_defines.names.gui_styles.magic_wand_popup_slot_table] = {
- type = "table_style",
- parent = creative_mode_defines.names.gui_styles.slot_table,
- width = magic_wand_popup_slot_table_width,
- scalable = false
+ type = "table_style",
+ parent = creative_mode_defines.names.gui_styles.slot_table,
+ width = magic_wand_popup_slot_table_width,
+ scalable = false,
}
-- The item-on-ground slot on magic wand popup.
default_style[creative_mode_defines.names.gui_styles.magic_wand_popup_item_on_ground_slot_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.magic_wand_popup_ghost_slot_button,
- default_graphical_set = {
- top_border = 1,
- right_border = 1,
- bottom_border = 1,
- left_border = 1,
- filename = "__core__/graphics/gui.png",
- width = 36,
- height = 36,
- x = 111,
- y = 72
- },
- hovered_graphical_set = {
- top_border = 1,
- right_border = 1,
- bottom_border = 1,
- left_border = 1,
- filename = "__core__/graphics/gui.png",
- priority = "extra-high-no-scale",
- width = 36,
- height = 36,
- x = 148,
- y = 72
- },
- clicked_graphical_set = {
- top_border = 1,
- right_border = 1,
- bottom_border = 1,
- left_border = 1,
- filename = "__core__/graphics/gui.png",
- priority = "extra-high-no-scale",
- width = 36,
- height = 36,
- x = 185,
- y = 72
- }
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.magic_wand_popup_ghost_slot_button,
+ default_graphical_set = {
+ top_border = 1,
+ right_border = 1,
+ bottom_border = 1,
+ left_border = 1,
+ filename = "__core__/graphics/gui.png",
+ width = 36,
+ height = 36,
+ x = 111,
+ y = 72,
+ },
+ hovered_graphical_set = {
+ top_border = 1,
+ right_border = 1,
+ bottom_border = 1,
+ left_border = 1,
+ filename = "__core__/graphics/gui.png",
+ priority = "extra-high-no-scale",
+ width = 36,
+ height = 36,
+ x = 148,
+ y = 72,
+ },
+ clicked_graphical_set = {
+ top_border = 1,
+ right_border = 1,
+ bottom_border = 1,
+ left_border = 1,
+ filename = "__core__/graphics/gui.png",
+ priority = "extra-high-no-scale",
+ width = 36,
+ height = 36,
+ x = 185,
+ y = 72,
+ },
}
-- The ghost slot on magic wand popup.
default_style[creative_mode_defines.names.gui_styles.magic_wand_popup_ghost_slot_button] = {
- type = "button_style",
- parent = "blue_slot",
- left_click_sound = {
- {
- filename = "__core__/sound/list-box-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "blue_slot",
+ left_click_sound = {
+ {
+ filename = "__core__/sound/list-box-click.ogg",
+ volume = 1,
+ },
+ },
}
--------------------------------------------------------------------
-- The style for events menu frame caption label.
default_style[creative_mode_defines.names.gui_styles.events_menu_frame_caption_label] = {
- type = "label_style",
- -- parent = creative_mode_defines.names.gui_styles.frame_caption_label,
- width = events_menu_frame_caption_label_width,
- scalable = false
+ type = "label_style",
+ -- parent = creative_mode_defines.names.gui_styles.frame_caption_label,
+ width = events_menu_frame_caption_label_width,
+ scalable = false,
}
--------------------------------------------------------------------
-- The style for interfaces scroll pane.
default_style[creative_mode_defines.names.gui_styles.interfaces_scroll_pane] = {
- type = "scroll_pane_style",
- parent = "scroll_pane",
- maximal_height = cheat_all_height
+ type = "scroll_pane_style",
+ parent = "scroll_pane",
+ maximal_height = cheat_all_height,
}
-- The style for interface buttons.
default_style[creative_mode_defines.names.gui_styles.interface_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.cheat_apply_button,
- width = cheat_width
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_apply_button,
+ width = cheat_width,
}
-- The style for interface contents scroll pane.
default_style[creative_mode_defines.names.gui_styles.interface_contents_scroll_pane] = {
- type = "scroll_pane_style",
- parent = creative_mode_defines.names.gui_styles.interfaces_scroll_pane,
- maximal_height = cheat_all_height - 120
+ type = "scroll_pane_style",
+ parent = creative_mode_defines.names.gui_styles.interfaces_scroll_pane,
+ maximal_height = cheat_all_height - 120,
}
-- The style for interface content buttons.
default_style[creative_mode_defines.names.gui_styles.interface_content_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.interface_button,
- align = "left",
- font = "default"
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.interface_button,
+ align = "left",
+ font = "default",
}
--------------------------------------------------------------------
-- The access right option on/off button with on state style.
default_style[creative_mode_defines.names.gui_styles.access_right_on_off_button_on] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.cheat_on_off_button_on,
- width = access_right_on_off_button_width
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_on_off_button_on,
+ width = access_right_on_off_button_width,
}
-- The access right option on/off button with off state style.
default_style[creative_mode_defines.names.gui_styles.access_right_on_off_button_off] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
- width = access_right_on_off_button_width
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
+ width = access_right_on_off_button_width,
}
--------------------------------------------------------------------
-- The disable Creative Mode button style.
default_style[creative_mode_defines.names.gui_styles.disable_creative_mode_button] = {
- type = "button_style",
- parent = "button",
- width = 250,
- default_graphical_set = {
- type = "composition",
- filename = creative_mode_defines.mod_directory .. "/graphics/gui/red-button.png",
- priority = "extra-high-no-scale",
- corner_size = {3, 3},
- position = {0, 0}
- },
- left_click_sound = {
- {
- filename = "__core__/sound/gui-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ width = 250,
+ default_graphical_set = {
+ type = "composition",
+ filename = creative_mode_defines.mod_directory .. "/graphics/gui/red-button.png",
+ priority = "extra-high-no-scale",
+ corner_size = { 3, 3 },
+ position = { 0, 0 },
+ },
+ left_click_sound = {
+ {
+ filename = "__core__/sound/gui-click.ogg",
+ volume = 1,
+ },
+ },
}
--------------------------------------------------------------------
-- The entity GUI open button style.
default_style[creative_mode_defines.names.gui_styles.entity_open_button] = {
- type = "button_style",
- parent = "button",
- scalable = false,
- top_padding = 0,
- right_padding = 0,
- bottom_padding = 0,
- left_padding = 0,
- width = big_button_width_height + 1,
- height = big_button_width_height + 1,
- left_click_sound = {
- {
- filename = "__core__/sound/gui-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ scalable = false,
+ top_padding = 0,
+ right_padding = 0,
+ bottom_padding = 0,
+ left_padding = 0,
+ width = big_button_width_height + 1,
+ height = big_button_width_height + 1,
+ left_click_sound = {
+ {
+ filename = "__core__/sound/gui-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The creative chest item-group label style.
default_style[creative_mode_defines.names.gui_styles.creative_chest_item_group_label] = {
- type = "label_style",
- parent = "label",
- width = (inventory_slot_width * 10 + 1 * 9) -
- (creative_chest_item_group_left_right_button_width * 2 + creative_chest_item_group_number_label_width),
- scalable = false
+ type = "label_style",
+ parent = "label",
+ width = (inventory_slot_width * 10 + 1 * 9)
+ - (creative_chest_item_group_left_right_button_width * 2 + creative_chest_item_group_number_label_width),
+ scalable = false,
}
-- The creative chest item-group-number label style.
default_style[creative_mode_defines.names.gui_styles.creative_chest_item_group_number_label] = {
- type = "label_style",
- parent = creative_mode_defines.names.gui_styles.creative_chest_item_group_label,
- align = "center",
- width = creative_chest_item_group_number_label_width,
- scalable = false
+ type = "label_style",
+ parent = creative_mode_defines.names.gui_styles.creative_chest_item_group_label,
+ align = "center",
+ width = creative_chest_item_group_number_label_width,
+ scalable = false,
}
-- The creative chest item-group left or right button style.
default_style[creative_mode_defines.names.gui_styles.creative_chest_item_group_left_right_button] = {
- type = "button_style",
- parent = "button",
- scalable = false,
- top_padding = 0,
- right_padding = 0,
- bottom_padding = 0,
- left_padding = 0,
- width = creative_chest_item_group_left_right_button_width,
- height = big_button_width_height,
- left_click_sound = {
- {
- filename = "__core__/sound/gui-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = "button",
+ scalable = false,
+ top_padding = 0,
+ right_padding = 0,
+ bottom_padding = 0,
+ left_padding = 0,
+ width = creative_chest_item_group_left_right_button_width,
+ height = big_button_width_height,
+ left_click_sound = {
+ {
+ filename = "__core__/sound/gui-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The creative chest select-slot label style.
default_style[creative_mode_defines.names.gui_styles.creative_chest_select_slot_label] = {
- type = "label_style",
- parent = creative_mode_defines.names.gui_styles.creative_chest_item_group_label,
- width = (inventory_slot_width * 10 + 1 * 9) - (big_button_width_height * 2),
- scalable = false
+ type = "label_style",
+ parent = creative_mode_defines.names.gui_styles.creative_chest_item_group_label,
+ width = (inventory_slot_width * 10 + 1 * 9) - (big_button_width_height * 2),
+ scalable = false,
}
-- The 36x36 original display mode button style.
default_style[creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_original] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.entity_open_button,
- default_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 0,
- big_button_width_height * 2,
- big_button_width_height,
- big_button_width_height
- ),
- hovered_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 1,
- big_button_width_height * 2,
- big_button_width_height,
- big_button_width_height
- ),
- clicked_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 2,
- big_button_width_height * 2,
- big_button_width_height,
- big_button_width_height
- ),
- disabled_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 3,
- big_button_width_height * 2,
- big_button_width_height,
- big_button_width_height
- )
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.entity_open_button,
+ default_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 0,
+ big_button_width_height * 2,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ hovered_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 1,
+ big_button_width_height * 2,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ clicked_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 2,
+ big_button_width_height * 2,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ disabled_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 3,
+ big_button_width_height * 2,
+ big_button_width_height,
+ big_button_width_height
+ ),
}
-- The 36x36 compact display mode button style.
default_style[creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_compact] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.entity_open_button,
- default_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 0,
- big_button_width_height * 3,
- big_button_width_height,
- big_button_width_height
- ),
- hovered_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 1,
- big_button_width_height * 3,
- big_button_width_height,
- big_button_width_height
- ),
- clicked_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 2,
- big_button_width_height * 3,
- big_button_width_height,
- big_button_width_height
- ),
- disabled_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 3,
- big_button_width_height * 3,
- big_button_width_height,
- big_button_width_height
- )
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.entity_open_button,
+ default_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 0,
+ big_button_width_height * 3,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ hovered_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 1,
+ big_button_width_height * 3,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ clicked_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 2,
+ big_button_width_height * 3,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ disabled_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 3,
+ big_button_width_height * 3,
+ big_button_width_height,
+ big_button_width_height
+ ),
}
-- The 36x36 toggle all button style.
default_style[creative_mode_defines.names.gui_styles.inventory_toggle_all_button] = {
- type = "button_style",
- parent = creative_mode_defines.names.gui_styles.entity_open_button,
- default_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 0,
- big_button_width_height * 1,
- big_button_width_height,
- big_button_width_height
- ),
- hovered_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 1,
- big_button_width_height * 1,
- big_button_width_height,
- big_button_width_height
- ),
- clicked_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 2,
- big_button_width_height * 1,
- big_button_width_height,
- big_button_width_height
- ),
- disabled_graphical_set = extract_monolith(
- "big-buttons.png",
- big_button_width_height * 3,
- big_button_width_height * 1,
- big_button_width_height,
- big_button_width_height
- ),
- left_click_sound = {
- {
- filename = "__core__/sound/gui-click.ogg",
- volume = 1
- }
- }
+ type = "button_style",
+ parent = creative_mode_defines.names.gui_styles.entity_open_button,
+ default_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 0,
+ big_button_width_height * 1,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ hovered_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 1,
+ big_button_width_height * 1,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ clicked_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 2,
+ big_button_width_height * 1,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ disabled_graphical_set = extract_monolith(
+ "big-buttons.png",
+ big_button_width_height * 3,
+ big_button_width_height * 1,
+ big_button_width_height,
+ big_button_width_height
+ ),
+ left_click_sound = {
+ {
+ filename = "__core__/sound/gui-click.ogg",
+ volume = 1,
+ },
+ },
}
-- The item count textfield style.
default_style[creative_mode_defines.names.gui_styles.item_count_textfield] = {
- type = "textbox_style",
- parent = "short_number_textfield",
- width = 70
+ type = "textbox_style",
+ parent = "short_number_textfield",
+ width = 70,
}
diff --git a/prototypes/technology.lua b/prototypes/technology.lua
index 67e4e31..acfc47b 100644
--- a/prototypes/technology.lua
+++ b/prototypes/technology.lua
@@ -1,30 +1,35 @@
-local function create_void_technology_ingredients()
- local research_items = {}
- for _, tool in pairs(data.raw.tool) do
- table.insert(research_items, {
- tool.name, 1
- })
- end
-
- return research_items
-end
-
-data:extend({{
- type = "technology",
- name = creative_mode_defines.names.technology.void_technology,
- enabled = false,
- icon_size = 64,
- icons = {{
- icon = "__base__/graphics/icons/lab.png",
- tint = {
- r = 50,
- g = 50,
- b = 50
- }
- }},
- unit = {
- count = 4294967296,
- ingredients = create_void_technology_ingredients(),
- time = settings.startup[creative_mode_defines.names.settings.time_for_void_technology].value
- }
-}})
+local function create_void_technology_ingredients()
+ local research_items = {}
+ for _, tool in pairs(data.raw.tool) do
+ table.insert(research_items, {
+ tool.name,
+ 1,
+ })
+ end
+
+ return research_items
+end
+
+data:extend({
+ {
+ type = "technology",
+ name = creative_mode_defines.names.technology.void_technology,
+ enabled = false,
+ icon_size = 64,
+ icons = {
+ {
+ icon = "__base__/graphics/icons/lab.png",
+ tint = {
+ r = 50,
+ g = 50,
+ b = 50,
+ },
+ },
+ },
+ unit = {
+ count = 4294967296,
+ ingredients = create_void_technology_ingredients(),
+ time = settings.startup[creative_mode_defines.names.settings.time_for_void_technology].value,
+ },
+ },
+})
diff --git a/scripts/autofill-requester-chest.lua b/scripts/autofill-requester-chest.lua
index fcc66f0..35baeee 100644
--- a/scripts/autofill-requester-chest.lua
+++ b/scripts/autofill-requester-chest.lua
@@ -1,100 +1,99 @@
-- This file contains variables or functions that are related to the Autofill Requester Chest in this mod.
if not autofill_requester_chest then
- autofill_requester_chest = {}
+ autofill_requester_chest = {}
end
-- Refill the given chest according to its requests.
local function refill_chest(chest)
- local inventory = chest.get_output_inventory()
- local inventory_size = #inventory
- local slot = 1
- local item_prototypes = prototypes.item
- local math_ceil = math.ceil
+ local inventory = chest.get_output_inventory()
+ local inventory_size = #inventory
+ local slot = 1
+ local item_prototypes = prototypes.item
+ local math_ceil = math.ceil
- -- local request_slot_count = chest.request_slot_count
- local request_slot_count = get_character_request_slot_count(chest)
- for slot_index = 1, request_slot_count, 1 do
- -- Get the request in the iterated request slot.
- local points = chest.get_logistic_point()
- for index, point in ipairs(points) do
- if point ~= nil and point.enabled and point.filters ~= nil then
- local requested_item_stack = point.filters[slot_index]
- -- local request = chest.get_request_slot(request_slot)
- if requested_item_stack then
- -- Get the requested item name and count.
- local item_name = requested_item_stack.name
- local item_count = requested_item_stack.count
- -- How many slots are required?
- if item_count > 0 then
- local stack_size = item_prototypes[item_name].stack_size
- -- Set items until it fulfills the requested amount.
- local is_last_stack = false
- repeat
- local set_count
- if item_count <= stack_size then
- set_count = item_count
- is_last_stack = true
- else
- set_count = stack_size
- end
- inventory[slot].set_stack {name = item_name, count = set_count}
- item_count = item_count - set_count
- slot = slot + 1
- if slot > inventory_size then
- -- No more slot.
- return
- end
- until is_last_stack
- end
- end
- end
- end
- end
- -- Empty the remaining slots.
- for i = slot, inventory_size, 1 do
- inventory[i].clear()
- end
+ -- local request_slot_count = chest.request_slot_count
+ local request_slot_count = get_character_request_slot_count(chest)
+ for slot_index = 1, request_slot_count, 1 do
+ -- Get the request in the iterated request slot.
+ local points = chest.get_logistic_point()
+ for index, point in ipairs(points) do
+ if point ~= nil and point.enabled and point.filters ~= nil then
+ local requested_item_stack = point.filters[slot_index]
+ -- local request = chest.get_request_slot(request_slot)
+ if requested_item_stack then
+ -- Get the requested item name and count.
+ local item_name = requested_item_stack.name
+ local item_count = requested_item_stack.count
+ -- How many slots are required?
+ if item_count > 0 then
+ local stack_size = item_prototypes[item_name].stack_size
+ -- Set items until it fulfills the requested amount.
+ local is_last_stack = false
+ repeat
+ local set_count
+ if item_count <= stack_size then
+ set_count = item_count
+ is_last_stack = true
+ else
+ set_count = stack_size
+ end
+ inventory[slot].set_stack({ name = item_name, count = set_count })
+ item_count = item_count - set_count
+ slot = slot + 1
+ if slot > inventory_size then
+ -- No more slot.
+ return
+ end
+ until is_last_stack
+ end
+ end
+ end
+ end
+ end
+ -- Empty the remaining slots.
+ for i = slot, inventory_size, 1 do
+ inventory[i].clear()
+ end
end
-- Refill the chest contents among the given array of chests according to the given index of the next chest to update.
-- Returns the index of the next chest to update in the next tick.
local function refill_chests(chests, next_chest_to_update)
- if #chests <= 0 then
- return 1
- end
+ if #chests <= 0 then
+ return 1
+ end
- local chest_index = next_chest_to_update
- for i = 1, 5, 1 do
- local chest = chests[chest_index]
- if chest.valid then
- if not chest.to_be_deconstructed(chest.force) then
- -- Refill the chest.
- refill_chest(chest)
- end
+ local chest_index = next_chest_to_update
+ for i = 1, 5, 1 do
+ local chest = chests[chest_index]
+ if chest.valid then
+ if not chest.to_be_deconstructed(chest.force) then
+ -- Refill the chest.
+ refill_chest(chest)
+ end
- -- Prepare for the next chest.
- chest_index = chest_index + 1
- -- No more next chest. Return to the first chest.
- if chest_index > #chests then
- return 1
- end
- else
- table.remove(chests, chest_index)
- if chest_index > #chests then
- return 1
- end
- end
- end
- -- Return the index of the next chest to update.
- return chest_index
+ -- Prepare for the next chest.
+ chest_index = chest_index + 1
+ -- No more next chest. Return to the first chest.
+ if chest_index > #chests then
+ return 1
+ end
+ else
+ table.remove(chests, chest_index)
+ if chest_index > #chests then
+ return 1
+ end
+ end
+ end
+ -- Return the index of the next chest to update.
+ return chest_index
end
-- Processes the tables related to Autofill Requester Chests in storage.
function autofill_requester_chest.tick()
- -- Refill the chests.
- storage.creative_mode.autofill_requester_chest_next_update_index =
- refill_chests(
- storage.creative_mode.autofill_requester_chest,
- storage.creative_mode.autofill_requester_chest_next_update_index
- )
+ -- Refill the chests.
+ storage.creative_mode.autofill_requester_chest_next_update_index = refill_chests(
+ storage.creative_mode.autofill_requester_chest,
+ storage.creative_mode.autofill_requester_chest_next_update_index
+ )
end
diff --git a/scripts/cheats.lua b/scripts/cheats.lua
index 012e7b8..a49b19b 100644
--- a/scripts/cheats.lua
+++ b/scripts/cheats.lua
@@ -2,2249 +2,2238 @@ require("rights")
-- This file contains functions for enabling/disabling cheats.
if not cheats then
- cheats = {}
+ cheats = {}
end
-- Values for default cheating.
cheats.default_cheat_values = {
- reach_distance = 10000000,
- mining_speed = 1000,
- running_speed = 2,
+ reach_distance = 10000000,
+ mining_speed = 1000,
+ running_speed = 2,
}
--------------------------------------------------------------------
-- Function for limiting the value to be positive only before it is applied.
local function uint32_limit_value_before_apply_function(value)
- -- Negative value will cause error.
- return util.clamp(value, 0, 4294967295)
+ -- Negative value will cause error.
+ return util.clamp(value, 0, 4294967295)
end
-- Function for limiting the value to be positive only before it is applied.
local function int32_limit_value_before_apply_function(value)
- -- Negative value will cause error.
- return util.clamp(value, -2147483648, 2147483647)
+ -- Negative value will cause error.
+ return util.clamp(value, -2147483648, 2147483647)
end
-- Function for limiting the value to be positive only before it is applied.
local function pickup_distance_limit_value_before_apply_function(value)
- -- Negative value will cause error.
- return util.clamp(value, 0, 320)
+ -- Negative value will cause error.
+ return util.clamp(value, 0, 320)
end
-- Function for limiting the value to be inside a large but safe range before it is applied.
local function large_range_limit_value_before_apply_function(value)
- return util.clamp(value, -1, 4294967296)
+ return util.clamp(value, -1, 4294967296)
end
-- Applies all character-related personal cheats to the given player. Also updates GUI status about the cheat for all players, in case the given player is selected.
local function apply_character_cheats_to_player(player)
- -- Cheat mode.
- if storage.creative_mode.personal_cheats.cheat_mode[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.cheat_mode.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.cheat_mode[player.index],
- nil
- )
- end
- -- Invincible player.
- if storage.creative_mode.personal_cheats.invincible_player[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.invincible_player.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.invincible_player[player.index],
- nil
- )
- end
- -- Reach distance.
- if storage.creative_mode.personal_cheats.reach_distance[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.reach_distance.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.reach_distance[player.index],
- nil
- )
- end
- -- Build distance.
- if storage.creative_mode.personal_cheats.build_distance[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.build_distance.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.build_distance[player.index],
- nil
- )
- end
- -- Resource reach distance.
- if storage.creative_mode.personal_cheats.resource_reach_distance[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.resource_reach_distance.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.resource_reach_distance[player.index],
- nil
- )
- end
- -- Item drop distance.
- if storage.creative_mode.personal_cheats.item_drop_distance[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.item_drop_distance.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.item_drop_distance[player.index],
- nil
- )
- end
- -- Item pickup distance.
- if storage.creative_mode.personal_cheats.item_pickup_distance[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.item_pickup_distance.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.item_pickup_distance[player.index],
- nil
- )
- end
- -- Loot pickup distance.
- if storage.creative_mode.personal_cheats.loot_pickup_distance[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.loot_pickup_distance.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.loot_pickup_distance[player.index],
- nil
- )
- end
- -- Mining speed.
- if storage.creative_mode.personal_cheats.mining_speed[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.mining_speed.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.mining_speed[player.index],
- nil
- )
- end
- -- Running speed.
- if storage.creative_mode.personal_cheats.running_speed[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.running_speed.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.running_speed[player.index],
- nil
- )
- end
- -- Crafting speed.
- if storage.creative_mode.personal_cheats.crafting_speed[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.crafting_speed.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.crafting_speed[player.index],
- nil
- )
- end
- -- Inventory bonus.
- if storage.creative_mode.personal_cheats.inventory_bonus[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.inventory_bonus.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.inventory_bonus[player.index],
- nil
- )
- end
- -- Health bonus.
- if storage.creative_mode.personal_cheats.health_bonus[player.index] ~= nil then
- cheats.personal_cheats_data.cheats.health_bonus.apply_to_target_function(
- player,
- storage.creative_mode.personal_cheats.health_bonus[player.index],
- nil
- )
- end
-
- gui_menu_cheats.update_character_cheats_status_for_all_players_as_player_updated_his_status(player)
+ -- Cheat mode.
+ if storage.creative_mode.personal_cheats.cheat_mode[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.cheat_mode.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.cheat_mode[player.index],
+ nil
+ )
+ end
+ -- Invincible player.
+ if storage.creative_mode.personal_cheats.invincible_player[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.invincible_player.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.invincible_player[player.index],
+ nil
+ )
+ end
+ -- Reach distance.
+ if storage.creative_mode.personal_cheats.reach_distance[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.reach_distance.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.reach_distance[player.index],
+ nil
+ )
+ end
+ -- Build distance.
+ if storage.creative_mode.personal_cheats.build_distance[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.build_distance.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.build_distance[player.index],
+ nil
+ )
+ end
+ -- Resource reach distance.
+ if storage.creative_mode.personal_cheats.resource_reach_distance[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.resource_reach_distance.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.resource_reach_distance[player.index],
+ nil
+ )
+ end
+ -- Item drop distance.
+ if storage.creative_mode.personal_cheats.item_drop_distance[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.item_drop_distance.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.item_drop_distance[player.index],
+ nil
+ )
+ end
+ -- Item pickup distance.
+ if storage.creative_mode.personal_cheats.item_pickup_distance[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.item_pickup_distance.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.item_pickup_distance[player.index],
+ nil
+ )
+ end
+ -- Loot pickup distance.
+ if storage.creative_mode.personal_cheats.loot_pickup_distance[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.loot_pickup_distance.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.loot_pickup_distance[player.index],
+ nil
+ )
+ end
+ -- Mining speed.
+ if storage.creative_mode.personal_cheats.mining_speed[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.mining_speed.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.mining_speed[player.index],
+ nil
+ )
+ end
+ -- Running speed.
+ if storage.creative_mode.personal_cheats.running_speed[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.running_speed.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.running_speed[player.index],
+ nil
+ )
+ end
+ -- Crafting speed.
+ if storage.creative_mode.personal_cheats.crafting_speed[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.crafting_speed.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.crafting_speed[player.index],
+ nil
+ )
+ end
+ -- Inventory bonus.
+ if storage.creative_mode.personal_cheats.inventory_bonus[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.inventory_bonus.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.inventory_bonus[player.index],
+ nil
+ )
+ end
+ -- Health bonus.
+ if storage.creative_mode.personal_cheats.health_bonus[player.index] ~= nil then
+ cheats.personal_cheats_data.cheats.health_bonus.apply_to_target_function(
+ player,
+ storage.creative_mode.personal_cheats.health_bonus[player.index],
+ nil
+ )
+ end
+
+ gui_menu_cheats.update_character_cheats_status_for_all_players_as_player_updated_his_status(player)
end
-- Data about all personal cheats.
cheats.personal_cheats_data = {
- -- Function for checking whether the target is self of the source player.
- check_is_self_function = function(source_player, player)
- return source_player == player
- end,
- -- Function for print a message to the admin after he failed to apply changes to a target.
- print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
- source_player.print({ "message.creative-mode_failed-to-apply-to-single-player-admin", target.name, reason })
- end,
- -- Function for print a message to the admin after he failed to apply changes to multiple targets.
- print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
- source_player.print({ "message.creative-mode_failed-to-apply-to-multiple-players-admin", fail_count, reason })
- end,
- -- Function for printing a message to the target after the admin applied "Enable All" or "Disable All" on it.
- print_enabled_all_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_personal-cheats-enabled-all-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_personal-cheats-disabled-all-by-admin", source_player.name })
- end
- end,
- -- All cheats in this category. No other data except cheat data should be put inside.
- cheats = {
- cheat_mode = {
- -- Whether this cheat is one of the default cheats that can be triggered by the "Enable All" and "Disable All" buttons.
- is_default = true,
- -- Value when "Enable All" is applied.
- default_enable_value = true,
- -- Value when "Disable All" is applied.
- default_disable_value = false,
- -- Function for getting the current value of this cheat on the target. Nil for apply-cheat.
- -- Note: this function will NOT be used to control whether apply_to_target_function will be called.
- get_value_function = function(player)
- -- If player is respawning, accessing cheat_mode will cause error.
- if player and player.connected and player.controller_type ~= defines.controllers.ghost then
- return player.cheat_mode
- end
- return nil
- end,
- -- Function for limiting the value before it is applied to any target. For example, you can limit the value to be >= 0 by clamping it. Nil for no limit.
- limit_value_before_apply_function = nil,
- -- Function for applying the cheat to a single target. source_player may be nil, depending on the cheat. Returns the locale key of failure reason if it cannot be applied to target.
- apply_to_target_function = function(player, enable, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
-
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- end
-
- storage.creative_mode.personal_cheats.cheat_mode[player.index] = enable
- player.cheat_mode = enable
- return nil
- end,
- -- Function for printing a message to the target if the source player succeeded to apply the cheat to it.
- -- Only called if the the new value is different from current and target is not the source player himself according to the result of check_is_self_function.
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_cheat-mode-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_cheat-mode-disabled-by-admin", source_player.name })
- end
- end,
- -- Function for getting whether the given player can access this cheat. Nil = all players can access, as long as they can see it.
- get_player_can_access_function = nil,
- },
- invincible_player = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.enable_invincible_player_by_default].value
- end,
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return not player.character.destructible
- else
- return nil
- end
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
-
- if player.character then
- storage.creative_mode.personal_cheats.invincible_player[player.index] = enable
- player.character.destructible = not enable
- return nil
- end
-
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_invincible-player-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_invincible-player-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- keep_last_item = {
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(player)
- if player then
- return storage.creative_mode.personal_cheats.keep_last_item[player.index] or false
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.personal_cheats.keep_last_item[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_keep-last-item-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_keep-last-item-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- repair_mined_item = {
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(player)
- if player then
- return storage.creative_mode.personal_cheats.repair_mined_item[player.index] or false
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.personal_cheats.repair_mined_item[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_repair-mined-item-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_repair-mined-item-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- instant_request = {
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(player)
- if player then
- return storage.creative_mode.personal_cheats.instant_request[player.index] or false
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.personal_cheats.instant_request[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_instant-request-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_instant-request-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- instant_trash = {
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(player)
- if player then
- return storage.creative_mode.personal_cheats.instant_trash[player.index] or false
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.personal_cheats.instant_trash[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_instant-trash-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_instant-trash-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- instant_blueprint = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.enable_instant_blueprint_by_default].value
- end,
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(player)
- if player then
- return storage.creative_mode.personal_cheats.instant_blueprint[player.index] or false
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.personal_cheats.instant_blueprint[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_instant-blueprint-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_instant-blueprint-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- instant_deconstruction = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.enable_instant_deconstruction_by_default].value
- end,
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(player)
- if player then
- return storage.creative_mode.personal_cheats.instant_deconstruction[player.index] or false
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.personal_cheats.instant_deconstruction[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_instant-deconstruction-enabled-by-admin", source_player.name })
- else
- player.print({
- "message.creative-mode_instant-deconstruction-disabled-by-admin",
- source_player.name,
- })
- end
- end,
- get_player_can_access_function = nil,
- },
- reach_distance = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_long_reach_by_default].value
- end,
- is_default = true,
- default_enable_value = cheats.default_cheat_values.reach_distance,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_reach_distance_bonus
- else
- return nil
- end
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
- if player.character then
- storage.creative_mode.personal_cheats.reach_distance[player.index] = value
- player.character_reach_distance_bonus = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({ "message.creative-mode_reach-distance-updated-by-admin", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- build_distance = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_long_reach_by_default].value
- end,
- is_default = true,
- default_enable_value = cheats.default_cheat_values.reach_distance,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_build_distance_bonus
- else
- return nil
- end
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
- if player.character then
- storage.creative_mode.personal_cheats.build_distance[player.index] = value
- player.character_build_distance_bonus = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({ "message.creative-mode_build-distance-updated-by-admin", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- resource_reach_distance = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_long_reach_by_default].value
- end,
- is_default = true,
- default_enable_value = cheats.default_cheat_values.reach_distance,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_resource_reach_distance_bonus
- else
- return nil
- end
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
- if player.character then
- storage.creative_mode.personal_cheats.resource_reach_distance[player.index] = value
- player.character_resource_reach_distance_bonus = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({
- "message.creative-mode_resource-reach-distance-updated-by-admin",
- source_player.name,
- value,
- })
- end,
- get_player_can_access_function = nil,
- },
- item_drop_distance = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_long_reach_by_default].value
- end,
- is_default = true,
- default_enable_value = cheats.default_cheat_values.reach_distance,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_item_drop_distance_bonus
- else
- return nil
- end
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
- if player.character then
- storage.creative_mode.personal_cheats.item_drop_distance[player.index] = value
- player.character_item_drop_distance_bonus = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({ "message.creative-mode_item-drop-distance-updated-by-admin", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- item_pickup_distance = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_item_pickup_distance_bonus
- else
- return nil
- end
- end,
- limit_value_before_apply_function = pickup_distance_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
- if player.character then
- storage.creative_mode.personal_cheats.item_pickup_distance[player.index] = value
- player.character_item_pickup_distance_bonus = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({
- "message.creative-mode_item-pickup-distance-updated-by-admin",
- source_player.name,
- value,
- })
- end,
- get_player_can_access_function = nil,
- },
- loot_pickup_distance = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_loot_pickup_distance_bonus
- else
- return nil
- end
- end,
- limit_value_before_apply_function = pickup_distance_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
- if player.character then
- storage.creative_mode.personal_cheats.loot_pickup_distance[player.index] = value
- player.character_loot_pickup_distance_bonus = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({
- "message.creative-mode_loot-pickup-distance-updated-by-admin",
- source_player.name,
- value,
- })
- end,
- get_player_can_access_function = nil,
- },
- mining_speed = {
- is_default = true,
- default_enable_value = cheats.default_cheat_values.mining_speed,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_mining_speed_modifier
- else
- return nil
- end
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
-
- if player.character then
- storage.creative_mode.personal_cheats.mining_speed[player.index] = value
- player.character_mining_speed_modifier = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({ "message.creative-mode_mining-speed-updated-by-admin", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- running_speed = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_fast_run_by_default].value
- end,
- is_default = true,
- default_enable_value = cheats.default_cheat_values.running_speed,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_running_speed_modifier
- else
- return nil
- end
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
-
- if player.character then
- storage.creative_mode.personal_cheats.running_speed[player.index] = value
- player.character_running_speed_modifier = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({ "message.creative-mode_running-speed-updated-by-admin", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- crafting_speed = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_crafting_speed_modifier
- else
- return nil
- end
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
-
- if player.character then
- storage.creative_mode.personal_cheats.crafting_speed[player.index] = value
- player.character_crafting_speed_modifier = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({ "message.creative-mode_crafting-speed-updated-by-admin", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- inventory_bonus = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_inventory_slots_bonus
- else
- return nil
- end
- end,
- limit_value_before_apply_function = function(value)
- return util.clamp(value, 0, 100000)
- end,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
-
- if player.character then
- storage.creative_mode.personal_cheats.inventory_bonus[player.index] = value
- player.character_inventory_slots_bonus = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({ "message.creative-mode_inventory-bonus-updated-by-admin", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- health_bonus = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(player)
- if player and player.connected and player.character then
- return player.character_health_bonus
- else
- return nil
- end
- end,
- limit_value_before_apply_function = int32_limit_value_before_apply_function,
- apply_to_target_function = function(player, value, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
-
- if player.character then
- storage.creative_mode.personal_cheats.health_bonus[player.index] = value
- player.character_health_bonus = value
- return nil
- end
- if player.controller_type == defines.controllers.ghost then
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- else
- return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
- end
- end,
- print_applied_by_admin_message_function = function(source_player, player, value)
- player.print({ "message.creative-mode_health-bonus-updated-by-admin", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- god_mode = {
- is_default = false,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(player)
- if player and player.connected then
- if player.character then
- return false
- else
- -- It is possible that the player has just died and is waiting for respawn.
- return player.controller_type ~= defines.controllers.ghost
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- if not player.connected then
- return { "message.creative-mode_player-is-offline" }
- end
- if player.controller_type == defines.controllers.ghost then
- -- Cannot apply before player respawned.
- return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
- end
- -- Cheat mode will be reset after toggling god mode, so we will need to apply it again.
- local cheat_mode = player.cheat_mode
- if enable then
- -- Store the character so that we can get it back when god mode is off.
- local character = player.character
- -- Make sure the player is not already in god mode.
- if character then
- storage.creative_mode.personal_cheats.god_mode_character[player.index] = character
- -- Remove character (Enter god mode).
- player.character = nil
- if character then
- -- Transfer items.
- local character_main = character.get_inventory(defines.inventory.character_main)
- local god_main = player.get_inventory(defines.inventory.god_main)
- util.transfer_inventory_contents(character_main, god_main)
- -- Transfer cursor stack.
- local cursor_stack = character.cursor_stack
- if cursor_stack and cursor_stack.valid_for_read then
- player.cursor_stack.set_stack(cursor_stack)
- character.cursor_stack.clear()
- end
- end
- -- Update cheat status on GUI.
- gui_menu_cheats.update_character_cheats_status_for_all_players_as_player_updated_his_status(
- player
- )
- end
- else
- -- Make sure the player is in god mode.
- if not player.character then
- -- Restore the character if it is still here.
- local character = storage.creative_mode.personal_cheats.god_mode_character[player.index]
- if character and character.valid then
- storage.creative_mode.personal_cheats.god_mode_character[player.index] = nil
- else
- -- Character is dead! Create new one.
- character = player.surface.create_entity({
- name = "character",
- position = player.position,
- force = player.force,
- })
- end
- -- Transfer items.
- local character_main = character.get_inventory(defines.inventory.character_main)
- local god_main = player.get_inventory(defines.inventory.god_main)
- if god_main and character_main then
- util.transfer_inventory_contents(god_main, character_main)
- end
- -- Transfer cursor stack.
- local cursor_stack = player.cursor_stack
- if cursor_stack and cursor_stack.valid_for_read then
- character.cursor_stack.set_stack(cursor_stack)
- player.cursor_stack.clear()
- end
- -- Note: surface teleportation only works on player at this moment. So we can't teleport the character to the player's surface.
- local surface = player.surface
- local position = player.position
- -- Note: to set player character, the character has to be on the same surface as the player. Because we cannot teleport the character, we can only teleport the player.
- player.teleport(character.position, character.surface)
- -- Set character.
- player.character = character
- -- Teleport.
- player.teleport(position, surface)
- -- Apply character cheats.
- apply_character_cheats_to_player(player)
- -- Note: don't raise the on_player_respawned event as it will generate a gun and ammo (starting items).
- end
- end
- -- Apply cheat mode.
- player.cheat_mode = cheat_mode
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_god-mode-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_god-mode-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- },
+ -- Function for checking whether the target is self of the source player.
+ check_is_self_function = function(source_player, player)
+ return source_player == player
+ end,
+ -- Function for print a message to the admin after he failed to apply changes to a target.
+ print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
+ source_player.print({ "message.creative-mode_failed-to-apply-to-single-player-admin", target.name, reason })
+ end,
+ -- Function for print a message to the admin after he failed to apply changes to multiple targets.
+ print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
+ source_player.print({ "message.creative-mode_failed-to-apply-to-multiple-players-admin", fail_count, reason })
+ end,
+ -- Function for printing a message to the target after the admin applied "Enable All" or "Disable All" on it.
+ print_enabled_all_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_personal-cheats-enabled-all-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_personal-cheats-disabled-all-by-admin", source_player.name })
+ end
+ end,
+ -- All cheats in this category. No other data except cheat data should be put inside.
+ cheats = {
+ cheat_mode = {
+ -- Whether this cheat is one of the default cheats that can be triggered by the "Enable All" and "Disable All" buttons.
+ is_default = true,
+ -- Value when "Enable All" is applied.
+ default_enable_value = true,
+ -- Value when "Disable All" is applied.
+ default_disable_value = false,
+ -- Function for getting the current value of this cheat on the target. Nil for apply-cheat.
+ -- Note: this function will NOT be used to control whether apply_to_target_function will be called.
+ get_value_function = function(player)
+ -- If player is respawning, accessing cheat_mode will cause error.
+ if player and player.connected and player.controller_type ~= defines.controllers.ghost then
+ return player.cheat_mode
+ end
+ return nil
+ end,
+ -- Function for limiting the value before it is applied to any target. For example, you can limit the value to be >= 0 by clamping it. Nil for no limit.
+ limit_value_before_apply_function = nil,
+ -- Function for applying the cheat to a single target. source_player may be nil, depending on the cheat. Returns the locale key of failure reason if it cannot be applied to target.
+ apply_to_target_function = function(player, enable, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ end
+
+ storage.creative_mode.personal_cheats.cheat_mode[player.index] = enable
+ player.cheat_mode = enable
+ return nil
+ end,
+ -- Function for printing a message to the target if the source player succeeded to apply the cheat to it.
+ -- Only called if the the new value is different from current and target is not the source player himself according to the result of check_is_self_function.
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_cheat-mode-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_cheat-mode-disabled-by-admin", source_player.name })
+ end
+ end,
+ -- Function for getting whether the given player can access this cheat. Nil = all players can access, as long as they can see it.
+ get_player_can_access_function = nil,
+ },
+ invincible_player = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.enable_invincible_player_by_default].value
+ end,
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return not player.character.destructible
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+
+ if player.character then
+ storage.creative_mode.personal_cheats.invincible_player[player.index] = enable
+ player.character.destructible = not enable
+ return nil
+ end
+
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_invincible-player-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_invincible-player-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ keep_last_item = {
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(player)
+ if player then
+ return storage.creative_mode.personal_cheats.keep_last_item[player.index] or false
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.personal_cheats.keep_last_item[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_keep-last-item-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_keep-last-item-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ repair_mined_item = {
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(player)
+ if player then
+ return storage.creative_mode.personal_cheats.repair_mined_item[player.index] or false
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.personal_cheats.repair_mined_item[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_repair-mined-item-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_repair-mined-item-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ instant_request = {
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(player)
+ if player then
+ return storage.creative_mode.personal_cheats.instant_request[player.index] or false
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.personal_cheats.instant_request[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_instant-request-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_instant-request-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ instant_trash = {
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(player)
+ if player then
+ return storage.creative_mode.personal_cheats.instant_trash[player.index] or false
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.personal_cheats.instant_trash[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_instant-trash-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_instant-trash-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ instant_blueprint = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.enable_instant_blueprint_by_default].value
+ end,
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(player)
+ if player then
+ return storage.creative_mode.personal_cheats.instant_blueprint[player.index] or false
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.personal_cheats.instant_blueprint[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_instant-blueprint-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_instant-blueprint-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ instant_deconstruction = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.enable_instant_deconstruction_by_default].value
+ end,
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(player)
+ if player then
+ return storage.creative_mode.personal_cheats.instant_deconstruction[player.index] or false
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.personal_cheats.instant_deconstruction[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_instant-deconstruction-enabled-by-admin", source_player.name })
+ else
+ player.print({
+ "message.creative-mode_instant-deconstruction-disabled-by-admin",
+ source_player.name,
+ })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ reach_distance = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_long_reach_by_default].value
+ end,
+ is_default = true,
+ default_enable_value = cheats.default_cheat_values.reach_distance,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_reach_distance_bonus
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+ if player.character then
+ storage.creative_mode.personal_cheats.reach_distance[player.index] = value
+ player.character_reach_distance_bonus = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({ "message.creative-mode_reach-distance-updated-by-admin", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ build_distance = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_long_reach_by_default].value
+ end,
+ is_default = true,
+ default_enable_value = cheats.default_cheat_values.reach_distance,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_build_distance_bonus
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+ if player.character then
+ storage.creative_mode.personal_cheats.build_distance[player.index] = value
+ player.character_build_distance_bonus = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({ "message.creative-mode_build-distance-updated-by-admin", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ resource_reach_distance = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_long_reach_by_default].value
+ end,
+ is_default = true,
+ default_enable_value = cheats.default_cheat_values.reach_distance,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_resource_reach_distance_bonus
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+ if player.character then
+ storage.creative_mode.personal_cheats.resource_reach_distance[player.index] = value
+ player.character_resource_reach_distance_bonus = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({
+ "message.creative-mode_resource-reach-distance-updated-by-admin",
+ source_player.name,
+ value,
+ })
+ end,
+ get_player_can_access_function = nil,
+ },
+ item_drop_distance = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_long_reach_by_default].value
+ end,
+ is_default = true,
+ default_enable_value = cheats.default_cheat_values.reach_distance,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_item_drop_distance_bonus
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+ if player.character then
+ storage.creative_mode.personal_cheats.item_drop_distance[player.index] = value
+ player.character_item_drop_distance_bonus = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({ "message.creative-mode_item-drop-distance-updated-by-admin", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ item_pickup_distance = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_item_pickup_distance_bonus
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = pickup_distance_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+ if player.character then
+ storage.creative_mode.personal_cheats.item_pickup_distance[player.index] = value
+ player.character_item_pickup_distance_bonus = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({
+ "message.creative-mode_item-pickup-distance-updated-by-admin",
+ source_player.name,
+ value,
+ })
+ end,
+ get_player_can_access_function = nil,
+ },
+ loot_pickup_distance = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_loot_pickup_distance_bonus
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = pickup_distance_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+ if player.character then
+ storage.creative_mode.personal_cheats.loot_pickup_distance[player.index] = value
+ player.character_loot_pickup_distance_bonus = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({
+ "message.creative-mode_loot-pickup-distance-updated-by-admin",
+ source_player.name,
+ value,
+ })
+ end,
+ get_player_can_access_function = nil,
+ },
+ mining_speed = {
+ is_default = true,
+ default_enable_value = cheats.default_cheat_values.mining_speed,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_mining_speed_modifier
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+
+ if player.character then
+ storage.creative_mode.personal_cheats.mining_speed[player.index] = value
+ player.character_mining_speed_modifier = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({ "message.creative-mode_mining-speed-updated-by-admin", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ running_speed = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.enable_personal_fast_run_by_default].value
+ end,
+ is_default = true,
+ default_enable_value = cheats.default_cheat_values.running_speed,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_running_speed_modifier
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+
+ if player.character then
+ storage.creative_mode.personal_cheats.running_speed[player.index] = value
+ player.character_running_speed_modifier = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({ "message.creative-mode_running-speed-updated-by-admin", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ crafting_speed = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_crafting_speed_modifier
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+
+ if player.character then
+ storage.creative_mode.personal_cheats.crafting_speed[player.index] = value
+ player.character_crafting_speed_modifier = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({ "message.creative-mode_crafting-speed-updated-by-admin", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ inventory_bonus = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_inventory_slots_bonus
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = function(value)
+ return util.clamp(value, 0, 100000)
+ end,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+
+ if player.character then
+ storage.creative_mode.personal_cheats.inventory_bonus[player.index] = value
+ player.character_inventory_slots_bonus = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({ "message.creative-mode_inventory-bonus-updated-by-admin", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ health_bonus = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(player)
+ if player and player.connected and player.character then
+ return player.character_health_bonus
+ else
+ return nil
+ end
+ end,
+ limit_value_before_apply_function = int32_limit_value_before_apply_function,
+ apply_to_target_function = function(player, value, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+
+ if player.character then
+ storage.creative_mode.personal_cheats.health_bonus[player.index] = value
+ player.character_health_bonus = value
+ return nil
+ end
+ if player.controller_type == defines.controllers.ghost then
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ else
+ return { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" }
+ end
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, value)
+ player.print({ "message.creative-mode_health-bonus-updated-by-admin", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ god_mode = {
+ is_default = false,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(player)
+ if player and player.connected then
+ if player.character then
+ return false
+ else
+ -- It is possible that the player has just died and is waiting for respawn.
+ return player.controller_type ~= defines.controllers.ghost
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ if not player.connected then
+ return { "message.creative-mode_player-is-offline" }
+ end
+ if player.controller_type == defines.controllers.ghost then
+ -- Cannot apply before player respawned.
+ return { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" }
+ end
+ -- Cheat mode will be reset after toggling god mode, so we will need to apply it again.
+ local cheat_mode = player.cheat_mode
+ if enable then
+ -- Store the character so that we can get it back when god mode is off.
+ local character = player.character
+ -- Make sure the player is not already in god mode.
+ if character then
+ storage.creative_mode.personal_cheats.god_mode_character[player.index] = character
+ -- Remove character (Enter god mode).
+ player.character = nil
+ if character then
+ -- Transfer items.
+ local character_main = character.get_inventory(defines.inventory.character_main)
+ local god_main = player.get_inventory(defines.inventory.god_main)
+ util.transfer_inventory_contents(character_main, god_main)
+ -- Transfer cursor stack.
+ local cursor_stack = character.cursor_stack
+ if cursor_stack and cursor_stack.valid_for_read then
+ player.cursor_stack.set_stack(cursor_stack)
+ character.cursor_stack.clear()
+ end
+ end
+ -- Update cheat status on GUI.
+ gui_menu_cheats.update_character_cheats_status_for_all_players_as_player_updated_his_status(player)
+ end
+ else
+ -- Make sure the player is in god mode.
+ if not player.character then
+ -- Restore the character if it is still here.
+ local character = storage.creative_mode.personal_cheats.god_mode_character[player.index]
+ if character and character.valid then
+ storage.creative_mode.personal_cheats.god_mode_character[player.index] = nil
+ else
+ -- Character is dead! Create new one.
+ character = player.surface.create_entity({
+ name = "character",
+ position = player.position,
+ force = player.force,
+ })
+ end
+ -- Transfer items.
+ local character_main = character.get_inventory(defines.inventory.character_main)
+ local god_main = player.get_inventory(defines.inventory.god_main)
+ if god_main and character_main then
+ util.transfer_inventory_contents(god_main, character_main)
+ end
+ -- Transfer cursor stack.
+ local cursor_stack = player.cursor_stack
+ if cursor_stack and cursor_stack.valid_for_read then
+ character.cursor_stack.set_stack(cursor_stack)
+ player.cursor_stack.clear()
+ end
+ -- Note: surface teleportation only works on player at this moment. So we can't teleport the character to the player's surface.
+ local surface = player.surface
+ local position = player.position
+ -- Note: to set player character, the character has to be on the same surface as the player. Because we cannot teleport the character, we can only teleport the player.
+ player.teleport(character.position, character.surface)
+ -- Set character.
+ player.character = character
+ -- Teleport.
+ player.teleport(position, surface)
+ -- Apply character cheats.
+ apply_character_cheats_to_player(player)
+ -- Note: don't raise the on_player_respawned event as it will generate a gun and ammo (starting items).
+ end
+ end
+ -- Apply cheat mode.
+ player.cheat_mode = cheat_mode
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_god-mode-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_god-mode-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ },
}
-- Data about all team cheats.
cheats.team_cheats_data = {
- check_is_self_function = function(source_player, force)
- return false
- end,
- print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
- -- No reason to fail so far.
- end,
- print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
- -- No reason to fail so far.
- end,
- print_enabled_all_by_admin_message_function = function(source_player, force, enable)
- if enable then
- force.print({ "message.creative-mode_team-cheats-enabled-all", source_player.name })
- else
- force.print({ "message.creative-mode_team-cheats-disabled-all", source_player.name })
- end
- end,
- cheats = {
- creative_tools_recipes = {
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(force)
- if force then
- return force.recipes[creative_mode_defines.names.recipes.item_source].enabled
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(force, enable, source_player)
- -- Item recipes.
- for _, recipe_name in pairs(creative_mode_defines.names.recipes) do
- local recipe = force.recipes[recipe_name]
- if recipe then
- recipe.enabled = enable
- end
- end
- -- Free fluid recipes. Get the recipe names by looping through the fluid prototypes in game.
- for _, fluid in pairs(prototypes.fluid) do
- local recipe = force.recipes[creative_mode_defines.names.free_fluid_recipe_prefix .. fluid.name]
- if recipe then
- recipe.enabled = enable
- end
- end
- -- Enemy recipes.
- for _, entity in pairs(prototypes.entity) do
- local recipe = force.recipes[creative_mode_defines.names.enemy_recipe_prefix .. entity.name]
- if recipe then
- recipe.enabled = enable
- end
- end
- -- Technology
- for _, technology_name in pairs(creative_mode_defines.names.technology) do
- local technology = force.technologies[technology_name]
- if technology then
- technology.enabled = enable
- end
- end
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, enable)
- if enable then
- force.print({ "message.creative-mode_creative-tools-recipes-enabled", source_player.name })
- else
- force.print({ "message.creative-mode_creative-tools-recipes-disabled", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- loaders_recipes = {
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(force)
- if force then
- for _, recipe_name in pairs(creative_mode_defines.names.loader_recipes) do
- if not (force.recipes[recipe_name] and force.recipes[recipe_name].enabled) then
- return false
- end
- end
- return true
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(force, enable, source_player)
- for _, recipe_name in pairs(creative_mode_defines.names.loader_recipes) do
- if force.recipes[recipe_name] then
- force.recipes[recipe_name].enabled = enable
- end
- end
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, enable)
- if enable then
- force.print({ "message.creative-mode_loaders-recipes-enabled", source_player.name })
- else
- force.print({ "message.creative-mode_loaders-recipes-disabled", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- research_all_technologies = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.default_technology_research_cheat_type].value
- ~= creative_mode_defines.values.default_technology_research_cheat_types.nothing
- end,
- is_default = true,
- get_default_enable_value_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.default_technology_research_cheat_type].value
- == creative_mode_defines.values.default_technology_research_cheat_types.research_all
- end,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(force)
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(force, enable, source_player)
- if enable then
- force.research_all_technologies()
- -- "Unresearch" the void technology.
- if force.technologies[creative_mode_defines.names.technology.void_technology] ~= nil then
- force.technologies[creative_mode_defines.names.technology.void_technology].researched = false
- end
- else
- -- Calling LuaForce::reset() will hide all the originally hidden recipes.
- -- We have to enable them back if they were enabled.
- local creative_tools_recipes_enabled =
- cheats.team_cheats_data.cheats.creative_tools_recipes.get_value_function(force)
- local loaders_recipes_enabled =
- cheats.team_cheats_data.cheats.loaders_recipes.get_value_function(force)
-
- force.reset()
-
- if creative_tools_recipes_enabled then
- cheats.team_cheats_data.cheats.creative_tools_recipes.apply_to_target_function(
- force,
- true,
- source_player
- )
- end
- if loaders_recipes_enabled then
- cheats.team_cheats_data.cheats.loaders_recipes.apply_to_target_function(
- force,
- true,
- source_player
- )
- end
- end
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, enable)
- if enable then
- force.print({ "message.creative-mode_all-technologies-researched", source_player.name })
- else
- force.print({ "message.creative-mode_all-technologies-reset", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- instant_research = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.default_technology_research_cheat_type].value
- ~= creative_mode_defines.values.default_technology_research_cheat_types.nothing
- end,
- is_default = true,
- get_default_enable_value_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.default_technology_research_cheat_type].value
- == creative_mode_defines.values.default_technology_research_cheat_types.instant_research
- end,
- default_enable_value = false,
- default_disable_value = false,
- get_value_function = function(force)
- if force then
- return storage.creative_mode.team_cheats.instant_research[force.name] or false
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(force, enable, source_player)
- storage.creative_mode.team_cheats.instant_research[force.name] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, enable)
- if enable then
- force.print({ "message.creative-mode_instant-research-enabled", source_player.name })
- else
- force.print({ "message.creative-mode_instant-research-disabled", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- reach_distance = {
- is_default = false,
- default_enable_value = cheats.default_cheat_values.reach_distance,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_reach_distance_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.character_reach_distance_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-reach-distance-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- build_distance = {
- is_default = false,
- default_enable_value = cheats.default_cheat_values.reach_distance,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_build_distance_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.character_build_distance_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-build-distance-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- resource_reach_distance = {
- is_default = false,
- default_enable_value = cheats.default_cheat_values.reach_distance,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_resource_reach_distance_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.character_resource_reach_distance_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-resource-reach-distance-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- item_drop_distance = {
- is_default = false,
- default_enable_value = cheats.default_cheat_values.reach_distance,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_item_drop_distance_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.character_item_drop_distance_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-item-drop-distance-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- item_pickup_distance = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_item_pickup_distance_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.character_item_pickup_distance_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-item-pickup-distance-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- loot_pickup_distance = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_loot_pickup_distance_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.character_loot_pickup_distance_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-loot-pickup-distance-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- mining_speed = {
- is_default = false,
- default_enable_value = cheats.default_cheat_values.mining_speed,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- -- Not character_mining_speed_modifier
- return force.manual_mining_speed_modifier
- end
- return nil
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.manual_mining_speed_modifier = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-mining-speed-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- running_speed = {
- is_default = false,
- default_enable_value = cheats.default_cheat_values.running_speed,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_running_speed_modifier
- end
- return nil
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.character_running_speed_modifier = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-running-speed-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- crafting_speed = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.manual_crafting_speed_modifier
- end
- return nil
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.manual_crafting_speed_modifier = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_team-crafting-speed-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- character_inventory_bonus = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_inventory_slots_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = function(value)
- return util.clamp(value, 0, 100000)
- end,
- apply_to_target_function = function(force, value, source_player)
- force.character_inventory_slots_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_character-inventory-bonus-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- health_bonus = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.character_health_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.character_health_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_character-health-bonus-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- inserter_capacity_bonus = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.inserter_stack_size_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.inserter_stack_size_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_inserter-capacity-bonus", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- bulk_inserter_capacity_bonus = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.bulk_inserter_capacity_bonus
- end
- return nil
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(force, value, source_player)
- force.bulk_inserter_capacity_bonus = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_bulk-inserter-capacity-bonus", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- evolution_factor = {
- get_is_default_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.override_evolution_factor_by_default].value
- end,
- is_default = false,
- get_default_enable_value_from_player = function(source_player)
- return source_player.mod_settings[creative_mode_defines.names.settings.default_evolution_factor].value
- end,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(force)
- if force then
- return force.get_evolution_factor()
- end
- return nil
- end,
- limit_value_before_apply_function = function(value)
- return util.clamp(value, 0, 1)
- end,
- apply_to_target_function = function(force, value, source_player)
- force.set_evolution_factor(value)
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_evolution-factor-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- chart_all = {
- is_default = false,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = nil,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(force, value, source_player)
- force.chart_all()
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_chart-all-applied", source_player.name })
- end,
- get_player_can_access_function = nil,
- },
- kill_all_units = {
- is_default = false,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = nil,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(force, value, source_player)
- force.kill_all_units()
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, force, value)
- force.print({ "message.creative-mode_kill-all-units-applied", source_player.name })
- end,
- get_player_can_access_function = nil,
- },
- },
+ check_is_self_function = function(source_player, force)
+ return false
+ end,
+ print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
+ -- No reason to fail so far.
+ end,
+ print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
+ -- No reason to fail so far.
+ end,
+ print_enabled_all_by_admin_message_function = function(source_player, force, enable)
+ if enable then
+ force.print({ "message.creative-mode_team-cheats-enabled-all", source_player.name })
+ else
+ force.print({ "message.creative-mode_team-cheats-disabled-all", source_player.name })
+ end
+ end,
+ cheats = {
+ creative_tools_recipes = {
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(force)
+ if force then
+ return force.recipes[creative_mode_defines.names.recipes.item_source].enabled
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(force, enable, source_player)
+ -- Item recipes.
+ for _, recipe_name in pairs(creative_mode_defines.names.recipes) do
+ local recipe = force.recipes[recipe_name]
+ if recipe then
+ recipe.enabled = enable
+ end
+ end
+ -- Free fluid recipes. Get the recipe names by looping through the fluid prototypes in game.
+ for _, fluid in pairs(prototypes.fluid) do
+ local recipe = force.recipes[creative_mode_defines.names.free_fluid_recipe_prefix .. fluid.name]
+ if recipe then
+ recipe.enabled = enable
+ end
+ end
+ -- Enemy recipes.
+ for _, entity in pairs(prototypes.entity) do
+ local recipe = force.recipes[creative_mode_defines.names.enemy_recipe_prefix .. entity.name]
+ if recipe then
+ recipe.enabled = enable
+ end
+ end
+ -- Technology
+ for _, technology_name in pairs(creative_mode_defines.names.technology) do
+ local technology = force.technologies[technology_name]
+ if technology then
+ technology.enabled = enable
+ end
+ end
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, enable)
+ if enable then
+ force.print({ "message.creative-mode_creative-tools-recipes-enabled", source_player.name })
+ else
+ force.print({ "message.creative-mode_creative-tools-recipes-disabled", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ loaders_recipes = {
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(force)
+ if force then
+ for _, recipe_name in pairs(creative_mode_defines.names.loader_recipes) do
+ if not (force.recipes[recipe_name] and force.recipes[recipe_name].enabled) then
+ return false
+ end
+ end
+ return true
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(force, enable, source_player)
+ for _, recipe_name in pairs(creative_mode_defines.names.loader_recipes) do
+ if force.recipes[recipe_name] then
+ force.recipes[recipe_name].enabled = enable
+ end
+ end
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, enable)
+ if enable then
+ force.print({ "message.creative-mode_loaders-recipes-enabled", source_player.name })
+ else
+ force.print({ "message.creative-mode_loaders-recipes-disabled", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ research_all_technologies = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.default_technology_research_cheat_type].value
+ ~= creative_mode_defines.values.default_technology_research_cheat_types.nothing
+ end,
+ is_default = true,
+ get_default_enable_value_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.default_technology_research_cheat_type].value
+ == creative_mode_defines.values.default_technology_research_cheat_types.research_all
+ end,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(force)
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(force, enable, source_player)
+ if enable then
+ force.research_all_technologies()
+ -- "Unresearch" the void technology.
+ if force.technologies[creative_mode_defines.names.technology.void_technology] ~= nil then
+ force.technologies[creative_mode_defines.names.technology.void_technology].researched = false
+ end
+ else
+ -- Calling LuaForce::reset() will hide all the originally hidden recipes.
+ -- We have to enable them back if they were enabled.
+ local creative_tools_recipes_enabled =
+ cheats.team_cheats_data.cheats.creative_tools_recipes.get_value_function(force)
+ local loaders_recipes_enabled = cheats.team_cheats_data.cheats.loaders_recipes.get_value_function(force)
+
+ force.reset()
+
+ if creative_tools_recipes_enabled then
+ cheats.team_cheats_data.cheats.creative_tools_recipes.apply_to_target_function(force, true, source_player)
+ end
+ if loaders_recipes_enabled then
+ cheats.team_cheats_data.cheats.loaders_recipes.apply_to_target_function(force, true, source_player)
+ end
+ end
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, enable)
+ if enable then
+ force.print({ "message.creative-mode_all-technologies-researched", source_player.name })
+ else
+ force.print({ "message.creative-mode_all-technologies-reset", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ instant_research = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.default_technology_research_cheat_type].value
+ ~= creative_mode_defines.values.default_technology_research_cheat_types.nothing
+ end,
+ is_default = true,
+ get_default_enable_value_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.default_technology_research_cheat_type].value
+ == creative_mode_defines.values.default_technology_research_cheat_types.instant_research
+ end,
+ default_enable_value = false,
+ default_disable_value = false,
+ get_value_function = function(force)
+ if force then
+ return storage.creative_mode.team_cheats.instant_research[force.name] or false
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(force, enable, source_player)
+ storage.creative_mode.team_cheats.instant_research[force.name] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, enable)
+ if enable then
+ force.print({ "message.creative-mode_instant-research-enabled", source_player.name })
+ else
+ force.print({ "message.creative-mode_instant-research-disabled", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ reach_distance = {
+ is_default = false,
+ default_enable_value = cheats.default_cheat_values.reach_distance,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_reach_distance_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_reach_distance_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-reach-distance-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ build_distance = {
+ is_default = false,
+ default_enable_value = cheats.default_cheat_values.reach_distance,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_build_distance_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_build_distance_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-build-distance-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ resource_reach_distance = {
+ is_default = false,
+ default_enable_value = cheats.default_cheat_values.reach_distance,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_resource_reach_distance_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_resource_reach_distance_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-resource-reach-distance-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ item_drop_distance = {
+ is_default = false,
+ default_enable_value = cheats.default_cheat_values.reach_distance,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_item_drop_distance_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_item_drop_distance_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-item-drop-distance-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ item_pickup_distance = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_item_pickup_distance_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_item_pickup_distance_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-item-pickup-distance-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ loot_pickup_distance = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_loot_pickup_distance_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_loot_pickup_distance_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-loot-pickup-distance-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ mining_speed = {
+ is_default = false,
+ default_enable_value = cheats.default_cheat_values.mining_speed,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ -- Not character_mining_speed_modifier
+ return force.manual_mining_speed_modifier
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.manual_mining_speed_modifier = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-mining-speed-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ running_speed = {
+ is_default = false,
+ default_enable_value = cheats.default_cheat_values.running_speed,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_running_speed_modifier
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_running_speed_modifier = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-running-speed-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ crafting_speed = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.manual_crafting_speed_modifier
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.manual_crafting_speed_modifier = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_team-crafting-speed-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ character_inventory_bonus = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_inventory_slots_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = function(value)
+ return util.clamp(value, 0, 100000)
+ end,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_inventory_slots_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_character-inventory-bonus-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ health_bonus = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.character_health_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.character_health_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_character-health-bonus-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ inserter_capacity_bonus = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.inserter_stack_size_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.inserter_stack_size_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_inserter-capacity-bonus", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ bulk_inserter_capacity_bonus = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.bulk_inserter_capacity_bonus
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(force, value, source_player)
+ force.bulk_inserter_capacity_bonus = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_bulk-inserter-capacity-bonus", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ evolution_factor = {
+ get_is_default_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.override_evolution_factor_by_default].value
+ end,
+ is_default = false,
+ get_default_enable_value_from_player = function(source_player)
+ return source_player.mod_settings[creative_mode_defines.names.settings.default_evolution_factor].value
+ end,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(force)
+ if force then
+ return force.get_evolution_factor()
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = function(value)
+ return util.clamp(value, 0, 1)
+ end,
+ apply_to_target_function = function(force, value, source_player)
+ force.set_evolution_factor(value)
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_evolution-factor-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ chart_all = {
+ is_default = false,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = nil,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(force, value, source_player)
+ force.chart_all()
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_chart-all-applied", source_player.name })
+ end,
+ get_player_can_access_function = nil,
+ },
+ kill_all_units = {
+ is_default = false,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = nil,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(force, value, source_player)
+ force.kill_all_units()
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, force, value)
+ force.print({ "message.creative-mode_kill-all-units-applied", source_player.name })
+ end,
+ get_player_can_access_function = nil,
+ },
+ },
}
-- Data about all surface cheats.
cheats.surface_cheats_data = {
- check_is_self_function = function(source_player, surface)
- return false
- end,
- print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
- -- No reason to fail so far.
- end,
- print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
- -- No reason to fail so far.
- end,
- print_enabled_all_by_admin_message_function = function(source_player, surface, enable)
- -- No enable all so far.
- end,
- cheats = {
- freeze_daytime = {
- is_default = true,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(surface)
- if surface then
- return surface.freeze_daytime
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(surface, enable, source_player)
- surface.freeze_daytime = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, enable)
- if enable then
- surface.print({ "message.creative-mode_daytime-frozen", source_player.name })
- else
- surface.print({ "message.creative-mode_daytime-unfrozen", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- daytime = {
- is_default = true,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(surface)
- if surface then
- return surface.daytime
- end
- return nil
- end,
- limit_value_before_apply_function = function(value)
- return util.clamp(value, 0, 1)
- end,
- apply_to_target_function = function(surface, value, source_player)
- surface.daytime = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, value)
- surface.print({ "message.creative-mode_daytime-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- daytime_selection = {
- is_default = false,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(surface)
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(surface, enable, source_player)
- local value
- if enable then
- value = 0
- else
- value = 0.5
- end
- cheats.apply_cheat_to_targets(
- source_player,
- { surface },
- cheats.surface_cheats_data,
- cheats.surface_cheats_data.cheats.daytime,
- value,
- false
- )
- -- Update the GUI status of the daytime cheat.
- gui_menu_cheats.update_daytime_cheats_status_for_all_players_as_surface_updated_its_daytime(surface)
- end,
- print_applied_by_admin_message_function = function(source_player, surface, enable)
- local value
- if enable then
- value = 0
- else
- value = 0.5
- end
- surface.print({ "message.creative-mode_daytime-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- peaceful_mode = {
- is_default = false,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(surface)
- if surface then
- return surface.peaceful_mode
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(surface, enable, source_player)
- surface.peaceful_mode = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, enable)
- if enable then
- surface.print({ "message.creative-mode_peaceful-mode-enabled", source_player.name })
- else
- surface.print({ "message.creative-mode_peaceful-mode-disabled", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- destroy_all_enemies = {
- is_default = false,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = nil,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(surface, value, source_player)
- for chunk in surface.get_chunks() do
- local area = { { chunk.x * 32, chunk.y * 32 }, { chunk.x * 32 + 32, chunk.y * 32 + 32 } }
- for _, entity in
- pairs(surface.find_entities_filtered({
- area = area,
- force = "enemy",
- }))
- do
- util.kill_entity_and_raise_event(entity, source_player)
- end
- end
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, value)
- surface.print({ "message.creative-mode_destroy-all-enemies-applied", source_player.name })
- end,
- get_player_can_access_function = nil,
- },
- remove_all_enemies = {
- is_default = false,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = nil,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(surface, value, source_player)
- for chunk in surface.get_chunks() do
- local area = { { chunk.x * 32, chunk.y * 32 }, { chunk.x * 32 + 32, chunk.y * 32 + 32 } }
- for _, entity in
- pairs(surface.find_entities_filtered({
- area = area,
- force = "enemy",
- }))
- do
- util.destroy_entity_and_raise_event(entity, source_player, false)
- end
- end
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, value)
- surface.print({ "message.creative-mode_remove-all-enemies-applied", source_player.name })
- end,
- get_player_can_access_function = nil,
- },
- dont_generate_enemy = {
- is_default = false,
- default_enable_value = true,
- default_disable_value = false,
- get_value_function = function(surface)
- if surface then
- return storage.creative_mode.surface_cheats.dont_generate_enemy[surface.index] == true
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(surface, enable, source_player)
- storage.creative_mode.surface_cheats.dont_generate_enemy[surface.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, enable)
- if enable then
- surface.print({ "message.creative-mode_dont-generate-enemy-enabled", source_player.name })
- else
- surface.print({ "message.creative-mode_dont-generate-enemy-disabled", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- pressure = {
- is_default = false,
- default_enable_value = 1000,
- default_disable_value = 0,
- get_value_function = function(surface)
- return surface.get_property("pressure")
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(surface, value, source_player)
- surface.set_property("pressure", value)
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, value)
- surface.print({ "message.creative-mode_surface-pressure-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- magnetic_field = {
- is_default = false,
- default_enable_value = 1000,
- default_disable_value = 0,
- get_value_function = function(surface)
- return surface.get_property("magnetic-field")
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(surface, value, source_player)
- surface.set_property("magnetic-field", value)
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, value)
- surface.print({ "message.creative-mode_surface-magnetic-field-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- gravity = {
- is_default = false,
- default_enable_value = 1000,
- default_disable_value = 0,
- get_value_function = function(surface)
- return surface.get_property("gravity")
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(surface, value, source_player)
- surface.set_property("gravity", value)
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, surface, value)
- surface.print({ "message.creative-mode_surface-gravity-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- },
+ check_is_self_function = function(source_player, surface)
+ return false
+ end,
+ print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
+ -- No reason to fail so far.
+ end,
+ print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
+ -- No reason to fail so far.
+ end,
+ print_enabled_all_by_admin_message_function = function(source_player, surface, enable)
+ -- No enable all so far.
+ end,
+ cheats = {
+ freeze_daytime = {
+ is_default = true,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(surface)
+ if surface then
+ return surface.freeze_daytime
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(surface, enable, source_player)
+ surface.freeze_daytime = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, enable)
+ if enable then
+ surface.print({ "message.creative-mode_daytime-frozen", source_player.name })
+ else
+ surface.print({ "message.creative-mode_daytime-unfrozen", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ daytime = {
+ is_default = true,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(surface)
+ if surface then
+ return surface.daytime
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = function(value)
+ return util.clamp(value, 0, 1)
+ end,
+ apply_to_target_function = function(surface, value, source_player)
+ surface.daytime = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, value)
+ surface.print({ "message.creative-mode_daytime-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ daytime_selection = {
+ is_default = false,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(surface)
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(surface, enable, source_player)
+ local value
+ if enable then
+ value = 0
+ else
+ value = 0.5
+ end
+ cheats.apply_cheat_to_targets(
+ source_player,
+ { surface },
+ cheats.surface_cheats_data,
+ cheats.surface_cheats_data.cheats.daytime,
+ value,
+ false
+ )
+ -- Update the GUI status of the daytime cheat.
+ gui_menu_cheats.update_daytime_cheats_status_for_all_players_as_surface_updated_its_daytime(surface)
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, enable)
+ local value
+ if enable then
+ value = 0
+ else
+ value = 0.5
+ end
+ surface.print({ "message.creative-mode_daytime-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ peaceful_mode = {
+ is_default = false,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(surface)
+ if surface then
+ return surface.peaceful_mode
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(surface, enable, source_player)
+ surface.peaceful_mode = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, enable)
+ if enable then
+ surface.print({ "message.creative-mode_peaceful-mode-enabled", source_player.name })
+ else
+ surface.print({ "message.creative-mode_peaceful-mode-disabled", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ destroy_all_enemies = {
+ is_default = false,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = nil,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(surface, value, source_player)
+ for chunk in surface.get_chunks() do
+ local area = { { chunk.x * 32, chunk.y * 32 }, { chunk.x * 32 + 32, chunk.y * 32 + 32 } }
+ for _, entity in
+ pairs(surface.find_entities_filtered({
+ area = area,
+ force = "enemy",
+ }))
+ do
+ util.kill_entity_and_raise_event(entity, source_player)
+ end
+ end
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, value)
+ surface.print({ "message.creative-mode_destroy-all-enemies-applied", source_player.name })
+ end,
+ get_player_can_access_function = nil,
+ },
+ remove_all_enemies = {
+ is_default = false,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = nil,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(surface, value, source_player)
+ for chunk in surface.get_chunks() do
+ local area = { { chunk.x * 32, chunk.y * 32 }, { chunk.x * 32 + 32, chunk.y * 32 + 32 } }
+ for _, entity in
+ pairs(surface.find_entities_filtered({
+ area = area,
+ force = "enemy",
+ }))
+ do
+ util.destroy_entity_and_raise_event(entity, source_player, false)
+ end
+ end
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, value)
+ surface.print({ "message.creative-mode_remove-all-enemies-applied", source_player.name })
+ end,
+ get_player_can_access_function = nil,
+ },
+ dont_generate_enemy = {
+ is_default = false,
+ default_enable_value = true,
+ default_disable_value = false,
+ get_value_function = function(surface)
+ if surface then
+ return storage.creative_mode.surface_cheats.dont_generate_enemy[surface.index] == true
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(surface, enable, source_player)
+ storage.creative_mode.surface_cheats.dont_generate_enemy[surface.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, enable)
+ if enable then
+ surface.print({ "message.creative-mode_dont-generate-enemy-enabled", source_player.name })
+ else
+ surface.print({ "message.creative-mode_dont-generate-enemy-disabled", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ pressure = {
+ is_default = false,
+ default_enable_value = 1000,
+ default_disable_value = 0,
+ get_value_function = function(surface)
+ return surface.get_property("pressure")
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(surface, value, source_player)
+ surface.set_property("pressure", value)
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, value)
+ surface.print({ "message.creative-mode_surface-pressure-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ magnetic_field = {
+ is_default = false,
+ default_enable_value = 1000,
+ default_disable_value = 0,
+ get_value_function = function(surface)
+ return surface.get_property("magnetic-field")
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(surface, value, source_player)
+ surface.set_property("magnetic-field", value)
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, value)
+ surface.print({ "message.creative-mode_surface-magnetic-field-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ gravity = {
+ is_default = false,
+ default_enable_value = 1000,
+ default_disable_value = 0,
+ get_value_function = function(surface)
+ return surface.get_property("gravity")
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(surface, value, source_player)
+ surface.set_property("gravity", value)
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, surface, value)
+ surface.print({ "message.creative-mode_surface-gravity-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ },
}
-- Data about all global cheats.
cheats.global_cheats_data = {
- check_is_self_function = function(source_player, target)
- return false
- end,
- print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
- -- No reason to fail so far.
- end,
- print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
- -- No reason to fail so far.
- end,
- print_enabled_all_by_admin_message_function = function(source_player, target, enable)
- -- No enable all so far.
- end,
- cheats = {
- pollution = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(target)
- return game.map_settings.pollution.enabled
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(target, enable, source_player)
- game.map_settings.pollution.enabled = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, enable)
- if enable then
- game.print({ "message.creative-mode_pollution-enabled", source_player.name })
- else
- game.print({ "message.creative-mode_pollution-disabled", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- enemy_evolution = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(target)
- return game.map_settings.enemy_evolution.enabled
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(target, enable, source_player)
- game.map_settings.enemy_evolution.enabled = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, enable)
- if enable then
- game.print({ "message.creative-mode_enemy-evolution-enabled", source_player.name })
- else
- game.print({ "message.creative-mode_enemy-evolution-disabled", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- evolution_time_factor = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(target)
- return game.map_settings.enemy_evolution.time_factor
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(target, value, source_player)
- game.map_settings.enemy_evolution.time_factor = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, value)
- game.print({ "message.creative-mode_evolution-time-factor-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- evolution_destroy_factor = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(target)
- return game.map_settings.enemy_evolution.destroy_factor
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(target, value, source_player)
- game.map_settings.enemy_evolution.destroy_factor = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, value)
- game.print({ "message.creative-mode_evolution-destroy-factor-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- evolution_pollution_factor = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(target)
- return game.map_settings.enemy_evolution.pollution_factor
- end,
- limit_value_before_apply_function = large_range_limit_value_before_apply_function,
- apply_to_target_function = function(target, value, source_player)
- game.map_settings.enemy_evolution.pollution_factor = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, value)
- game.print({ "message.creative-mode_evolution-pollution-factor-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- enemy_expansion = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(target)
- return game.map_settings.enemy_expansion.enabled
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(target, enable, source_player)
- game.map_settings.enemy_expansion.enabled = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, enable)
- if enable then
- game.print({ "message.creative-mode_enemy-expansion-enabled", source_player.name })
- else
- game.print({ "message.creative-mode_enemy-expansion-disabled", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- enemy_expansion_min_cooldown = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(target)
- return game.map_settings.enemy_expansion.min_expansion_cooldown
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(target, value, source_player)
- game.map_settings.enemy_expansion.min_expansion_cooldown = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, value)
- game.print({ "message.creative-mode_enemy-expansion-min-cooldown-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- enemy_expansion_max_cooldown = {
- is_default = false,
- default_enable_value = 0,
- default_disable_value = 0,
- get_value_function = function(target)
- return game.map_settings.enemy_expansion.max_expansion_cooldown
- end,
- limit_value_before_apply_function = uint32_limit_value_before_apply_function,
- apply_to_target_function = function(target, value, source_player)
- game.map_settings.enemy_expansion.max_expansion_cooldown = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, value)
- game.print({ "message.creative-mode_enemy-expansion-max-cooldown-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- game_speed = {
- is_default = false,
- default_enable_value = 1,
- default_disable_value = 1,
- get_value_function = function(target)
- return game.speed
- end,
- limit_value_before_apply_function = function(value)
- return util.clamp(value, 0.1, 100)
- end,
- apply_to_target_function = function(target, value, source_player)
- game.speed = value
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, target, value)
- game.print({ "message.creative-mode_game-speed-updated", source_player.name, value })
- end,
- get_player_can_access_function = nil,
- },
- },
+ check_is_self_function = function(source_player, target)
+ return false
+ end,
+ print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
+ -- No reason to fail so far.
+ end,
+ print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
+ -- No reason to fail so far.
+ end,
+ print_enabled_all_by_admin_message_function = function(source_player, target, enable)
+ -- No enable all so far.
+ end,
+ cheats = {
+ pollution = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(target)
+ return game.map_settings.pollution.enabled
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(target, enable, source_player)
+ game.map_settings.pollution.enabled = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, enable)
+ if enable then
+ game.print({ "message.creative-mode_pollution-enabled", source_player.name })
+ else
+ game.print({ "message.creative-mode_pollution-disabled", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ enemy_evolution = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(target)
+ return game.map_settings.enemy_evolution.enabled
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(target, enable, source_player)
+ game.map_settings.enemy_evolution.enabled = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, enable)
+ if enable then
+ game.print({ "message.creative-mode_enemy-evolution-enabled", source_player.name })
+ else
+ game.print({ "message.creative-mode_enemy-evolution-disabled", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ evolution_time_factor = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(target)
+ return game.map_settings.enemy_evolution.time_factor
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(target, value, source_player)
+ game.map_settings.enemy_evolution.time_factor = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, value)
+ game.print({ "message.creative-mode_evolution-time-factor-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ evolution_destroy_factor = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(target)
+ return game.map_settings.enemy_evolution.destroy_factor
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(target, value, source_player)
+ game.map_settings.enemy_evolution.destroy_factor = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, value)
+ game.print({ "message.creative-mode_evolution-destroy-factor-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ evolution_pollution_factor = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(target)
+ return game.map_settings.enemy_evolution.pollution_factor
+ end,
+ limit_value_before_apply_function = large_range_limit_value_before_apply_function,
+ apply_to_target_function = function(target, value, source_player)
+ game.map_settings.enemy_evolution.pollution_factor = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, value)
+ game.print({ "message.creative-mode_evolution-pollution-factor-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ enemy_expansion = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(target)
+ return game.map_settings.enemy_expansion.enabled
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(target, enable, source_player)
+ game.map_settings.enemy_expansion.enabled = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, enable)
+ if enable then
+ game.print({ "message.creative-mode_enemy-expansion-enabled", source_player.name })
+ else
+ game.print({ "message.creative-mode_enemy-expansion-disabled", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ enemy_expansion_min_cooldown = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(target)
+ return game.map_settings.enemy_expansion.min_expansion_cooldown
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(target, value, source_player)
+ game.map_settings.enemy_expansion.min_expansion_cooldown = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, value)
+ game.print({ "message.creative-mode_enemy-expansion-min-cooldown-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ enemy_expansion_max_cooldown = {
+ is_default = false,
+ default_enable_value = 0,
+ default_disable_value = 0,
+ get_value_function = function(target)
+ return game.map_settings.enemy_expansion.max_expansion_cooldown
+ end,
+ limit_value_before_apply_function = uint32_limit_value_before_apply_function,
+ apply_to_target_function = function(target, value, source_player)
+ game.map_settings.enemy_expansion.max_expansion_cooldown = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, value)
+ game.print({ "message.creative-mode_enemy-expansion-max-cooldown-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ game_speed = {
+ is_default = false,
+ default_enable_value = 1,
+ default_disable_value = 1,
+ get_value_function = function(target)
+ return game.speed
+ end,
+ limit_value_before_apply_function = function(value)
+ return util.clamp(value, 0.1, 100)
+ end,
+ apply_to_target_function = function(target, value, source_player)
+ game.speed = value
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, target, value)
+ game.print({ "message.creative-mode_game-speed-updated", source_player.name, value })
+ end,
+ get_player_can_access_function = nil,
+ },
+ },
}
-- Data about all build options.
cheats.build_options_data = {
- check_is_self_function = function(source_player, player)
- return source_player == player
- end,
- print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
- -- No reason to fail so far.
- end,
- print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
- -- No reason to fail so far.
- end,
- print_enabled_all_by_admin_message_function = function(source_player, player, enable)
- -- No enable all so far.
- end,
- cheats = {
- active = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(player)
- if player then
- if storage.creative_mode.build_options.active[player.index] ~= nil then
- return storage.creative_mode.build_options.active[player.index]
- else
- return true
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.build_options.active[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_build-active-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_build-active-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- destructible = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(player)
- if player then
- if storage.creative_mode.build_options.destructible[player.index] ~= nil then
- return storage.creative_mode.build_options.destructible[player.index]
- else
- return true
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.build_options.destructible[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_build-destructible-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_build-destructible-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- minable = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(player)
- if player then
- if storage.creative_mode.build_options.minable[player.index] ~= nil then
- return storage.creative_mode.build_options.minable[player.index]
- else
- return true
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.build_options.minable[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_build-minable-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_build-minable-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- rotatable = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(player)
- if player then
- if storage.creative_mode.build_options.rotatable[player.index] ~= nil then
- return storage.creative_mode.build_options.rotatable[player.index]
- else
- return true
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.build_options.rotatable[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_build-rotatable-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_build-rotatable-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- operable = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(player)
- if player then
- if storage.creative_mode.build_options.operable[player.index] ~= nil then
- return storage.creative_mode.build_options.operable[player.index]
- else
- return true
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.build_options.operable[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_build-operable-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_build-operable-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- full_health = {
- is_default = false,
- default_enable_value = false,
- default_disable_value = true,
- get_value_function = function(player)
- if player then
- if storage.creative_mode.build_options.full_health[player.index] ~= nil then
- return storage.creative_mode.build_options.full_health[player.index]
- else
- return true
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, enable, source_player)
- storage.creative_mode.build_options.full_health[player.index] = enable
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, enable)
- if enable then
- player.print({ "message.creative-mode_build-full-health-enabled-by-admin", source_player.name })
- else
- player.print({ "message.creative-mode_build-full-health-disabled-by-admin", source_player.name })
- end
- end,
- get_player_can_access_function = nil,
- },
- team = {
- is_default = false,
- default_enable_value = "",
- default_disable_value = "",
- get_value_function = function(player)
- if player then
- if storage.creative_mode.build_options.team[player.index] ~= nil then
- local force_name = storage.creative_mode.build_options.team[player.index]
- if game.forces[force_name] then
- return game.forces[force_name]
- else
- return player.force
- end
- else
- return player.force
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(player, force, source_player)
- storage.creative_mode.build_options.team[player.index] = force.name
- return nil
- end,
- print_applied_by_admin_message_function = function(source_player, player, force)
- player.print({ "message.creative-mode_build-team-updated-by-admin", source_player.name, force.name })
- end,
- get_player_can_access_function = rights.can_player_access_build_team_options,
- },
- },
+ check_is_self_function = function(source_player, player)
+ return source_player == player
+ end,
+ print_admin_failed_to_apply_to_single_target_message_function = function(source_player, target, reason)
+ -- No reason to fail so far.
+ end,
+ print_admin_failed_to_apply_to_multi_targets_message_function = function(source_player, fail_count, reason)
+ -- No reason to fail so far.
+ end,
+ print_enabled_all_by_admin_message_function = function(source_player, player, enable)
+ -- No enable all so far.
+ end,
+ cheats = {
+ active = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(player)
+ if player then
+ if storage.creative_mode.build_options.active[player.index] ~= nil then
+ return storage.creative_mode.build_options.active[player.index]
+ else
+ return true
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.build_options.active[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_build-active-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_build-active-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ destructible = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(player)
+ if player then
+ if storage.creative_mode.build_options.destructible[player.index] ~= nil then
+ return storage.creative_mode.build_options.destructible[player.index]
+ else
+ return true
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.build_options.destructible[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_build-destructible-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_build-destructible-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ minable = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(player)
+ if player then
+ if storage.creative_mode.build_options.minable[player.index] ~= nil then
+ return storage.creative_mode.build_options.minable[player.index]
+ else
+ return true
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.build_options.minable[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_build-minable-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_build-minable-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ rotatable = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(player)
+ if player then
+ if storage.creative_mode.build_options.rotatable[player.index] ~= nil then
+ return storage.creative_mode.build_options.rotatable[player.index]
+ else
+ return true
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.build_options.rotatable[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_build-rotatable-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_build-rotatable-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ operable = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(player)
+ if player then
+ if storage.creative_mode.build_options.operable[player.index] ~= nil then
+ return storage.creative_mode.build_options.operable[player.index]
+ else
+ return true
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.build_options.operable[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_build-operable-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_build-operable-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ full_health = {
+ is_default = false,
+ default_enable_value = false,
+ default_disable_value = true,
+ get_value_function = function(player)
+ if player then
+ if storage.creative_mode.build_options.full_health[player.index] ~= nil then
+ return storage.creative_mode.build_options.full_health[player.index]
+ else
+ return true
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, enable, source_player)
+ storage.creative_mode.build_options.full_health[player.index] = enable
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, enable)
+ if enable then
+ player.print({ "message.creative-mode_build-full-health-enabled-by-admin", source_player.name })
+ else
+ player.print({ "message.creative-mode_build-full-health-disabled-by-admin", source_player.name })
+ end
+ end,
+ get_player_can_access_function = nil,
+ },
+ team = {
+ is_default = false,
+ default_enable_value = "",
+ default_disable_value = "",
+ get_value_function = function(player)
+ if player then
+ if storage.creative_mode.build_options.team[player.index] ~= nil then
+ local force_name = storage.creative_mode.build_options.team[player.index]
+ if game.forces[force_name] then
+ return game.forces[force_name]
+ else
+ return player.force
+ end
+ else
+ return player.force
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(player, force, source_player)
+ storage.creative_mode.build_options.team[player.index] = force.name
+ return nil
+ end,
+ print_applied_by_admin_message_function = function(source_player, player, force)
+ player.print({ "message.creative-mode_build-team-updated-by-admin", source_player.name, force.name })
+ end,
+ get_player_can_access_function = rights.can_player_access_build_team_options,
+ },
+ },
}
-- Data about all magic wand modifications.
-- Actually a simplified version of the above cheats data.
cheats.magic_wand_modifications = {
- check_is_self_function = function(source_player, target)
- return true
- end,
- cheats = {
- active = {
- get_value_function = function(entity)
- if entity and entity.valid then
- return entity.active
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, enable, source_player)
- -- Fix for this bug report: https://forums.factorio.com/viewtopic.php?f=30&t=41386&p=243803#p243803
- if entity.type == "smoke" or entity.type == "corpse" then
- return nil
- end
- if entity.name == "entity-ghost" or entity.name == "tile-ghost" then
- return nil
- end
- entity.active = enable
- return nil
- end,
- },
- destructible = {
- get_value_function = function(entity)
- if entity and entity.valid then
- return entity.destructible
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, enable, source_player)
- entity.destructible = enable
- return nil
- end,
- },
- minable = {
- get_value_function = function(entity)
- if entity and entity.valid then
- return entity.minable
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, enable, source_player)
- entity.minable = enable
- return nil
- end,
- },
- rotatable = {
- get_value_function = function(entity)
- if entity and entity.valid then
- return entity.rotatable
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, enable, source_player)
- entity.rotatable = enable
- return nil
- end,
- },
- operable = {
- get_value_function = function(entity)
- if entity and entity.valid then
- return entity.operable
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, enable, source_player)
- entity.operable = enable
- return nil
- end,
- },
- full_health = {
- get_value_function = function(entity)
- if entity and entity.valid then
- if entity.health then
- return entity.health >= entity.prototype.get_max_health()
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, enable, source_player)
- if entity.health then
- if enable then
- entity.health = entity.prototype.get_max_health()
- else
- entity.health = 1
- end
- end
- return nil
- end,
- },
- backer_name = {
- get_value_function = function(entity)
- if entity and entity.valid then
- return entity.backer_name
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, value, source_player)
- if entity.supports_backer_name() then
- entity.backer_name = value
- end
- return nil
- end,
- },
- to_be_looted = {
- get_value_function = function(entity)
- if entity and entity.valid then
- if entity.name == "item-on-ground" then
- return entity.to_be_looted
- end
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, enable, source_player)
- if entity.name == "item-on-ground" then
- entity.to_be_looted = enable
- end
- return nil
- end,
- },
- revive = {
- get_value_function = nil,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, value, source_player)
- if entity.name == "entity-ghost" then
- util.revive_entity_ghost_and_raise_event(entity, source_player, false)
- elseif entity.name == "tile-ghost" then
- util.revive_tile_ghost_and_raise_event(entity, source_player, false)
- end
- return nil
- end,
- },
- kill = {
- get_value_function = nil,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, value, source_player)
- util.kill_entity_and_raise_event(entity, source_player)
- return nil
- end,
- },
- destroy = {
- get_value_function = nil,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, value, source_player)
- util.destroy_entity_and_raise_event(entity, source_player, false)
- return nil
- end,
- },
- team = {
- get_value_function = function(entity)
- if entity and entity.valid then
- return entity.force
- end
- return nil
- end,
- limit_value_before_apply_function = nil,
- apply_to_target_function = function(entity, force, source_player)
- entity.force = force
- return nil
- end,
- },
- },
+ check_is_self_function = function(source_player, target)
+ return true
+ end,
+ cheats = {
+ active = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ return entity.active
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, enable, source_player)
+ -- Fix for this bug report: https://forums.factorio.com/viewtopic.php?f=30&t=41386&p=243803#p243803
+ if entity.type == "smoke" or entity.type == "corpse" then
+ return nil
+ end
+ if entity.name == "entity-ghost" or entity.name == "tile-ghost" then
+ return nil
+ end
+ entity.active = enable
+ return nil
+ end,
+ },
+ destructible = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ return entity.destructible
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, enable, source_player)
+ entity.destructible = enable
+ return nil
+ end,
+ },
+ minable = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ return entity.minable
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, enable, source_player)
+ entity.minable = enable
+ return nil
+ end,
+ },
+ rotatable = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ return entity.rotatable
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, enable, source_player)
+ entity.rotatable = enable
+ return nil
+ end,
+ },
+ operable = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ return entity.operable
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, enable, source_player)
+ entity.operable = enable
+ return nil
+ end,
+ },
+ full_health = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ if entity.health then
+ return entity.health >= entity.prototype.get_max_health()
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, enable, source_player)
+ if entity.health then
+ if enable then
+ entity.health = entity.prototype.get_max_health()
+ else
+ entity.health = 1
+ end
+ end
+ return nil
+ end,
+ },
+ backer_name = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ return entity.backer_name
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, value, source_player)
+ if entity.supports_backer_name() then
+ entity.backer_name = value
+ end
+ return nil
+ end,
+ },
+ to_be_looted = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ if entity.name == "item-on-ground" then
+ return entity.to_be_looted
+ end
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, enable, source_player)
+ if entity.name == "item-on-ground" then
+ entity.to_be_looted = enable
+ end
+ return nil
+ end,
+ },
+ revive = {
+ get_value_function = nil,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, value, source_player)
+ if entity.name == "entity-ghost" then
+ util.revive_entity_ghost_and_raise_event(entity, source_player, false)
+ elseif entity.name == "tile-ghost" then
+ util.revive_tile_ghost_and_raise_event(entity, source_player, false)
+ end
+ return nil
+ end,
+ },
+ kill = {
+ get_value_function = nil,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, value, source_player)
+ util.kill_entity_and_raise_event(entity, source_player)
+ return nil
+ end,
+ },
+ destroy = {
+ get_value_function = nil,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, value, source_player)
+ util.destroy_entity_and_raise_event(entity, source_player, false)
+ return nil
+ end,
+ },
+ team = {
+ get_value_function = function(entity)
+ if entity and entity.valid then
+ return entity.force
+ end
+ return nil
+ end,
+ limit_value_before_apply_function = nil,
+ apply_to_target_function = function(entity, force, source_player)
+ entity.force = force
+ return nil
+ end,
+ },
+ },
}
--------------------------------------------------------------------
@@ -2252,440 +2241,433 @@ cheats.magic_wand_modifications = {
-- Applies the given value to the cheat of given cheat data (e.g. cheat_mode), under the given cheats data (e.g. personal_cheats_data), to the given targets.
-- If the cheat is simply an apply-cheat, just provide nil for the value.
function cheats.apply_cheat_to_targets(source_player, targets, cheats_data, cheat, value, should_print_message)
- local fail_count = 0
- local is_self_failed = false
- local failed_target = nil
- local failure_reason = nil
- -- Limit value before it is applied if necessary.
- if cheat.limit_value_before_apply_function then
- value = cheat.limit_value_before_apply_function(value)
- end
- -- Apply to targets.
- if targets then
- for _, target in pairs(targets) do
- if target.valid then -- Just play safe.
- local value_before_change
- if cheat.get_value_function == nil then
- value_before_change = -1
- else
- value_before_change = cheat.get_value_function(target)
- end
- local failure = cheat.apply_to_target_function(target, value, source_player)
- local is_self = cheats_data.check_is_self_function(source_player, target)
- if failure == nil then
- -- Succeeded to apply the cheat.
- -- It is possible that floating-point values are rounded by Factorio internally.
- local value_after_change
- if cheat.get_value_function == nil then
- value_after_change = 0 -- Make sure it is different from value_before_change
- else
- value_after_change = cheat.get_value_function(target)
- end
- if should_print_message and not is_self then
- if value_before_change ~= value_after_change then
- cheat.print_applied_by_admin_message_function(source_player, target, value_after_change)
- else
- -- Before is the same as after. But some cheats just cannot get the current value. They are always nil.
- -- In that case, we print the message according to the value.
- if value_after_change == nil then
- cheat.print_applied_by_admin_message_function(source_player, target, value)
- end
- end
- end
- else
- -- Failed to apply the cheat.
- is_self_failed = is_self_failed or is_self
- failed_target = target
- if failure_reason == nil then
- failure_reason = failure
- end
- fail_count = fail_count + 1
- end
- end
- end
- else
- -- No target. It may be the game itself.
- local value_before_change
- if cheat.get_value_function == nil then
- value_before_change = -1
- else
- value_before_change = cheat.get_value_function(nil)
- end
- local failure = cheat.apply_to_target_function(nil, value, source_player)
- local is_self = cheats_data.check_is_self_function(source_player, nil)
- if failure == nil then
- -- Succeeded to apply the cheat.
- local value_after_change
- if cheat.get_value_function == nil then
- value_after_change = 0
- else
- value_after_change = cheat.get_value_function(nil)
- end
- if should_print_message and not is_self and value_before_change ~= value_after_change then
- cheat.print_applied_by_admin_message_function(source_player, nil, value_after_change)
- end
- else
- -- Failed to apply the cheat.
- is_self_failed = is_self_failed or is_self
- failed_target = nil
- if failure_reason == nil then
- failure_reason = failure
- end
- fail_count = fail_count + 1
- end
- end
-
- -- Failed to apply on one or more players
- if should_print_message and failure_reason ~= nil then
- if fail_count <= 1 then
- if is_self_failed then
- -- Failed to apply on self.
- source_player.print(failure_reason)
- else
- -- Failed to apply on a non-self target.
- cheats_data.print_admin_failed_to_apply_to_single_target_message_function(
- source_player,
- failed_target,
- failure_reason
- )
- end
- else
- -- Failed to apply on multiple targets.
- cheats_data.print_admin_failed_to_apply_to_multi_targets_message_function(
- source_player,
- fail_count,
- failure_reason
- )
- end
- end
- return fail_count
+ local fail_count = 0
+ local is_self_failed = false
+ local failed_target = nil
+ local failure_reason = nil
+ -- Limit value before it is applied if necessary.
+ if cheat.limit_value_before_apply_function then
+ value = cheat.limit_value_before_apply_function(value)
+ end
+ -- Apply to targets.
+ if targets then
+ for _, target in pairs(targets) do
+ if target.valid then -- Just play safe.
+ local value_before_change
+ if cheat.get_value_function == nil then
+ value_before_change = -1
+ else
+ value_before_change = cheat.get_value_function(target)
+ end
+ local failure = cheat.apply_to_target_function(target, value, source_player)
+ local is_self = cheats_data.check_is_self_function(source_player, target)
+ if failure == nil then
+ -- Succeeded to apply the cheat.
+ -- It is possible that floating-point values are rounded by Factorio internally.
+ local value_after_change
+ if cheat.get_value_function == nil then
+ value_after_change = 0 -- Make sure it is different from value_before_change
+ else
+ value_after_change = cheat.get_value_function(target)
+ end
+ if should_print_message and not is_self then
+ if value_before_change ~= value_after_change then
+ cheat.print_applied_by_admin_message_function(source_player, target, value_after_change)
+ else
+ -- Before is the same as after. But some cheats just cannot get the current value. They are always nil.
+ -- In that case, we print the message according to the value.
+ if value_after_change == nil then
+ cheat.print_applied_by_admin_message_function(source_player, target, value)
+ end
+ end
+ end
+ else
+ -- Failed to apply the cheat.
+ is_self_failed = is_self_failed or is_self
+ failed_target = target
+ if failure_reason == nil then
+ failure_reason = failure
+ end
+ fail_count = fail_count + 1
+ end
+ end
+ end
+ else
+ -- No target. It may be the game itself.
+ local value_before_change
+ if cheat.get_value_function == nil then
+ value_before_change = -1
+ else
+ value_before_change = cheat.get_value_function(nil)
+ end
+ local failure = cheat.apply_to_target_function(nil, value, source_player)
+ local is_self = cheats_data.check_is_self_function(source_player, nil)
+ if failure == nil then
+ -- Succeeded to apply the cheat.
+ local value_after_change
+ if cheat.get_value_function == nil then
+ value_after_change = 0
+ else
+ value_after_change = cheat.get_value_function(nil)
+ end
+ if should_print_message and not is_self and value_before_change ~= value_after_change then
+ cheat.print_applied_by_admin_message_function(source_player, nil, value_after_change)
+ end
+ else
+ -- Failed to apply the cheat.
+ is_self_failed = is_self_failed or is_self
+ failed_target = nil
+ if failure_reason == nil then
+ failure_reason = failure
+ end
+ fail_count = fail_count + 1
+ end
+ end
+
+ -- Failed to apply on one or more players
+ if should_print_message and failure_reason ~= nil then
+ if fail_count <= 1 then
+ if is_self_failed then
+ -- Failed to apply on self.
+ source_player.print(failure_reason)
+ else
+ -- Failed to apply on a non-self target.
+ cheats_data.print_admin_failed_to_apply_to_single_target_message_function(
+ source_player,
+ failed_target,
+ failure_reason
+ )
+ end
+ else
+ -- Failed to apply on multiple targets.
+ cheats_data.print_admin_failed_to_apply_to_multi_targets_message_function(
+ source_player,
+ fail_count,
+ failure_reason
+ )
+ end
+ end
+ return fail_count
end
-- Enables or disables all the cheats in the given cheats data to the given targets.
-- @param cheats_data For example, the personal_cheats_data.
function cheats.enable_or_disable_all_cheats_to_targets(
- source_player,
- targets,
- cheats_data,
- enable,
- should_print_message
+ source_player,
+ targets,
+ cheats_data,
+ enable,
+ should_print_message
)
- -- Iterate all cheats inside the cheats_data to enable or disable them.
- for _, cheat_data in pairs(cheats_data.cheats) do
- local is_default
- if enable and source_player and cheat_data.get_is_default_from_player then
- is_default = cheat_data.get_is_default_from_player(source_player)
- else
- is_default = cheat_data.is_default
- end
- if is_default then
- if
- cheat_data.get_player_can_access_function == nil
- or cheat_data.get_player_can_access_function(source_player)
- then
- local value
- if enable then
- if source_player and cheat_data.get_default_enable_value_from_player then
- value = cheat_data.get_default_enable_value_from_player(source_player)
- else
- value = cheat_data.default_enable_value
- end
- else
- value = cheat_data.default_disable_value
- end
- cheats.apply_cheat_to_targets(source_player, targets, cheats_data, cheat_data, value, false)
- end
- end
- end
- -- Print to targets.
- if should_print_message then
- for _, target in pairs(targets) do
- local is_self = cheats_data.check_is_self_function(source_player, target)
- if not is_self then
- cheats_data.print_enabled_all_by_admin_message_function(source_player, target, enable)
- end
- end
- end
+ -- Iterate all cheats inside the cheats_data to enable or disable them.
+ for _, cheat_data in pairs(cheats_data.cheats) do
+ local is_default
+ if enable and source_player and cheat_data.get_is_default_from_player then
+ is_default = cheat_data.get_is_default_from_player(source_player)
+ else
+ is_default = cheat_data.is_default
+ end
+ if is_default then
+ if
+ cheat_data.get_player_can_access_function == nil or cheat_data.get_player_can_access_function(source_player)
+ then
+ local value
+ if enable then
+ if source_player and cheat_data.get_default_enable_value_from_player then
+ value = cheat_data.get_default_enable_value_from_player(source_player)
+ else
+ value = cheat_data.default_enable_value
+ end
+ else
+ value = cheat_data.default_disable_value
+ end
+ cheats.apply_cheat_to_targets(source_player, targets, cheats_data, cheat_data, value, false)
+ end
+ end
+ end
+ -- Print to targets.
+ if should_print_message then
+ for _, target in pairs(targets) do
+ local is_self = cheats_data.check_is_self_function(source_player, target)
+ if not is_self then
+ cheats_data.print_enabled_all_by_admin_message_function(source_player, target, enable)
+ end
+ end
+ end
end
--------------------------------------------------------------------
-- Returns whether Creative Mode has been enabled. If not, a message will be printed for the given player.
function cheats.check_creative_mode_has_enabled(player)
- -- If creative mode has not been enabled, notify the player in charge and do nothing.
- if not storage.creative_mode.enabled then
- if player then
- player.print({ "message.creative-mode_not-yet-enabled" })
- end
- return false
- end
- return true
+ -- If creative mode has not been enabled, notify the player in charge and do nothing.
+ if not storage.creative_mode.enabled then
+ if player then
+ player.print({ "message.creative-mode_not-yet-enabled" })
+ end
+ return false
+ end
+ return true
end
-- Enables or disables Creative Mode for all players.
-- @param source_player The player who enables or disables Creative Mode.
-- @param ignore_current_state Whether the current state of Creative Mode should be ignored, such that the given command for enabling or disabling Creative Mode will be executed for sure.
function cheats.enable_or_disable_creative_mode(
- source_player,
- enable,
- is_permanent,
- auto_apply_to_all_cheats,
- ignore_current_state
+ source_player,
+ enable,
+ is_permanent,
+ auto_apply_to_all_cheats,
+ ignore_current_state
)
- if not ignore_current_state then
- if enable then
- -- If creative mode has been enabled, notify the player in charge and do nothing.
- if storage.creative_mode.enabled then
- if source_player then
- source_player.print({ "message.creative-mode_already-enabled" })
- end
- return
- end
-
- -- If creative mode has already been permanently disabled, notify the player in charge and do nothing.
- if storage.creative_mode.permanently_disabled then
- if source_player then
- source_player.print({ "message.creative-mode_enable-failed" })
- end
- return
- end
- else
- -- If creative mode has not been enabled, notify the player in charge and do nothing.
- if not cheats.check_creative_mode_has_enabled(source_player) then
- return
- end
- end
- end
-
- -- Also unhide/hide the items so they can be selected as filter.
- -- Unfortunately, LuaItemPrototype doesn't have flags property. This cannot be done at this moment.
- -- for _, item in pairs(creative_mode_defines.names.items) do
- -- if prototypes.item[item] ~= nil then
- -- if enable then
- -- table.remove(prototypes.item[item].flags, 2) -- The hidden flag is the second one.
- -- else
- -- table.insert(prototypes.item[item].flags, "hidden")
- -- end
- -- end
- -- end
-
- local player_name = source_player.name
-
- -- Save as creative mode has been enabled/disabled.
- local previous_state = storage.creative_mode.enabled
- storage.creative_mode.enabled = enable
-
- if enable then
- -- Notify the players.
- game.print({ "message.creative-mode_enable-succeeded", player_name })
-
- -- Also raise the on-enable event.
- if not previous_state then
- remote_interface.raise_on_enabled_event(source_player)
- end
- else
- -- Notify the players.
- if is_permanent then
- game.print({ "message.creative-mode_permanently-disable-succeeded", player_name })
- else
- game.print({ "message.creative-mode_disable-succeeded", player_name })
- end
-
- -- Also raise the on-disable event.
- if previous_state then
- remote_interface.raise_on_disabled_event(source_player)
- end
- end
-
- -- If it is permanently disabled, save the state so it cannot be enabled later.
- if not enable and is_permanent then
- storage.creative_mode.permanently_disabled = true
- end
-
- -- Apply to all cheats if needed
- if auto_apply_to_all_cheats then
- -- Personal cheats.
- cheats.enable_or_disable_all_cheats_to_targets(
- source_player,
- game.players,
- cheats.personal_cheats_data,
- enable,
- false
- )
- -- Team cheats.
- cheats.enable_or_disable_all_cheats_to_targets(
- source_player,
- game.forces,
- cheats.team_cheats_data,
- enable,
- false
- )
- -- Surface cheat - freeze daytime.
- cheats.apply_cheat_to_targets(
- source_player,
- game.surfaces,
- cheats.surface_cheats_data,
- cheats.surface_cheats_data.cheats.freeze_daytime,
- enable,
- false
- )
- -- Surface cheat - set daytime to 0.
- if enable then
- cheats.apply_cheat_to_targets(
- source_player,
- game.surfaces,
- cheats.surface_cheats_data,
- cheats.surface_cheats_data.cheats.daytime,
- 0,
- false
- )
- end
-
- if enable then
- game.print({ "message.creative-mode_enabled-all-cheats", player_name })
- end
- else
- -- Unlock the creative tools' recipes.
- for _, force in pairs(game.forces) do
- cheats.team_cheats_data.cheats.creative_tools_recipes.apply_to_target_function(force, enable, nil)
- end
- end
-
- -- Create or destroy the Creative Mode menu button.
- gui_menu.create_or_destroy_main_menu_open_button_for_all_players()
+ if not ignore_current_state then
+ if enable then
+ -- If creative mode has been enabled, notify the player in charge and do nothing.
+ if storage.creative_mode.enabled then
+ if source_player then
+ source_player.print({ "message.creative-mode_already-enabled" })
+ end
+ return
+ end
+
+ -- If creative mode has already been permanently disabled, notify the player in charge and do nothing.
+ if storage.creative_mode.permanently_disabled then
+ if source_player then
+ source_player.print({ "message.creative-mode_enable-failed" })
+ end
+ return
+ end
+ else
+ -- If creative mode has not been enabled, notify the player in charge and do nothing.
+ if not cheats.check_creative_mode_has_enabled(source_player) then
+ return
+ end
+ end
+ end
+
+ -- Also unhide/hide the items so they can be selected as filter.
+ -- Unfortunately, LuaItemPrototype doesn't have flags property. This cannot be done at this moment.
+ -- for _, item in pairs(creative_mode_defines.names.items) do
+ -- if prototypes.item[item] ~= nil then
+ -- if enable then
+ -- table.remove(prototypes.item[item].flags, 2) -- The hidden flag is the second one.
+ -- else
+ -- table.insert(prototypes.item[item].flags, "hidden")
+ -- end
+ -- end
+ -- end
+
+ local player_name = source_player.name
+
+ -- Save as creative mode has been enabled/disabled.
+ local previous_state = storage.creative_mode.enabled
+ storage.creative_mode.enabled = enable
+
+ if enable then
+ -- Notify the players.
+ game.print({ "message.creative-mode_enable-succeeded", player_name })
+
+ -- Also raise the on-enable event.
+ if not previous_state then
+ remote_interface.raise_on_enabled_event(source_player)
+ end
+ else
+ -- Notify the players.
+ if is_permanent then
+ game.print({ "message.creative-mode_permanently-disable-succeeded", player_name })
+ else
+ game.print({ "message.creative-mode_disable-succeeded", player_name })
+ end
+
+ -- Also raise the on-disable event.
+ if previous_state then
+ remote_interface.raise_on_disabled_event(source_player)
+ end
+ end
+
+ -- If it is permanently disabled, save the state so it cannot be enabled later.
+ if not enable and is_permanent then
+ storage.creative_mode.permanently_disabled = true
+ end
+
+ -- Apply to all cheats if needed
+ if auto_apply_to_all_cheats then
+ -- Personal cheats.
+ cheats.enable_or_disable_all_cheats_to_targets(
+ source_player,
+ game.players,
+ cheats.personal_cheats_data,
+ enable,
+ false
+ )
+ -- Team cheats.
+ cheats.enable_or_disable_all_cheats_to_targets(source_player, game.forces, cheats.team_cheats_data, enable, false)
+ -- Surface cheat - freeze daytime.
+ cheats.apply_cheat_to_targets(
+ source_player,
+ game.surfaces,
+ cheats.surface_cheats_data,
+ cheats.surface_cheats_data.cheats.freeze_daytime,
+ enable,
+ false
+ )
+ -- Surface cheat - set daytime to 0.
+ if enable then
+ cheats.apply_cheat_to_targets(
+ source_player,
+ game.surfaces,
+ cheats.surface_cheats_data,
+ cheats.surface_cheats_data.cheats.daytime,
+ 0,
+ false
+ )
+ end
+
+ if enable then
+ game.print({ "message.creative-mode_enabled-all-cheats", player_name })
+ end
+ else
+ -- Unlock the creative tools' recipes.
+ for _, force in pairs(game.forces) do
+ cheats.team_cheats_data.cheats.creative_tools_recipes.apply_to_target_function(force, enable, nil)
+ end
+ end
+
+ -- Create or destroy the Creative Mode menu button.
+ gui_menu.create_or_destroy_main_menu_open_button_for_all_players()
end
--------------------------------------------------------------------
-- Applies cheat events that have been pending in the previous ticks.
function cheats.tick()
- -- Instant blueprint. Iterate from back to front.
- for i = #storage.creative_mode.pending_instant_blueprint, 1, -1 do
- local data = storage.creative_mode.pending_instant_blueprint[i]
- local entity = data.entity
- if entity.valid then
- local player_index = data.player_index
- local player = game.players[player_index]
- local is_item_request_proxy = data.is_item_request_proxy
- if is_item_request_proxy then
- -- It is an item request proxy. Fulfill its request.
- entity.item_requests = util.fulfill_item_requests(entity.proxy_target, entity.item_requests)
- -- Check if all items have be inserted so we can destroy the proxy.
- local is_fulfilled = true
- for _, item_request in ipairs(entity.item_requests) do
- if item_request.count > 0 then
- is_fulfilled = false
- break
- end
- end
- if is_fulfilled then
- entity.destroy()
- end
- table.remove(storage.creative_mode.pending_instant_blueprint, i)
- else
- -- It is a ghost entity. Revive it.
- local is_entity_ghost = data.is_entity_ghost
- local try_revive_count = data.try_revive_count
- local revive_result
- if is_entity_ghost then
- revive_result = util.revive_entity_ghost_and_raise_event(entity, player, true)
- else
- revive_result = util.revive_tile_ghost_and_raise_event(entity, player, true)
- end
-
- if revive_result == nil then
- -- The ghost can not be revived.
- if try_revive_count >= 1 then
- -- We have tried before, but still no luck. Just give up.
- table.remove(storage.creative_mode.pending_instant_blueprint, i)
- else
- -- Try again in the next tick.
- storage.creative_mode.pending_instant_blueprint[i].try_revive_count = try_revive_count + 1
- end
- end
- end
- else
- table.remove(storage.creative_mode.pending_instant_blueprint, i)
- end
- end
-
- -- Instant deconstruction. Iterate from back to front.
- -- Prepare for tile deconstruction.
- local new_tiles_on_surfaces = nil
- for i = #storage.creative_mode.pending_instant_deconstruction, 1, -1 do
- local data = storage.creative_mode.pending_instant_deconstruction[i]
- local entity = data.entity
- if entity.valid then
- local player_index = data.player_index
- -- Make sure it is really needed to deconstruct.
- -- Filtered Deconstruction Planner unmarks filtered entities right after they are marked by the deconstruction planner.
- if entity.to_be_deconstructed(entity.force) then
- if entity.type == "deconstructible-tile-proxy" then
- -- It is a tile to be removed, not a real entity.
- local surface = entity.surface
- local surface_name = surface.name
- local position = entity.position
- -- Don't mine the raw tiles. Only mine the man-made ones (covering hidden tiles).
- local hidden_tile = surface.get_hidden_tile(position)
- if hidden_tile then
- -- Group the tiles to be set. Set them only after all data is ready.
- if not new_tiles_on_surfaces then
- new_tiles_on_surfaces = {}
- end
- -- Don't directly use "surface" as the key, because in each iteration, surface is a different instance of table. Use surface name instead because it is a primitive data type.
- if not new_tiles_on_surfaces[surface_name] then
- new_tiles_on_surfaces[surface_name] = {}
- end
- -- Tile array, for setting tiles.
- if not new_tiles_on_surfaces[surface_name].tiles then
- new_tiles_on_surfaces[surface_name].tiles = {}
- end
- -- Position array associated with player index, for raising event.
- if not new_tiles_on_surfaces[surface_name].event_data then
- new_tiles_on_surfaces[surface_name].event_data = {}
- end
- if not new_tiles_on_surfaces[surface_name].event_data[player_index] then
- new_tiles_on_surfaces[surface_name].event_data[player_index] = {}
- end
- -- Record.
- table.insert(new_tiles_on_surfaces[surface_name].event_data[player_index], position)
- table.insert(new_tiles_on_surfaces[surface_name].tiles, {
- name = hidden_tile,
- position = position,
- })
- end
- entity.destroy()
- else
- util.destroy_entity_and_raise_event(entity, game.players[player_index], true)
- end
- end
- end
- table.remove(storage.creative_mode.pending_instant_deconstruction, i)
- end
- -- Destroy tiles and raise event.
- if new_tiles_on_surfaces then
- for surface_name, data in pairs(new_tiles_on_surfaces) do
- local surface = game.surfaces[surface_name]
- -- Set tiles and raise the event
- surface.set_tiles(data.tiles, true, true, true, true)
- end
- end
-
- -- Surface cheat - don't generate enemy.
- for i = #storage.creative_mode.pending_areas_to_remove_enemies, 1, -1 do
- local surface = storage.creative_mode.pending_areas_to_remove_enemies[i].surface
- local area = storage.creative_mode.pending_areas_to_remove_enemies[i].area
- if surface.valid then
- for _, entity in
- pairs(surface.find_entities_filtered({
- area = area,
- force = "enemy",
- }))
- do
- entity.destroy()
- end
- end
- table.remove(storage.creative_mode.pending_areas_to_remove_enemies, i)
- end
+ -- Instant blueprint. Iterate from back to front.
+ for i = #storage.creative_mode.pending_instant_blueprint, 1, -1 do
+ local data = storage.creative_mode.pending_instant_blueprint[i]
+ local entity = data.entity
+ if entity.valid then
+ local player_index = data.player_index
+ local player = game.players[player_index]
+ local is_item_request_proxy = data.is_item_request_proxy
+ if is_item_request_proxy then
+ -- It is an item request proxy. Fulfill its request.
+ entity.item_requests = util.fulfill_item_requests(entity.proxy_target, entity.item_requests)
+ -- Check if all items have be inserted so we can destroy the proxy.
+ local is_fulfilled = true
+ for _, item_request in ipairs(entity.item_requests) do
+ if item_request.count > 0 then
+ is_fulfilled = false
+ break
+ end
+ end
+ if is_fulfilled then
+ entity.destroy()
+ end
+ table.remove(storage.creative_mode.pending_instant_blueprint, i)
+ else
+ -- It is a ghost entity. Revive it.
+ local is_entity_ghost = data.is_entity_ghost
+ local try_revive_count = data.try_revive_count
+ local revive_result
+ if is_entity_ghost then
+ revive_result = util.revive_entity_ghost_and_raise_event(entity, player, true)
+ else
+ revive_result = util.revive_tile_ghost_and_raise_event(entity, player, true)
+ end
+
+ if revive_result == nil then
+ -- The ghost can not be revived.
+ if try_revive_count >= 1 then
+ -- We have tried before, but still no luck. Just give up.
+ table.remove(storage.creative_mode.pending_instant_blueprint, i)
+ else
+ -- Try again in the next tick.
+ storage.creative_mode.pending_instant_blueprint[i].try_revive_count = try_revive_count + 1
+ end
+ end
+ end
+ else
+ table.remove(storage.creative_mode.pending_instant_blueprint, i)
+ end
+ end
+
+ -- Instant deconstruction. Iterate from back to front.
+ -- Prepare for tile deconstruction.
+ local new_tiles_on_surfaces = nil
+ for i = #storage.creative_mode.pending_instant_deconstruction, 1, -1 do
+ local data = storage.creative_mode.pending_instant_deconstruction[i]
+ local entity = data.entity
+ if entity.valid then
+ local player_index = data.player_index
+ -- Make sure it is really needed to deconstruct.
+ -- Filtered Deconstruction Planner unmarks filtered entities right after they are marked by the deconstruction planner.
+ if entity.to_be_deconstructed(entity.force) then
+ if entity.type == "deconstructible-tile-proxy" then
+ -- It is a tile to be removed, not a real entity.
+ local surface = entity.surface
+ local surface_name = surface.name
+ local position = entity.position
+ -- Don't mine the raw tiles. Only mine the man-made ones (covering hidden tiles).
+ local hidden_tile = surface.get_hidden_tile(position)
+ if hidden_tile then
+ -- Group the tiles to be set. Set them only after all data is ready.
+ if not new_tiles_on_surfaces then
+ new_tiles_on_surfaces = {}
+ end
+ -- Don't directly use "surface" as the key, because in each iteration, surface is a different instance of table. Use surface name instead because it is a primitive data type.
+ if not new_tiles_on_surfaces[surface_name] then
+ new_tiles_on_surfaces[surface_name] = {}
+ end
+ -- Tile array, for setting tiles.
+ if not new_tiles_on_surfaces[surface_name].tiles then
+ new_tiles_on_surfaces[surface_name].tiles = {}
+ end
+ -- Position array associated with player index, for raising event.
+ if not new_tiles_on_surfaces[surface_name].event_data then
+ new_tiles_on_surfaces[surface_name].event_data = {}
+ end
+ if not new_tiles_on_surfaces[surface_name].event_data[player_index] then
+ new_tiles_on_surfaces[surface_name].event_data[player_index] = {}
+ end
+ -- Record.
+ table.insert(new_tiles_on_surfaces[surface_name].event_data[player_index], position)
+ table.insert(new_tiles_on_surfaces[surface_name].tiles, {
+ name = hidden_tile,
+ position = position,
+ })
+ end
+ entity.destroy()
+ else
+ util.destroy_entity_and_raise_event(entity, game.players[player_index], true)
+ end
+ end
+ end
+ table.remove(storage.creative_mode.pending_instant_deconstruction, i)
+ end
+ -- Destroy tiles and raise event.
+ if new_tiles_on_surfaces then
+ for surface_name, data in pairs(new_tiles_on_surfaces) do
+ local surface = game.surfaces[surface_name]
+ -- Set tiles and raise the event
+ surface.set_tiles(data.tiles, true, true, true, true)
+ end
+ end
+
+ -- Surface cheat - don't generate enemy.
+ for i = #storage.creative_mode.pending_areas_to_remove_enemies, 1, -1 do
+ local surface = storage.creative_mode.pending_areas_to_remove_enemies[i].surface
+ local area = storage.creative_mode.pending_areas_to_remove_enemies[i].area
+ if surface.valid then
+ for _, entity in
+ pairs(surface.find_entities_filtered({
+ area = area,
+ force = "enemy",
+ }))
+ do
+ entity.destroy()
+ end
+ end
+ table.remove(storage.creative_mode.pending_areas_to_remove_enemies, i)
+ end
end
----
@@ -2695,67 +2677,68 @@ local keep_last_item_blacklist = {}
-- Registers or deregisters the given item name to or from the blacklist of keep last item.
-- If it is deregistration, returns whether the process is success.
function cheats.register_or_deregister_item_to_be_ignored_by_keep_last_item(item_name, is_register)
- if is_register then
- -- Register.
- keep_last_item_blacklist[item_name] = true
- else
- -- Deregister.
- if keep_last_item_blacklist[item_name] then
- keep_last_item_blacklist[item_name] = nil
- return true
- end
- return false
- end
+ if is_register then
+ -- Register.
+ keep_last_item_blacklist[item_name] = true
+ else
+ -- Deregister.
+ if keep_last_item_blacklist[item_name] then
+ keep_last_item_blacklist[item_name] = nil
+ return true
+ end
+ return false
+ end
end
-- Returns whether the given item name has been blacklisted by keep last item.
function cheats.has_item_ignored_by_keep_last_item(item_name)
- return keep_last_item_blacklist[item_name] ~= nil
+ return keep_last_item_blacklist[item_name] ~= nil
end
-- Applies cheats to the player when he/she uses item to build something.
function cheats.on_pre_build(player)
- -- Keep last item.
- if storage.creative_mode.personal_cheats.keep_last_item[player.index] then
- local cursor_stack = player.cursor_stack
- if cursor_stack.valid_for_read then -- Don't know why sometimes the stack becomes invalid and causes error.
- local cursor_stack_name = cursor_stack.name
- -- Make sure the item is not blacklisted.
- if not keep_last_item_blacklist[cursor_stack_name] then
- if player.get_item_count(cursor_stack_name) <= 1 then
- local cursor_stack_prototype = cursor_stack.prototype
- if cursor_stack_prototype.stackable and cursor_stack_prototype.stack_size > 1 then
- -- The item is stackable. Simply increase the stack size on the cursor.
- cursor_stack.count = 2
- -- But it is possible that cursor stack count is still 1 because the item is damaged, i.e. prototype is stackable but the actual item is not!
- if cursor_stack.count <= 1 then
- -- Insert an item to player's inventory.
- if player.insert({
- name = cursor_stack_name,
- count = 1,
- }) > 0 then
- -- This event is invoked even if the player uses the item to build ghost entity, i.e. no item is going to be spent.
- -- In that case, we will have to get back the inserted item.
- storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] =
- game.tick
- end
- else
- -- Successfully set cursor stack to 2.
- storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = game.tick
- end
- else
- -- The item is not stackable. Insert the item to the player's inventory.
- if player.insert({
- name = cursor_stack_name,
- count = 1,
- }) > 0 then
- storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = game.tick
- end
- end
- end
- end
- end
- end
+ -- Keep last item.
+ if storage.creative_mode.personal_cheats.keep_last_item[player.index] then
+ local cursor_stack = player.cursor_stack
+ if cursor_stack.valid_for_read then -- Don't know why sometimes the stack becomes invalid and causes error.
+ local cursor_stack_name = cursor_stack.name
+ -- Make sure the item is not blacklisted.
+ if not keep_last_item_blacklist[cursor_stack_name] then
+ if player.get_item_count(cursor_stack_name) <= 1 then
+ local cursor_stack_prototype = cursor_stack.prototype
+ if cursor_stack_prototype.stackable and cursor_stack_prototype.stack_size > 1 then
+ -- The item is stackable. Simply increase the stack size on the cursor.
+ cursor_stack.count = 2
+ -- But it is possible that cursor stack count is still 1 because the item is damaged, i.e. prototype is stackable but the actual item is not!
+ if cursor_stack.count <= 1 then
+ -- Insert an item to player's inventory.
+ if
+ player.insert({
+ name = cursor_stack_name,
+ count = 1,
+ }) > 0
+ then
+ -- This event is invoked even if the player uses the item to build ghost entity, i.e. no item is going to be spent.
+ -- In that case, we will have to get back the inserted item.
+ storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = game.tick
+ end
+ else
+ -- Successfully set cursor stack to 2.
+ storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = game.tick
+ end
+ else
+ -- The item is not stackable. Insert the item to the player's inventory.
+ if player.insert({
+ name = cursor_stack_name,
+ count = 1,
+ }) > 0 then
+ storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = game.tick
+ end
+ end
+ end
+ end
+ end
+ end
end
----
@@ -2766,47 +2749,47 @@ local instant_blueprint_blacklist = {}
-- Registers or deregisters the given entity name to or from the blacklist of instant blueprint.
-- If it is deregistration, returns whether the process is success.
function cheats.register_or_deregister_entity_to_be_ignored_by_instant_blueprint(entity_name, is_register)
- if is_register then
- -- Register.
- instant_blueprint_blacklist[entity_name] = true
- else
- -- Deregister.
- if instant_blueprint_blacklist[entity_name] then
- instant_blueprint_blacklist[entity_name] = nil
- return true
- end
- return false
- end
+ if is_register then
+ -- Register.
+ instant_blueprint_blacklist[entity_name] = true
+ else
+ -- Deregister.
+ if instant_blueprint_blacklist[entity_name] then
+ instant_blueprint_blacklist[entity_name] = nil
+ return true
+ end
+ return false
+ end
end
-- Returns whether the given entity name has been blacklisted by instant blueprint.
function cheats.has_entity_ignored_by_instant_blueprint(entity_name)
- return instant_blueprint_blacklist[entity_name] ~= nil
+ return instant_blueprint_blacklist[entity_name] ~= nil
end
-- Applies cheats to the player when he/she builds something.
function cheats.on_built_entity(player, entity, is_ghost, is_entity_ghost, is_item_request_proxy)
- -- Keep last item.
- if storage.creative_mode.personal_cheats.keep_last_item[player.index] then
- if storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] == game.tick then
- -- An item has been given to the player for free.
- if is_ghost then
- -- But the player didn't spend the item. So, we get the item back.
- local cursor_stack = player.cursor_stack
- local cursor_stack_prototype = cursor_stack.prototype
- if cursor_stack_prototype.stackable and cursor_stack_prototype.stack_size > 1 then
- cursor_stack.count = 1
- else
- player.remove_item({
- name = cursor_stack.name,
- count = 1,
- })
- end
- end
- else --
- -- If the player use the rail planner system to build rails, it is possible that the rail is consumed but the on_pre_build was not fired.
- -- The following was a planned fix for that, but unfortunately, the cursor stack has already become invalid for read and we cannot get its data.
- --[[
+ -- Keep last item.
+ if storage.creative_mode.personal_cheats.keep_last_item[player.index] then
+ if storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] == game.tick then
+ -- An item has been given to the player for free.
+ if is_ghost then
+ -- But the player didn't spend the item. So, we get the item back.
+ local cursor_stack = player.cursor_stack
+ local cursor_stack_prototype = cursor_stack.prototype
+ if cursor_stack_prototype.stackable and cursor_stack_prototype.stack_size > 1 then
+ cursor_stack.count = 1
+ else
+ player.remove_item({
+ name = cursor_stack.name,
+ count = 1,
+ })
+ end
+ end
+ else --
+ -- If the player use the rail planner system to build rails, it is possible that the rail is consumed but the on_pre_build was not fired.
+ -- The following was a planned fix for that, but unfortunately, the cursor stack has already become invalid for read and we cannot get its data.
+ --[[
if not is_ghost and (entity.type == "straight-rail" or entity.type == "curved-rail") then
local cursor_stack = player.cursor_stack
-- Check if the stack is no longer valid (i.e. count <= 0) and it is a rail planner item.
@@ -2816,73 +2799,73 @@ function cheats.on_built_entity(player, entity, is_ghost, is_entity_ghost, is_it
end
end
]]
- -- Approach no. 2
- -- It works, but need more work to make it mod-proof. (Build a rail entity type to rail item table)
- --[[
+ -- Approach no. 2
+ -- It works, but need more work to make it mod-proof. (Build a rail entity type to rail item table)
+ --[[
if not is_ghost and (entity.type == "straight-rail" or entity.type == "curved-rail") then
if player.get_item_count("rail") <= 0 then
player.insert{name = "rail", count = 1}
end
end
--]]
- end
- storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = nil
- end
-
- -- Build options.
- -- Active.
- if storage.creative_mode.build_options.active[player.index] == false then
- entity.active = false
- end
- -- Destructible.
- if storage.creative_mode.build_options.destructible[player.index] == false then
- entity.destructible = false
- end
- -- Minable.
- if storage.creative_mode.build_options.minable[player.index] == false then
- entity.minable = false
- end
- -- Rotatable.
- if storage.creative_mode.build_options.rotatable[player.index] == false then
- entity.rotatable = false
- end
- -- Operable.
- if storage.creative_mode.build_options.operable[player.index] == false then
- entity.operable = false
- end
- -- Full health.
- if storage.creative_mode.build_options.full_health[player.index] == false then
- if entity.health ~= nil then
- entity.health = 1
- end
- end
- -- Team.
- if storage.creative_mode.build_options.team[player.index] ~= nil then
- local force = game.forces[storage.creative_mode.build_options.team[player.index]]
- if force then
- entity.force = force
- end
- end
-
- -- Instant blueprint. (Has to be done at last.)
- if storage.creative_mode.personal_cheats.instant_blueprint[player.index] then
- if is_ghost or is_item_request_proxy then
- -- Make sure the entity is not ignored by instant blueprint.
- if not is_ghost or not instant_blueprint_blacklist[entity.ghost_name] then
- -- We don't do the job if the instant-blueprint mod is installed and is activated.
- if not mod_compatibler.is_instant_blueprint_installed_and_activated_for_player(player) then
- -- Don't construct it right now.
- table.insert(storage.creative_mode.pending_instant_blueprint, {
- entity = entity,
- player_index = player.index,
- is_entity_ghost = is_entity_ghost,
- try_revive_count = 0, -- We will only try to revive each ghost twice.
- is_item_request_proxy = is_item_request_proxy,
- })
- end
- end
- end
- end
+ end
+ storage.creative_mode.personal_cheats.has_restored_cursor_stack[player.index] = nil
+ end
+
+ -- Build options.
+ -- Active.
+ if storage.creative_mode.build_options.active[player.index] == false then
+ entity.active = false
+ end
+ -- Destructible.
+ if storage.creative_mode.build_options.destructible[player.index] == false then
+ entity.destructible = false
+ end
+ -- Minable.
+ if storage.creative_mode.build_options.minable[player.index] == false then
+ entity.minable = false
+ end
+ -- Rotatable.
+ if storage.creative_mode.build_options.rotatable[player.index] == false then
+ entity.rotatable = false
+ end
+ -- Operable.
+ if storage.creative_mode.build_options.operable[player.index] == false then
+ entity.operable = false
+ end
+ -- Full health.
+ if storage.creative_mode.build_options.full_health[player.index] == false then
+ if entity.health ~= nil then
+ entity.health = 1
+ end
+ end
+ -- Team.
+ if storage.creative_mode.build_options.team[player.index] ~= nil then
+ local force = game.forces[storage.creative_mode.build_options.team[player.index]]
+ if force then
+ entity.force = force
+ end
+ end
+
+ -- Instant blueprint. (Has to be done at last.)
+ if storage.creative_mode.personal_cheats.instant_blueprint[player.index] then
+ if is_ghost or is_item_request_proxy then
+ -- Make sure the entity is not ignored by instant blueprint.
+ if not is_ghost or not instant_blueprint_blacklist[entity.ghost_name] then
+ -- We don't do the job if the instant-blueprint mod is installed and is activated.
+ if not mod_compatibler.is_instant_blueprint_installed_and_activated_for_player(player) then
+ -- Don't construct it right now.
+ table.insert(storage.creative_mode.pending_instant_blueprint, {
+ entity = entity,
+ player_index = player.index,
+ is_entity_ghost = is_entity_ghost,
+ try_revive_count = 0, -- We will only try to revive each ghost twice.
+ is_item_request_proxy = is_item_request_proxy,
+ })
+ end
+ end
+ end
+ end
end
----
@@ -2893,101 +2876,101 @@ local instant_deconstruction_blacklist = {}
-- Registers or deregisters the given entity name to or from the blacklist of instant deconstruction.
-- If it is deregistration, returns whether the process is success.
function cheats.register_or_deregister_entity_to_be_ignored_by_instant_deconstruction(entity_name, is_register)
- if is_register then
- -- Register.
- instant_deconstruction_blacklist[entity_name] = true
- else
- -- Deregister.
- if instant_deconstruction_blacklist[entity_name] then
- instant_deconstruction_blacklist[entity_name] = nil
- return true
- end
- return false
- end
+ if is_register then
+ -- Register.
+ instant_deconstruction_blacklist[entity_name] = true
+ else
+ -- Deregister.
+ if instant_deconstruction_blacklist[entity_name] then
+ instant_deconstruction_blacklist[entity_name] = nil
+ return true
+ end
+ return false
+ end
end
-- Returns whether the given entity name has been blacklisted by instant deconstruction.
function cheats.has_entity_ignored_by_instant_deconstruction(entity_name)
- return instant_deconstruction_blacklist[entity_name] ~= nil
+ return instant_deconstruction_blacklist[entity_name] ~= nil
end
-- Applies cheats when an entity is marked for deconstruction.
function cheats.on_marked_for_deconstruction(player_index, entity)
- -- Thanks Nexela for the inspiration of following snippet.
- -- Instant deconstruction, raise script_raised_destroy event.
- -- Make sure player_index is provided. Some mods use LuaEntity::order_deconstruction which dosn't not have player_index.
- if player_index ~= nil then
- if storage.creative_mode.personal_cheats.instant_deconstruction[player_index] then
- -- Make sure the entity is not ignored.
- if not instant_deconstruction_blacklist[entity.name] then
- -- We shouldn't raise event if the instant-blueprint mod is installed and is activated.
- if not mod_compatibler.is_instant_blueprint_installed_and_activated_for_player_index(player_index) then
- -- Don't destroy it right now. Filtered Deconstruction Planner may unmark the entity if it is filtered.
- table.insert(storage.creative_mode.pending_instant_deconstruction, {
- entity = entity,
- player_index = player_index,
- })
- end
- end
- end
- end
+ -- Thanks Nexela for the inspiration of following snippet.
+ -- Instant deconstruction, raise script_raised_destroy event.
+ -- Make sure player_index is provided. Some mods use LuaEntity::order_deconstruction which dosn't not have player_index.
+ if player_index ~= nil then
+ if storage.creative_mode.personal_cheats.instant_deconstruction[player_index] then
+ -- Make sure the entity is not ignored.
+ if not instant_deconstruction_blacklist[entity.name] then
+ -- We shouldn't raise event if the instant-blueprint mod is installed and is activated.
+ if not mod_compatibler.is_instant_blueprint_installed_and_activated_for_player_index(player_index) then
+ -- Don't destroy it right now. Filtered Deconstruction Planner may unmark the entity if it is filtered.
+ table.insert(storage.creative_mode.pending_instant_deconstruction, {
+ entity = entity,
+ player_index = player_index,
+ })
+ end
+ end
+ end
+ end
end
----
-- Applies cheats when a player mined an entity, before it is removed from map.
function cheats.on_preplayer_mined_item(player_index, entity)
- -- Repair mined item.
- if storage.creative_mode.personal_cheats.repair_mined_item[player_index] then
- if entity.health ~= nil then
- entity.health = entity.prototype.get_max_health()
- end
- end
+ -- Repair mined item.
+ if storage.creative_mode.personal_cheats.repair_mined_item[player_index] then
+ if entity.health ~= nil then
+ entity.health = entity.prototype.get_max_health()
+ end
+ end
end
-- Applies cheats to the respawned player's character if necessary.
function cheats.on_player_respawned(event)
- local player = game.players[event.player_index]
- apply_character_cheats_to_player(player)
+ local player = game.players[event.player_index]
+ apply_character_cheats_to_player(player)
end
-- Applies cheats to the player who either newly joined the game or joined back the game.
function cheats.on_player_joined_game(event)
- local player = game.players[event.player_index]
- if player then
- apply_character_cheats_to_player(player)
- end
+ local player = game.players[event.player_index]
+ if player then
+ apply_character_cheats_to_player(player)
+ end
end
-- Applies cheats to the force whose research has been started if necessary.
function cheats.on_research_started(event)
- local research = event.research
- local force = research.force
-
- -- Exclude our void technology from the instant research... Destroys the point I guess :D
- if
- storage.creative_mode.team_cheats.instant_research[force.name]
- and research.name ~= creative_mode_defines.names.technology.void_technology
- then
- force.research_progress = 1
- end
+ local research = event.research
+ local force = research.force
+
+ -- Exclude our void technology from the instant research... Destroys the point I guess :D
+ if
+ storage.creative_mode.team_cheats.instant_research[force.name]
+ and research.name ~= creative_mode_defines.names.technology.void_technology
+ then
+ force.research_progress = 1
+ end
end
-- Applies cheats to the newly generated chunk if necessary.
function cheats.on_chunk_generated(event)
- local area = event.area
- local surface = event.surface
- -- Surface cheat - don't generate enemy.
- if storage.creative_mode.surface_cheats.dont_generate_enemy[surface.index] then
- -- Remove the enemies in the on_tick event.
- -- Extend the area a bit.
- area.left_top.x = area.left_top.x - 32
- area.left_top.y = area.left_top.y - 32
- area.right_bottom.x = area.right_bottom.x + 32
- area.right_bottom.y = area.right_bottom.y + 32
- table.insert(storage.creative_mode.pending_areas_to_remove_enemies, {
- surface = surface,
- area = area,
- })
- end
+ local area = event.area
+ local surface = event.surface
+ -- Surface cheat - don't generate enemy.
+ if storage.creative_mode.surface_cheats.dont_generate_enemy[surface.index] then
+ -- Remove the enemies in the on_tick event.
+ -- Extend the area a bit.
+ area.left_top.x = area.left_top.x - 32
+ area.left_top.y = area.left_top.y - 32
+ area.right_bottom.x = area.right_bottom.x + 32
+ area.right_bottom.y = area.right_bottom.y + 32
+ table.insert(storage.creative_mode.pending_areas_to_remove_enemies, {
+ surface = surface,
+ area = area,
+ })
+ end
end
diff --git a/scripts/configurable-super-boiler.lua b/scripts/configurable-super-boiler.lua
index 323913b..b96293b 100644
--- a/scripts/configurable-super-boiler.lua
+++ b/scripts/configurable-super-boiler.lua
@@ -1,61 +1,61 @@
-- This file contains variables or functions that are related to the Super Boiler in this mod.
if not configurable_super_boiler then
- configurable_super_boiler = {}
+ configurable_super_boiler = {}
end
-- Processes the table of configurable_super_boiler_data in storage.
function configurable_super_boiler.tick()
- -- Loop through the table of super-boiler to give free energy and heat up fluid inside.
- for index, configurable_super_boiler_data in ipairs(storage.creative_mode.configurable_super_boiler_data) do
- local configurable_super_boiler = configurable_super_boiler_data.entity
- local temperature = configurable_super_boiler_data.temperature
- if configurable_super_boiler.valid then
- if not configurable_super_boiler.to_be_deconstructed(configurable_super_boiler.force) then
- configurable_super_boiler.energy = 1000000000000000
- fluid_providers_util.set_all_fluids_to_temperature(configurable_super_boiler, temperature)
- end
- else
- table.remove(storage.creative_mode.configurable_super_boiler_data, index)
- end
- end
+ -- Loop through the table of super-boiler to give free energy and heat up fluid inside.
+ for index, configurable_super_boiler_data in ipairs(storage.creative_mode.configurable_super_boiler_data) do
+ local configurable_super_boiler = configurable_super_boiler_data.entity
+ local temperature = configurable_super_boiler_data.temperature
+ if configurable_super_boiler.valid then
+ if not configurable_super_boiler.to_be_deconstructed(configurable_super_boiler.force) then
+ configurable_super_boiler.energy = 1000000000000000
+ fluid_providers_util.set_all_fluids_to_temperature(configurable_super_boiler, temperature)
+ end
+ else
+ table.remove(storage.creative_mode.configurable_super_boiler_data, index)
+ end
+ end
end
-- Updates the temperature of the boiler of given data to the given value.
-- This will not update the GUI.
function configurable_super_boiler.update_temperature(configurable_super_boiler_data, new_temperature)
- if configurable_super_boiler_data.temperature ~= new_temperature then
- local entity = configurable_super_boiler_data.entity
- entity.surface.create_entity {
- name = "flying-text",
- position = entity.position,
- color = {r = 1, g = 1, b = 1},
- text = new_temperature .. "°C"
- }
- configurable_super_boiler_data.temperature = new_temperature
- end
+ if configurable_super_boiler_data.temperature ~= new_temperature then
+ local entity = configurable_super_boiler_data.entity
+ entity.surface.create_entity({
+ name = "flying-text",
+ position = entity.position,
+ color = { r = 1, g = 1, b = 1 },
+ text = new_temperature .. "°C",
+ })
+ configurable_super_boiler_data.temperature = new_temperature
+ end
end
-- Returns the configurable super boiler data according to the given entity.
-- If no data is found, nil will be returned.
function configurable_super_boiler.get_data_for_entity(entity)
- for _, configurable_super_boiler_data in ipairs(storage.creative_mode.configurable_super_boiler_data) do
- if configurable_super_boiler_data.entity == entity then
- return configurable_super_boiler_data
- end
- end
- return nil
+ for _, configurable_super_boiler_data in ipairs(storage.creative_mode.configurable_super_boiler_data) do
+ if configurable_super_boiler_data.entity == entity then
+ return configurable_super_boiler_data
+ end
+ end
+ return nil
end
-- Pastes the temperature of the source super boiler to the destination super boiler.
function configurable_super_boiler.on_entity_copied_pasted(source, destination)
- local source_data = configurable_super_boiler.get_data_for_entity(source)
- if not source_data then
- return
- end
- local destination_data = configurable_super_boiler.get_data_for_entity(destination)
- if not destination_data then
- return
- end
+ local source_data = configurable_super_boiler.get_data_for_entity(source)
+ if not source_data then
+ return
+ end
+ local destination_data = configurable_super_boiler.get_data_for_entity(destination)
+ if not destination_data then
+ return
+ end
- configurable_super_boiler.update_temperature(destination_data, source_data.temperature)
+ configurable_super_boiler.update_temperature(destination_data, source_data.temperature)
end
diff --git a/scripts/creative-cargo-wagon.lua b/scripts/creative-cargo-wagon.lua
index 0ae75a5..cb78bc6 100644
--- a/scripts/creative-cargo-wagon.lua
+++ b/scripts/creative-cargo-wagon.lua
@@ -1,17 +1,16 @@
-- This file contains variables or functions that are related to the Creative Cargo Wagon in this mod.
if not creative_cargo_wagon then
- creative_cargo_wagon = {}
+ creative_cargo_wagon = {}
end
-- Processes the tables related to Creative Cargo Wagon in storage.
function creative_cargo_wagon.tick()
- -- Refill creative-cargo-wagons.
- storage.creative_mode.creative_cargo_wagon_next_update_group,
- storage.creative_mode.creative_cargo_wagon_next_update_group_subindex =
- creative_chest_util.refill_chests(
- storage.creative_mode.creative_cargo_wagon_data_groups,
- storage.creative_mode.creative_cargo_wagon_next_update_group,
- storage.creative_mode.creative_cargo_wagon_next_update_group_subindex,
- storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items
- )
+ -- Refill creative-cargo-wagons.
+ storage.creative_mode.creative_cargo_wagon_next_update_group, storage.creative_mode.creative_cargo_wagon_next_update_group_subindex =
+ creative_chest_util.refill_chests(
+ storage.creative_mode.creative_cargo_wagon_data_groups,
+ storage.creative_mode.creative_cargo_wagon_next_update_group,
+ storage.creative_mode.creative_cargo_wagon_next_update_group_subindex,
+ storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items
+ )
end
diff --git a/scripts/creative-chest-util.lua b/scripts/creative-chest-util.lua
index 20de03c..51bf621 100644
--- a/scripts/creative-chest-util.lua
+++ b/scripts/creative-chest-util.lua
@@ -1,45 +1,45 @@
-- This file contains variables or functions that are related to the Creative Chest family in this mod.
if not creative_chest_util then
- creative_chest_util = {}
+ creative_chest_util = {}
end
-- All possible inventory display mode for creative chests.
creative_chest_util.inventory_display_modes = {
- original_mode = 1,
- compact_mode = 2,
+ original_mode = 1,
+ compact_mode = 2,
}
-- Returns the total number of items to be contained according to whether the container should also contain hidden items.
local function get_total_item_count(contain_hidden_items)
- local count = #storage.non_hidden_item_list
- + #creative_mode_defines.values.creative_provider_chest_additional_content_names
- + #storage.hidden_creative_enemy_item_list
- if contain_hidden_items then
- count = count + #storage.non_creative_hidden_item_list
- end
- return count
+ local count = #storage.non_hidden_item_list
+ + #creative_mode_defines.values.creative_provider_chest_additional_content_names
+ + #storage.hidden_creative_enemy_item_list
+ if contain_hidden_items then
+ count = count + #storage.non_creative_hidden_item_list
+ end
+ return count
end
-- Returns the item prototype at given index according to whether the container should contain hidden items.
function creative_chest_util.get_item_at(item_index, contain_hidden_items)
- local current_item_count = #storage.non_hidden_item_list
- if item_index <= current_item_count then
- return storage.non_hidden_item_list[item_index]
- end
- item_index = item_index - current_item_count
- if contain_hidden_items then
- current_item_count = #storage.non_creative_hidden_item_list
- if item_index <= current_item_count then
- return storage.non_creative_hidden_item_list[item_index]
- end
- item_index = item_index - current_item_count
- end
- local creative_item_count = #creative_mode_defines.values.creative_provider_chest_additional_content_names
- if item_index <= creative_item_count then
- return prototypes.item[creative_mode_defines.values.creative_provider_chest_additional_content_names[item_index]]
- end
- item_index = item_index - creative_item_count
- return storage.hidden_creative_enemy_item_list[item_index]
+ local current_item_count = #storage.non_hidden_item_list
+ if item_index <= current_item_count then
+ return storage.non_hidden_item_list[item_index]
+ end
+ item_index = item_index - current_item_count
+ if contain_hidden_items then
+ current_item_count = #storage.non_creative_hidden_item_list
+ if item_index <= current_item_count then
+ return storage.non_creative_hidden_item_list[item_index]
+ end
+ item_index = item_index - current_item_count
+ end
+ local creative_item_count = #creative_mode_defines.values.creative_provider_chest_additional_content_names
+ if item_index <= creative_item_count then
+ return prototypes.item[creative_mode_defines.values.creative_provider_chest_additional_content_names[item_index]]
+ end
+ item_index = item_index - creative_item_count
+ return storage.hidden_creative_enemy_item_list[item_index]
end
-------------------------------------------------------------------------
@@ -48,416 +48,410 @@ end
-- Returns the usable inventory size (except the extra slot for voiding items) for creative chest and creative provider chest.
function creative_chest_util.get_creative_provider_chest_usable_inventory_size()
- return prototypes.entity[creative_mode_defines.names.entities.creative_chest].get_inventory_size(1) - 1
+ return prototypes.entity[creative_mode_defines.names.entities.creative_chest].get_inventory_size(1) - 1
end
-- Returns the total number of items to be container by each creative chest or creative provider chest.
function creative_chest_util.get_creative_provider_chest_total_item_count()
- return get_total_item_count(
- settings.global[creative_mode_defines.names.settings.creative_chest_contains_hidden_items].value
- )
+ return get_total_item_count(
+ settings.global[creative_mode_defines.names.settings.creative_chest_contains_hidden_items].value
+ )
end
--------
-- Returns the usable inventory size (except the extra slot for voiding items) for creative cargo wagon.
function creative_chest_util.get_creative_cargo_wagon_usable_inventory_size()
- return prototypes.entity[creative_mode_defines.names.entities.creative_cargo_wagon].get_inventory_size(1) - 1
+ return prototypes.entity[creative_mode_defines.names.entities.creative_cargo_wagon].get_inventory_size(1) - 1
end
-- Returns the total number of items to be container by each creative cargo wagon.
function creative_chest_util.get_creative_cargo_wagon_total_item_count()
- return get_total_item_count(
- settings.global[creative_mode_defines.names.settings.creative_cargo_wagon_contains_hidden_items].value
- )
+ return get_total_item_count(
+ settings.global[creative_mode_defines.names.settings.creative_cargo_wagon_contains_hidden_items].value
+ )
end
-------------------------------------------------------------------------
-- Updates the data used by the Creative Chest family according to the in-game item list in storage.
function creative_chest_util.update_item_lists_data()
- -- Creative chest and creative provider chest:
- -- There may be more items than the usable inventory size of each creative chest. We need to find out how many chests are needed for one cycle first.
- -- It is also the total number of item groups.
- local usable_inventory_size = creative_chest_util.get_creative_provider_chest_usable_inventory_size()
- storage.creative_mode.creative_provider_chest_num_in_cycle =
- math.ceil(creative_chest_util.get_creative_provider_chest_total_item_count() / usable_inventory_size)
- -- Chests in the same cycle are divided into groups. Let's say we have 251 items, so the first group will contain the first 250 items, and the last group will contain the last item.
- storage.creative_mode.creative_provider_chest_next_place_group = 1
- storage.creative_mode.creative_chest_next_place_group = 1
- -- For performance reason, we don't update all groups in the same tick.
- storage.creative_mode.creative_provider_chest_next_update_group = 1
- storage.creative_mode.creative_chest_next_update_group = 1
- -- And we don't update all chests in the same group.
- storage.creative_mode.creative_provider_chest_next_update_group_subindex = 1
- storage.creative_mode.creative_chest_next_update_group_subindex = 1
+ -- Creative chest and creative provider chest:
+ -- There may be more items than the usable inventory size of each creative chest. We need to find out how many chests are needed for one cycle first.
+ -- It is also the total number of item groups.
+ local usable_inventory_size = creative_chest_util.get_creative_provider_chest_usable_inventory_size()
+ storage.creative_mode.creative_provider_chest_num_in_cycle =
+ math.ceil(creative_chest_util.get_creative_provider_chest_total_item_count() / usable_inventory_size)
+ -- Chests in the same cycle are divided into groups. Let's say we have 251 items, so the first group will contain the first 250 items, and the last group will contain the last item.
+ storage.creative_mode.creative_provider_chest_next_place_group = 1
+ storage.creative_mode.creative_chest_next_place_group = 1
+ -- For performance reason, we don't update all groups in the same tick.
+ storage.creative_mode.creative_provider_chest_next_update_group = 1
+ storage.creative_mode.creative_chest_next_update_group = 1
+ -- And we don't update all chests in the same group.
+ storage.creative_mode.creative_provider_chest_next_update_group_subindex = 1
+ storage.creative_mode.creative_chest_next_update_group_subindex = 1
- -- Store the settings that can affect the number of chests per item cycle when we have calculated the above maths, so that we know we will need to calculate again if change is detected.
- storage.creative_mode.last_creative_provider_chest_size = usable_inventory_size
- storage.creative_mode.last_creative_provider_chest_contain_hidden_items =
- settings.global[creative_mode_defines.names.settings.creative_chest_contains_hidden_items].value
+ -- Store the settings that can affect the number of chests per item cycle when we have calculated the above maths, so that we know we will need to calculate again if change is detected.
+ storage.creative_mode.last_creative_provider_chest_size = usable_inventory_size
+ storage.creative_mode.last_creative_provider_chest_contain_hidden_items =
+ settings.global[creative_mode_defines.names.settings.creative_chest_contains_hidden_items].value
- -- Creative cargo wagon:
- -- Do the same as above.
- usable_inventory_size = creative_chest_util.get_creative_cargo_wagon_usable_inventory_size()
- storage.creative_mode.creative_cargo_wagon_num_in_cycle =
- math.ceil(creative_chest_util.get_creative_cargo_wagon_total_item_count() / usable_inventory_size)
- storage.creative_mode.creative_cargo_wagon_next_place_group = 1
- storage.creative_mode.creative_cargo_wagon_next_update_group = 1
- storage.creative_mode.creative_cargo_wagon_next_update_group_subindex = 1
- storage.creative_mode.last_creative_cargo_wagon_size = usable_inventory_size
- storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items =
- settings.global[creative_mode_defines.names.settings.creative_cargo_wagon_contains_hidden_items].value
+ -- Creative cargo wagon:
+ -- Do the same as above.
+ usable_inventory_size = creative_chest_util.get_creative_cargo_wagon_usable_inventory_size()
+ storage.creative_mode.creative_cargo_wagon_num_in_cycle =
+ math.ceil(creative_chest_util.get_creative_cargo_wagon_total_item_count() / usable_inventory_size)
+ storage.creative_mode.creative_cargo_wagon_next_place_group = 1
+ storage.creative_mode.creative_cargo_wagon_next_update_group = 1
+ storage.creative_mode.creative_cargo_wagon_next_update_group_subindex = 1
+ storage.creative_mode.last_creative_cargo_wagon_size = usable_inventory_size
+ storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items =
+ settings.global[creative_mode_defines.names.settings.creative_cargo_wagon_contains_hidden_items].value
end
-- Validates the data used by the Creative Chest family. If needed, updates the data.
-- Returns whether the data is updated.
local function validate_or_update_data()
- if
- storage.creative_mode.last_creative_provider_chest_size == nil
- or storage.creative_mode.last_creative_provider_chest_size ~= creative_chest_util.get_creative_provider_chest_usable_inventory_size()
- or storage.creative_mode.last_creative_provider_chest_contain_hidden_items == nil
- or storage.creative_mode.last_creative_provider_chest_contain_hidden_items ~= settings.global[creative_mode_defines.names.settings.creative_chest_contains_hidden_items].value
- or storage.creative_mode.last_creative_cargo_wagon_size == nil
- or storage.creative_mode.last_creative_cargo_wagon_size ~= creative_chest_util.get_creative_cargo_wagon_usable_inventory_size()
- or storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items == nil
- or storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items
- ~= settings.global[creative_mode_defines.names.settings.creative_cargo_wagon_contains_hidden_items].value
- then
- creative_chest_util.update_item_lists_data()
- return true
- end
- return false
+ if
+ storage.creative_mode.last_creative_provider_chest_size == nil
+ or storage.creative_mode.last_creative_provider_chest_size ~= creative_chest_util.get_creative_provider_chest_usable_inventory_size()
+ or storage.creative_mode.last_creative_provider_chest_contain_hidden_items == nil
+ or storage.creative_mode.last_creative_provider_chest_contain_hidden_items ~= settings.global[creative_mode_defines.names.settings.creative_chest_contains_hidden_items].value
+ or storage.creative_mode.last_creative_cargo_wagon_size == nil
+ or storage.creative_mode.last_creative_cargo_wagon_size ~= creative_chest_util.get_creative_cargo_wagon_usable_inventory_size()
+ or storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items == nil
+ or storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items
+ ~= settings.global[creative_mode_defines.names.settings.creative_cargo_wagon_contains_hidden_items].value
+ then
+ creative_chest_util.update_item_lists_data()
+ return true
+ end
+ return false
end
-- Whether data validation has been done.
local has_validated_data = false
-- Processes the tables related to the Creative Chest family in storage.
function creative_chest_util.tick()
- -- Check whether the user has changed the settings that can affect the number of chests per item cycle. If so, update the item list and regroup the items.
- if not has_validated_data and game.tick >= 1 then
- if validate_or_update_data() then
- game.print({ "message.creative-mode_creative-chest-item-group-updated" })
- end
- has_validated_data = true
- end
+ -- Check whether the user has changed the settings that can affect the number of chests per item cycle. If so, update the item list and regroup the items.
+ if not has_validated_data and game.tick >= 1 then
+ if validate_or_update_data() then
+ game.print({ "message.creative-mode_creative-chest-item-group-updated" })
+ end
+ has_validated_data = true
+ end
end
-------------------------------------------------------------------------
-- Returns the start and end item indexes among the item lists for the group of given group number.
function creative_chest_util.get_start_end_item_index_for_group(
- group_number,
- usable_inventory_size,
- contain_hidden_items
+ group_number,
+ usable_inventory_size,
+ contain_hidden_items
)
- local start_item_index = (group_number - 1) * usable_inventory_size + 1
- local end_item_index = math.min(group_number * usable_inventory_size, get_total_item_count(contain_hidden_items))
- return start_item_index, end_item_index
+ local start_item_index = (group_number - 1) * usable_inventory_size + 1
+ local end_item_index = math.min(group_number * usable_inventory_size, get_total_item_count(contain_hidden_items))
+ return start_item_index, end_item_index
end
-- Returns the inventory of the given chest.
function creative_chest_util.get_inventory(chest)
- local inventory = chest.get_output_inventory()
- if not inventory then
- inventory = chest.get_inventory(defines.inventory.cargo_wagon)
- end
- return inventory
+ local inventory = chest.get_output_inventory()
+ if not inventory then
+ inventory = chest.get_inventory(defines.inventory.cargo_wagon)
+ end
+ return inventory
end
-- Returns the inventory of the chest of the given chest data.
function creative_chest_util.get_inventory_from_data(chest_data)
- local chest = chest_data.entity
- local inventory = chest.get_output_inventory()
- if not inventory then
- if chest_data.is_cargo_wagon then
- inventory = chest.get_inventory(defines.inventory.cargo_wagon)
- end
- end
- return inventory
+ local chest = chest_data.entity
+ local inventory = chest.get_output_inventory()
+ if not inventory then
+ if chest_data.is_cargo_wagon then
+ inventory = chest.get_inventory(defines.inventory.cargo_wagon)
+ end
+ end
+ return inventory
end
-- Refills the inventories of some Creative Chests according to the given chest groups, group index to be updated, and the subindex of chest to be updated.
-- Returns the updated group index and subindex.
function creative_chest_util.refill_chests(
- chest_data_groups,
- next_update_group,
- next_update_group_subindex,
- contain_hidden_items
+ chest_data_groups,
+ next_update_group,
+ next_update_group_subindex,
+ contain_hidden_items
)
- -- Looping through the huge item list can be a heavy task, therefore we divided the task by groups and chests.
- -- Only the group of the current group number has to be updated.
- if chest_data_groups[next_update_group] then
- local start_item_index = nil
- local end_item_index = nil
- -- Not even that, we also update only one chest in each tick.
- local data = chest_data_groups[next_update_group][next_update_group_subindex]
- if data then
- local chest = data.entity
- if chest.valid then
- if not chest.to_be_deconstructed(chest.force) then
- local inventory = creative_chest_util.get_inventory_from_data(data)
- local slot = 1
- local displayed_slot = 1
- local display_mode = data.inventory_display_mode
- local inventory_size = #inventory
- local filtered_slots = data.filtered_slots
- local filtered_slots_count = #filtered_slots
- local next_filtered_slot_to_check = 1
- if filtered_slots_count <= 0 then
- next_filtered_slot_to_check = 0
- end
- if start_item_index == nil or end_item_index == nil then
- start_item_index, end_item_index = creative_chest_util.get_start_end_item_index_for_group(
- next_update_group,
- inventory_size - 1,
- contain_hidden_items
- )
- end
- -- Refill its inventory with items.
- for i = start_item_index, end_item_index, 1 do
- -- Fill the slot only if it is not filtered out.
- if next_filtered_slot_to_check <= 0 or filtered_slots[next_filtered_slot_to_check] ~= slot then
- local item = creative_chest_util.get_item_at(i, contain_hidden_items)
- inventory[displayed_slot].set_stack({ name = item.name, count = item.stack_size })
- displayed_slot = displayed_slot + 1
- else
- -- Clear the slot. Only Original Display Mode will create holes in between.
- if display_mode == creative_chest_util.inventory_display_modes.original_mode then
- inventory[displayed_slot].clear()
- displayed_slot = displayed_slot + 1
- end
- -- Check for the next index of filtered slot if possible.
- if filtered_slots_count >= next_filtered_slot_to_check + 1 then
- next_filtered_slot_to_check = next_filtered_slot_to_check + 1
- else
- next_filtered_slot_to_check = 0
- end
- end
- -- Next slot.
- slot = slot + 1
- -- Though it is unlikely to happen... (caused by mod version change?) Break the loop if slot exceeds.
- if slot > inventory_size then
- break
- end
- end
- -- Clear the remaining slots.
- for i = displayed_slot, inventory_size, 1 do
- inventory[i].clear()
- end
- end
- else
- table.remove(chest_data_groups[next_update_group], next_update_group_subindex)
- end
- else
- table.remove(chest_data_groups[next_update_group], next_update_group_subindex)
- end
- end
- -- Prepare the subindex for the next chest in the same group.
- if chest_data_groups[next_update_group] and next_update_group_subindex < #chest_data_groups[next_update_group] then
- next_update_group_subindex = next_update_group_subindex + 1
- else
- -- Next group.
- next_update_group_subindex = 1
- if next_update_group < #chest_data_groups then
- next_update_group = next_update_group + 1
- else
- next_update_group = 1
- end
- end
+ -- Looping through the huge item list can be a heavy task, therefore we divided the task by groups and chests.
+ -- Only the group of the current group number has to be updated.
+ if chest_data_groups[next_update_group] then
+ local start_item_index = nil
+ local end_item_index = nil
+ -- Not even that, we also update only one chest in each tick.
+ local data = chest_data_groups[next_update_group][next_update_group_subindex]
+ if data then
+ local chest = data.entity
+ if chest.valid then
+ if not chest.to_be_deconstructed(chest.force) then
+ local inventory = creative_chest_util.get_inventory_from_data(data)
+ local slot = 1
+ local displayed_slot = 1
+ local display_mode = data.inventory_display_mode
+ local inventory_size = #inventory
+ local filtered_slots = data.filtered_slots
+ local filtered_slots_count = #filtered_slots
+ local next_filtered_slot_to_check = 1
+ if filtered_slots_count <= 0 then
+ next_filtered_slot_to_check = 0
+ end
+ if start_item_index == nil or end_item_index == nil then
+ start_item_index, end_item_index = creative_chest_util.get_start_end_item_index_for_group(
+ next_update_group,
+ inventory_size - 1,
+ contain_hidden_items
+ )
+ end
+ -- Refill its inventory with items.
+ for i = start_item_index, end_item_index, 1 do
+ -- Fill the slot only if it is not filtered out.
+ if next_filtered_slot_to_check <= 0 or filtered_slots[next_filtered_slot_to_check] ~= slot then
+ local item = creative_chest_util.get_item_at(i, contain_hidden_items)
+ inventory[displayed_slot].set_stack({ name = item.name, count = item.stack_size })
+ displayed_slot = displayed_slot + 1
+ else
+ -- Clear the slot. Only Original Display Mode will create holes in between.
+ if display_mode == creative_chest_util.inventory_display_modes.original_mode then
+ inventory[displayed_slot].clear()
+ displayed_slot = displayed_slot + 1
+ end
+ -- Check for the next index of filtered slot if possible.
+ if filtered_slots_count >= next_filtered_slot_to_check + 1 then
+ next_filtered_slot_to_check = next_filtered_slot_to_check + 1
+ else
+ next_filtered_slot_to_check = 0
+ end
+ end
+ -- Next slot.
+ slot = slot + 1
+ -- Though it is unlikely to happen... (caused by mod version change?) Break the loop if slot exceeds.
+ if slot > inventory_size then
+ break
+ end
+ end
+ -- Clear the remaining slots.
+ for i = displayed_slot, inventory_size, 1 do
+ inventory[i].clear()
+ end
+ end
+ else
+ table.remove(chest_data_groups[next_update_group], next_update_group_subindex)
+ end
+ else
+ table.remove(chest_data_groups[next_update_group], next_update_group_subindex)
+ end
+ end
+ -- Prepare the subindex for the next chest in the same group.
+ if chest_data_groups[next_update_group] and next_update_group_subindex < #chest_data_groups[next_update_group] then
+ next_update_group_subindex = next_update_group_subindex + 1
+ else
+ -- Next group.
+ next_update_group_subindex = 1
+ if next_update_group < #chest_data_groups then
+ next_update_group = next_update_group + 1
+ else
+ next_update_group = 1
+ end
+ end
- return next_update_group, next_update_group_subindex
+ return next_update_group, next_update_group_subindex
end
-- Returns true if the entity is one of the new style of creative chest, which are handled differently.
function creative_chest_util.is_new_creative(entity)
- if
- entity.name == creative_mode_defines.names.entities.new_creative_chest
- or entity.name == creative_mode_defines.names.entities.new_creative_provider_chest
- then
- return true
- end
- return false
+ if
+ entity.name == creative_mode_defines.names.entities.new_creative_chest
+ or entity.name == creative_mode_defines.names.entities.new_creative_provider_chest
+ then
+ return true
+ end
+ return false
end
-- Sets the infinity chest filters to the appropriate items based on the chests group.
function creative_chest_util.set_chest_filter(data)
- if data then
- local chest = data.entity
- if chest.valid then
- if not chest.to_be_deconstructed(chest.force) then
- local inventory = creative_chest_util.get_inventory_from_data(data)
- local slot = 1
- local displayed_slot = 1
- local display_mode = data.inventory_display_mode
- local inventory_size = #inventory
- local filtered_slots = data.filtered_slots
- local filtered_slots_count = #filtered_slots
- local next_filtered_slot_to_check = 1
- local contain_hidden_items = storage.creative_mode.last_creative_provider_chest_contain_hidden_items
- if filtered_slots_count <= 0 then
- next_filtered_slot_to_check = 0
- end
- local start_item_index, end_item_index = creative_chest_util.get_start_end_item_index_for_group(
- data.group,
- inventory_size - 1,
- contain_hidden_items
- )
- -- Clear the current filters so we can set them
- chest.infinity_container_filters = {}
- for i = start_item_index, end_item_index, 1 do
- -- Fill the slot only if it is not filtered out.
- if next_filtered_slot_to_check <= 0 or filtered_slots[next_filtered_slot_to_check] ~= slot then
- local item = creative_chest_util.get_item_at(i, contain_hidden_items)
- if not item.spoil_result then
- -- Skip spoilable items by default
- -- Set the infinity container's filter slot to be the given item
- chest.set_infinity_container_filter(
- displayed_slot,
- {
- name = item.name,
- quality = chest.quality.name,
- count = item.stack_size,
- mode = "exactly",
- }
- )
- displayed_slot = displayed_slot + 1
- end
- else
- -- Skip the filter slot if using original mode - leaves a hole in the filters to make it obvious an item was skipped.
- if display_mode == creative_chest_util.inventory_display_modes.original_mode then
- displayed_slot = displayed_slot + 1
- end
- -- Check for the next index of filtered slot if possible.
- if filtered_slots_count >= next_filtered_slot_to_check + 1 then
- next_filtered_slot_to_check = next_filtered_slot_to_check + 1
- else
- next_filtered_slot_to_check = 0
- end
- end
- -- Next slot.
- slot = slot + 1
- -- Though it is unlikely to happen... (caused by mod version change?) Break the loop if slot exceeds.
- if slot > inventory_size then
- break
- end
- end
- end
- else
- -- This shouldn't happen anymore as this only fires when the chest is placed or the GUI is changed, neither of which should be able to happen on a chest that isn't valid.
- end
- end
+ if data then
+ local chest = data.entity
+ if chest.valid then
+ if not chest.to_be_deconstructed(chest.force) then
+ local inventory = creative_chest_util.get_inventory_from_data(data)
+ local slot = 1
+ local displayed_slot = 1
+ local display_mode = data.inventory_display_mode
+ local inventory_size = #inventory
+ local filtered_slots = data.filtered_slots
+ local filtered_slots_count = #filtered_slots
+ local next_filtered_slot_to_check = 1
+ local contain_hidden_items = storage.creative_mode.last_creative_provider_chest_contain_hidden_items
+ if filtered_slots_count <= 0 then
+ next_filtered_slot_to_check = 0
+ end
+ local start_item_index, end_item_index =
+ creative_chest_util.get_start_end_item_index_for_group(data.group, inventory_size - 1, contain_hidden_items)
+ -- Clear the current filters so we can set them
+ chest.infinity_container_filters = {}
+ for i = start_item_index, end_item_index, 1 do
+ -- Fill the slot only if it is not filtered out.
+ if next_filtered_slot_to_check <= 0 or filtered_slots[next_filtered_slot_to_check] ~= slot then
+ local item = creative_chest_util.get_item_at(i, contain_hidden_items)
+ if not item.spoil_result then
+ -- Skip spoilable items by default
+ -- Set the infinity container's filter slot to be the given item
+ chest.set_infinity_container_filter(displayed_slot, {
+ name = item.name,
+ quality = chest.quality.name,
+ count = item.stack_size,
+ mode = "exactly",
+ })
+ displayed_slot = displayed_slot + 1
+ end
+ else
+ -- Skip the filter slot if using original mode - leaves a hole in the filters to make it obvious an item was skipped.
+ if display_mode == creative_chest_util.inventory_display_modes.original_mode then
+ displayed_slot = displayed_slot + 1
+ end
+ -- Check for the next index of filtered slot if possible.
+ if filtered_slots_count >= next_filtered_slot_to_check + 1 then
+ next_filtered_slot_to_check = next_filtered_slot_to_check + 1
+ else
+ next_filtered_slot_to_check = 0
+ end
+ end
+ -- Next slot.
+ slot = slot + 1
+ -- Though it is unlikely to happen... (caused by mod version change?) Break the loop if slot exceeds.
+ if slot > inventory_size then
+ break
+ end
+ end
+ end
+ else
+ -- This shouldn't happen anymore as this only fires when the chest is placed or the GUI is changed, neither of which should be able to happen on a chest that isn't valid.
+ end
+ end
end
-- Returns the responsible creative chest data groups for the given entity.
-- Also returns the number of chests for each item cycle (i.e. max group number) and whether the entity should contain hidden items.
function creative_chest_util.get_creative_chest_data_groups(entity)
- if entity.name == creative_mode_defines.names.entities.creative_chest then
- return storage.creative_mode.creative_chest_data_groups,
- storage.creative_mode.creative_provider_chest_num_in_cycle,
- storage.creative_mode.last_creative_provider_chest_contain_hidden_items
- elseif entity.name == creative_mode_defines.names.entities.creative_provider_chest then
- return storage.creative_mode.creative_provider_chest_data_groups,
- storage.creative_mode.creative_provider_chest_num_in_cycle,
- storage.creative_mode.last_creative_provider_chest_contain_hidden_items
- elseif entity.name == creative_mode_defines.names.entities.new_creative_chest then
- return storage.creative_mode.new_creative_chests,
- storage.creative_mode.creative_provider_chest_num_in_cycle,
- storage.creative_mode.last_creative_provider_chest_contain_hidden_items
- elseif entity.name == creative_mode_defines.names.entities.new_creative_provider_chest then
- return storage.creative_mode.new_creative_provider_chests,
- storage.creative_mode.creative_provider_chest_num_in_cycle,
- storage.creative_mode.last_creative_provider_chest_contain_hidden_items
- elseif entity.name == creative_mode_defines.names.entities.creative_cargo_wagon then
- return storage.creative_mode.creative_cargo_wagon_data_groups,
- storage.creative_mode.creative_cargo_wagon_num_in_cycle,
- storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items
- end
- return nil, 0, false
+ if entity.name == creative_mode_defines.names.entities.creative_chest then
+ return storage.creative_mode.creative_chest_data_groups,
+ storage.creative_mode.creative_provider_chest_num_in_cycle,
+ storage.creative_mode.last_creative_provider_chest_contain_hidden_items
+ elseif entity.name == creative_mode_defines.names.entities.creative_provider_chest then
+ return storage.creative_mode.creative_provider_chest_data_groups,
+ storage.creative_mode.creative_provider_chest_num_in_cycle,
+ storage.creative_mode.last_creative_provider_chest_contain_hidden_items
+ elseif entity.name == creative_mode_defines.names.entities.new_creative_chest then
+ return storage.creative_mode.new_creative_chests,
+ storage.creative_mode.creative_provider_chest_num_in_cycle,
+ storage.creative_mode.last_creative_provider_chest_contain_hidden_items
+ elseif entity.name == creative_mode_defines.names.entities.new_creative_provider_chest then
+ return storage.creative_mode.new_creative_provider_chests,
+ storage.creative_mode.creative_provider_chest_num_in_cycle,
+ storage.creative_mode.last_creative_provider_chest_contain_hidden_items
+ elseif entity.name == creative_mode_defines.names.entities.creative_cargo_wagon then
+ return storage.creative_mode.creative_cargo_wagon_data_groups,
+ storage.creative_mode.creative_cargo_wagon_num_in_cycle,
+ storage.creative_mode.last_creative_cargo_wagon_contain_hidden_items
+ end
+ return nil, 0, false
end
-- Returns the data and group number of the given Creative Chest. Also returns the index of the chest in that group as the second parameter.
-- If the given entity is not found in any group (maybe caused by error), 0, 0 will be returned.
function creative_chest_util.get_creative_chest_data_group_number(entity, chest_data_groups)
- -- The new creative chests and new creative provider chests are stored differently.
- if creative_chest_util.is_new_creative(entity) then
- for chest_index_in_group, chest_data_in_group in ipairs(chest_data_groups) do
- if chest_data_in_group.entity == entity then
- return chest_data_in_group, chest_data_in_group.group, chest_index_in_group
- end
- end
- return nil, 0, 0
- end
- if chest_data_groups then
- for group_index = 1, #chest_data_groups, 1 do
- local group = chest_data_groups[group_index]
- if group then
- for chest_index_in_group, chest_data_in_group in ipairs(chest_data_groups[group_index]) do
- if chest_data_in_group.entity == entity then
- return chest_data_in_group, group_index, chest_index_in_group
- end
- end
- end
- end
- end
- return nil, 0, 0
+ -- The new creative chests and new creative provider chests are stored differently.
+ if creative_chest_util.is_new_creative(entity) then
+ for chest_index_in_group, chest_data_in_group in ipairs(chest_data_groups) do
+ if chest_data_in_group.entity == entity then
+ return chest_data_in_group, chest_data_in_group.group, chest_index_in_group
+ end
+ end
+ return nil, 0, 0
+ end
+ if chest_data_groups then
+ for group_index = 1, #chest_data_groups, 1 do
+ local group = chest_data_groups[group_index]
+ if group then
+ for chest_index_in_group, chest_data_in_group in ipairs(chest_data_groups[group_index]) do
+ if chest_data_in_group.entity == entity then
+ return chest_data_in_group, group_index, chest_index_in_group
+ end
+ end
+ end
+ end
+ end
+ return nil, 0, 0
end
-- Moves the destination chest to the group with same group number of the source chest when copy-paste is done on Creative Chest family.
-- Also copies the filtered slots and inventory display mode from the source chest to the destination chest.
function creative_chest_util.on_entity_copied_pasted(source_chest, destination_chest)
- local source_groups = creative_chest_util.get_creative_chest_data_groups(source_chest)
- local destination_groups = creative_chest_util.get_creative_chest_data_groups(destination_chest)
+ local source_groups = creative_chest_util.get_creative_chest_data_groups(source_chest)
+ local destination_groups = creative_chest_util.get_creative_chest_data_groups(destination_chest)
- local source_chest_data, source_group_number =
- creative_chest_util.get_creative_chest_data_group_number(source_chest, source_groups)
- if source_chest_data == nil or source_group_number == 0 then
- return
- end
- local destination_chest_data, destination_group_number, destination_index_in_group =
- creative_chest_util.get_creative_chest_data_group_number(destination_chest, destination_groups)
- if destination_chest_data == nil or destination_group_number == 0 then
- return
- end
- -- Copy the table of filtered slots from the source chest to the destination chest.
- destination_chest_data.filtered_slots = table.deepcopy(source_chest_data.filtered_slots)
- -- Copy inventory display mode.
- destination_chest_data.inventory_display_mode = source_chest_data.inventory_display_mode
- -- Move the destination chest from its original group to the group with the same group number of the source chest.
- if source_group_number ~= destination_group_number then
- table.remove(destination_groups[destination_group_number], destination_index_in_group)
- -- But it should still be inside the original groups table. (One table for non-logistic, one for logistic)
- if not destination_groups[source_group_number] then
- destination_groups[source_group_number] = {}
- end
- table.insert(destination_groups[source_group_number], destination_chest_data)
- end
+ local source_chest_data, source_group_number =
+ creative_chest_util.get_creative_chest_data_group_number(source_chest, source_groups)
+ if source_chest_data == nil or source_group_number == 0 then
+ return
+ end
+ local destination_chest_data, destination_group_number, destination_index_in_group =
+ creative_chest_util.get_creative_chest_data_group_number(destination_chest, destination_groups)
+ if destination_chest_data == nil or destination_group_number == 0 then
+ return
+ end
+ -- Copy the table of filtered slots from the source chest to the destination chest.
+ destination_chest_data.filtered_slots = table.deepcopy(source_chest_data.filtered_slots)
+ -- Copy inventory display mode.
+ destination_chest_data.inventory_display_mode = source_chest_data.inventory_display_mode
+ -- Move the destination chest from its original group to the group with the same group number of the source chest.
+ if source_group_number ~= destination_group_number then
+ table.remove(destination_groups[destination_group_number], destination_index_in_group)
+ -- But it should still be inside the original groups table. (One table for non-logistic, one for logistic)
+ if not destination_groups[source_group_number] then
+ destination_groups[source_group_number] = {}
+ end
+ table.insert(destination_groups[source_group_number], destination_chest_data)
+ end
end
-- Changes the group number of the given creative chest data from the old one to new one.
-- Returns whether it is successfully changed.
function creative_chest_util.change_creative_chest_group_number(
- chest_data,
- chest_groups,
- old_group_number,
- old_index_in_group,
- new_group_number,
- entity
+ chest_data,
+ chest_groups,
+ old_group_number,
+ old_index_in_group,
+ new_group_number,
+ entity
)
- if old_group_number ~= new_group_number then
- -- Once again new providers are handled differently
- if creative_chest_util.is_new_creative(entity) then
- chest_data.group = new_group_number
- creative_chest_util.set_chest_filter(chest_data)
- return true
- else
- table.remove(chest_groups[old_group_number], old_index_in_group)
- if not chest_groups[new_group_number] then
- chest_groups[new_group_number] = {}
- end
- table.insert(chest_groups[new_group_number], chest_data)
- return true
- end
- end
- return false
+ if old_group_number ~= new_group_number then
+ -- Once again new providers are handled differently
+ if creative_chest_util.is_new_creative(entity) then
+ chest_data.group = new_group_number
+ creative_chest_util.set_chest_filter(chest_data)
+ return true
+ else
+ table.remove(chest_groups[old_group_number], old_index_in_group)
+ if not chest_groups[new_group_number] then
+ chest_groups[new_group_number] = {}
+ end
+ table.insert(chest_groups[new_group_number], chest_data)
+ return true
+ end
+ end
+ return false
end
diff --git a/scripts/creative-chest.lua b/scripts/creative-chest.lua
index afc970c..66770b1 100644
--- a/scripts/creative-chest.lua
+++ b/scripts/creative-chest.lua
@@ -1,16 +1,16 @@
-- This file contains variables or functions that are related to the Creative Chest in this mod.
if not creative_chest then
- creative_chest = {}
+ creative_chest = {}
end
-- Processes the tables related to Creative Chests in storage.
function creative_chest.tick()
- -- Refill creative-chests.
- storage.creative_mode.creative_chest_next_update_group, storage.creative_mode.creative_chest_next_update_group_subindex =
- creative_chest_util.refill_chests(
- storage.creative_mode.creative_chest_data_groups,
- storage.creative_mode.creative_chest_next_update_group,
- storage.creative_mode.creative_chest_next_update_group_subindex,
- storage.creative_mode.last_creative_provider_chest_contain_hidden_items
- )
+ -- Refill creative-chests.
+ storage.creative_mode.creative_chest_next_update_group, storage.creative_mode.creative_chest_next_update_group_subindex =
+ creative_chest_util.refill_chests(
+ storage.creative_mode.creative_chest_data_groups,
+ storage.creative_mode.creative_chest_next_update_group,
+ storage.creative_mode.creative_chest_next_update_group_subindex,
+ storage.creative_mode.last_creative_provider_chest_contain_hidden_items
+ )
end
diff --git a/scripts/creative-lab.lua b/scripts/creative-lab.lua
index eae7526..2a7cf37 100644
--- a/scripts/creative-lab.lua
+++ b/scripts/creative-lab.lua
@@ -1,61 +1,60 @@
--- This file contains variables or functions that are related to the Creative Lab in this mod.
-if not creative_lab then
- creative_lab = {}
-end
-
--- Processes the table of creative_lab in storage.
-function creative_lab.tick()
- local next_update_index = storage.creative_mode.creative_lab_next_update_index
- local creative_labs = storage.creative_mode.creative_lab
- local lab_count = #creative_labs
-
- if lab_count <= 0 then
- -- Nothing to do.
- return
- end
-
- -- Remove invalid labs from the array.
- local labs_updated = false
- for i = lab_count, 1, -1 do
- local lab = creative_labs[i]
- if lab.valid then
-
- else
- table.remove(creative_labs, i)
- labs_updated = true
- lab_count = lab_count - 1
- end
- end
-
- -- Do we still have valid labs?
- if lab_count > 0 then
- -- Make sure the update index is in range.
- if next_update_index > lab_count then
- next_update_index = lab_count
- end
- -- Refill science packs. Because there may be many science packs, we only refill 10 labs at most in every tick.
- for i = 1, 10, 1 do
- local creative_lab = creative_labs[next_update_index]
- -- Update the lab.
- if not creative_lab.to_be_deconstructed(creative_lab.force) then
- for _, item in ipairs(storage.tool_item_list) do
- creative_lab.insert {name = item.name, count = prototypes.item[item.name].stack_size}
- end
- end
- -- Prepare for the next lab.
- next_update_index = next_update_index + 1
- if next_update_index > lab_count then
- -- No more next lab. Return to the first one.
- next_update_index = 1
- break
- end
- end
- else
- next_update_index = 1
- end
-
- if labs_updated then
- storage.creative_mode.creative_lab = creative_labs
- end
- storage.creative_mode.creative_lab_next_update_index = next_update_index
-end
+-- This file contains variables or functions that are related to the Creative Lab in this mod.
+if not creative_lab then
+ creative_lab = {}
+end
+
+-- Processes the table of creative_lab in storage.
+function creative_lab.tick()
+ local next_update_index = storage.creative_mode.creative_lab_next_update_index
+ local creative_labs = storage.creative_mode.creative_lab
+ local lab_count = #creative_labs
+
+ if lab_count <= 0 then
+ -- Nothing to do.
+ return
+ end
+
+ -- Remove invalid labs from the array.
+ local labs_updated = false
+ for i = lab_count, 1, -1 do
+ local lab = creative_labs[i]
+ if lab.valid then
+ else
+ table.remove(creative_labs, i)
+ labs_updated = true
+ lab_count = lab_count - 1
+ end
+ end
+
+ -- Do we still have valid labs?
+ if lab_count > 0 then
+ -- Make sure the update index is in range.
+ if next_update_index > lab_count then
+ next_update_index = lab_count
+ end
+ -- Refill science packs. Because there may be many science packs, we only refill 10 labs at most in every tick.
+ for i = 1, 10, 1 do
+ local creative_lab = creative_labs[next_update_index]
+ -- Update the lab.
+ if not creative_lab.to_be_deconstructed(creative_lab.force) then
+ for _, item in ipairs(storage.tool_item_list) do
+ creative_lab.insert({ name = item.name, count = prototypes.item[item.name].stack_size })
+ end
+ end
+ -- Prepare for the next lab.
+ next_update_index = next_update_index + 1
+ if next_update_index > lab_count then
+ -- No more next lab. Return to the first one.
+ next_update_index = 1
+ break
+ end
+ end
+ else
+ next_update_index = 1
+ end
+
+ if labs_updated then
+ storage.creative_mode.creative_lab = creative_labs
+ end
+ storage.creative_mode.creative_lab_next_update_index = next_update_index
+end
diff --git a/scripts/creative-provider-chest.lua b/scripts/creative-provider-chest.lua
index 777c3d0..2766b36 100644
--- a/scripts/creative-provider-chest.lua
+++ b/scripts/creative-provider-chest.lua
@@ -1,17 +1,16 @@
-- This file contains variables or functions that are related to the Creative Provider Chest in this mod.
if not creative_provider_chest then
- creative_provider_chest = {}
+ creative_provider_chest = {}
end
-- Processes the tables related to Creative Provider Chests in storage.
function creative_provider_chest.tick()
- -- Refill creative-provider-chests.
- storage.creative_mode.creative_provider_chest_next_update_group,
- storage.creative_mode.creative_provider_chest_next_update_group_subindex =
- creative_chest_util.refill_chests(
- storage.creative_mode.creative_provider_chest_data_groups,
- storage.creative_mode.creative_provider_chest_next_update_group,
- storage.creative_mode.creative_provider_chest_next_update_group_subindex,
- storage.creative_mode.last_creative_provider_chest_contain_hidden_items
- )
+ -- Refill creative-provider-chests.
+ storage.creative_mode.creative_provider_chest_next_update_group, storage.creative_mode.creative_provider_chest_next_update_group_subindex =
+ creative_chest_util.refill_chests(
+ storage.creative_mode.creative_provider_chest_data_groups,
+ storage.creative_mode.creative_provider_chest_next_update_group,
+ storage.creative_mode.creative_provider_chest_next_update_group_subindex,
+ storage.creative_mode.last_creative_provider_chest_contain_hidden_items
+ )
end
diff --git a/scripts/duplicating-cargo-wagon.lua b/scripts/duplicating-cargo-wagon.lua
index 3b358fe..e5d6bde 100644
--- a/scripts/duplicating-cargo-wagon.lua
+++ b/scripts/duplicating-cargo-wagon.lua
@@ -1,13 +1,12 @@
-- This file contains variables or functions that are related to the Duplicating Cargo Wagon in this mod.
if not duplicating_cargo_wagon then
- duplicating_cargo_wagon = {}
+ duplicating_cargo_wagon = {}
end
-- Processes the tables related to Duplicating Provider Chest in storage.
function duplicating_cargo_wagon.tick()
- storage.creative_mode.duplicating_cargo_wagon_next_update_index =
- duplicating_chest_util.duplicate_contents(
- storage.creative_mode.duplicating_cargo_wagon_data,
- storage.creative_mode.duplicating_cargo_wagon_next_update_index
- )
+ storage.creative_mode.duplicating_cargo_wagon_next_update_index = duplicating_chest_util.duplicate_contents(
+ storage.creative_mode.duplicating_cargo_wagon_data,
+ storage.creative_mode.duplicating_cargo_wagon_next_update_index
+ )
end
diff --git a/scripts/duplicating-chest-util.lua b/scripts/duplicating-chest-util.lua
index 2da1444..df0483a 100644
--- a/scripts/duplicating-chest-util.lua
+++ b/scripts/duplicating-chest-util.lua
@@ -1,139 +1,139 @@
-- This file contains variables or functions that are related to the Duplicating Chest family in this mod.
if not duplicating_chest_util then
- duplicating_chest_util = {}
+ duplicating_chest_util = {}
end
-- Returns the inventory of the given chest.
function duplicating_chest_util.get_inventory(chest)
- local inventory = chest.get_output_inventory()
- if not inventory then
- inventory = chest.get_inventory(defines.inventory.cargo_wagon)
- end
- return inventory
+ local inventory = chest.get_output_inventory()
+ if not inventory then
+ inventory = chest.get_inventory(defines.inventory.cargo_wagon)
+ end
+ return inventory
end
-- Fills the inventory of the given chest with the given item prototype.
local function fill_chest_with_item(chest, item_prototype)
- local inventory = duplicating_chest_util.get_inventory(chest)
- for i = 1, #inventory, 1 do
- inventory[i].set_stack(item_prototype.name)
- end
+ local inventory = duplicating_chest_util.get_inventory(chest)
+ for i = 1, #inventory, 1 do
+ inventory[i].set_stack(item_prototype.name)
+ end
end
-- Refills some chests among the given array of chests according to the given index of the next chest to update.
-- Returns the index of the next chest to update in the next tick.
function duplicating_chest_util.duplicate_contents(chest_datas, next_chest_to_update)
- if #chest_datas <= 0 then
- return 1
- end
+ if #chest_datas <= 0 then
+ return 1
+ end
- local chest_index = next_chest_to_update
- for i = 1, 10, 1 do
- local chest_data = chest_datas[chest_index]
- local chest = chest_data.entity
- local lock_item = chest_data.lock_item
- local locked_item_name = chest_data.locked_item_name
+ local chest_index = next_chest_to_update
+ for i = 1, 10, 1 do
+ local chest_data = chest_datas[chest_index]
+ local chest = chest_data.entity
+ local lock_item = chest_data.lock_item
+ local locked_item_name = chest_data.locked_item_name
- if chest.valid then
- if not chest.to_be_deconstructed(chest.force) then
- -- Get the item to be duplicated.
- local item_to_be_duplicated = nil
- if lock_item and locked_item_name then
- -- this is funny - locking the item, resets the spoilage to 100%
- item_to_be_duplicated = prototypes.item[locked_item_name]
- end
- if item_to_be_duplicated then
- -- The locked item is valid. Fill the chest with such item.
- fill_chest_with_item(chest, item_to_be_duplicated)
- else
- local inventory = duplicating_chest_util.get_inventory(chest)
- local item = inventory[1]
- -- item.valid is true as long as the entity is valid. So it cannot be used for checking whether there is actually an item stack.
- -- We have to use valid_for_read instead.
- if item ~= nil and item.valid_for_read then
- -- Fill the whole chest immediately.
- -- we can either insert the real item (including spoilage progress and quality) or fill the inventory completely
- -- inventory.insert {name = item.name, count = item.prototype.stack_size * #inventory, quality = item.quality}
- inventory.insert(item)
+ if chest.valid then
+ if not chest.to_be_deconstructed(chest.force) then
+ -- Get the item to be duplicated.
+ local item_to_be_duplicated = nil
+ if lock_item and locked_item_name then
+ -- this is funny - locking the item, resets the spoilage to 100%
+ item_to_be_duplicated = prototypes.item[locked_item_name]
+ end
+ if item_to_be_duplicated then
+ -- The locked item is valid. Fill the chest with such item.
+ fill_chest_with_item(chest, item_to_be_duplicated)
+ else
+ local inventory = duplicating_chest_util.get_inventory(chest)
+ local item = inventory[1]
+ -- item.valid is true as long as the entity is valid. So it cannot be used for checking whether there is actually an item stack.
+ -- We have to use valid_for_read instead.
+ if item ~= nil and item.valid_for_read then
+ -- Fill the whole chest immediately.
+ -- we can either insert the real item (including spoilage progress and quality) or fill the inventory completely
+ -- inventory.insert {name = item.name, count = item.prototype.stack_size * #inventory, quality = item.quality}
+ inventory.insert(item)
- -- Lock the item if it should be locked.
- if lock_item then
- chest_data.locked_item_name = item.name
- end
- end
- end
- end
+ -- Lock the item if it should be locked.
+ if lock_item then
+ chest_data.locked_item_name = item.name
+ end
+ end
+ end
+ end
- -- Prepare for the next chest.
- chest_index = chest_index + 1
- -- No more next chest. Return to the first chest.
- if chest_index > #chest_datas then
- return 1
- end
- else
- table.remove(chest_datas, chest_index)
- if chest_index > #chest_datas then
- return 1
- end
- end
- end
- -- Return the index of the next chest to update.
- return chest_index
+ -- Prepare for the next chest.
+ chest_index = chest_index + 1
+ -- No more next chest. Return to the first chest.
+ if chest_index > #chest_datas then
+ return 1
+ end
+ else
+ table.remove(chest_datas, chest_index)
+ if chest_index > #chest_datas then
+ return 1
+ end
+ end
+ end
+ -- Return the index of the next chest to update.
+ return chest_index
end
--------------------------------------------------------------
-- Look up table for mapping the entity name to duplicating chest data list.
local entity_name_to_data_list_look_up = {
- [creative_mode_defines.names.entities.duplicating_chest] = function()
- return storage.creative_mode.duplicating_chest_data
- end,
- [creative_mode_defines.names.entities.duplicating_provider_chest] = function()
- return storage.creative_mode.duplicating_provider_chest_data
- end,
- [creative_mode_defines.names.entities.duplicating_cargo_wagon] = function()
- return storage.creative_mode.duplicating_cargo_wagon_data
- end
+ [creative_mode_defines.names.entities.duplicating_chest] = function()
+ return storage.creative_mode.duplicating_chest_data
+ end,
+ [creative_mode_defines.names.entities.duplicating_provider_chest] = function()
+ return storage.creative_mode.duplicating_provider_chest_data
+ end,
+ [creative_mode_defines.names.entities.duplicating_cargo_wagon] = function()
+ return storage.creative_mode.duplicating_cargo_wagon_data
+ end,
}
-- Returns the duplicating chest data according to the given entity.
-- If no data is found, nil will be returned.
function duplicating_chest_util.get_data_for_entity(entity)
- local look_up_function = entity_name_to_data_list_look_up[entity.name]
- if look_up_function then
- local data_list = look_up_function()
- if data_list then
- for _, data in ipairs(data_list) do
- if data.entity == entity then
- return data
- end
- end
- end
- end
- return nil
+ local look_up_function = entity_name_to_data_list_look_up[entity.name]
+ if look_up_function then
+ local data_list = look_up_function()
+ if data_list then
+ for _, data in ipairs(data_list) do
+ if data.entity == entity then
+ return data
+ end
+ end
+ end
+ end
+ return nil
end
--------------------------------------------------------------
-- Copies the contents from the source chest to the destination chest when copy-paste is done on the Duplicating Chest family.
function duplicating_chest_util.on_entity_copied_pasted(source_chest, destination_chest)
- local source_inventory = duplicating_chest_util.get_inventory(source_chest)
- local source_data = duplicating_chest_util.get_data_for_entity(source_chest)
- local destination_inventory = duplicating_chest_util.get_inventory(destination_chest)
- local destination_data = duplicating_chest_util.get_data_for_entity(destination_chest)
+ local source_inventory = duplicating_chest_util.get_inventory(source_chest)
+ local source_data = duplicating_chest_util.get_data_for_entity(source_chest)
+ local destination_inventory = duplicating_chest_util.get_inventory(destination_chest)
+ local destination_data = duplicating_chest_util.get_data_for_entity(destination_chest)
- destination_inventory.clear()
+ destination_inventory.clear()
- local source_item = source_inventory[1]
- if source_item ~= nil and source_item.valid_for_read then
- destination_inventory.insert {
- name = source_item.name,
- count = source_item.prototype.stack_size * #destination_inventory
- }
- end
+ local source_item = source_inventory[1]
+ if source_item ~= nil and source_item.valid_for_read then
+ destination_inventory.insert({
+ name = source_item.name,
+ count = source_item.prototype.stack_size * #destination_inventory,
+ })
+ end
- if source_data and destination_data then
- destination_data.lock_item = source_data.lock_item
- destination_data.locked_item_name = source_data.locked_item_name
- end
+ if source_data and destination_data then
+ destination_data.lock_item = source_data.lock_item
+ destination_data.locked_item_name = source_data.locked_item_name
+ end
end
diff --git a/scripts/duplicating-chest.lua b/scripts/duplicating-chest.lua
index 51b3319..db6436a 100644
--- a/scripts/duplicating-chest.lua
+++ b/scripts/duplicating-chest.lua
@@ -1,13 +1,12 @@
-- This file contains variables or functions that are related to the Duplicating Chest in this mod.
if not duplicating_chest then
- duplicating_chest = {}
+ duplicating_chest = {}
end
-- Processes the tables related to Duplicating Chest in storage.
function duplicating_chest.tick()
- storage.creative_mode.duplicating_chest_next_update_index =
- duplicating_chest_util.duplicate_contents(
- storage.creative_mode.duplicating_chest_data,
- storage.creative_mode.duplicating_chest_next_update_index
- )
+ storage.creative_mode.duplicating_chest_next_update_index = duplicating_chest_util.duplicate_contents(
+ storage.creative_mode.duplicating_chest_data,
+ storage.creative_mode.duplicating_chest_next_update_index
+ )
end
diff --git a/scripts/duplicating-provider-chest.lua b/scripts/duplicating-provider-chest.lua
index dea808b..c6553c6 100644
--- a/scripts/duplicating-provider-chest.lua
+++ b/scripts/duplicating-provider-chest.lua
@@ -1,13 +1,12 @@
-- This file contains variables or functions that are related to the Duplicating Provider Chest in this mod.
if not duplicating_provider_chest then
- duplicating_provider_chest = {}
+ duplicating_provider_chest = {}
end
-- Processes the tables related to Duplicating Provider Chest in storage.
function duplicating_provider_chest.tick()
- storage.creative_mode.duplicating_provider_chest_next_update_index =
- duplicating_chest_util.duplicate_contents(
- storage.creative_mode.duplicating_provider_chest_data,
- storage.creative_mode.duplicating_provider_chest_next_update_index
- )
+ storage.creative_mode.duplicating_provider_chest_next_update_index = duplicating_chest_util.duplicate_contents(
+ storage.creative_mode.duplicating_provider_chest_data,
+ storage.creative_mode.duplicating_provider_chest_next_update_index
+ )
end
diff --git a/scripts/duplicator.lua b/scripts/duplicator.lua
index b4556e0..f3fe519 100644
--- a/scripts/duplicator.lua
+++ b/scripts/duplicator.lua
@@ -1,82 +1,82 @@
-- This file contains variables or functions that are related to the Duplicator in this mod.
if not duplicator then
- duplicator = {}
+ duplicator = {}
end
-- The position shift for duplicating items or fluids for each direction.
local duplicator_shift = {
- [defines.direction.north] = {x = 0, y = 1},
- [defines.direction.east] = {x = -1, y = 0},
- [defines.direction.south] = {x = 0, y = -1},
- [defines.direction.west] = {x = 1, y = 0}
+ [defines.direction.north] = { x = 0, y = 1 },
+ [defines.direction.east] = { x = -1, y = 0 },
+ [defines.direction.south] = { x = 0, y = -1 },
+ [defines.direction.west] = { x = 1, y = 0 },
}
-- Processes the table of duplicator_data in storage.
function duplicator.tick()
- -- Loop through the table of duplicator data to duplicate items.
- for index, duplicator_data in ipairs(storage.creative_mode.duplicator_data) do
- local duplicator = duplicator_data.entity
- -- Work only if the entity is valid.
- if duplicator.valid then
- -- Check if it is active and also not marked for deconstruction.
- if duplicator.active and not duplicator.to_be_deconstructed(duplicator.force) then
- -- Give the item-source free energy.
- duplicator.energy = 100000 -- It seems not working?
- -- Check if it is enabled according to its circuit network state and logistic network state.
- if util.is_inserter_enabled(duplicator) then
- -- Get the duplicator's surface, position and shift for item/fluid duplication.
- local surf = duplicator.surface
- local pos = duplicator.position
- local dir = duplicator.direction
- local shift = duplicator_shift[dir]
- local filter = nil
- if duplicator.use_filters then
- filter = duplicator.get_filter(1)
- end
- if filter then
- filter = filter.name
- end
- -- Duplicate the items in front of it.
- item_providers_util.output_or_remove_item(
- surf,
- pos,
- shift.x,
- shift.y,
- util.oppositedirection(dir),
- filter,
- output_or_remove_item_operation_mode.duplicate_mode,
- nil,
- duplicator_data
- )
- end
- end
- else
- -- Remove invalid entity.
- table.remove(storage.creative_mode.duplicator_data, index)
- end
- end
+ -- Loop through the table of duplicator data to duplicate items.
+ for index, duplicator_data in ipairs(storage.creative_mode.duplicator_data) do
+ local duplicator = duplicator_data.entity
+ -- Work only if the entity is valid.
+ if duplicator.valid then
+ -- Check if it is active and also not marked for deconstruction.
+ if duplicator.active and not duplicator.to_be_deconstructed(duplicator.force) then
+ -- Give the item-source free energy.
+ duplicator.energy = 100000 -- It seems not working?
+ -- Check if it is enabled according to its circuit network state and logistic network state.
+ if util.is_inserter_enabled(duplicator) then
+ -- Get the duplicator's surface, position and shift for item/fluid duplication.
+ local surf = duplicator.surface
+ local pos = duplicator.position
+ local dir = duplicator.direction
+ local shift = duplicator_shift[dir]
+ local filter = nil
+ if duplicator.use_filters then
+ filter = duplicator.get_filter(1)
+ end
+ if filter then
+ filter = filter.name
+ end
+ -- Duplicate the items in front of it.
+ item_providers_util.output_or_remove_item(
+ surf,
+ pos,
+ shift.x,
+ shift.y,
+ util.oppositedirection(dir),
+ filter,
+ output_or_remove_item_operation_mode.duplicate_mode,
+ nil,
+ duplicator_data
+ )
+ end
+ end
+ else
+ -- Remove invalid entity.
+ table.remove(storage.creative_mode.duplicator_data, index)
+ end
+ end
end
-- Returns the entity data for the given matter duplicator entity.
function duplicator.get_data_for_entity(entity)
- for _, data in ipairs(storage.creative_mode.duplicator_data) do
- if data.entity == entity then
- return data
- end
- end
- return nil
+ for _, data in ipairs(storage.creative_mode.duplicator_data) do
+ if data.entity == entity then
+ return data
+ end
+ end
+ return nil
end
-- Copies the additional configurations from the source entity to the destination entity.
function duplicator.on_entity_copied_pasted(source, destination)
- local source_data = duplicator.get_data_for_entity(source)
- local destination_data = duplicator.get_data_for_entity(destination)
- if not source_data then
- return
- end
- if not destination_data then
- return
- end
- destination_data.can_duplicate_in_vehicle = source_data.can_duplicate_in_vehicle
- destination_data.can_duplicate_in_player = source_data.can_duplicate_in_player
+ local source_data = duplicator.get_data_for_entity(source)
+ local destination_data = duplicator.get_data_for_entity(destination)
+ if not source_data then
+ return
+ end
+ if not destination_data then
+ return
+ end
+ destination_data.can_duplicate_in_vehicle = source_data.can_duplicate_in_vehicle
+ destination_data.can_duplicate_in_player = source_data.can_duplicate_in_player
end
diff --git a/scripts/equipments.lua b/scripts/equipments.lua
index db61852..7916421 100644
--- a/scripts/equipments.lua
+++ b/scripts/equipments.lua
@@ -1,15 +1,15 @@
-- This file contains variables or functions that are related to the equipments in this mod.
if not equipments then
- equipments = {}
+ equipments = {}
end
-- Refills the energy of the registered equipments in the global table.
function equipments.tick()
- for index, equipment in ipairs(storage.energy_refill_equipments) do
- if equipment.valid then
- equipment.energy = 10000000000000000000000000
- else
- table.remove(storage.energy_refill_equipments, index)
- end
- end
+ for index, equipment in ipairs(storage.energy_refill_equipments) do
+ if equipment.valid then
+ equipment.energy = 10000000000000000000000000
+ else
+ table.remove(storage.energy_refill_equipments, index)
+ end
+ end
end
diff --git a/scripts/events.lua b/scripts/events.lua
index f2b596c..c921a96 100644
--- a/scripts/events.lua
+++ b/scripts/events.lua
@@ -1,29 +1,25 @@
-- This file manages event-related variables or functions that are specific for this mod.
-- But the GUI related events are in gui.lua instead.
if not events then
- events = {}
+ events = {}
end
-- Calls the remote functions.
local function call_remote_functions()
- -- Exclude the alien attractors from keep last item.
- remote.call("creative-mode", "exclude_from_keep_last_item", creative_mode_defines.names.items.alien_attractor_small)
- remote.call(
- "creative-mode",
- "exclude_from_keep_last_item",
- creative_mode_defines.names.items.alien_attractor_medium
- )
- remote.call("creative-mode", "exclude_from_keep_last_item", creative_mode_defines.names.items.alien_attractor_large)
- -- Also run the examples, after our interface is ready for that.
- -- Example: register the remote function register_by_remote_function_example_1 to the modding UI.
- remote.call(
- "creative-mode",
- "register_remote_function_to_modding_ui",
- "creative-mode", -- Interface name
- "register_by_remote_function_example_1" -- Function name
- )
-
- --[[
+ -- Exclude the alien attractors from keep last item.
+ remote.call("creative-mode", "exclude_from_keep_last_item", creative_mode_defines.names.items.alien_attractor_small)
+ remote.call("creative-mode", "exclude_from_keep_last_item", creative_mode_defines.names.items.alien_attractor_medium)
+ remote.call("creative-mode", "exclude_from_keep_last_item", creative_mode_defines.names.items.alien_attractor_large)
+ -- Also run the examples, after our interface is ready for that.
+ -- Example: register the remote function register_by_remote_function_example_1 to the modding UI.
+ remote.call(
+ "creative-mode",
+ "register_remote_function_to_modding_ui",
+ "creative-mode", -- Interface name
+ "register_by_remote_function_example_1" -- Function name
+ )
+
+ --[[
-- Demo for subscribing and using the custom events.
script.on_event(remote.call("creative-mode", "on_enabled"), function(event)
game.print("Test: Creative Mode enabled!")
@@ -33,17 +29,17 @@ local function call_remote_functions()
end)
--]]
- --[[
+ --[[
-- Demo for excluding an item from the keep-last-item personal cheat.
remote.call("creative-mode", "exclude_from_keep_last_item", "assembling-machine-2")
--]]
- --[[
+ --[[
-- Demo for excluding an entity from the instant-blueprint personal cheat.
remote.call("creative-mode", "exclude_from_instant_blueprint", "assembling-machine-3")
--]]
- --[[
+ --[[
-- Demo for excluding an entity from the instant-deconstruction personal cheat.
remote.call("creative-mode", "exclude_from_instant_deconstruction", "oil-refinery")
--]]
@@ -51,1230 +47,1225 @@ end
-- Callback of the on_init event, which is invoked when a new game is started.
function events.on_init()
- -- Initializes meta-table.
- global_util.initialize_or_update_global()
+ -- Initializes meta-table.
+ global_util.initialize_or_update_global()
- -- Generate event IDs if they are not generated.
- remote_interface.get_or_load_on_enabled_event_id()
- remote_interface.get_or_load_on_disabled_event_id()
+ -- Generate event IDs if they are not generated.
+ remote_interface.get_or_load_on_enabled_event_id()
+ remote_interface.get_or_load_on_disabled_event_id()
- -- Call remote functions.
- call_remote_functions()
+ -- Call remote functions.
+ call_remote_functions()
- -- Initializes the item lists.
- global_util.initialize_item_lists_if_not_exist()
+ -- Initializes the item lists.
+ global_util.initialize_item_lists_if_not_exist()
end
-- Callback of the on_load event, which is invoked when an existing game is loaded.
-- The global table should not be touched here.
function events.on_load(event)
- -- Generate event IDs if they are not generated.
- remote_interface.get_or_load_on_enabled_event_id()
- remote_interface.get_or_load_on_disabled_event_id()
+ -- Generate event IDs if they are not generated.
+ remote_interface.get_or_load_on_enabled_event_id()
+ remote_interface.get_or_load_on_disabled_event_id()
- -- Call remote functions.
- call_remote_functions()
+ -- Call remote functions.
+ call_remote_functions()
end
-- Callback of the on_configuration_changed event, which is invoked when the game version or any active mods changed.
function events.on_configuration_changed(data)
- -- Game version changed?
- local is_game_changed = data.old_version ~= data.new_version
- -- Any mod changed?
- local is_any_mod_changed = data.mod_changes ~= nil
- -- Is this mod changed?
- local is_our_mod_changed = false
- if is_any_mod_changed then
- is_our_mod_changed = data.mod_changes[creative_mode_defines.mod_id] ~= nil
- end
- -- Is this mod just installed for an existing game?
- local is_our_mod_new = false
- if is_our_mod_changed then
- is_our_mod_new = data.mod_changes[creative_mode_defines.mod_id].old_version == nil
- and data.mod_changes[creative_mode_defines.mod_id].new_version ~= nil
- end
-
- -- If our mod has changed (whether version is different or the mod is new for existing game), new meta-tables may be needed. Initializes them if needed.
- if is_our_mod_changed then
- global_util.initialize_or_update_global()
-
- if not is_our_mod_new then
- local our_mod_old_version = data.mod_changes[creative_mode_defines.mod_id].old_version
- local our_mod_new_version = data.mod_changes[creative_mode_defines.mod_id].new_version
- global_util.update_global_as_our_mod_updated(our_mod_old_version, our_mod_new_version)
-
- if our_mod_old_version < "0.2.0" and our_mod_new_version >= "0.2.0" then
- -- Big changes in the GUI system in v0.2.0, so we have to force close the opened GUI.
- for _, player in pairs(game.players) do
- gui_entity.create_or_destroy_gui_of_entity(player, nil, false)
- end
- -- Destroy more cheats popup.
- gui.destroy_more_cheats_popup()
- -- Create main menu button if Creative Mode is enabled.
- gui_menu.create_or_destroy_main_menu_open_button_for_all_players()
- end
- if our_mod_old_version <= "1.8.0" and our_mod_new_version >= "1.8.1" then
- -- We can clear out some of these tables. It MAY be a lot of info if someone's built a lot.
- storage.creative_mode.heat_source = nil
- storage.creative_mode.heat_void = nil
- storage.creative_mode.void_requester_chest = nil
- storage.creative_mode.void_chest = nil
- storage.creative_mode.void_storage_chest = nil
- storage.creative_mode.super_roboport = nil
- storage.creative_mode.fluid_source = nil
- storage.creative_mode.super_radar = nil
- storage.creative_mode.super_beacon = nil
- storage.creative_mode.energy_void = nil
- storage.creative_mode.passive_energy_void = nil
- storage.creative_mode.passive_energy_source = nil
- storage.creative_mode.energy_source = nil
- -- Ensure the tables for the new creative/providers chests exist.
- if not storage.creative_mode.new_creative_chest then
- storage.creative_mode.new_creative_chests = {}
- end
- if not storage.creative_mode.new_creative_provider_chest then
- storage.creative_mode.new_creative_provider_chest = {}
- end
- for _, surface in pairs(game.surfaces) do
- -- Find all our entities so we can get them updated to the new methods.
- -- We could just iterate our tables before clearing them, but this guarantees we get everything, and some data won't be good due to the prototype changes making the old entity references invalid.
- for _, entity in
- ipairs(surface.find_entities_filtered({
- name = {
- creative_mode_defines.names.entities.void_chest,
- creative_mode_defines.names.entities.void_storage_chest,
- creative_mode_defines.names.entities.void_requester_chest,
- creative_mode_defines.names.entities.heat_source,
- creative_mode_defines.names.entities.heat_void,
- creative_mode_defines.names.entities.creative_chest,
- creative_mode_defines.names.entities.creative_provider_chest,
- },
- }))
- do
- if entity.name == creative_mode_defines.names.entities.creative_chest then
- -- We need to replace all the old creative chests with the new one
- if entity.valid then
- -- First we need to find the data for this chest
- local old_data, group_number = creative_chest_util.get_creative_chest_data_group_number(
- entity,
- storage.creative_mode.creative_chest_data_groups
- )
- -- Make the new chest over the old one
- local new_entity = entity.surface.create_entity({
- name = creative_mode_defines.names.entities.new_creative_chest,
- position = entity.position,
- force = entity.force,
- fast_replace = true,
- spill = false,
- raise_built = false,
- create_build_effect_smoke = false,
- })
- if old_data == nil or group_number == 0 then --No data found, or an invalid group number.
- --Make a new chest and register it as if it were just built.
- global_util.register_entity(new_entity)
- else -- We have good data, so copy it to our new chest
- new_entity.remove_unfiltered_items = true -- We don't want anything except our filters in these
- local chest_data = {
- entity = new_entity, -- The new-creative-chest entity.
- group = group_number, -- Same group as the old chest.
- filtered_slots = old_data.filtered_slots, -- The slot indexes that are filtered out in this chest.
- inventory_display_mode = old_data.inventory_display_mode, -- The inventory display mode. Not very useful in the new chests.
- is_cargo_wagon = false, -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
- }
- table.insert(storage.creative_mode.new_creative_chests, chest_data)
- -- Now that all our data is set, set the filters.
- creative_chest_util.set_chest_filter(chest_data)
- end
- entity.destroy() -- Destroy the old chest - it's useless.
- end
- elseif entity.name == creative_mode_defines.names.entities.creative_provider_chest then
- -- We need to replace all the old creative provider chests with the new one
- if entity.valid then
- -- First we need to find the data for this chest
- local old_data, group_number = creative_chest_util.get_creative_chest_data_group_number(
- entity,
- storage.creative_mode.creative_provider_chest_data_groups
- )
- -- Make the new chest over the old one
- local new_entity = entity.surface.create_entity({
- name = creative_mode_defines.names.entities.new_creative_provider_chest,
- position = entity.position,
- force = entity.force,
- fast_replace = true,
- spill = false,
- raise_built = false,
- create_build_effect_smoke = false,
- })
- if old_data == nil or group_number == 0 then --No data found, or an invalid group number.
- --Make a new chest and register it as if it were just built.
- global_util.register_entity(new_entity)
- else -- We have good data, so copy it to our new chest
- new_entity.remove_unfiltered_items = true -- We don't want anything except our filters in these
- local chest_data = {
- entity = new_entity, -- The new-creative-chest entity.
- group = group_number, -- Same group as the old chest.
- filtered_slots = old_data.filtered_slots, -- The slot indexes that are filtered out in this chest.
- inventory_display_mode = old_data.inventory_display_mode, -- The inventory display mode. Not very useful in the new chests.
- is_cargo_wagon = false, -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
- }
- table.insert(storage.creative_mode.new_creative_provider_chests, chest_data)
- -- Now that all our data is set, set the filters.
- creative_chest_util.set_chest_filter(chest_data)
- end
- entity.destroy() -- Destroy the old chest - it's useless.
- end
- else -- For the rest of the types we can just run their placement function again to set what we need
- --void_chest, void_storage_chest, void_requester_chest, heat_source, heat_void.
- --log("Fixing entity: " .. entity.name)
- global_util.register_entity(entity)
- end
- end
- end
- -- Remove the tables for creative chests/providers, as we don't need them anymore.
- storage.creative_mode.creative_chest_data_groups = nil
- storage.creative_mode.creative_provider_chest_data_groups = nil
- end
- end
-
- -- Make sure the main menu and modifer popup is closed whenever our mod version has changed.
- for _, player in pairs(game.connected_players) do
- gui_menu.destroy_main_menu_for_player(player)
- gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
- end
- end
-
- -- For game version changed or any mod changed, item list needs to be updated.
- if not global_util.item_lists_exist() or is_game_changed or is_any_mod_changed then
- global_util.renew_item_lists()
- end
-
- -- If creative mode is already enabled, we will also need to make sure all of our recipes are enabled in case there are new recipes for new items.
- if is_game_changed or is_any_mod_changed then
- local team_cheat_creative_tools_recipes = cheats.team_cheats_data.cheats.creative_tools_recipes
- for _, force in pairs(game.forces) do
- if team_cheat_creative_tools_recipes.get_value_function(force) then
- team_cheat_creative_tools_recipes.apply_to_target_function(force, true, nil)
- end
- end
- end
+ -- Game version changed?
+ local is_game_changed = data.old_version ~= data.new_version
+ -- Any mod changed?
+ local is_any_mod_changed = data.mod_changes ~= nil
+ -- Is this mod changed?
+ local is_our_mod_changed = false
+ if is_any_mod_changed then
+ is_our_mod_changed = data.mod_changes[creative_mode_defines.mod_id] ~= nil
+ end
+ -- Is this mod just installed for an existing game?
+ local is_our_mod_new = false
+ if is_our_mod_changed then
+ is_our_mod_new = data.mod_changes[creative_mode_defines.mod_id].old_version == nil
+ and data.mod_changes[creative_mode_defines.mod_id].new_version ~= nil
+ end
+
+ -- If our mod has changed (whether version is different or the mod is new for existing game), new meta-tables may be needed. Initializes them if needed.
+ if is_our_mod_changed then
+ global_util.initialize_or_update_global()
+
+ if not is_our_mod_new then
+ local our_mod_old_version = data.mod_changes[creative_mode_defines.mod_id].old_version
+ local our_mod_new_version = data.mod_changes[creative_mode_defines.mod_id].new_version
+ global_util.update_global_as_our_mod_updated(our_mod_old_version, our_mod_new_version)
+
+ if our_mod_old_version < "0.2.0" and our_mod_new_version >= "0.2.0" then
+ -- Big changes in the GUI system in v0.2.0, so we have to force close the opened GUI.
+ for _, player in pairs(game.players) do
+ gui_entity.create_or_destroy_gui_of_entity(player, nil, false)
+ end
+ -- Destroy more cheats popup.
+ gui.destroy_more_cheats_popup()
+ -- Create main menu button if Creative Mode is enabled.
+ gui_menu.create_or_destroy_main_menu_open_button_for_all_players()
+ end
+ if our_mod_old_version <= "1.8.0" and our_mod_new_version >= "1.8.1" then
+ -- We can clear out some of these tables. It MAY be a lot of info if someone's built a lot.
+ storage.creative_mode.heat_source = nil
+ storage.creative_mode.heat_void = nil
+ storage.creative_mode.void_requester_chest = nil
+ storage.creative_mode.void_chest = nil
+ storage.creative_mode.void_storage_chest = nil
+ storage.creative_mode.super_roboport = nil
+ storage.creative_mode.fluid_source = nil
+ storage.creative_mode.super_radar = nil
+ storage.creative_mode.super_beacon = nil
+ storage.creative_mode.energy_void = nil
+ storage.creative_mode.passive_energy_void = nil
+ storage.creative_mode.passive_energy_source = nil
+ storage.creative_mode.energy_source = nil
+ -- Ensure the tables for the new creative/providers chests exist.
+ if not storage.creative_mode.new_creative_chest then
+ storage.creative_mode.new_creative_chests = {}
+ end
+ if not storage.creative_mode.new_creative_provider_chest then
+ storage.creative_mode.new_creative_provider_chest = {}
+ end
+ for _, surface in pairs(game.surfaces) do
+ -- Find all our entities so we can get them updated to the new methods.
+ -- We could just iterate our tables before clearing them, but this guarantees we get everything, and some data won't be good due to the prototype changes making the old entity references invalid.
+ for _, entity in
+ ipairs(surface.find_entities_filtered({
+ name = {
+ creative_mode_defines.names.entities.void_chest,
+ creative_mode_defines.names.entities.void_storage_chest,
+ creative_mode_defines.names.entities.void_requester_chest,
+ creative_mode_defines.names.entities.heat_source,
+ creative_mode_defines.names.entities.heat_void,
+ creative_mode_defines.names.entities.creative_chest,
+ creative_mode_defines.names.entities.creative_provider_chest,
+ },
+ }))
+ do
+ if entity.name == creative_mode_defines.names.entities.creative_chest then
+ -- We need to replace all the old creative chests with the new one
+ if entity.valid then
+ -- First we need to find the data for this chest
+ local old_data, group_number = creative_chest_util.get_creative_chest_data_group_number(
+ entity,
+ storage.creative_mode.creative_chest_data_groups
+ )
+ -- Make the new chest over the old one
+ local new_entity = entity.surface.create_entity({
+ name = creative_mode_defines.names.entities.new_creative_chest,
+ position = entity.position,
+ force = entity.force,
+ fast_replace = true,
+ spill = false,
+ raise_built = false,
+ create_build_effect_smoke = false,
+ })
+ if old_data == nil or group_number == 0 then --No data found, or an invalid group number.
+ --Make a new chest and register it as if it were just built.
+ global_util.register_entity(new_entity)
+ else -- We have good data, so copy it to our new chest
+ new_entity.remove_unfiltered_items = true -- We don't want anything except our filters in these
+ local chest_data = {
+ entity = new_entity, -- The new-creative-chest entity.
+ group = group_number, -- Same group as the old chest.
+ filtered_slots = old_data.filtered_slots, -- The slot indexes that are filtered out in this chest.
+ inventory_display_mode = old_data.inventory_display_mode, -- The inventory display mode. Not very useful in the new chests.
+ is_cargo_wagon = false, -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
+ }
+ table.insert(storage.creative_mode.new_creative_chests, chest_data)
+ -- Now that all our data is set, set the filters.
+ creative_chest_util.set_chest_filter(chest_data)
+ end
+ entity.destroy() -- Destroy the old chest - it's useless.
+ end
+ elseif entity.name == creative_mode_defines.names.entities.creative_provider_chest then
+ -- We need to replace all the old creative provider chests with the new one
+ if entity.valid then
+ -- First we need to find the data for this chest
+ local old_data, group_number = creative_chest_util.get_creative_chest_data_group_number(
+ entity,
+ storage.creative_mode.creative_provider_chest_data_groups
+ )
+ -- Make the new chest over the old one
+ local new_entity = entity.surface.create_entity({
+ name = creative_mode_defines.names.entities.new_creative_provider_chest,
+ position = entity.position,
+ force = entity.force,
+ fast_replace = true,
+ spill = false,
+ raise_built = false,
+ create_build_effect_smoke = false,
+ })
+ if old_data == nil or group_number == 0 then --No data found, or an invalid group number.
+ --Make a new chest and register it as if it were just built.
+ global_util.register_entity(new_entity)
+ else -- We have good data, so copy it to our new chest
+ new_entity.remove_unfiltered_items = true -- We don't want anything except our filters in these
+ local chest_data = {
+ entity = new_entity, -- The new-creative-chest entity.
+ group = group_number, -- Same group as the old chest.
+ filtered_slots = old_data.filtered_slots, -- The slot indexes that are filtered out in this chest.
+ inventory_display_mode = old_data.inventory_display_mode, -- The inventory display mode. Not very useful in the new chests.
+ is_cargo_wagon = false, -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
+ }
+ table.insert(storage.creative_mode.new_creative_provider_chests, chest_data)
+ -- Now that all our data is set, set the filters.
+ creative_chest_util.set_chest_filter(chest_data)
+ end
+ entity.destroy() -- Destroy the old chest - it's useless.
+ end
+ else -- For the rest of the types we can just run their placement function again to set what we need
+ --void_chest, void_storage_chest, void_requester_chest, heat_source, heat_void.
+ --log("Fixing entity: " .. entity.name)
+ global_util.register_entity(entity)
+ end
+ end
+ end
+ -- Remove the tables for creative chests/providers, as we don't need them anymore.
+ storage.creative_mode.creative_chest_data_groups = nil
+ storage.creative_mode.creative_provider_chest_data_groups = nil
+ end
+ end
+
+ -- Make sure the main menu and modifer popup is closed whenever our mod version has changed.
+ for _, player in pairs(game.connected_players) do
+ gui_menu.destroy_main_menu_for_player(player)
+ gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
+ end
+ end
+
+ -- For game version changed or any mod changed, item list needs to be updated.
+ if not global_util.item_lists_exist() or is_game_changed or is_any_mod_changed then
+ global_util.renew_item_lists()
+ end
+
+ -- If creative mode is already enabled, we will also need to make sure all of our recipes are enabled in case there are new recipes for new items.
+ if is_game_changed or is_any_mod_changed then
+ local team_cheat_creative_tools_recipes = cheats.team_cheats_data.cheats.creative_tools_recipes
+ for _, force in pairs(game.forces) do
+ if team_cheat_creative_tools_recipes.get_value_function(force) then
+ team_cheat_creative_tools_recipes.apply_to_target_function(force, true, nil)
+ end
+ end
+ end
end
-- Callback of the on_runtime_mod_setting_changed event, which is invoked when a runtime mod setting is changed by a player.
local function on_runtime_mod_setting_changed(event)
- local setting = event.setting
- if
- setting == creative_mode_defines.names.settings.creative_chest_contains_hidden_items
- or setting == creative_mode_defines.names.settings.creative_cargo_wagon_contains_hidden_items
- then
- -- Creative chest contains hidden items.
- creative_chest_util.update_item_lists_data()
- game.print({ "message.creative-mode_creative-chest-item-group-updated" })
- end
+ local setting = event.setting
+ if
+ setting == creative_mode_defines.names.settings.creative_chest_contains_hidden_items
+ or setting == creative_mode_defines.names.settings.creative_cargo_wagon_contains_hidden_items
+ then
+ -- Creative chest contains hidden items.
+ creative_chest_util.update_item_lists_data()
+ game.print({ "message.creative-mode_creative-chest-item-group-updated" })
+ end
end
--------------------------------------------------------------------
-- Callback of the on_tick event.
function events.on_tick()
- -- Auto enable Creative Mode or ask for enabling it if not asked before.
- -- It is not shown in the 0th tick so the message box has to be closed before the popup is shown.
- if not storage.creative_mode.has_asked_for_enable and not storage.creative_mode.enabled then
- if game.tick >= 1 then
- -- Wait until the initial cutscene is over.
- -- We wait until there's at least one connected player not currently
- -- in a cutscene. There are likely ways to sneak around these
- -- checks, but it works perfect for Factorio 1.0's scenarios.
- local player = game.players[1]
- if player ~= nil and player.controller_type ~= defines.controllers.cutscene then
- storage.creative_mode.has_asked_for_enable = true
- -- Check the default initial action in settings.
- local default_initial_action =
- settings.global[creative_mode_defines.names.settings.default_initial_action].value
- if default_initial_action == creative_mode_defines.values.default_initial_actions.enable then
- -- Enable CM.
- cheats.enable_or_disable_creative_mode(player, true, false, false, true)
- elseif default_initial_action == creative_mode_defines.values.default_initial_actions.enable_all then
- -- Enable all cheats.
- cheats.enable_or_disable_creative_mode(player, true, false, true, true)
- elseif default_initial_action == creative_mode_defines.values.default_initial_actions.disable then
- -- Disable CM.
- cheats.enable_or_disable_creative_mode(player, false, false, false, true)
- elseif
- default_initial_action
- == creative_mode_defines.values.default_initial_actions.disable_permanently
- then
- -- Disable permanently.
- cheats.enable_or_disable_creative_mode(player, false, true, false, true)
- else
- -- Default: show popup.
- gui.show_main_popup(player, gui.main_popup_content_type.enable_creative_mode)
- end
- end
- end
- end
-
- -- Cheats should be executed first, so entities can be updated immediately after they are built by instant blueprint.
- gui.tick()
- cheats.tick()
-
- creative_chest_util.tick()
- creative_lab.tick()
- void_lab.tick()
- -- autofill_requester_chest.tick()
- duplicating_chest.tick()
- duplicating_provider_chest.tick()
- creative_cargo_wagon.tick()
- duplicating_cargo_wagon.tick()
- void_cargo_wagon.tick()
- fluid_void.tick()
- super_boiler.tick()
- super_cooler.tick()
- configurable_super_boiler.tick()
- item_source.tick()
- duplicator.tick()
- item_void.tick()
- random_item_source.tick()
- equipments.tick()
+ -- Auto enable Creative Mode or ask for enabling it if not asked before.
+ -- It is not shown in the 0th tick so the message box has to be closed before the popup is shown.
+ if not storage.creative_mode.has_asked_for_enable and not storage.creative_mode.enabled then
+ if game.tick >= 1 then
+ -- Wait until the initial cutscene is over.
+ -- We wait until there's at least one connected player not currently
+ -- in a cutscene. There are likely ways to sneak around these
+ -- checks, but it works perfect for Factorio 1.0's scenarios.
+ local player = game.players[1]
+ if player ~= nil and player.controller_type ~= defines.controllers.cutscene then
+ storage.creative_mode.has_asked_for_enable = true
+ -- Check the default initial action in settings.
+ local default_initial_action =
+ settings.global[creative_mode_defines.names.settings.default_initial_action].value
+ if default_initial_action == creative_mode_defines.values.default_initial_actions.enable then
+ -- Enable CM.
+ cheats.enable_or_disable_creative_mode(player, true, false, false, true)
+ elseif default_initial_action == creative_mode_defines.values.default_initial_actions.enable_all then
+ -- Enable all cheats.
+ cheats.enable_or_disable_creative_mode(player, true, false, true, true)
+ elseif default_initial_action == creative_mode_defines.values.default_initial_actions.disable then
+ -- Disable CM.
+ cheats.enable_or_disable_creative_mode(player, false, false, false, true)
+ elseif default_initial_action == creative_mode_defines.values.default_initial_actions.disable_permanently then
+ -- Disable permanently.
+ cheats.enable_or_disable_creative_mode(player, false, true, false, true)
+ else
+ -- Default: show popup.
+ gui.show_main_popup(player, gui.main_popup_content_type.enable_creative_mode)
+ end
+ end
+ end
+ end
+
+ -- Cheats should be executed first, so entities can be updated immediately after they are built by instant blueprint.
+ gui.tick()
+ cheats.tick()
+
+ creative_chest_util.tick()
+ creative_lab.tick()
+ void_lab.tick()
+ -- autofill_requester_chest.tick()
+ duplicating_chest.tick()
+ duplicating_provider_chest.tick()
+ creative_cargo_wagon.tick()
+ duplicating_cargo_wagon.tick()
+ void_cargo_wagon.tick()
+ fluid_void.tick()
+ super_boiler.tick()
+ super_cooler.tick()
+ configurable_super_boiler.tick()
+ item_source.tick()
+ duplicator.tick()
+ item_void.tick()
+ random_item_source.tick()
+ equipments.tick()
end
--------------------------------------------------------------------
-- Callback of the on_pre_build event, which is invoked when a player uses item to build something.
local function on_pre_build(event)
- local player = game.players[event.player_index]
- cheats.on_pre_build(player)
+ local player = game.players[event.player_index]
+ cheats.on_pre_build(player)
end
-- Callback of the on_built_entity event, which is invoked when an entity is built by player.
local function on_built_entity(event)
- local player = game.players[event.player_index]
- local entity = event.entity
- local is_entity_ghost = entity.name == "entity-ghost"
- local is_tile_ghost = entity.name == "tile-ghost"
- local is_ghost = is_entity_ghost or is_tile_ghost
- local is_item_request_proxy = entity.name == "item-request-proxy"
+ local player = game.players[event.player_index]
+ local entity = event.entity
+ local is_entity_ghost = entity.name == "entity-ghost"
+ local is_tile_ghost = entity.name == "tile-ghost"
+ local is_ghost = is_entity_ghost or is_tile_ghost
+ local is_item_request_proxy = entity.name == "item-request-proxy"
- -- Pass to cheats.lua to verify the built entity.
- cheats.on_built_entity(player, entity, is_ghost, is_entity_ghost, is_item_request_proxy)
+ -- Pass to cheats.lua to verify the built entity.
+ cheats.on_built_entity(player, entity, is_ghost, is_entity_ghost, is_item_request_proxy)
- -- Register the built entity if it is one of the creative entities and it needs to be updated via script.
- global_util.register_entity(entity)
+ -- Register the built entity if it is one of the creative entities and it needs to be updated via script.
+ global_util.register_entity(entity)
end
-- Callback of the script_raised_revive event, which is invoked when an entity is revived by robot.
local function script_raised_revive(event)
- global_util.register_entity(event.entity)
+ global_util.register_entity(event.entity)
end
-- Callback of the script_raised_built event, which is invoked when an entity is revived by robot.
local function script_raised_built(event)
- global_util.register_entity(event.entity)
+ global_util.register_entity(event.entity)
end
-- Returns whether the given entity is a member of the Creative Chest family (i.e. Creative Chest or Creative Provider Chest).
local function is_entity_creative_chest_family(entity)
- -- Creative chest.
- if entity.name == creative_mode_defines.names.entities.creative_chest then
- return true
- end
- -- Creative provider chest.
- if entity.name == creative_mode_defines.names.entities.creative_provider_chest then
- return true
- end
- -- New Creative chest.
- if entity.name == creative_mode_defines.names.entities.new_creative_chest then
- return true
- end
- -- New Creative provider chest.
- if entity.name == creative_mode_defines.names.entities.new_creative_provider_chest then
- return true
- end
- -- Creative cargo wagon.
- if entity.name == creative_mode_defines.names.entities.creative_cargo_wagon then
- return true
- end
- return false
+ -- Creative chest.
+ if entity.name == creative_mode_defines.names.entities.creative_chest then
+ return true
+ end
+ -- Creative provider chest.
+ if entity.name == creative_mode_defines.names.entities.creative_provider_chest then
+ return true
+ end
+ -- New Creative chest.
+ if entity.name == creative_mode_defines.names.entities.new_creative_chest then
+ return true
+ end
+ -- New Creative provider chest.
+ if entity.name == creative_mode_defines.names.entities.new_creative_provider_chest then
+ return true
+ end
+ -- Creative cargo wagon.
+ if entity.name == creative_mode_defines.names.entities.creative_cargo_wagon then
+ return true
+ end
+ return false
end
-- Returns whether the given entity is a member of the Duplicating Chest family (i.e. Duplicating Chest or Duplicating Provider Chest).
local function is_entity_duplicating_chest_family(entity)
- -- Duplicating chest.
- if entity.name == creative_mode_defines.names.entities.duplicating_chest then
- return true
- end
- -- Duplicating provider chest.
- if entity.name == creative_mode_defines.names.entities.duplicating_provider_chest then
- return true
- end
- -- Duplicating cargo wagon.
- if entity.name == creative_mode_defines.names.entities.duplicating_cargo_wagon then
- return true
- end
-
- return false
+ -- Duplicating chest.
+ if entity.name == creative_mode_defines.names.entities.duplicating_chest then
+ return true
+ end
+ -- Duplicating provider chest.
+ if entity.name == creative_mode_defines.names.entities.duplicating_provider_chest then
+ return true
+ end
+ -- Duplicating cargo wagon.
+ if entity.name == creative_mode_defines.names.entities.duplicating_cargo_wagon then
+ return true
+ end
+
+ return false
end
-- Returns whether the given entity is a member of the Void Chest Family (i.e. Void Requester Chest or Void Storage Chest).
local function is_entity_void_chest_family(entity)
- -- Void logistic/storage/regular chest are no longer in this list as they don't need any scripting.
- -- Void cargo wagon.
- if entity.name == creative_mode_defines.names.entities.void_cargo_wagon then
- return true
- end
+ -- Void logistic/storage/regular chest are no longer in this list as they don't need any scripting.
+ -- Void cargo wagon.
+ if entity.name == creative_mode_defines.names.entities.void_cargo_wagon then
+ return true
+ end
end
-- Clears the inventory of the given entity before it is mined so that player will not be filled by the items inside it and robots will not need to clear it before deconstruction.
-- Nothing will be done if such action is not necessary according to the entity type.
-- Returns whether the inventory is cleared.
local function clear_inventory_before_mined_if_needed(entity)
- -- Creative chest family.
- if is_entity_creative_chest_family(entity) then
- local inventory = creative_chest_util.get_inventory(entity)
- inventory.clear()
- return true
- end
-
- -- Autofill requester chest.
- if entity.name == creative_mode_defines.names.entities.autofill_requester_chest then
- entity.get_output_inventory().clear()
- return true
- end
-
- -- Duplicating chest family.
- if is_entity_duplicating_chest_family(entity) then
- local inventory = duplicating_chest_util.get_inventory(entity)
- inventory.clear()
- return true
- end
-
- -- Void chest family.
- if is_entity_void_chest_family(entity) then
- local inventory = void_chest_util.get_inventory(entity)
- inventory.clear()
- return true
- end
-
- -- Creative lab.
- if entity.name == creative_mode_defines.names.entities.creative_lab then
- local inventory = entity.get_inventory(defines.inventory.lab_input)
- if inventory then
- inventory.clear()
- return true
- end
- end
-
- return false
+ -- Creative chest family.
+ if is_entity_creative_chest_family(entity) then
+ local inventory = creative_chest_util.get_inventory(entity)
+ inventory.clear()
+ return true
+ end
+
+ -- Autofill requester chest.
+ if entity.name == creative_mode_defines.names.entities.autofill_requester_chest then
+ entity.get_output_inventory().clear()
+ return true
+ end
+
+ -- Duplicating chest family.
+ if is_entity_duplicating_chest_family(entity) then
+ local inventory = duplicating_chest_util.get_inventory(entity)
+ inventory.clear()
+ return true
+ end
+
+ -- Void chest family.
+ if is_entity_void_chest_family(entity) then
+ local inventory = void_chest_util.get_inventory(entity)
+ inventory.clear()
+ return true
+ end
+
+ -- Creative lab.
+ if entity.name == creative_mode_defines.names.entities.creative_lab then
+ local inventory = entity.get_inventory(defines.inventory.lab_input)
+ if inventory then
+ inventory.clear()
+ return true
+ end
+ end
+
+ return false
end
-- Callback of the on_preplayer_mined_item event, which is invoked just before a player starts mining something.
local function on_preplayer_mined_item(event)
- -- Clear inventory if needed.
- clear_inventory_before_mined_if_needed(event.entity)
- -- Apply cheats.
- cheats.on_preplayer_mined_item(event.player_index, event.entity)
+ -- Clear inventory if needed.
+ clear_inventory_before_mined_if_needed(event.entity)
+ -- Apply cheats.
+ cheats.on_preplayer_mined_item(event.player_index, event.entity)
end
-- Callback of the script_raised_destroy event, which is invoked when a script destroys something.
local function script_raised_destroy(event)
- -- Clear inventory if needed.
- clear_inventory_before_mined_if_needed(event.entity)
+ -- Clear inventory if needed.
+ clear_inventory_before_mined_if_needed(event.entity)
end
-- Callback of the on_marked_for_deconstruction event, which is invoked when an entity is marked for deconstruction.
local function on_marked_for_deconstruction(event)
- -- Clear inventory if needed.
- clear_inventory_before_mined_if_needed(event.entity)
+ -- Clear inventory if needed.
+ clear_inventory_before_mined_if_needed(event.entity)
- -- Apply cheats, e.g. instant deconstruction.
- cheats.on_marked_for_deconstruction(event.player_index, event.entity)
+ -- Apply cheats, e.g. instant deconstruction.
+ cheats.on_marked_for_deconstruction(event.player_index, event.entity)
end
-- Callback of the on_entity_settings_pasted event, which is invoked after entity copy-paste is done.
local function on_entity_settings_pasted(event)
- -- If both the source and destination entities are members of the Creative Chest family, move the destination chest to the group number of the source chest.
- if is_entity_creative_chest_family(event.source) and is_entity_creative_chest_family(event.destination) then
- creative_chest_util.on_entity_copied_pasted(event.source, event.destination)
- return
- end
-
- -- If both the source and destination entities are members of the Duplicating Chest family, copy the contents from the source chest to the destination chest.
- if is_entity_duplicating_chest_family(event.source) and is_entity_duplicating_chest_family(event.destination) then
- duplicating_chest_util.on_entity_copied_pasted(event.source, event.destination)
- return
- end
-
- -- If both the source and destination entities are Configurable Super Boilers...
- if
- event.source.name == creative_mode_defines.names.entities.configurable_super_boiler
- and event.destination.name == event.source.name
- then
- configurable_super_boiler.on_entity_copied_pasted(event.source, event.destination)
- return
- end
-
- -- If both the source and destination entities are Matter Sources...
- if
- event.source.name == creative_mode_defines.names.entities.item_source
- and event.destination.name == event.source.name
- then
- item_source.on_entity_copied_pasted(event.source, event.destination)
- return
- end
-
- -- If both the source and destination entities are Matter Duplicators...
- if
- event.source.name == creative_mode_defines.names.entities.duplicator
- and event.destination.name == event.source.name
- then
- duplicator.on_entity_copied_pasted(event.source, event.destination)
- return
- end
-
- -- If both the source and destination entities are Matter Voids...
- if
- event.source.name == creative_mode_defines.names.entities.item_void
- and event.destination.name == event.source.name
- then
- item_void.on_entity_copied_pasted(event.source, event.destination)
- return
- end
-
- if
- event.source.name == creative_mode_defines.names.entities.linked_belt
- and event.destination.name == creative_mode_defines.names.entities.linked_belt
- then
- -- Remove their previous links, if any.
- event.source.disconnect_linked_belts()
- event.destination.disconnect_linked_belts()
- -- Setup these belts as input and output, respectively.
- event.source.linked_belt_type = "input"
- event.destination.linked_belt_type = "output"
- -- then connect them to each other. This overrides any previous settings.
- event.source.connect_linked_belts(event.destination)
- return
- end
+ -- If both the source and destination entities are members of the Creative Chest family, move the destination chest to the group number of the source chest.
+ if is_entity_creative_chest_family(event.source) and is_entity_creative_chest_family(event.destination) then
+ creative_chest_util.on_entity_copied_pasted(event.source, event.destination)
+ return
+ end
+
+ -- If both the source and destination entities are members of the Duplicating Chest family, copy the contents from the source chest to the destination chest.
+ if is_entity_duplicating_chest_family(event.source) and is_entity_duplicating_chest_family(event.destination) then
+ duplicating_chest_util.on_entity_copied_pasted(event.source, event.destination)
+ return
+ end
+
+ -- If both the source and destination entities are Configurable Super Boilers...
+ if
+ event.source.name == creative_mode_defines.names.entities.configurable_super_boiler
+ and event.destination.name == event.source.name
+ then
+ configurable_super_boiler.on_entity_copied_pasted(event.source, event.destination)
+ return
+ end
+
+ -- If both the source and destination entities are Matter Sources...
+ if
+ event.source.name == creative_mode_defines.names.entities.item_source
+ and event.destination.name == event.source.name
+ then
+ item_source.on_entity_copied_pasted(event.source, event.destination)
+ return
+ end
+
+ -- If both the source and destination entities are Matter Duplicators...
+ if
+ event.source.name == creative_mode_defines.names.entities.duplicator
+ and event.destination.name == event.source.name
+ then
+ duplicator.on_entity_copied_pasted(event.source, event.destination)
+ return
+ end
+
+ -- If both the source and destination entities are Matter Voids...
+ if
+ event.source.name == creative_mode_defines.names.entities.item_void
+ and event.destination.name == event.source.name
+ then
+ item_void.on_entity_copied_pasted(event.source, event.destination)
+ return
+ end
+
+ if
+ event.source.name == creative_mode_defines.names.entities.linked_belt
+ and event.destination.name == creative_mode_defines.names.entities.linked_belt
+ then
+ -- Remove their previous links, if any.
+ event.source.disconnect_linked_belts()
+ event.destination.disconnect_linked_belts()
+ -- Setup these belts as input and output, respectively.
+ event.source.linked_belt_type = "input"
+ event.destination.linked_belt_type = "output"
+ -- then connect them to each other. This overrides any previous settings.
+ event.source.connect_linked_belts(event.destination)
+ return
+ end
end
-- Callback of the on_player_created event, which is invoked after a player is created.
local function on_player_created(event)
- local player = game.players[event.player_index]
- gui_menu.create_or_destroy_main_menu_open_button_for_player(player)
+ local player = game.players[event.player_index]
+ gui_menu.create_or_destroy_main_menu_open_button_for_player(player)
end
-- Callback of the on_player_respawned event, which is invoked after a player is respawned.
local function on_player_respawned(event)
- cheats.on_player_respawned(event)
+ cheats.on_player_respawned(event)
end
-- Callback of the on_player_joined_game event, which is invoked after a player joined a multiplayer game.
local function on_player_joined_game(event)
- cheats.on_player_joined_game(event)
- gui.on_player_joined_game(event)
+ cheats.on_player_joined_game(event)
+ gui.on_player_joined_game(event)
end
-- Callback of the on_player_left_game event, which is invoked after a player left a multiplayer game.
local function on_player_left_game(event)
- gui.on_player_left_game(event)
+ gui.on_player_left_game(event)
end
-- Callback of the on_player_changed_surface event, which is invoked after a player went to another surface.
local function on_player_changed_surface(event)
- gui.on_player_changed_surface(event)
+ gui.on_player_changed_surface(event)
end
-- Callback of the on_player_cursor_stack_changed event, which is invoked after a player picks up or puts down an item stack.
local function on_player_cursor_stack_changed(event)
- gui.on_player_cursor_stack_changed(event)
+ gui.on_player_cursor_stack_changed(event)
end
-- Callback of the on_player_selected_area event, which is invoked after a player selected an area with a selection-tool item.
local function on_player_selected_area(event)
- local player = game.players[event.player_index]
- local area = event.area
- local item_name = event.item
- local entities = event.entities
- local tiles = event.tiles
-
- -- Forward the event to magic wand - creator.
- if magic_wand_creator.on_player_selected_area(player, area, item_name, entities, tiles) then
- return
- end
- -- Forward the event to magic wand - healer.
- if magic_wand_healer.on_player_selected_area(player, area, item_name, entities, tiles) then
- return
- end
- -- Forward the event to magic wand - modifier.
- if magic_wand_modifier.on_player_selected_area(player, area, item_name, entities, tiles) then
- return
- end
+ local player = game.players[event.player_index]
+ local area = event.area
+ local item_name = event.item
+ local entities = event.entities
+ local tiles = event.tiles
+
+ -- Forward the event to magic wand - creator.
+ if magic_wand_creator.on_player_selected_area(player, area, item_name, entities, tiles) then
+ return
+ end
+ -- Forward the event to magic wand - healer.
+ if magic_wand_healer.on_player_selected_area(player, area, item_name, entities, tiles) then
+ return
+ end
+ -- Forward the event to magic wand - modifier.
+ if magic_wand_modifier.on_player_selected_area(player, area, item_name, entities, tiles) then
+ return
+ end
end
-- Callback of the on_player_alt_selected_area event, which is invoked after a player alt-selected an area with a selection-tool item.
local function on_player_alt_selected_area(event)
- local player = game.players[event.player_index]
- local area = event.area
- local item_name = event.item
- local entities = event.entities
- local tiles = event.tiles
-
- -- Forward the event to magic wand - creator.
- if magic_wand_creator.on_player_alt_selected_area(player, area, item_name, entities, tiles) then
- return
- end
- -- Forward the event to magic wand - healer.
- if magic_wand_healer.on_player_alt_selected_area(player, area, item_name, entities, tiles) then
- return
- end
- -- Forward the event to magic wand - modifier.
- if magic_wand_modifier.on_player_alt_selected_area(player, area, item_name, entities, tiles) then
- return
- end
+ local player = game.players[event.player_index]
+ local area = event.area
+ local item_name = event.item
+ local entities = event.entities
+ local tiles = event.tiles
+
+ -- Forward the event to magic wand - creator.
+ if magic_wand_creator.on_player_alt_selected_area(player, area, item_name, entities, tiles) then
+ return
+ end
+ -- Forward the event to magic wand - healer.
+ if magic_wand_healer.on_player_alt_selected_area(player, area, item_name, entities, tiles) then
+ return
+ end
+ -- Forward the event to magic wand - modifier.
+ if magic_wand_modifier.on_player_alt_selected_area(player, area, item_name, entities, tiles) then
+ return
+ end
end
-- Callback of the on_player_placed_equipment event, which is invoked after a player placed an equipment into equipment grid.
local function on_player_placed_equipment(event)
- local equipment = event.equipment
+ local equipment = event.equipment
- -- Register the equipments that need to be refilled with energy.
- if equipment.name == creative_mode_defines.names.equipments.super_personal_roboport_equipment then
- table.insert(storage.energy_refill_equipments, equipment)
- end
+ -- Register the equipments that need to be refilled with energy.
+ if equipment.name == creative_mode_defines.names.equipments.super_personal_roboport_equipment then
+ table.insert(storage.energy_refill_equipments, equipment)
+ end
end
-- Callback of the on_research_started event, which is invoked after a research is started.
local function on_research_started(event)
- cheats.on_research_started(event)
+ cheats.on_research_started(event)
end
-- Callback of the on_chunk_generated event, which is invoked after a chunk is generated.
local function on_chunk_generated(event)
- cheats.on_chunk_generated(event)
+ cheats.on_chunk_generated(event)
end
-- Callback of the on_gui_closed event. Forward to gui.lua
local function on_gui_closed(event)
- gui.on_gui_closed(event)
+ gui.on_gui_closed(event)
end
-- Callback of the on_gui_click event. Forward to gui.lua.
local function on_gui_click(event)
- gui.on_gui_click(event)
+ gui.on_gui_click(event)
end
-- Callback of the on_gui_text_changed event. Forward to gui.lua.
local function on_gui_text_changed(event)
- gui.on_gui_text_changed(event)
+ gui.on_gui_text_changed(event)
end
-- Callback of the on_gui_checked_state_changed evnet. Forward to gui.lua.
local function on_gui_checked_state_changed(event)
- gui.on_gui_checked_state_changed(event)
+ gui.on_gui_checked_state_changed(event)
end
-- Callback of the on_gui_selection_state_changed event. Forward to gui.lua.
local function on_gui_selection_state_changed(event)
- gui.on_gui_selection_state_changed(event)
+ gui.on_gui_selection_state_changed(event)
end
-- Callback of the on_robot_built_entity event. Forward to register entity.
local function on_robot_built_entity(event)
- -- Register the built entity if it is one of the creative entities and it needs to be updated via script.
- global_util.register_entity(event.entity)
+ -- Register the built entity if it is one of the creative entities and it needs to be updated via script.
+ global_util.register_entity(event.entity)
end
-- The look up table for forwarding events to the corresponding handlers.
local event_handlers_look_up = {
- [defines.events.on_pre_build] = on_pre_build,
- [defines.events.on_built_entity] = on_built_entity,
- [defines.events.script_raised_revive] = script_raised_revive,
- [defines.events.script_raised_built] = script_raised_built,
- [defines.events.on_pre_player_mined_item] = on_preplayer_mined_item,
- [defines.events.script_raised_destroy] = script_raised_destroy,
- [defines.events.on_marked_for_deconstruction] = on_marked_for_deconstruction,
- [defines.events.on_entity_settings_pasted] = on_entity_settings_pasted,
- [defines.events.on_player_created] = on_player_created,
- [defines.events.on_player_respawned] = on_player_respawned,
- [defines.events.on_player_joined_game] = on_player_joined_game,
- [defines.events.on_player_left_game] = on_player_left_game,
- [defines.events.on_player_changed_surface] = on_player_changed_surface,
- [defines.events.on_player_selected_area] = on_player_selected_area,
- [defines.events.on_player_alt_selected_area] = on_player_alt_selected_area,
- [defines.events.on_player_cursor_stack_changed] = on_player_cursor_stack_changed,
- [defines.events.on_player_placed_equipment] = on_player_placed_equipment,
- [defines.events.on_research_started] = on_research_started,
- [defines.events.on_robot_built_entity] = on_robot_built_entity,
- [defines.events.on_chunk_generated] = on_chunk_generated,
- [defines.events.on_gui_closed] = on_gui_closed,
- [defines.events.on_gui_click] = on_gui_click,
- [defines.events.on_gui_text_changed] = on_gui_text_changed,
- [defines.events.on_gui_checked_state_changed] = on_gui_checked_state_changed,
- [defines.events.on_gui_selection_state_changed] = on_gui_selection_state_changed,
- [defines.events.on_runtime_mod_setting_changed] = on_runtime_mod_setting_changed,
+ [defines.events.on_pre_build] = on_pre_build,
+ [defines.events.on_built_entity] = on_built_entity,
+ [defines.events.script_raised_revive] = script_raised_revive,
+ [defines.events.script_raised_built] = script_raised_built,
+ [defines.events.on_pre_player_mined_item] = on_preplayer_mined_item,
+ [defines.events.script_raised_destroy] = script_raised_destroy,
+ [defines.events.on_marked_for_deconstruction] = on_marked_for_deconstruction,
+ [defines.events.on_entity_settings_pasted] = on_entity_settings_pasted,
+ [defines.events.on_player_created] = on_player_created,
+ [defines.events.on_player_respawned] = on_player_respawned,
+ [defines.events.on_player_joined_game] = on_player_joined_game,
+ [defines.events.on_player_left_game] = on_player_left_game,
+ [defines.events.on_player_changed_surface] = on_player_changed_surface,
+ [defines.events.on_player_selected_area] = on_player_selected_area,
+ [defines.events.on_player_alt_selected_area] = on_player_alt_selected_area,
+ [defines.events.on_player_cursor_stack_changed] = on_player_cursor_stack_changed,
+ [defines.events.on_player_placed_equipment] = on_player_placed_equipment,
+ [defines.events.on_research_started] = on_research_started,
+ [defines.events.on_robot_built_entity] = on_robot_built_entity,
+ [defines.events.on_chunk_generated] = on_chunk_generated,
+ [defines.events.on_gui_closed] = on_gui_closed,
+ [defines.events.on_gui_click] = on_gui_click,
+ [defines.events.on_gui_text_changed] = on_gui_text_changed,
+ [defines.events.on_gui_checked_state_changed] = on_gui_checked_state_changed,
+ [defines.events.on_gui_selection_state_changed] = on_gui_selection_state_changed,
+ [defines.events.on_runtime_mod_setting_changed] = on_runtime_mod_setting_changed,
}
-- Does nothing.
local function get_empty_message(log_prefix, param_name, param)
- return nil
+ return nil
end
-- Prints Entity parameter.
local function get_entity_param_message(log_prefix, param_name, param)
- local entity_type = param.type
- local entity_name = param.name
- local message = log_prefix
- if param_name ~= "" then
- message = message .. '"' .. param_name .. '"'
- end
- message = message .. ' :: LuaEntity: {type = "' .. entity_type .. '", name = "' .. entity_name .. '"'
- if param.valid then
- if entity_name == "entity-ghost" or entity_name == "tile-ghost" then
- message = message .. ', ghost_name = "' .. param.ghost_name .. '"'
- end
- if entity_type == "item-entity" then
- local stack = param.stack
- if stack.valid_for_read then
- message = message
- .. ', stack = {type = "'
- .. stack.type
- .. '", name = "'
- .. stack.name
- .. '", count = '
- .. stack.count
- .. "}"
- else
- message = message .. ", stack.valid_for_read = false"
- end
- end
- if param.backer_name then
- message = message .. ', backer_name = "' .. param.backer_name .. '"'
- end
- if param.unit_number then
- message = message .. ", unit_number = " .. param.unit_number
- end
- message = message .. ", position = {" .. param.position.x .. ", " .. param.position.y .. "}"
- else
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local entity_type = param.type
+ local entity_name = param.name
+ local message = log_prefix
+ if param_name ~= "" then
+ message = message .. '"' .. param_name .. '"'
+ end
+ message = message .. ' :: LuaEntity: {type = "' .. entity_type .. '", name = "' .. entity_name .. '"'
+ if param.valid then
+ if entity_name == "entity-ghost" or entity_name == "tile-ghost" then
+ message = message .. ', ghost_name = "' .. param.ghost_name .. '"'
+ end
+ if entity_type == "item-entity" then
+ local stack = param.stack
+ if stack.valid_for_read then
+ message = message
+ .. ', stack = {type = "'
+ .. stack.type
+ .. '", name = "'
+ .. stack.name
+ .. '", count = '
+ .. stack.count
+ .. "}"
+ else
+ message = message .. ", stack.valid_for_read = false"
+ end
+ end
+ if param.backer_name then
+ message = message .. ', backer_name = "' .. param.backer_name .. '"'
+ end
+ if param.unit_number then
+ message = message .. ", unit_number = " .. param.unit_number
+ end
+ message = message .. ", position = {" .. param.position.x .. ", " .. param.position.y .. "}"
+ else
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints Prototype parameter.
local function get_prototype_param_message(log_prefix, param_name, param)
- local entity_type = param.type
- local entity_name = param.name
- local message = log_prefix
- if param_name ~= "" then
- message = message .. '"' .. param_name .. '"'
- end
- message = message .. ' :: LuaItemPrototype: {type = "' .. entity_type .. '", name = "' .. entity_name .. '"'
- if param.valid then
- message = message .. ", valid = true"
- else
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local entity_type = param.type
+ local entity_name = param.name
+ local message = log_prefix
+ if param_name ~= "" then
+ message = message .. '"' .. param_name .. '"'
+ end
+ message = message .. ' :: LuaItemPrototype: {type = "' .. entity_type .. '", name = "' .. entity_name .. '"'
+ if param.valid then
+ message = message .. ", valid = true"
+ else
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints table parameter.
local function get_table_param_message(log_prefix, param_name, param)
- local table = param.get()
+ local table = param.get()
- local message = log_prefix .. '"' .. param_name .. '" table :: {'
- for i, entry in ipairs(table) do
- message = message .. get_entity_param_message(i, "", entry)
- if next(table, i) ~= nil then
- message = message .. ", "
- end
- end
- message = message .. "}"
- return message
+ local message = log_prefix .. '"' .. param_name .. '" table :: {'
+ for i, entry in ipairs(table) do
+ message = message .. get_entity_param_message(i, "", entry)
+ if next(table, i) ~= nil then
+ message = message .. ", "
+ end
+ end
+ message = message .. "}"
+ return message
end
-- Prints uint parameter.
local function get_uint_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: uint: ' .. param)
+ return (log_prefix .. '"' .. param_name .. '" :: uint: ' .. param)
end
-- Prints BoundingBox parameter.
local function get_boundingbox_param_message(log_prefix, param_name, param)
- return (
- log_prefix
- .. '"'
- .. param_name
- .. '" :: BoundingBox: {left_top = ('
- .. param.left_top.x
- .. ", "
- .. param.left_top.y
- .. "), right_bottom = ("
- .. param.right_bottom.x
- .. ", "
- .. param.right_bottom.y
- .. ")}"
- )
+ return (
+ log_prefix
+ .. '"'
+ .. param_name
+ .. '" :: BoundingBox: {left_top = ('
+ .. param.left_top.x
+ .. ", "
+ .. param.left_top.y
+ .. "), right_bottom = ("
+ .. param.right_bottom.x
+ .. ", "
+ .. param.right_bottom.y
+ .. ")}"
+ )
end
-- Prints Surface parameter.
local function get_surface_param_message(log_prefix, param_name, param)
- local message = log_prefix
- .. '"'
- .. param_name
- .. '" :: LuaSurface: {name = "'
- .. param.name
- .. '", index = '
- .. param.index
- .. '"'
- if not param.valid then
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local message = log_prefix
+ .. '"'
+ .. param_name
+ .. '" :: LuaSurface: {name = "'
+ .. param.name
+ .. '", index = '
+ .. param.index
+ .. '"'
+ if not param.valid then
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints Force parameter.
local function get_force_param_message(log_prefix, param_name, param)
- local message = log_prefix .. '"' .. param_name .. '" :: LuaForce: {name = "' .. param.name .. '"'
- if not param.valid then
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local message = log_prefix .. '"' .. param_name .. '" :: LuaForce: {name = "' .. param.name .. '"'
+ if not param.valid then
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints GuiElement parameter.
local function get_guielement_param_message(log_prefix, param_name, param)
- local message = log_prefix
- .. '"'
- .. param_name
- .. '" :: LuaGuiElement: {name = "'
- .. param.name
- .. '", type = "'
- .. param.type
- .. '"'
- if not param.valid then
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local message = log_prefix
+ .. '"'
+ .. param_name
+ .. '" :: LuaGuiElement: {name = "'
+ .. param.name
+ .. '", type = "'
+ .. param.type
+ .. '"'
+ if not param.valid then
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints SimpleItemStack parameter.
local function get_simpleitemstack_param_message(log_prefix, param_name, param)
- local message = log_prefix .. '"' .. param_name
- if param.valid_for_read then
- message = message .. '" :: LuaItemStack: {name = "' .. param.name .. '", count = ' .. param.count .. "}"
- end
- return message
+ local message = log_prefix .. '"' .. param_name
+ if param.valid_for_read then
+ message = message .. '" :: LuaItemStack: {name = "' .. param.name .. '", count = ' .. param.count .. "}"
+ end
+ return message
end
-- Prints string parameter.
local function get_string_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: string: "' .. param .. '"')
+ return (log_prefix .. '"' .. param_name .. '" :: string: "' .. param .. '"')
end
-- Prints Equipment parameter.
local function get_equipment_param_message(log_prefix, param_name, param)
- local message = log_prefix
- .. '"'
- .. param_name
- .. '" :: LuaEquipment: {type = "'
- .. param.type
- .. '", name = "'
- .. param.name
- .. '"'
- if param.valid then
- message = message .. ", position = {" .. param.position.x .. ", " .. param.position.y .. "}"
- else
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local message = log_prefix
+ .. '"'
+ .. param_name
+ .. '" :: LuaEquipment: {type = "'
+ .. param.type
+ .. '", name = "'
+ .. param.name
+ .. '"'
+ if param.valid then
+ message = message .. ", position = {" .. param.position.x .. ", " .. param.position.y .. "}"
+ else
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints EquipmentGrid parameter.
local function get_equipmentgrid_param_message(log_prefix, param_name, param)
- local message = log_prefix
- .. '"'
- .. param_name
- .. '" :: LuaEquipmentGrid: {width = '
- .. param.width
- .. ", height = "
- .. param.height
- if not param.valid then
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local message = log_prefix
+ .. '"'
+ .. param_name
+ .. '" :: LuaEquipmentGrid: {width = '
+ .. param.width
+ .. ", height = "
+ .. param.height
+ if not param.valid then
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints Position parameter.
local function get_position_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: Position: {x = ' .. param.x .. ", y = " .. param.y .. "}")
+ return (log_prefix .. '"' .. param_name .. '" :: Position: {x = ' .. param.x .. ", y = " .. param.y .. "}")
end
-- Prints Technology parameter.
local function get_technology_param_message(log_prefix, param_name, param)
- local message = log_prefix .. '"' .. param_name .. '" :: LuaTechnology: {name = "' .. param.name .. '"'
- if param.valid then
- message = message .. ", level = " .. param.level .. ", upgrade = " .. tostring(param.upgrade)
- else
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local message = log_prefix .. '"' .. param_name .. '" :: LuaTechnology: {name = "' .. param.name .. '"'
+ if param.valid then
+ message = message .. ", level = " .. param.level .. ", upgrade = " .. tostring(param.upgrade)
+ else
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints Entity array parameter.
local function get_entity_array_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: array of LuaEntity: # = ' .. #param)
+ return (log_prefix .. '"' .. param_name .. '" :: array of LuaEntity: # = ' .. #param)
end
-- Prints Tile array parameter.
local function get_tile_array_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: array of LuaTile: # = ' .. #param)
+ return (log_prefix .. '"' .. param_name .. '" :: array of LuaTile: # = ' .. #param)
end
-- Prints Position array parameter.
local function get_position_array_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: array of Position: # = ' .. #param)
+ return (log_prefix .. '"' .. param_name .. '" :: array of Position: # = ' .. #param)
end
-- Prints boolean parameter.
local function get_boolean_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: boolean: ' .. tostring(param))
+ return (log_prefix .. '"' .. param_name .. '" :: boolean: ' .. tostring(param))
end
-- Prints number parameter.
local function get_number_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: number: ' .. param)
+ return (log_prefix .. '"' .. param_name .. '" :: number: ' .. param)
end
-- Returns the backer name of the given train.
local function get_train_backer_name(train)
- local front_movers = train.locomotives["front_movers"]
- if #front_movers > 0 then
- return front_movers[1].backer_name
- else
- local back_movers = train.locomotives["back_movers"]
- if #back_movers > 0 then
- return back_movers[1].backer_name
- end
- end
- return "(nil)"
+ local front_movers = train.locomotives["front_movers"]
+ if #front_movers > 0 then
+ return front_movers[1].backer_name
+ else
+ local back_movers = train.locomotives["back_movers"]
+ if #back_movers > 0 then
+ return back_movers[1].backer_name
+ end
+ end
+ return "(nil)"
end
-- Returns the train state string.
local function get_train_state_string(train)
- for key, id in pairs(defines.train_state) do
- if id == train.state then
- return "defines.train_state." .. key .. "(" .. id .. ")"
- end
- end
- return "(Unknown train state)" -- Should not be possible.
+ for key, id in pairs(defines.train_state) do
+ if id == train.state then
+ return "defines.train_state." .. key .. "(" .. id .. ")"
+ end
+ end
+ return "(Unknown train state)" -- Should not be possible.
end
-- Prints Train parameter.
local function get_train_param_message(log_prefix, param_name, param)
- local valid = param.valid
- local message = log_prefix .. '"' .. param_name .. '" :: LuaTrain: {'
- if valid then
- message = message
- .. 'backer_name = "'
- .. get_train_backer_name(param)
- .. '", state = '
- .. get_train_state_string(param)
- end
- message = message .. ", manual_mode = " .. tostring(param.manual_mode) .. ", speed = " .. param.speed
- if not valid then
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local valid = param.valid
+ local message = log_prefix .. '"' .. param_name .. '" :: LuaTrain: {'
+ if valid then
+ message = message
+ .. 'backer_name = "'
+ .. get_train_backer_name(param)
+ .. '", state = '
+ .. get_train_state_string(param)
+ end
+ message = message .. ", manual_mode = " .. tostring(param.manual_mode) .. ", speed = " .. param.speed
+ if not valid then
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints tag value as string.
local function get_string_tag_value(value)
- return tostring(value)
+ return tostring(value)
end
-- Prints function tag value.
local function get_function_tag_value(value)
- return "(function)"
+ return "(function)"
end
-- Prints table tag value.
local function get_table_tag_value(value)
- return "(table)"
+ return "(table)"
end
-- Prints userdata tag value.
local function get_userdata_tag_value(value)
- return "(userdata)"
+ return "(userdata)"
end
-- Prints thread tag value.
local function get_thread_tag_value(value)
- return "(thread)"
+ return "(thread)"
end
-- Look up table for tag values according to their types.
local get_tag_value_loop_up = {
- ["nil"] = get_string_tag_value,
- ["boolean"] = get_string_tag_value,
- ["number"] = get_string_tag_value,
- ["string"] = get_string_tag_value,
- ["function"] = get_function_tag_value,
- ["table"] = get_table_tag_value,
- ["userdata"] = get_userdata_tag_value,
- ["thread"] = get_thread_tag_value,
+ ["nil"] = get_string_tag_value,
+ ["boolean"] = get_string_tag_value,
+ ["number"] = get_string_tag_value,
+ ["string"] = get_string_tag_value,
+ ["function"] = get_function_tag_value,
+ ["table"] = get_table_tag_value,
+ ["userdata"] = get_userdata_tag_value,
+ ["thread"] = get_thread_tag_value,
}
-- Prints tags parameter.
local function get_tags_param_message(log_prefix, param_name, param)
- local message = log_prefix .. '"' .. param_name .. '" :: dictionary string - Any: {'
- local i = 1
- for key, value in pairs(param) do
- if i >= 2 then
- message = message .. ", "
- end
- local value_type = type(value)
- message = message .. "[" .. key .. "] = " .. get_tag_value_loop_up[value_type](value)
- i = i + 1
- end
- message = message .. "}"
- return message
+ local message = log_prefix .. '"' .. param_name .. '" :: dictionary string - Any: {'
+ local i = 1
+ for key, value in pairs(param) do
+ if i >= 2 then
+ message = message .. ", "
+ end
+ local value_type = type(value)
+ message = message .. "[" .. key .. "] = " .. get_tag_value_loop_up[value_type](value)
+ i = i + 1
+ end
+ message = message .. "}"
+ return message
end
-- Prints mouse button parameter.
local function get_mouse_button_param_message(log_prefix, param_name, param)
- return (log_prefix .. '"' .. param_name .. '" :: defines.mouse_button_type: ' .. tostring(param))
+ return (log_prefix .. '"' .. param_name .. '" :: defines.mouse_button_type: ' .. tostring(param))
end
-- Prints recipe parameter.
local function get_recipe_param_message(log_prefix, param_name, param)
- local message = log_prefix .. '"' .. param_name .. '" :: LuaRecipe: {name = ' .. param.name
- if not param.valid then
- message = message .. ", valid = false"
- end
- message = message .. "}"
- return message
+ local message = log_prefix .. '"' .. param_name .. '" :: LuaRecipe: {name = ' .. param.name
+ if not param.valid then
+ message = message .. ", valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- Prints inventory message.
local function get_inventory_param_message(log_prefix, param_name, param)
- local message = log_prefix .. '"' .. param_name .. '" :: LuaInventory: {'
- if param.valid then
- if param.index then
- message = message .. "index = " .. param.index .. ", "
- end
- message = message .. "# = " .. #param
- else
- message = message .. "valid = false"
- end
- message = message .. "}"
- return message
+ local message = log_prefix .. '"' .. param_name .. '" :: LuaInventory: {'
+ if param.valid then
+ if param.index then
+ message = message .. "index = " .. param.index .. ", "
+ end
+ message = message .. "# = " .. #param
+ else
+ message = message .. "valid = false"
+ end
+ message = message .. "}"
+ return message
end
-- The look up table for getting the messages for event parameters according to the parameter name.
local event_param_message_look_up = {
- -- Don't print for "name" and "tick"
- ["name"] = get_empty_message,
- ["tick"] = get_empty_message,
- ["player_index"] = get_uint_param_message,
- ["entity"] = get_entity_param_message,
- ["mapping"] = get_table_param_message,
- ["area"] = get_boundingbox_param_message,
- ["surface"] = get_surface_param_message,
- ["message"] = get_string_param_message,
- ["command"] = get_string_param_message,
- ["parameters"] = get_string_param_message,
- ["force"] = get_force_param_message,
- ["element"] = get_guielement_param_message,
- ["stack"] = get_simpleitemstack_param_message,
- ["item_stack"] = get_simpleitemstack_param_message,
- ["target"] = get_prototype_param_message,
- ["item-table"] = get_prototype_param_message,
- ["item-string"] = get_string_param_message,
- ["entities"] = get_entity_array_param_message,
- ["tiles"] = get_tile_array_param_message,
- ["positions"] = get_position_array_param_message,
- ["surface_index"] = get_uint_param_message,
- ["grid"] = get_equipmentgrid_param_message,
- ["count"] = get_uint_param_message,
- ["position"] = get_position_param_message,
- ["research"] = get_technology_param_message,
- ["robot"] = get_entity_param_message,
- ["rocket"] = get_entity_param_message,
- ["radar"] = get_entity_param_message,
- ["chunk_position"] = get_position_param_message,
- ["train"] = get_train_param_message,
- ["tags"] = get_tags_param_message,
- ["old_recipe_difficulty"] = get_uint_param_message,
- ["old_technology_difficulty"] = get_uint_param_message,
- ["cause"] = get_entity_param_message,
- ["by_script"] = get_boolean_param_message,
- ["old_name"] = get_string_param_message,
- ["button"] = get_mouse_button_param_message,
- ["alt"] = get_boolean_param_message,
- ["control"] = get_boolean_param_message,
- ["shift"] = get_boolean_param_message,
- ["market"] = get_entity_param_message,
- ["offer_index"] = get_uint_param_message,
- ["recipe"] = get_recipe_param_message,
- ["buffer"] = get_inventory_param_message,
- ["setting"] = get_string_param_message,
- ["last_entity"] = get_entity_param_message,
- ["rocket_silo"] = get_entity_param_message,
+ -- Don't print for "name" and "tick"
+ ["name"] = get_empty_message,
+ ["tick"] = get_empty_message,
+ ["player_index"] = get_uint_param_message,
+ ["entity"] = get_entity_param_message,
+ ["mapping"] = get_table_param_message,
+ ["area"] = get_boundingbox_param_message,
+ ["surface"] = get_surface_param_message,
+ ["message"] = get_string_param_message,
+ ["command"] = get_string_param_message,
+ ["parameters"] = get_string_param_message,
+ ["force"] = get_force_param_message,
+ ["element"] = get_guielement_param_message,
+ ["stack"] = get_simpleitemstack_param_message,
+ ["item_stack"] = get_simpleitemstack_param_message,
+ ["target"] = get_prototype_param_message,
+ ["item-table"] = get_prototype_param_message,
+ ["item-string"] = get_string_param_message,
+ ["entities"] = get_entity_array_param_message,
+ ["tiles"] = get_tile_array_param_message,
+ ["positions"] = get_position_array_param_message,
+ ["surface_index"] = get_uint_param_message,
+ ["grid"] = get_equipmentgrid_param_message,
+ ["count"] = get_uint_param_message,
+ ["position"] = get_position_param_message,
+ ["research"] = get_technology_param_message,
+ ["robot"] = get_entity_param_message,
+ ["rocket"] = get_entity_param_message,
+ ["radar"] = get_entity_param_message,
+ ["chunk_position"] = get_position_param_message,
+ ["train"] = get_train_param_message,
+ ["tags"] = get_tags_param_message,
+ ["old_recipe_difficulty"] = get_uint_param_message,
+ ["old_technology_difficulty"] = get_uint_param_message,
+ ["cause"] = get_entity_param_message,
+ ["by_script"] = get_boolean_param_message,
+ ["old_name"] = get_string_param_message,
+ ["button"] = get_mouse_button_param_message,
+ ["alt"] = get_boolean_param_message,
+ ["control"] = get_boolean_param_message,
+ ["shift"] = get_boolean_param_message,
+ ["market"] = get_entity_param_message,
+ ["offer_index"] = get_uint_param_message,
+ ["recipe"] = get_recipe_param_message,
+ ["buffer"] = get_inventory_param_message,
+ ["setting"] = get_string_param_message,
+ ["last_entity"] = get_entity_param_message,
+ ["rocket_silo"] = get_entity_param_message,
}
-- Additional look up table for getting the messages for event parameters according to the parameter name and also the event ID.
-- Because some events use the same parameter name. That's why we need another look up table for separating them.
local repeated_event_param_message_look_up = {
- [defines.events.on_entity_settings_pasted] = {
- ["source"] = get_entity_param_message,
- ["destination"] = get_entity_param_message,
- },
- [defines.events.on_forces_merging] = {
- ["source"] = get_force_param_message,
- ["destination"] = get_force_param_message,
- },
- [defines.events.on_pre_entity_settings_pasted] = {
- ["source"] = get_entity_param_message,
- ["destination"] = get_entity_param_message,
- },
- [defines.events.on_player_placed_equipment] = {
- ["equipment"] = get_equipment_param_message,
- },
- [defines.events.on_player_removed_equipment] = {
- ["equipment"] = get_string_param_message,
- },
+ [defines.events.on_entity_settings_pasted] = {
+ ["source"] = get_entity_param_message,
+ ["destination"] = get_entity_param_message,
+ },
+ [defines.events.on_forces_merging] = {
+ ["source"] = get_force_param_message,
+ ["destination"] = get_force_param_message,
+ },
+ [defines.events.on_pre_entity_settings_pasted] = {
+ ["source"] = get_entity_param_message,
+ ["destination"] = get_entity_param_message,
+ },
+ [defines.events.on_player_placed_equipment] = {
+ ["equipment"] = get_equipment_param_message,
+ },
+ [defines.events.on_player_removed_equipment] = {
+ ["equipment"] = get_string_param_message,
+ },
}
-- Prints undocumented boolean parameter.
local function get_undocumented_boolean_param_message(log_prefix, param_name, param, allow_localised_string)
- if allow_localised_string then
- return { "gui.creative-mode_undocumented-boolean", log_prefix, param_name, tostring(param) }
- end
- return (log_prefix .. '"' .. param_name .. '" (undocumented) :: boolean: ' .. tostring(param))
+ if allow_localised_string then
+ return { "gui.creative-mode_undocumented-boolean", log_prefix, param_name, tostring(param) }
+ end
+ return (log_prefix .. '"' .. param_name .. '" (undocumented) :: boolean: ' .. tostring(param))
end
-- Prints undocumented number parameter.
local function get_undocumented_number_param_message(log_prefix, param_name, param, allow_localised_string)
- if allow_localised_string then
- return { "gui.creative-mode_undocumented-number", log_prefix, param_name, param }
- end
- return (log_prefix .. '"' .. param_name .. '" (undocumented) :: number: ' .. param)
+ if allow_localised_string then
+ return { "gui.creative-mode_undocumented-number", log_prefix, param_name, param }
+ end
+ return (log_prefix .. '"' .. param_name .. '" (undocumented) :: number: ' .. param)
end
-- Prints undocumented string parameter.
local function get_undocumented_string_param_message(log_prefix, param_name, param, allow_localised_string)
- if allow_localised_string then
- return { "gui.creative-mode_undocumented-string", log_prefix, param_name, param }
- end
- return (log_prefix .. '"' .. param_name .. '" (undocumented) :: string: "' .. param .. '"')
+ if allow_localised_string then
+ return { "gui.creative-mode_undocumented-string", log_prefix, param_name, param }
+ end
+ return (log_prefix .. '"' .. param_name .. '" (undocumented) :: string: "' .. param .. '"')
end
-- Prints undocumented function parameter.
local function get_undocumented_function_param_message(log_prefix, param_name, param, allow_localised_string)
- if allow_localised_string then
- return { "gui.creative-mode_undocumented-function", log_prefix, param_name }
- end
- return (log_prefix .. '"' .. param_name .. '" (undocumented) :: function')
+ if allow_localised_string then
+ return { "gui.creative-mode_undocumented-function", log_prefix, param_name }
+ end
+ return (log_prefix .. '"' .. param_name .. '" (undocumented) :: function')
end
-- Prints undocumented table parameter.
local function get_undocumented_table_param_message(log_prefix, param_name, param, allow_localised_string)
- if allow_localised_string then
- return { "gui.creative-mode_undocumented-table", log_prefix, param_name }
- end
- return (log_prefix .. '"' .. param_name .. '" (undocumented) :: table')
+ if allow_localised_string then
+ return { "gui.creative-mode_undocumented-table", log_prefix, param_name }
+ end
+ return (log_prefix .. '"' .. param_name .. '" (undocumented) :: table')
end
-- Prints undocumented userdata parameter.
local function get_undocumented_userdata_param_message(log_prefix, param_name, param, allow_localised_string)
- if allow_localised_string then
- return { "gui.creative-mode_undocumented-userdata", log_prefix, param_name }
- end
- return (log_prefix .. '"' .. param_name .. '" (undocumented) :: userdata')
+ if allow_localised_string then
+ return { "gui.creative-mode_undocumented-userdata", log_prefix, param_name }
+ end
+ return (log_prefix .. '"' .. param_name .. '" (undocumented) :: userdata')
end
-- Prints undocumented thread parameter.
local function get_undocumented_thread_param_message(log_prefix, param_name, param, allow_localised_string)
- if allow_localised_string then
- return { "gui.creative-mode_undocumented-thread", log_prefix, param_name }
- end
- return (log_prefix .. '"' .. param_name .. '" (undocumented) :: thread')
+ if allow_localised_string then
+ return { "gui.creative-mode_undocumented-thread", log_prefix, param_name }
+ end
+ return (log_prefix .. '"' .. param_name .. '" (undocumented) :: thread')
end
-- Extra look up table for undocumented parameters according to their types.
local undocumented_event_param_message_loop_up = {
- ["boolean"] = get_undocumented_boolean_param_message,
- ["number"] = get_undocumented_number_param_message,
- ["string"] = get_undocumented_string_param_message,
- ["function"] = get_undocumented_function_param_message,
- ["userdata"] = get_undocumented_userdata_param_message,
- ["thread"] = get_undocumented_thread_param_message,
+ ["boolean"] = get_undocumented_boolean_param_message,
+ ["number"] = get_undocumented_number_param_message,
+ ["string"] = get_undocumented_string_param_message,
+ ["function"] = get_undocumented_function_param_message,
+ ["userdata"] = get_undocumented_userdata_param_message,
+ ["thread"] = get_undocumented_thread_param_message,
}
-- Look up table for quickly converting event IDs to event names.
local event_id_to_names_look_up = {}
for event_name, event_id in pairs(defines.events) do
- event_id_to_names_look_up[event_id] = event_name
+ event_id_to_names_look_up[event_id] = event_name
end
-- Creates the event name message according to the given event if the message has not been created yet.
-- Also returns the tick prefix. The prefix will be included in the message. It is for further message creation.
local function create_event_name_message_if_not_exist(event, tick_prefix, message)
- if message ~= nil then
- return tick_prefix, message
- end
+ if message ~= nil then
+ return tick_prefix, message
+ end
- local event_id = event.name
- local event_name = event_id_to_names_look_up[event_id]
- tick_prefix = "T" .. event.tick .. "\t\t"
- return tick_prefix, tick_prefix .. event_name .. " (ID " .. event_id .. ")"
+ local event_id = event.name
+ local event_name = event_id_to_names_look_up[event_id]
+ tick_prefix = "T" .. event.tick .. "\t\t"
+ return tick_prefix, tick_prefix .. event_name .. " (ID " .. event_id .. ")"
end
-- Returns the message for the given parameter with given name in the event of given ID.
-- If the message will be printed to console, allow_localised_string can be true; otherwise, if the returned message will be concatenated, it has to be false.
local function get_event_param_message(message_prefix, event_id, param_name, param, allow_localised_string)
- -- Check for the repeated event params look up table first.
- if
- repeated_event_param_message_look_up[event_id] and repeated_event_param_message_look_up[event_id][param_name]
- then
- return repeated_event_param_message_look_up[event_id][param_name](message_prefix, param_name, param)
- else
- -- Prepare param_name if there's multiple fits...
- if param_name == "item" then
- local param_type = type(param)
- if param_type == "table" then
- param_name = param_name .. "-table"
- elseif param_type == "string" then
- param_name = param_name .. "-string"
- end
- end
- -- Check for the normal event params look up table.
- if event_param_message_look_up[param_name] then
- return event_param_message_look_up[param_name](message_prefix, param_name, param)
- else
- -- Undocumated param. We will try to parse it anyway.
- local param_type = type(param)
- if undocumented_event_param_message_loop_up[param_type] then
- return undocumented_event_param_message_loop_up[param_type](
- message_prefix,
- param_name,
- param,
- allow_localised_string
- )
- end
- -- Unknown type.
- if allow_localised_string then
- return { "gui.creative-mode_undocumented-unknown-type", message_prefix, param_name, param_type }
- else
- return message_prefix .. '"' .. param_name .. '" (undocumented) = ' .. param_type .. " (unknown type)"
- end
- end
- end
+ -- Check for the repeated event params look up table first.
+ if repeated_event_param_message_look_up[event_id] and repeated_event_param_message_look_up[event_id][param_name] then
+ return repeated_event_param_message_look_up[event_id][param_name](message_prefix, param_name, param)
+ else
+ -- Prepare param_name if there's multiple fits...
+ if param_name == "item" then
+ local param_type = type(param)
+ if param_type == "table" then
+ param_name = param_name .. "-table"
+ elseif param_type == "string" then
+ param_name = param_name .. "-string"
+ end
+ end
+ -- Check for the normal event params look up table.
+ if event_param_message_look_up[param_name] then
+ return event_param_message_look_up[param_name](message_prefix, param_name, param)
+ else
+ -- Undocumated param. We will try to parse it anyway.
+ local param_type = type(param)
+ if undocumented_event_param_message_loop_up[param_type] then
+ return undocumented_event_param_message_loop_up[param_type](
+ message_prefix,
+ param_name,
+ param,
+ allow_localised_string
+ )
+ end
+ -- Unknown type.
+ if allow_localised_string then
+ return { "gui.creative-mode_undocumented-unknown-type", message_prefix, param_name, param_type }
+ else
+ return message_prefix .. '"' .. param_name .. '" (undocumented) = ' .. param_type .. " (unknown type)"
+ end
+ end
+ end
end
-- The file name for writing event logs into txt file.
@@ -1284,154 +1275,148 @@ local event_write_file_path = nil
-- Returns the file path for writing events for this section.
-- Due to limitation on the API, it is impossible to read system time. To separate logs between different sections, a separator will be added.
local function get_event_write_file_path(player)
- if not event_write_file_path then
- event_write_file_path = events.event_write_file_name
- helpers.write_file(
- event_write_file_path,
- "-------------------------------------------------\n",
- true,
- player.index
- )
- end
- return event_write_file_path
+ if not event_write_file_path then
+ event_write_file_path = events.event_write_file_name
+ helpers.write_file(event_write_file_path, "-------------------------------------------------\n", true, player.index)
+ end
+ return event_write_file_path
end
-- Writes or logs the given event according to the given data.
-- Returns the tick_prefix, name_message, param_message_prefix and full_write_or_log_message so they can be reused.
local function write_or_log_events(
- player,
- is_write,
- also_apply_to_params,
- event_id,
- event,
- tick_prefix,
- name_message,
- param_message_prefix,
- full_write_or_log_message
+ player,
+ is_write,
+ also_apply_to_params,
+ event_id,
+ event,
+ tick_prefix,
+ name_message,
+ param_message_prefix,
+ full_write_or_log_message
)
- local final_message
- -- Log the tick followed by the event name.
- tick_prefix, name_message = create_event_name_message_if_not_exist(event, tick_prefix, name_message)
-
- -- Append the parameters if necessary.
- if also_apply_to_params then
- -- Create the full log message only if it does not exist.
- if not full_write_or_log_message then
- full_write_or_log_message = name_message
- if not param_message_prefix then
- param_message_prefix = tick_prefix .. "(ID " .. event_id .. ")\t"
- end
- for param_name, param in pairs(event) do
- local message = get_event_param_message(param_message_prefix, event_id, param_name, param, false)
- if message then
- full_write_or_log_message = full_write_or_log_message .. "\n" .. message
- end
- end
- end
-
- -- Append the full message.
- final_message = full_write_or_log_message
- else
- -- Only append the event name.
- final_message = name_message
- end
-
- if is_write then
- -- Write.
- helpers.write_file(get_event_write_file_path(player), final_message .. "\n", true, player.index)
- else
- -- Log.
- log(final_message)
- end
-
- return tick_prefix, name_message, param_message_prefix, full_store_or_log_message
+ local final_message
+ -- Log the tick followed by the event name.
+ tick_prefix, name_message = create_event_name_message_if_not_exist(event, tick_prefix, name_message)
+
+ -- Append the parameters if necessary.
+ if also_apply_to_params then
+ -- Create the full log message only if it does not exist.
+ if not full_write_or_log_message then
+ full_write_or_log_message = name_message
+ if not param_message_prefix then
+ param_message_prefix = tick_prefix .. "(ID " .. event_id .. ")\t"
+ end
+ for param_name, param in pairs(event) do
+ local message = get_event_param_message(param_message_prefix, event_id, param_name, param, false)
+ if message then
+ full_write_or_log_message = full_write_or_log_message .. "\n" .. message
+ end
+ end
+ end
+
+ -- Append the full message.
+ final_message = full_write_or_log_message
+ else
+ -- Only append the event name.
+ final_message = name_message
+ end
+
+ if is_write then
+ -- Write.
+ helpers.write_file(get_event_write_file_path(player), final_message .. "\n", true, player.index)
+ else
+ -- Log.
+ log(final_message)
+ end
+
+ return tick_prefix, name_message, param_message_prefix, full_store_or_log_message
end
-- Generic event handler. All events, except on_tick, will be handled here.
function events.on_event(event)
- -- Note: event.name is acutally the event ID.
- local event_id = event.name
-
- -- Print or log the event if necessary.
- -- Create the messages only once.
- local tick_prefix = nil
- local name_message = nil
- local param_message_prefix = nil
- local full_write_or_log_message = nil
- if storage.creative_mode and storage.creative_mode.selected_events and game.players then
- for _, player in pairs(game.connected_players) do
- local selected_events = storage.creative_mode.selected_events[player.index]
- if selected_events and selected_events[event_id] then
- -- Print event.
- if storage.creative_mode.print_events[player.index] ~= false then
- -- Print the tick followed by the event name.
- tick_prefix, name_message = create_event_name_message_if_not_exist(event, tick_prefix, name_message)
- player.print(name_message)
-
- -- Print parameters.
- if storage.creative_mode.also_print_event_params[player.index] ~= false then
- if not param_message_prefix then
- param_message_prefix = tick_prefix .. "(ID " .. event_id .. ")\t"
- end
- for param_name, param in pairs(event) do
- local message =
- get_event_param_message(param_message_prefix, event_id, param_name, param, true)
- if message then
- player.print(message)
- end
- end
- end
- end
-
- -- Write events.
- if storage.creative_mode.write_events[player.index] then
- tick_prefix, name_message, param_message_prefix, full_write_or_log_message = write_or_log_events(
- player,
- true,
- storage.creative_mode.also_write_event_params[player.index] ~= false,
- event_id,
- event,
- tick_prefix,
- name_message,
- param_message_prefix,
- full_write_or_log_message
- )
- end
-
- -- Log events.
- if storage.creative_mode.log_events[player.index] then
- tick_prefix, name_message, param_message_prefix, full_write_or_log_message = write_or_log_events(
- player,
- false,
- storage.creative_mode.also_log_event_params[player.index] ~= false,
- event_id,
- event,
- tick_prefix,
- name_message,
- param_message_prefix,
- full_write_or_log_message
- )
- end
- end
- end
- end
-
- -- Forward the event to the corresponding handler.
- if event_handlers_look_up[event_id] then
- event_handlers_look_up[event_id](event)
- end
+ -- Note: event.name is acutally the event ID.
+ local event_id = event.name
+
+ -- Print or log the event if necessary.
+ -- Create the messages only once.
+ local tick_prefix = nil
+ local name_message = nil
+ local param_message_prefix = nil
+ local full_write_or_log_message = nil
+ if storage.creative_mode and storage.creative_mode.selected_events and game.players then
+ for _, player in pairs(game.connected_players) do
+ local selected_events = storage.creative_mode.selected_events[player.index]
+ if selected_events and selected_events[event_id] then
+ -- Print event.
+ if storage.creative_mode.print_events[player.index] ~= false then
+ -- Print the tick followed by the event name.
+ tick_prefix, name_message = create_event_name_message_if_not_exist(event, tick_prefix, name_message)
+ player.print(name_message)
+
+ -- Print parameters.
+ if storage.creative_mode.also_print_event_params[player.index] ~= false then
+ if not param_message_prefix then
+ param_message_prefix = tick_prefix .. "(ID " .. event_id .. ")\t"
+ end
+ for param_name, param in pairs(event) do
+ local message = get_event_param_message(param_message_prefix, event_id, param_name, param, true)
+ if message then
+ player.print(message)
+ end
+ end
+ end
+ end
+
+ -- Write events.
+ if storage.creative_mode.write_events[player.index] then
+ tick_prefix, name_message, param_message_prefix, full_write_or_log_message = write_or_log_events(
+ player,
+ true,
+ storage.creative_mode.also_write_event_params[player.index] ~= false,
+ event_id,
+ event,
+ tick_prefix,
+ name_message,
+ param_message_prefix,
+ full_write_or_log_message
+ )
+ end
+
+ -- Log events.
+ if storage.creative_mode.log_events[player.index] then
+ tick_prefix, name_message, param_message_prefix, full_write_or_log_message = write_or_log_events(
+ player,
+ false,
+ storage.creative_mode.also_log_event_params[player.index] ~= false,
+ event_id,
+ event,
+ tick_prefix,
+ name_message,
+ param_message_prefix,
+ full_write_or_log_message
+ )
+ end
+ end
+ end
+ end
+
+ -- Forward the event to the corresponding handler.
+ if event_handlers_look_up[event_id] then
+ event_handlers_look_up[event_id](event)
+ end
end
require("instant_cheats")
function events.on_entity_logistic_slot_changed(data)
-handle_entity_logistic_slot_changed(data)
+ handle_entity_logistic_slot_changed(data)
end
function events.on_player_main_inventory_changed(data)
- handle_player_main_inventory_changed(data)
+ handle_player_main_inventory_changed(data)
end
function events.on_player_trash_inventory_changed(data)
- handle_player_trash_inventory_changed(data)
+ handle_player_trash_inventory_changed(data)
end
diff --git a/scripts/fluid-providers-util.lua b/scripts/fluid-providers-util.lua
index e975c22..60a8418 100644
--- a/scripts/fluid-providers-util.lua
+++ b/scripts/fluid-providers-util.lua
@@ -1,59 +1,59 @@
-- This file contains variables or functions that are common for our fluid provider entities and specific for this mod.
if not fluid_providers_util then
- fluid_providers_util = {}
+ fluid_providers_util = {}
end
-- Removes all fluids inside the given entity.
function fluid_providers_util.remove_all_fluids(entity)
- for i = 1, #entity.fluidbox, 1 do
- entity.fluidbox[i] = nil
- end
+ for i = 1, #entity.fluidbox, 1 do
+ entity.fluidbox[i] = nil
+ end
end
-- Duplicates the fluid in each fluid box of the given entity.
function fluid_providers_util.duplicate_fluid_in_each_fluidbox(entity)
- local fluidbox = entity.fluidbox
- for i = 1, #fluidbox, 1 do
- local fluid = fluidbox[i]
- local capacity = fluidbox.get_capacity(i)
- if fluid ~= nil then
- fluid.amount = math.min(capacity, fluid.amount + 50)
- entity.fluidbox[i] = fluid
- end
- end
+ local fluidbox = entity.fluidbox
+ for i = 1, #fluidbox, 1 do
+ local fluid = fluidbox[i]
+ local capacity = fluidbox.get_capacity(i)
+ if fluid ~= nil then
+ fluid.amount = math.min(capacity, fluid.amount + 50)
+ entity.fluidbox[i] = fluid
+ end
+ end
end
-- Heats all fluids inside the given entity up to their corresponding maximum temperature.
function fluid_providers_util.heat_all_fluids_up_to_max_temperature(entity)
- for i = 1, #entity.fluidbox, 1 do
- local fluid = entity.fluidbox[i]
- if fluid then
- local fluid_prototype = prototypes.fluid[fluid.name]
- fluid.temperature = fluid_prototype.max_temperature
- entity.fluidbox[i] = fluid
- end
- end
+ for i = 1, #entity.fluidbox, 1 do
+ local fluid = entity.fluidbox[i]
+ if fluid then
+ local fluid_prototype = prototypes.fluid[fluid.name]
+ fluid.temperature = fluid_prototype.max_temperature
+ entity.fluidbox[i] = fluid
+ end
+ end
end
-- Cools all fluids inside the given entity down to their corresponding default temperature.
function fluid_providers_util.cool_all_fluids_down_to_default_temperature(entity)
- for i = 1, #entity.fluidbox, 1 do
- local fluid = entity.fluidbox[i]
- if fluid then
- local fluid_prototype = prototypes.fluid[fluid.name]
- fluid.temperature = fluid_prototype.default_temperature
- entity.fluidbox[i] = fluid
- end
- end
+ for i = 1, #entity.fluidbox, 1 do
+ local fluid = entity.fluidbox[i]
+ if fluid then
+ local fluid_prototype = prototypes.fluid[fluid.name]
+ fluid.temperature = fluid_prototype.default_temperature
+ entity.fluidbox[i] = fluid
+ end
+ end
end
-- Sets all fluids inside the given entity to the given temperature.
function fluid_providers_util.set_all_fluids_to_temperature(entity, temperature)
- for i = 1, #entity.fluidbox, 1 do
- local fluid = entity.fluidbox[i]
- if fluid then
- fluid.temperature = temperature
- entity.fluidbox[i] = fluid
- end
- end
+ for i = 1, #entity.fluidbox, 1 do
+ local fluid = entity.fluidbox[i]
+ if fluid then
+ fluid.temperature = temperature
+ entity.fluidbox[i] = fluid
+ end
+ end
end
diff --git a/scripts/fluid-void.lua b/scripts/fluid-void.lua
index d34374d..0848d0b 100644
--- a/scripts/fluid-void.lua
+++ b/scripts/fluid-void.lua
@@ -1,20 +1,20 @@
-- This files contains variables and functions that are related to the Fluid Void in this mod.
if not fluid_void then
- fluid_void = {}
+ fluid_void = {}
end
-- Processes the fluid_void table in storage.
function fluid_void.tick()
- -- Loop through the table of fluid-void to nullify the fluid inside its fluid box.
- for index, fluid_void in ipairs(storage.creative_mode.fluid_void) do
- if fluid_void.valid then
- if not fluid_void.to_be_deconstructed(fluid_void.force) then
- for i = 1, #fluid_void.fluidbox do
- fluid_void.fluidbox[i] = nil
- end
- end
- else
- table.remove(storage.creative_mode.fluid_void, index)
- end
- end
+ -- Loop through the table of fluid-void to nullify the fluid inside its fluid box.
+ for index, fluid_void in ipairs(storage.creative_mode.fluid_void) do
+ if fluid_void.valid then
+ if not fluid_void.to_be_deconstructed(fluid_void.force) then
+ for i = 1, #fluid_void.fluidbox do
+ fluid_void.fluidbox[i] = nil
+ end
+ end
+ else
+ table.remove(storage.creative_mode.fluid_void, index)
+ end
+ end
end
diff --git a/scripts/global-util.lua b/scripts/global-util.lua
index eafa1f3..8b78f49 100644
--- a/scripts/global-util.lua
+++ b/scripts/global-util.lua
@@ -1,808 +1,820 @@
--- This file contains functions to initialize and update the global meta-table used by this mod.
-if not global_util then
- global_util = {}
-end
-
--- Initializes the necessary meta-table if it doesn't exist yet. This is called for new games or existing games when the version of this mod has changed.
-function global_util.initialize_or_update_global()
- -- Generate table for storing data that will be used later.
- if not storage.creative_mode then
- storage.creative_mode = {}
- -- Store whether creative mode has been enabled.
- storage.creative_mode.enabled = false
- -- Whether the popup of asking for enabling Creative Mode has been shown.
- storage.creative_mode.has_asked_for_enable = false
- else
- if storage.creative_mode.enabled then
- storage.creative_mode.has_asked_for_enable = true
- end
- end
- -- Also generate the sub-tables to store our entities.
- if not storage.creative_mode.new_creative_chests then
- storage.creative_mode.new_creative_chests = {}
- end
- if not storage.creative_mode.creative_chest_next_group then
- storage.creative_mode.creative_chest_next_group = 1
- end -- The group number for the next placed creative chest. (Number of items in each group <= Chest inventory size)
- if not storage.creative_mode.new_creative_provider_chests then
- storage.creative_mode.new_creative_provider_chests = {}
- end
- if not storage.creative_mode.creative_provider_chest_next_group then
- storage.creative_mode.creative_provider_chest_next_group = 1
- end
- if not storage.creative_mode.autofill_requester_chest then
- storage.creative_mode.autofill_requester_chest = {}
- end
- if not storage.creative_mode.autofill_requester_chest_next_update_index then
- storage.creative_mode.autofill_requester_chest_next_update_index = 1
- end
- if not storage.creative_mode.duplicating_chest_data then
- storage.creative_mode.duplicating_chest_data = {}
- end
- if not storage.creative_mode.duplicating_chest_next_update_index then
- storage.creative_mode.duplicating_chest_next_update_index = 1
- end
- if not storage.creative_mode.duplicating_provider_chest_data then
- storage.creative_mode.duplicating_provider_chest_data = {}
- end
- if not storage.creative_mode.duplicating_provider_chest_next_update_index then
- storage.creative_mode.duplicating_provider_chest_next_update_index = 1
- end
- if not storage.creative_mode.void_lab then
- storage.creative_mode.void_lab = {}
- end
- if not storage.creative_mode.void_lab_next_update_index then
- storage.creative_mode.void_lab_next_update_index = 1
- end
- if not storage.creative_mode.creative_cargo_wagon_data_groups then
- storage.creative_mode.creative_cargo_wagon_data_groups = {}
- end
- if not storage.creative_mode.creative_cargo_wagon_next_group then
- storage.creative_mode.creative_cargo_wagon_next_group = 1
- end
- if not storage.creative_mode.duplicating_cargo_wagon_data then
- storage.creative_mode.duplicating_cargo_wagon_data = {}
- end
- if not storage.creative_mode.duplicating_cargo_wagon_next_update_index then
- storage.creative_mode.duplicating_cargo_wagon_next_update_index = 1
- end
- if not storage.creative_mode.void_cargo_wagon then
- storage.creative_mode.void_cargo_wagon = {}
- end
- if not storage.creative_mode.void_cargo_wagon_next_update_index then
- storage.creative_mode.void_cargo_wagon_next_update_index = 1
- end
- if not storage.creative_mode.fluid_void then
- storage.creative_mode.fluid_void = {}
- end
- if not storage.creative_mode.super_boiler then
- storage.creative_mode.super_boiler = {}
- end
- if not storage.creative_mode.super_cooler then
- storage.creative_mode.super_cooler = {}
- end
- if not storage.creative_mode.configurable_super_boiler_data then
- storage.creative_mode.configurable_super_boiler_data = {}
- end
- if not storage.creative_mode.item_source_data then
- storage.creative_mode.item_source_data = {}
- end
- if not storage.creative_mode.duplicator_data then
- storage.creative_mode.duplicator_data = {}
- end
- if not storage.creative_mode.item_void_data then
- storage.creative_mode.item_void_data = {}
- end
- if not storage.creative_mode.random_item_source_data then
- storage.creative_mode.random_item_source_data = {}
- end
- if not storage.creative_mode.creative_lab then
- storage.creative_mode.creative_lab = {}
- end
- if not storage.creative_mode.creative_lab_next_update_index then
- storage.creative_mode.creative_lab_next_update_index = 1
- end
-
- -- Table for storing the equipments that need to be refilled with energy.
- if not storage.energy_refill_equipments then
- storage.energy_refill_equipments = {}
- end
-
- -- Table for storing which entity each player has opened.
- if not storage.creative_mode.player_opened_entities then
- storage.creative_mode.player_opened_entities = {}
- end
- -- Table for storing whether the entity GUI is opened.
- if not storage.creative_mode.player_opened_entity_gui then
- storage.creative_mode.player_opened_entity_gui = {}
- end
-
- -- Update: item_void -> item_void_data (since v0.1.1)
- if storage.creative_mode.item_void then
- for _, item_void in ipairs(storage.creative_mode.item_void) do
- -- Re-register the entities again to move them into the new table.
- global_util.register_entity(item_void)
- end
- storage.creative_mode.item_void = nil
- end
-
- -- Update: creative_provider_chest_groups -> creative_provider_chest_data_groups (since v0.1.2)
- if storage.creative_mode.creative_provider_chest_groups then
- for index, groups in ipairs(storage.creative_mode.creative_provider_chest_groups) do
- -- Can't simply re-register in this case because the chests are divided into groups.
- if not storage.creative_mode.creative_provider_chest_data_groups[index] then
- storage.creative_mode.creative_provider_chest_data_groups[index] = {}
- end
- for index2, chest in ipairs(groups) do
- table.insert(storage.creative_mode.creative_provider_chest_data_groups[index], {
- entity = chest,
- filtered_slots = {}
- })
- end
- end
- storage.creative_mode.creative_provider_chest_groups = nil
- end
-
- -- Whether Creative Mode has been permanently disabled.
- if not storage.creative_mode.permanently_disabled then
- storage.creative_mode.permanently_disabled = false
- end
-
- -- Player rights.existence determinator
- if not storage.creative_mode.player_rights then
- storage.creative_mode.player_rights = {}
- end
- -- Right for enabling/disabling personal cheats.
- if storage.creative_mode.player_rights.access_personal_cheats == nil then
- storage.creative_mode.player_rights.access_personal_cheats = rights.default_access_personal_cheats_level
- end
- -- Right for enabling/disabling team cheats.
- if storage.creative_mode.player_rights.access_team_cheats == nil then
- storage.creative_mode.player_rights.access_team_cheats = rights.default_access_team_cheats_level
- end
- -- Right for enabling/disabling surface cheats.
- if storage.creative_mode.player_rights.access_surface_cheats == nil then
- storage.creative_mode.player_rights.access_surface_cheats = rights.default_access_surface_cheats_level
- end
- -- Right for enabling/disabling global cheats.
- if storage.creative_mode.player_rights.access_global_cheats == nil then
- storage.creative_mode.player_rights.access_global_cheats = rights.default_access_global_cheats_level
- end
- -- Right for changing build options.
- if storage.creative_mode.player_rights.access_build_options == nil then
- storage.creative_mode.player_rights.access_build_options = rights.default_access_build_options_level
- end
- -- Right for using the Creator Magic Wand. (True = all players can use; false = only admins can use)
- if storage.creative_mode.player_rights.use_creator_magic_wand == nil then
- storage.creative_mode.player_rights.use_creator_magic_wand = rights.default_use_creator_magic_wand
- end
- -- Right for using the Healer Magic Wand.
- if storage.creative_mode.player_rights.use_healer_magic_wand == nil then
- storage.creative_mode.player_rights.use_healer_magic_wand = rights.default_use_healer_magic_wand
- end
- -- Right for using the Modifier Magic Wand.
- if storage.creative_mode.player_rights.use_modifier_magic_wand == nil then
- storage.creative_mode.player_rights.use_modifier_magic_wand = rights.default_use_modifier_magic_wand
- end
- -- Right for accessing modding menu. (True = all players can access; false = only admins can access)
- if storage.creative_mode.player_rights.access_modding_menu == nil then
- storage.creative_mode.player_rights.access_modding_menu = rights.default_access_modding_menu
- end
-
- -- Table of personal cheats for each player.
- if not storage.creative_mode.personal_cheats then
- storage.creative_mode.personal_cheats = {}
- end
- -- Cheat mode.
- if not storage.creative_mode.personal_cheats.cheat_mode then
- storage.creative_mode.personal_cheats.cheat_mode = {}
- end
- -- Invincible player.
- if not storage.creative_mode.personal_cheats.invincible_player then
- storage.creative_mode.personal_cheats.invincible_player = {}
- end
- -- Keep last item.
- if not storage.creative_mode.personal_cheats.keep_last_item then
- storage.creative_mode.personal_cheats.keep_last_item = {}
- end
- -- Repair mined item.
- if not storage.creative_mode.personal_cheats.repair_mined_item then
- storage.creative_mode.personal_cheats.repair_mined_item = {}
- end
- -- Whether the cursor stack of each player has been restored after the player has put item to build something.
- -- We need to verify whether the built "something" is actually a ghost i.e. no item is spent, no need to restore.
- if not storage.creative_mode.personal_cheats.has_restored_cursor_stack then
- storage.creative_mode.personal_cheats.has_restored_cursor_stack = {}
- end
- -- Instant request.
- if not storage.creative_mode.personal_cheats.instant_request then
- storage.creative_mode.personal_cheats.instant_request = {}
- end
- -- Instant request: to minimize the impact to performance when there are many players in the game with many logistic request slots, we limited the maximum number of slots to be checked in each tick.
- -- The next player to be checked. It is ensure to be 1 even if it already exists in loaded save, because we don't want infinite loop in the get player function if someone loaded a multiplayer game that previously had many players.
- storage.creative_mode.personal_cheats.instant_request_next_player_index = 1
- -- The next slot to be checked in that player.
- if not storage.creative_mode.personal_cheats.instant_request_next_player_slot_index then
- storage.creative_mode.personal_cheats.instant_request_next_player_slot_index = 1
- end
- -- Instant trash.
- if not storage.creative_mode.personal_cheats.instant_trash then
- storage.creative_mode.personal_cheats.instant_trash = {}
- end
- -- Instant trash: number of players to be updated in each tick is limited.
- storage.creative_mode.personal_cheats.instant_trash_next_player_index = 1
- -- Instant blueprint.
- if not storage.creative_mode.personal_cheats.instant_blueprint then
- storage.creative_mode.personal_cheats.instant_blueprint = {}
- end
- -- Instant deconstruction.
- if not storage.creative_mode.personal_cheats.instant_deconstruction then
- storage.creative_mode.personal_cheats.instant_deconstruction = {}
- end
- -- Reach distance.
- if not storage.creative_mode.personal_cheats.reach_distance then
- storage.creative_mode.personal_cheats.reach_distance = {}
- end
- -- Build distance.
- if not storage.creative_mode.personal_cheats.build_distance then
- storage.creative_mode.personal_cheats.build_distance = {}
- end
- -- Resource reach distance.
- if not storage.creative_mode.personal_cheats.resource_reach_distance then
- storage.creative_mode.personal_cheats.resource_reach_distance = {}
- end
- -- Item drop distance.
- if not storage.creative_mode.personal_cheats.item_drop_distance then
- storage.creative_mode.personal_cheats.item_drop_distance = {}
- end
- -- Item pickup distance.
- if not storage.creative_mode.personal_cheats.item_pickup_distance then
- storage.creative_mode.personal_cheats.item_pickup_distance = {}
- end
- -- Loot pickup distance.
- if not storage.creative_mode.personal_cheats.loot_pickup_distance then
- storage.creative_mode.personal_cheats.loot_pickup_distance = {}
- end
- -- Mining speed.
- if not storage.creative_mode.personal_cheats.mining_speed then
- storage.creative_mode.personal_cheats.mining_speed = {}
- end
- -- Running speed.
- if not storage.creative_mode.personal_cheats.running_speed then
- storage.creative_mode.personal_cheats.running_speed = {}
- end
- -- Crafting speed.
- if not storage.creative_mode.personal_cheats.crafting_speed then
- storage.creative_mode.personal_cheats.crafting_speed = {}
- end
- -- Inventory bonus.
- if not storage.creative_mode.personal_cheats.inventory_bonus then
- storage.creative_mode.personal_cheats.inventory_bonus = {}
- end
- -- Quickbar bonus.
- if not storage.creative_mode.personal_cheats.quickbar_bonus then
- storage.creative_mode.personal_cheats.quickbar_bonus = {}
- end
- -- Health bonus.
- if not storage.creative_mode.personal_cheats.health_bonus then
- storage.creative_mode.personal_cheats.health_bonus = {}
- end
- -- God mode : list of characters that were previously characters of players before god mode was enabled.
- if not storage.creative_mode.personal_cheats.god_mode_character then
- storage.creative_mode.personal_cheats.god_mode_character = {}
- end
-
- -- Table of team cheats for each team.
- if not storage.creative_mode.team_cheats then
- storage.creative_mode.team_cheats = {}
- end
- -- Instant research.
- if not storage.creative_mode.team_cheats.instant_research then
- storage.creative_mode.team_cheats.instant_research = {}
- end
-
- -- Table of surface cheats for each surface.
- if not storage.creative_mode.surface_cheats then
- storage.creative_mode.surface_cheats = {}
- end
- -- Don't generate enemy.
- if not storage.creative_mode.surface_cheats.dont_generate_enemy then
- storage.creative_mode.surface_cheats.dont_generate_enemy = {}
- end
-
- -- Table of build options for each player.
- if not storage.creative_mode.build_options then
- storage.creative_mode.build_options = {}
- end
- -- Active.
- if not storage.creative_mode.build_options.active then
- storage.creative_mode.build_options.active = {}
- end
- -- Destructible.
- if not storage.creative_mode.build_options.destructible then
- storage.creative_mode.build_options.destructible = {}
- end
- -- Minable.
- if not storage.creative_mode.build_options.minable then
- storage.creative_mode.build_options.minable = {}
- end
- -- Rotatable.
- if not storage.creative_mode.build_options.rotatable then
- storage.creative_mode.build_options.rotatable = {}
- end
- -- Operable.
- if not storage.creative_mode.build_options.operable then
- storage.creative_mode.build_options.operable = {}
- end
- -- Full health.
- if not storage.creative_mode.build_options.full_health then
- storage.creative_mode.build_options.full_health = {}
- end
- -- Team (force name).
- if not storage.creative_mode.build_options.team then
- storage.creative_mode.build_options.team = {}
- end
-
- -- Table of magic wand settings for each player.
- if not storage.creative_mode.magic_wand_settings then
- storage.creative_mode.magic_wand_settings = {}
- end
- -- Creator.
- if not storage.creative_mode.magic_wand_settings.creator then
- storage.creative_mode.magic_wand_settings.creator = {}
- end
- -- Healer.
- if not storage.creative_mode.magic_wand_settings.healer then
- storage.creative_mode.magic_wand_settings.healer = {}
- end
- -- Modifier.
- if not storage.creative_mode.magic_wand_settings.modifier then
- storage.creative_mode.magic_wand_settings.modifier = {}
- end
- -- Modifier - selected entities.
- if not storage.creative_mode.modifier_magic_wand_selection then
- storage.creative_mode.modifier_magic_wand_selection = {}
- end
- -- Modifier - quick actions.
- if not storage.creative_mode.modifier_magic_wand_quick_actions then
- storage.creative_mode.modifier_magic_wand_quick_actions = {}
- end
-
- -- Unused. Previously it is used for global instant blueprint and instant deconstruction (before v0.2.0)
- if storage.creative_mode.cheats then
- storage.creative_mode.cheats = nil
- end
-
- -- List of ghost entities that are pending to be revived.
- -- A 1-tick delay is used for better compatilibty of other mods. This can also solve the problem that when shift-place a blueprint, the ghosts that collide with trees do not get revived even though the trees are removed by instant-deconstruction.
- if not storage.creative_mode.pending_instant_blueprint then
- storage.creative_mode.pending_instant_blueprint = {}
- end
-
- -- List of entities that are pending to be deconstructed.
- -- A 1-tick delay is used before we really destroy the entities. It is used to encounter mods like Filtered Deconstruction Planner which unmark filtered entities right after they are marked.
- if not storage.creative_mode.pending_instant_deconstruction then
- storage.creative_mode.pending_instant_deconstruction = {}
- end
-
- -- List of areas on surfaces for removing enemies.
- -- Because the on_chunk_generated event is invoked after enemy is generated (due to RSO?), we have to use a 1-tick delay to remove the enemies.
- if not storage.creative_mode.pending_areas_to_remove_enemies then
- storage.creative_mode.pending_areas_to_remove_enemies = {}
- end
-
- -- Table of events selected by each player.
- if not storage.creative_mode.selected_events then
- storage.creative_mode.selected_events = {}
- end
- -- Table of Booleans, for whether the selected events should be printed in each player's console.
- if not storage.creative_mode.print_events then
- storage.creative_mode.print_events = {}
- end
- -- Table of Booleans, for whether the parameters of the events should also be printed.
- if not storage.creative_mode.also_print_event_params then
- storage.creative_mode.also_print_event_params = {}
- end
- -- Table of Booleans, for whether the selected events should be written in each player's file system as txt files.
- if not storage.creative_mode.write_events then
- storage.creative_mode.write_events = {}
- end
- -- Table of Booleans, for whether the parameters of the events should also be written.
- if not storage.creative_mode.also_write_event_params then
- storage.creative_mode.also_write_event_params = {}
- end
- -- Table of Booleans, for whether the selected events should be logged in each player's file system as log files.
- if not storage.creative_mode.log_events then
- storage.creative_mode.log_events = {}
- end
- -- Table of Booleans, for whether the parameters of the events should also be logged.
- if not storage.creative_mode.also_log_event_params then
- storage.creative_mode.also_log_event_params = {}
- end
-
- -- Legacy config.
- storage.creative_mode.config = nil
-end
-
--- Updates the global meta-table according to the change of version of our mod.
--- Suitable for making big changes that require significant processing power and should perform as few times as possible.
-function global_util.update_global_as_our_mod_updated(our_mod_old_version, our_mod_new_version)
- -- Update: additional config for item_source_data, item_void_data and duplicator_data (since v0.2.0)
- if our_mod_old_version ~= nil then
- if our_mod_old_version < "0.2.0" and our_mod_new_version >= "0.2.0" then
- for _, data in ipairs(storage.creative_mode.item_source_data) do
- if data.can_insert_to_vehicle == nil then
- data.can_insert_to_vehicle = true
- end
- if data.can_insert_to_player == nil then
- data.can_insert_to_player = true
- end
- if data.insert_only_once_to_player == nil then
- data.insert_only_once_to_player = true
- end
- if data.insert_to_player_amount == nil then
- data.insert_to_player_amount = 1
- end
- if data.insert_to_player_by_stack == nil then
- data.insert_to_player_by_stack = true
- end
- if data.can_drop_on_ground == nil then
- data.can_drop_on_ground = false
- end
- end
- for _, data in ipairs(storage.creative_mode.duplicator_data) do
- if data.can_duplicate_in_vehicle == nil then
- data.can_duplicate_in_vehicle = true
- end
- if data.can_duplicate_in_player == nil then
- data.can_duplicate_in_player = false
- end
- end
- for _, data in ipairs(storage.creative_mode.item_void_data) do
- if data.can_remove_from_vehicle == nil then
- data.can_remove_from_vehicle = false
- end
- if data.can_remove_from_player == nil then
- data.can_remove_from_player = false
- end
- if data.can_remove_from_ground == nil then
- data.can_remove_from_ground = true
- end
- end
- end
-
- if our_mod_old_version >= "0.2.0" and our_mod_old_version < "0.2.2" and our_mod_new_version >= "0.2.2" then
- -- v0.2.0 ~ v0.2.1 -> v0.2.2+
- -- log events --- renamed to ---> write events. Keep the original array.
- if storage.creative_mode.log_events then
- for player_index, value in ipairs(storage.creative_mode.log_events) do
- storage.creative_mode.write_events[player_index] = value
- end
- end
- -- Fixed typo.
- if storage.creative_mode.also_log_even_params then
- for player_index, value in ipairs(storage.creative_mode.also_log_even_params) do
- storage.creative_mode.also_write_event_params[player_index] = value
- end
- storage.creative_mode.also_log_even_params = nil
- end
- end
-
- if our_mod_old_version <= "0.3.7" and our_mod_new_version >= "0.3.7" then
- -- v0.3.6- -> v0.3.7+
- -- duplicating_chest --- updated to ---> duplicating_chest_data.
- if storage.creative_mode.duplicating_chest then
- for _, entity in ipairs(storage.creative_mode.duplicating_chest) do
- global_util.register_entity(entity)
- end
- storage.creative_mode.duplicating_chest = nil
- end
- -- duplicating_provider_chest --- updated to ---> duplicating_provider_chest_data.
- if storage.creative_mode.duplicating_provider_chest then
- for _, entity in ipairs(storage.creative_mode.duplicating_provider_chest) do
- global_util.register_entity(entity)
- end
- storage.creative_mode.duplicating_provider_chest = nil
- end
- -- duplicating_cargo_wagon --- updated to ---> duplicating_cargo_wagon_data.
- if storage.creative_mode.duplicating_cargo_wagon then
- for _, entity in ipairs(storage.creative_mode.duplicating_cargo_wagon) do
- global_util.register_entity(entity)
- end
- storage.creative_mode.duplicating_cargo_wagon = nil
- end
- end
- end
-end
-
--- Renews the lists of all in-game items and also the data that is used by the Creative Chest family.
-function global_util.renew_item_lists()
- -- Unused.
- storage.item_list = nil
-
- -- All non-hidden items.
- storage.non_hidden_item_list = {}
- -- All hidden items, but not include our creative items.
- storage.non_creative_hidden_item_list = {}
- -- All enemy items created by us. They are hidden as well but should be included in the creative chests even if they do not contain hidden items.
- storage.hidden_creative_enemy_item_list = {}
-
- -- List of items with type equals to "tool"
- storage.tool_item_list = {}
-
- for _, item in pairs(prototypes.item) do
- if item.hidden then
- local is_our_enemy_item = util.string_starts_with(item.name, creative_mode_defines.names.enemy_item_prefix)
- if is_our_enemy_item then
- -- Our enemy item.
- table.insert(storage.hidden_creative_enemy_item_list, item)
- elseif not util.array_contains_val(creative_mode_defines.values
- .creative_provider_chest_additional_content_names, item.name) then
- -- Not our hidden item.
- table.insert(storage.non_creative_hidden_item_list, item)
- end
- else
- -- Non-hidden item.
- table.insert(storage.non_hidden_item_list, item)
- end
-
- if item.type == "tool" then
- -- Tool item.
- table.insert(storage.tool_item_list, item)
- end
- end
-
- global_util.remove_obsolete_items(storage.non_hidden_item_list)
- global_util.remove_obsolete_items(storage.non_creative_hidden_item_list)
- global_util.remove_obsolete_items(storage.hidden_creative_enemy_item_list)
- global_util.remove_obsolete_items(storage.tool_item_list)
-
- -- Update data for the Creative Chest family.
- creative_chest_util.update_item_lists_data()
-end
-
-function global_util.remove_obsolete_items(item_list)
- local i = 1
- while i <= #item_list do
- if item_list[i].type == "mining-tool" then
- table.remove(item_list, i)
- else
- i = i + 1
- end
- end
-end
-
--- Returns whether all of the item lists are already exist.
-function global_util.item_lists_exist()
- if not storage.non_hidden_item_list or not storage.non_creative_hidden_item_list or not storage.tool_item_list then
- return false
- end
- return true
-end
-
--- Initializes the lists of all in-game items if it doesn't not exist.
-function global_util.initialize_item_lists_if_not_exist()
- if not global_util.item_lists_exist() then
- global_util.renew_item_lists()
- end
-end
-
-----
-
--- Look up table for matching entity-register functions according to the entity name.
-local register_entity_look_up_functions = {
- [creative_mode_defines.names.entities.autofill_requester_chest] = function(entity)
- table.insert(storage.creative_mode.autofill_requester_chest, entity)
- end,
- [creative_mode_defines.names.entities.new_creative_chest] = function(entity)
- entity.remove_unfiltered_items = true -- We don't want anything except our set items in these
- chest_data = {
- entity = entity, -- The creative-chest entity.
- group = storage.creative_mode.creative_chest_next_place_group, -- Group is now a number stored in the data
- filtered_slots = {}, -- The slot indexes that are filtered out in this chest.
- inventory_display_mode = creative_chest_util.inventory_display_modes.original_mode, -- The inventory display mode.
- is_cargo_wagon = false -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
- }
- table.insert(storage.creative_mode.new_creative_chests, chest_data)
- creative_chest_util.set_chest_filter(chest_data)
- -- Increase the group number for the next chest.
- if storage.creative_mode.creative_chest_next_place_group <
- storage.creative_mode.creative_provider_chest_num_in_cycle then
- storage.creative_mode.creative_chest_next_place_group =
- storage.creative_mode.creative_chest_next_place_group + 1
- else
- storage.creative_mode.creative_chest_next_place_group = 1
- end
- end,
- [creative_mode_defines.names.entities.new_creative_provider_chest] = function(entity)
- entity.remove_unfiltered_items = true -- We don't want anything except our filters in these
- local chest_data = {
- entity = entity, -- The creative-chest entity.
- group = storage.creative_mode.creative_provider_chest_next_place_group, -- Group is now a number stored in the data
- filtered_slots = {}, -- The slot indexes that are filtered out in this chest.
- inventory_display_mode = creative_chest_util.inventory_display_modes.original_mode, -- The inventory display mode.
- is_cargo_wagon = false -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
- }
- table.insert(storage.creative_mode.new_creative_provider_chests, chest_data)
- creative_chest_util.set_chest_filter(chest_data)
- -- Increase the group number for the next chest.
- if storage.creative_mode.creative_provider_chest_next_place_group <
- storage.creative_mode.creative_provider_chest_num_in_cycle then
- storage.creative_mode.creative_provider_chest_next_place_group =
- storage.creative_mode.creative_provider_chest_next_place_group + 1
- else
- storage.creative_mode.creative_provider_chest_next_place_group = 1
- end
- end,
- [creative_mode_defines.names.entities.new_autofill_requester_chest] = function(entity)
- table.insert(storage.creative_mode.autofill_requester_chest, entity)
- end,
- [creative_mode_defines.names.entities.duplicating_chest] = function(entity)
- table.insert(storage.creative_mode.duplicating_chest_data, {
- entity = entity,
- lock_item = false, -- Whether the item to be duplicated is locked.
- locked_item_name = nil -- Name of the item to be duplicated even if the first slot is empty.
- })
- end,
- [creative_mode_defines.names.entities.duplicating_provider_chest] = function(entity)
- table.insert(storage.creative_mode.duplicating_provider_chest_data, {
- entity = entity,
- lock_item = false, -- Whether the item to be duplicated is locked.
- locked_item_name = nil -- Name of the item to be duplicated even if the first slot is empty.
- })
- end,
- [creative_mode_defines.names.entities.void_requester_chest] = function(entity)
- entity.remove_unfiltered_items = true
- end,
- [creative_mode_defines.names.entities.void_chest] = function(entity)
- entity.remove_unfiltered_items = true
- end,
- [creative_mode_defines.names.entities.void_storage_chest] = function(entity)
- entity.remove_unfiltered_items = true
- end,
- [creative_mode_defines.names.entities.creative_cargo_wagon] = function(entity)
- -- Creative Cargo Wagons are divided into groups.
- if not storage.creative_mode.creative_cargo_wagon_data_groups[storage.creative_mode
- .creative_cargo_wagon_next_place_group] then
- storage.creative_mode.creative_cargo_wagon_data_groups[storage.creative_mode
- .creative_cargo_wagon_next_place_group] = {}
- end
- table.insert(storage.creative_mode.creative_cargo_wagon_data_groups[storage.creative_mode
- .creative_cargo_wagon_next_place_group], {
- entity = entity, -- The creative-cargo-wagon entity.
- filtered_slots = {}, -- The slot indexes that are filtered out in this wagon.
- inventory_display_mode = creative_chest_util.inventory_display_modes.original_mode, -- The inventory display mode.
- is_cargo_wagon = true -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
- })
- -- Increase the group number for the next cargo wagon.
- if storage.creative_mode.creative_cargo_wagon_next_place_group <
- storage.creative_mode.creative_cargo_wagon_num_in_cycle then
- storage.creative_mode.creative_cargo_wagon_next_place_group =
- storage.creative_mode.creative_cargo_wagon_next_place_group + 1
- else
- storage.creative_mode.creative_cargo_wagon_next_place_group = 1
- end
- end,
- [creative_mode_defines.names.entities.duplicating_cargo_wagon] = function(entity)
- table.insert(storage.creative_mode.duplicating_cargo_wagon_data, {
- entity = entity,
- lock_item = false, -- Whether the item to be duplicated is locked.
- locked_item_name = nil -- Name of the item to be duplicated even if the first slot is empty.
- })
- end,
- [creative_mode_defines.names.entities.void_cargo_wagon] = function(entity)
- table.insert(storage.creative_mode.void_cargo_wagon, entity)
- end,
- [creative_mode_defines.names.entities.super_boiler] = function(entity)
- table.insert(storage.creative_mode.super_boiler, entity)
- end,
- [creative_mode_defines.names.entities.super_cooler] = function(entity)
- table.insert(storage.creative_mode.super_cooler, entity)
- end,
- [creative_mode_defines.names.entities.configurable_super_boiler] = function(entity)
- table.insert(storage.creative_mode.configurable_super_boiler_data, {
- entity = entity,
- temperature = 100.0
- })
- end,
- [creative_mode_defines.names.entities.heat_source] = function(entity)
- entity.set_heat_setting{temperature = 1000, mode = "exactly"}
- end,
- [creative_mode_defines.names.entities.heat_void] = function(entity)
- entity.set_heat_setting{temperature = 0, mode = "exactly"}
- end,
- [creative_mode_defines.names.entities.item_source] = function(entity)
- table.insert(storage.creative_mode.item_source_data, {
- entity = entity, -- The matter-source entity.
- slot1_inserted_players = nil, -- The players who have been inserted the item in the first slot.
- slot1_last_item_position_on_belt = nil, -- The position of the last inserted item to a transport belt by the first slot.
- slot2_inserted_players = nil, -- The players who have been inserted the item in the second slot.
- slot2_last_item_position_on_belt = nil, -- The position of the last inserted item to a transport belt by the second slot.
- last_working_transport_belt = nil, -- The transport belt it is working for since the last tick. This cache is used for reducing the needs for calling LuaSurface::find_entity.
- last_working_transport_belt_type = 0, -- The type of the transport belt.
- last_working_static_container = nil, -- The non-movable container (chest, logistic chest, pipe, assembling machine, rocket silo, furnace, roboport, etc.) it is working for since the last tick.
- last_working_static_container_inventories = nil, -- The table of inventories that the static container have.
- last_working_static_container_type = static_item_container_type.unknown, -- Type of the container.
- last_direction = entity.direction, -- The direction of the matter source since the last tick. Of course we need this to verify the last working entity.
- can_insert_to_vehicle = true, -- Whether it can insert items into vehicles.
- can_insert_to_player = true, -- Whether it can insert items into players.
- insert_only_once_to_player = true, -- Whether it will insert the items only once into the same player before he/she moves away and comes back.
- insert_to_player_amount = 1, -- Number of items to be inserted into the player in each time. Only works if insert_only_once_to_player is true.
- insert_to_player_by_stack = true, -- If true, insert_to_player_amount means number of item stacks. Otherwise, it means the number of individual items.
- can_drop_on_ground = false -- Whether it can drop items to the ground if nothing is in front of it.
- })
- end,
- [creative_mode_defines.names.entities.duplicator] = function(entity)
- table.insert(storage.creative_mode.duplicator_data, {
- entity = entity, -- The duplicator entity.
- line1_last_item_position_on_belt = nil, -- The position of the last inserted item on the first line of a transport belt.
- line2_last_item_position_on_belt = nil, -- The position of the last inserted item on the second line of a transport belt.
- last_working_transport_belt = nil, -- The transport belt it is working for since the last tick. This cache is used for reducing the needs for calling LuaSurface::find_entity.
- last_working_transport_belt_type = 0, -- The type of the transport belt.
- last_working_static_container = nil, -- The non-movable container (chest, logistic chest, assembling machine, rocket silo, furnace, roboport, etc.) it is working for since the last tick.
- last_working_static_container_inventories = nil, -- The table of inventories that the static container have.
- last_working_static_fluidbox = nil, -- The non-movable fluidbox (pipe, storage tank, boiler, generator, fluid-turret, etc.) it is working for since the last tick.
- last_direction = entity.direction, -- The direction of the duplicator since the last tick. Of course we need this to verify the last working entity.
- can_duplicate_in_vehicle = true, -- Whether it can duplicate items in vehicles.
- can_duplicate_in_player = false -- Whether it can duplicate items in players.
- })
- end,
- [creative_mode_defines.names.entities.item_void] = function(entity)
- table.insert(storage.creative_mode.item_void_data, {
- entity = entity, -- The matter-void entity.
- last_working_transport_belt = nil, -- The transport belt it is working for since the last tick. This cache is used for reducing the needs for calling LuaSurface::find_entity.
- last_working_transport_belt_type = 0, -- The type of the transport belt.
- last_working_static_container = nil, -- The non-movable container (chest, logistic chest, pipe, assembling machine, rocket silo, furnace, roboport, etc.) it is working for since the last tick.
- last_working_static_container_inventories = nil, -- The table of inventories that the static container have.
- last_working_static_fluidbox = nil, -- The non-movable fluidbox (pipe, storage tank, boiler, generator, fluid-turret, etc.) it is working for since the last tick.
- last_direction = entity.direction, -- The direction of the matter void since the last tick. Of course we need this to verify the last working entity.
- can_remove_from_vehicle = false, -- Whether it can remove items from vehicles.
- can_remove_from_player = false, -- Whether it can remove items from players.
- can_remove_from_ground = true -- Whether it can remove items from ground.
- })
- end,
- [creative_mode_defines.names.entities.random_item_source] = function(entity)
- -- The same structure as matter source data.
- table.insert(storage.creative_mode.random_item_source_data, {
- entity = entity, -- The random-item-source entity.
- slot1_inserted_players = nil, -- The players who have been inserted the item in the first slot.
- slot1_last_item_position_on_belt = nil, -- The position of the last inserted item to a transport belt by the first slot.
- slot2_inserted_players = nil, -- The players who have been inserted the item in the second slot.
- slot2_last_item_position_on_belt = nil, -- The position of the last inserted item to a transport belt by the second slot.
- last_working_transport_belt = nil, -- The transport belt it is working for since the last tick. This cache is used for reducing the needs for calling LuaSurface::find_entity.
- last_working_transport_belt_type = 0, -- The type of the transport belt.
- last_working_static_container = nil, -- The non-movable container (chest, logistic chest, pipe, assembling machine, rocket silo, furnace, roboport, etc.) it is working for since the last tick.
- last_working_static_container_inventories = nil, -- The table of inventories that the static container have.
- last_working_static_container_type = static_item_container_type.unknown, -- Type of the container.
- last_direction = entity.direction, -- The direction of the random item source since the last tick. Of course we need this to verify the last working entity.
- can_insert_to_vehicle = true, -- Whether it can insert items into vehicles.
- can_insert_to_player = true, -- Whether it can insert items into players.
- insert_only_once_to_player = true, -- Whether it will insert the items only once into the same player before he/she moves away and comes back.
- insert_to_player_amount = 1, -- Number of items to be inserted into the player in each time. Only works if insert_only_once_to_player is true.
- insert_to_player_by_stack = true, -- If true, insert_to_player_amount means number of item stacks. Otherwise, it means the number of individual items.
- can_drop_on_ground = false -- Whether it can drop items to the ground if nothing is in front of it.
- })
- end,
- [creative_mode_defines.names.entities.creative_lab] = function(entity)
- table.insert(storage.creative_mode.creative_lab, entity)
- end,
- [creative_mode_defines.names.entities.void_lab] = function(entity)
- table.insert(storage.creative_mode.void_lab, entity)
- end,
- [creative_mode_defines.names.entities.alien_attractor_proxy_small] = function(entity)
- entity.surface.build_enemy_base(entity.position, 5)
- end,
- [creative_mode_defines.names.entities.alien_attractor_proxy_medium] = function(entity)
- entity.surface.build_enemy_base(entity.position, 20)
- end,
- [creative_mode_defines.names.entities.alien_attractor_proxy_large] = function(entity)
- entity.surface.build_enemy_base(entity.position, 100)
- end
-}
-
--- Registers the given entity if needed.
-function global_util.register_entity(entity)
- if register_entity_look_up_functions[entity.name] then
- register_entity_look_up_functions[entity.name](entity)
- end
-end
+-- This file contains functions to initialize and update the global meta-table used by this mod.
+if not global_util then
+ global_util = {}
+end
+
+-- Initializes the necessary meta-table if it doesn't exist yet. This is called for new games or existing games when the version of this mod has changed.
+function global_util.initialize_or_update_global()
+ -- Generate table for storing data that will be used later.
+ if not storage.creative_mode then
+ storage.creative_mode = {}
+ -- Store whether creative mode has been enabled.
+ storage.creative_mode.enabled = false
+ -- Whether the popup of asking for enabling Creative Mode has been shown.
+ storage.creative_mode.has_asked_for_enable = false
+ else
+ if storage.creative_mode.enabled then
+ storage.creative_mode.has_asked_for_enable = true
+ end
+ end
+ -- Also generate the sub-tables to store our entities.
+ if not storage.creative_mode.new_creative_chests then
+ storage.creative_mode.new_creative_chests = {}
+ end
+ if not storage.creative_mode.creative_chest_next_group then
+ storage.creative_mode.creative_chest_next_group = 1
+ end -- The group number for the next placed creative chest. (Number of items in each group <= Chest inventory size)
+ if not storage.creative_mode.new_creative_provider_chests then
+ storage.creative_mode.new_creative_provider_chests = {}
+ end
+ if not storage.creative_mode.creative_provider_chest_next_group then
+ storage.creative_mode.creative_provider_chest_next_group = 1
+ end
+ if not storage.creative_mode.autofill_requester_chest then
+ storage.creative_mode.autofill_requester_chest = {}
+ end
+ if not storage.creative_mode.autofill_requester_chest_next_update_index then
+ storage.creative_mode.autofill_requester_chest_next_update_index = 1
+ end
+ if not storage.creative_mode.duplicating_chest_data then
+ storage.creative_mode.duplicating_chest_data = {}
+ end
+ if not storage.creative_mode.duplicating_chest_next_update_index then
+ storage.creative_mode.duplicating_chest_next_update_index = 1
+ end
+ if not storage.creative_mode.duplicating_provider_chest_data then
+ storage.creative_mode.duplicating_provider_chest_data = {}
+ end
+ if not storage.creative_mode.duplicating_provider_chest_next_update_index then
+ storage.creative_mode.duplicating_provider_chest_next_update_index = 1
+ end
+ if not storage.creative_mode.void_lab then
+ storage.creative_mode.void_lab = {}
+ end
+ if not storage.creative_mode.void_lab_next_update_index then
+ storage.creative_mode.void_lab_next_update_index = 1
+ end
+ if not storage.creative_mode.creative_cargo_wagon_data_groups then
+ storage.creative_mode.creative_cargo_wagon_data_groups = {}
+ end
+ if not storage.creative_mode.creative_cargo_wagon_next_group then
+ storage.creative_mode.creative_cargo_wagon_next_group = 1
+ end
+ if not storage.creative_mode.duplicating_cargo_wagon_data then
+ storage.creative_mode.duplicating_cargo_wagon_data = {}
+ end
+ if not storage.creative_mode.duplicating_cargo_wagon_next_update_index then
+ storage.creative_mode.duplicating_cargo_wagon_next_update_index = 1
+ end
+ if not storage.creative_mode.void_cargo_wagon then
+ storage.creative_mode.void_cargo_wagon = {}
+ end
+ if not storage.creative_mode.void_cargo_wagon_next_update_index then
+ storage.creative_mode.void_cargo_wagon_next_update_index = 1
+ end
+ if not storage.creative_mode.fluid_void then
+ storage.creative_mode.fluid_void = {}
+ end
+ if not storage.creative_mode.super_boiler then
+ storage.creative_mode.super_boiler = {}
+ end
+ if not storage.creative_mode.super_cooler then
+ storage.creative_mode.super_cooler = {}
+ end
+ if not storage.creative_mode.configurable_super_boiler_data then
+ storage.creative_mode.configurable_super_boiler_data = {}
+ end
+ if not storage.creative_mode.item_source_data then
+ storage.creative_mode.item_source_data = {}
+ end
+ if not storage.creative_mode.duplicator_data then
+ storage.creative_mode.duplicator_data = {}
+ end
+ if not storage.creative_mode.item_void_data then
+ storage.creative_mode.item_void_data = {}
+ end
+ if not storage.creative_mode.random_item_source_data then
+ storage.creative_mode.random_item_source_data = {}
+ end
+ if not storage.creative_mode.creative_lab then
+ storage.creative_mode.creative_lab = {}
+ end
+ if not storage.creative_mode.creative_lab_next_update_index then
+ storage.creative_mode.creative_lab_next_update_index = 1
+ end
+
+ -- Table for storing the equipments that need to be refilled with energy.
+ if not storage.energy_refill_equipments then
+ storage.energy_refill_equipments = {}
+ end
+
+ -- Table for storing which entity each player has opened.
+ if not storage.creative_mode.player_opened_entities then
+ storage.creative_mode.player_opened_entities = {}
+ end
+ -- Table for storing whether the entity GUI is opened.
+ if not storage.creative_mode.player_opened_entity_gui then
+ storage.creative_mode.player_opened_entity_gui = {}
+ end
+
+ -- Update: item_void -> item_void_data (since v0.1.1)
+ if storage.creative_mode.item_void then
+ for _, item_void in ipairs(storage.creative_mode.item_void) do
+ -- Re-register the entities again to move them into the new table.
+ global_util.register_entity(item_void)
+ end
+ storage.creative_mode.item_void = nil
+ end
+
+ -- Update: creative_provider_chest_groups -> creative_provider_chest_data_groups (since v0.1.2)
+ if storage.creative_mode.creative_provider_chest_groups then
+ for index, groups in ipairs(storage.creative_mode.creative_provider_chest_groups) do
+ -- Can't simply re-register in this case because the chests are divided into groups.
+ if not storage.creative_mode.creative_provider_chest_data_groups[index] then
+ storage.creative_mode.creative_provider_chest_data_groups[index] = {}
+ end
+ for index2, chest in ipairs(groups) do
+ table.insert(storage.creative_mode.creative_provider_chest_data_groups[index], {
+ entity = chest,
+ filtered_slots = {},
+ })
+ end
+ end
+ storage.creative_mode.creative_provider_chest_groups = nil
+ end
+
+ -- Whether Creative Mode has been permanently disabled.
+ if not storage.creative_mode.permanently_disabled then
+ storage.creative_mode.permanently_disabled = false
+ end
+
+ -- Player rights.existence determinator
+ if not storage.creative_mode.player_rights then
+ storage.creative_mode.player_rights = {}
+ end
+ -- Right for enabling/disabling personal cheats.
+ if storage.creative_mode.player_rights.access_personal_cheats == nil then
+ storage.creative_mode.player_rights.access_personal_cheats = rights.default_access_personal_cheats_level
+ end
+ -- Right for enabling/disabling team cheats.
+ if storage.creative_mode.player_rights.access_team_cheats == nil then
+ storage.creative_mode.player_rights.access_team_cheats = rights.default_access_team_cheats_level
+ end
+ -- Right for enabling/disabling surface cheats.
+ if storage.creative_mode.player_rights.access_surface_cheats == nil then
+ storage.creative_mode.player_rights.access_surface_cheats = rights.default_access_surface_cheats_level
+ end
+ -- Right for enabling/disabling global cheats.
+ if storage.creative_mode.player_rights.access_global_cheats == nil then
+ storage.creative_mode.player_rights.access_global_cheats = rights.default_access_global_cheats_level
+ end
+ -- Right for changing build options.
+ if storage.creative_mode.player_rights.access_build_options == nil then
+ storage.creative_mode.player_rights.access_build_options = rights.default_access_build_options_level
+ end
+ -- Right for using the Creator Magic Wand. (True = all players can use; false = only admins can use)
+ if storage.creative_mode.player_rights.use_creator_magic_wand == nil then
+ storage.creative_mode.player_rights.use_creator_magic_wand = rights.default_use_creator_magic_wand
+ end
+ -- Right for using the Healer Magic Wand.
+ if storage.creative_mode.player_rights.use_healer_magic_wand == nil then
+ storage.creative_mode.player_rights.use_healer_magic_wand = rights.default_use_healer_magic_wand
+ end
+ -- Right for using the Modifier Magic Wand.
+ if storage.creative_mode.player_rights.use_modifier_magic_wand == nil then
+ storage.creative_mode.player_rights.use_modifier_magic_wand = rights.default_use_modifier_magic_wand
+ end
+ -- Right for accessing modding menu. (True = all players can access; false = only admins can access)
+ if storage.creative_mode.player_rights.access_modding_menu == nil then
+ storage.creative_mode.player_rights.access_modding_menu = rights.default_access_modding_menu
+ end
+
+ -- Table of personal cheats for each player.
+ if not storage.creative_mode.personal_cheats then
+ storage.creative_mode.personal_cheats = {}
+ end
+ -- Cheat mode.
+ if not storage.creative_mode.personal_cheats.cheat_mode then
+ storage.creative_mode.personal_cheats.cheat_mode = {}
+ end
+ -- Invincible player.
+ if not storage.creative_mode.personal_cheats.invincible_player then
+ storage.creative_mode.personal_cheats.invincible_player = {}
+ end
+ -- Keep last item.
+ if not storage.creative_mode.personal_cheats.keep_last_item then
+ storage.creative_mode.personal_cheats.keep_last_item = {}
+ end
+ -- Repair mined item.
+ if not storage.creative_mode.personal_cheats.repair_mined_item then
+ storage.creative_mode.personal_cheats.repair_mined_item = {}
+ end
+ -- Whether the cursor stack of each player has been restored after the player has put item to build something.
+ -- We need to verify whether the built "something" is actually a ghost i.e. no item is spent, no need to restore.
+ if not storage.creative_mode.personal_cheats.has_restored_cursor_stack then
+ storage.creative_mode.personal_cheats.has_restored_cursor_stack = {}
+ end
+ -- Instant request.
+ if not storage.creative_mode.personal_cheats.instant_request then
+ storage.creative_mode.personal_cheats.instant_request = {}
+ end
+ -- Instant request: to minimize the impact to performance when there are many players in the game with many logistic request slots, we limited the maximum number of slots to be checked in each tick.
+ -- The next player to be checked. It is ensure to be 1 even if it already exists in loaded save, because we don't want infinite loop in the get player function if someone loaded a multiplayer game that previously had many players.
+ storage.creative_mode.personal_cheats.instant_request_next_player_index = 1
+ -- The next slot to be checked in that player.
+ if not storage.creative_mode.personal_cheats.instant_request_next_player_slot_index then
+ storage.creative_mode.personal_cheats.instant_request_next_player_slot_index = 1
+ end
+ -- Instant trash.
+ if not storage.creative_mode.personal_cheats.instant_trash then
+ storage.creative_mode.personal_cheats.instant_trash = {}
+ end
+ -- Instant trash: number of players to be updated in each tick is limited.
+ storage.creative_mode.personal_cheats.instant_trash_next_player_index = 1
+ -- Instant blueprint.
+ if not storage.creative_mode.personal_cheats.instant_blueprint then
+ storage.creative_mode.personal_cheats.instant_blueprint = {}
+ end
+ -- Instant deconstruction.
+ if not storage.creative_mode.personal_cheats.instant_deconstruction then
+ storage.creative_mode.personal_cheats.instant_deconstruction = {}
+ end
+ -- Reach distance.
+ if not storage.creative_mode.personal_cheats.reach_distance then
+ storage.creative_mode.personal_cheats.reach_distance = {}
+ end
+ -- Build distance.
+ if not storage.creative_mode.personal_cheats.build_distance then
+ storage.creative_mode.personal_cheats.build_distance = {}
+ end
+ -- Resource reach distance.
+ if not storage.creative_mode.personal_cheats.resource_reach_distance then
+ storage.creative_mode.personal_cheats.resource_reach_distance = {}
+ end
+ -- Item drop distance.
+ if not storage.creative_mode.personal_cheats.item_drop_distance then
+ storage.creative_mode.personal_cheats.item_drop_distance = {}
+ end
+ -- Item pickup distance.
+ if not storage.creative_mode.personal_cheats.item_pickup_distance then
+ storage.creative_mode.personal_cheats.item_pickup_distance = {}
+ end
+ -- Loot pickup distance.
+ if not storage.creative_mode.personal_cheats.loot_pickup_distance then
+ storage.creative_mode.personal_cheats.loot_pickup_distance = {}
+ end
+ -- Mining speed.
+ if not storage.creative_mode.personal_cheats.mining_speed then
+ storage.creative_mode.personal_cheats.mining_speed = {}
+ end
+ -- Running speed.
+ if not storage.creative_mode.personal_cheats.running_speed then
+ storage.creative_mode.personal_cheats.running_speed = {}
+ end
+ -- Crafting speed.
+ if not storage.creative_mode.personal_cheats.crafting_speed then
+ storage.creative_mode.personal_cheats.crafting_speed = {}
+ end
+ -- Inventory bonus.
+ if not storage.creative_mode.personal_cheats.inventory_bonus then
+ storage.creative_mode.personal_cheats.inventory_bonus = {}
+ end
+ -- Quickbar bonus.
+ if not storage.creative_mode.personal_cheats.quickbar_bonus then
+ storage.creative_mode.personal_cheats.quickbar_bonus = {}
+ end
+ -- Health bonus.
+ if not storage.creative_mode.personal_cheats.health_bonus then
+ storage.creative_mode.personal_cheats.health_bonus = {}
+ end
+ -- God mode : list of characters that were previously characters of players before god mode was enabled.
+ if not storage.creative_mode.personal_cheats.god_mode_character then
+ storage.creative_mode.personal_cheats.god_mode_character = {}
+ end
+
+ -- Table of team cheats for each team.
+ if not storage.creative_mode.team_cheats then
+ storage.creative_mode.team_cheats = {}
+ end
+ -- Instant research.
+ if not storage.creative_mode.team_cheats.instant_research then
+ storage.creative_mode.team_cheats.instant_research = {}
+ end
+
+ -- Table of surface cheats for each surface.
+ if not storage.creative_mode.surface_cheats then
+ storage.creative_mode.surface_cheats = {}
+ end
+ -- Don't generate enemy.
+ if not storage.creative_mode.surface_cheats.dont_generate_enemy then
+ storage.creative_mode.surface_cheats.dont_generate_enemy = {}
+ end
+
+ -- Table of build options for each player.
+ if not storage.creative_mode.build_options then
+ storage.creative_mode.build_options = {}
+ end
+ -- Active.
+ if not storage.creative_mode.build_options.active then
+ storage.creative_mode.build_options.active = {}
+ end
+ -- Destructible.
+ if not storage.creative_mode.build_options.destructible then
+ storage.creative_mode.build_options.destructible = {}
+ end
+ -- Minable.
+ if not storage.creative_mode.build_options.minable then
+ storage.creative_mode.build_options.minable = {}
+ end
+ -- Rotatable.
+ if not storage.creative_mode.build_options.rotatable then
+ storage.creative_mode.build_options.rotatable = {}
+ end
+ -- Operable.
+ if not storage.creative_mode.build_options.operable then
+ storage.creative_mode.build_options.operable = {}
+ end
+ -- Full health.
+ if not storage.creative_mode.build_options.full_health then
+ storage.creative_mode.build_options.full_health = {}
+ end
+ -- Team (force name).
+ if not storage.creative_mode.build_options.team then
+ storage.creative_mode.build_options.team = {}
+ end
+
+ -- Table of magic wand settings for each player.
+ if not storage.creative_mode.magic_wand_settings then
+ storage.creative_mode.magic_wand_settings = {}
+ end
+ -- Creator.
+ if not storage.creative_mode.magic_wand_settings.creator then
+ storage.creative_mode.magic_wand_settings.creator = {}
+ end
+ -- Healer.
+ if not storage.creative_mode.magic_wand_settings.healer then
+ storage.creative_mode.magic_wand_settings.healer = {}
+ end
+ -- Modifier.
+ if not storage.creative_mode.magic_wand_settings.modifier then
+ storage.creative_mode.magic_wand_settings.modifier = {}
+ end
+ -- Modifier - selected entities.
+ if not storage.creative_mode.modifier_magic_wand_selection then
+ storage.creative_mode.modifier_magic_wand_selection = {}
+ end
+ -- Modifier - quick actions.
+ if not storage.creative_mode.modifier_magic_wand_quick_actions then
+ storage.creative_mode.modifier_magic_wand_quick_actions = {}
+ end
+
+ -- Unused. Previously it is used for global instant blueprint and instant deconstruction (before v0.2.0)
+ if storage.creative_mode.cheats then
+ storage.creative_mode.cheats = nil
+ end
+
+ -- List of ghost entities that are pending to be revived.
+ -- A 1-tick delay is used for better compatilibty of other mods. This can also solve the problem that when shift-place a blueprint, the ghosts that collide with trees do not get revived even though the trees are removed by instant-deconstruction.
+ if not storage.creative_mode.pending_instant_blueprint then
+ storage.creative_mode.pending_instant_blueprint = {}
+ end
+
+ -- List of entities that are pending to be deconstructed.
+ -- A 1-tick delay is used before we really destroy the entities. It is used to encounter mods like Filtered Deconstruction Planner which unmark filtered entities right after they are marked.
+ if not storage.creative_mode.pending_instant_deconstruction then
+ storage.creative_mode.pending_instant_deconstruction = {}
+ end
+
+ -- List of areas on surfaces for removing enemies.
+ -- Because the on_chunk_generated event is invoked after enemy is generated (due to RSO?), we have to use a 1-tick delay to remove the enemies.
+ if not storage.creative_mode.pending_areas_to_remove_enemies then
+ storage.creative_mode.pending_areas_to_remove_enemies = {}
+ end
+
+ -- Table of events selected by each player.
+ if not storage.creative_mode.selected_events then
+ storage.creative_mode.selected_events = {}
+ end
+ -- Table of Booleans, for whether the selected events should be printed in each player's console.
+ if not storage.creative_mode.print_events then
+ storage.creative_mode.print_events = {}
+ end
+ -- Table of Booleans, for whether the parameters of the events should also be printed.
+ if not storage.creative_mode.also_print_event_params then
+ storage.creative_mode.also_print_event_params = {}
+ end
+ -- Table of Booleans, for whether the selected events should be written in each player's file system as txt files.
+ if not storage.creative_mode.write_events then
+ storage.creative_mode.write_events = {}
+ end
+ -- Table of Booleans, for whether the parameters of the events should also be written.
+ if not storage.creative_mode.also_write_event_params then
+ storage.creative_mode.also_write_event_params = {}
+ end
+ -- Table of Booleans, for whether the selected events should be logged in each player's file system as log files.
+ if not storage.creative_mode.log_events then
+ storage.creative_mode.log_events = {}
+ end
+ -- Table of Booleans, for whether the parameters of the events should also be logged.
+ if not storage.creative_mode.also_log_event_params then
+ storage.creative_mode.also_log_event_params = {}
+ end
+
+ -- Legacy config.
+ storage.creative_mode.config = nil
+end
+
+-- Updates the global meta-table according to the change of version of our mod.
+-- Suitable for making big changes that require significant processing power and should perform as few times as possible.
+function global_util.update_global_as_our_mod_updated(our_mod_old_version, our_mod_new_version)
+ -- Update: additional config for item_source_data, item_void_data and duplicator_data (since v0.2.0)
+ if our_mod_old_version ~= nil then
+ if our_mod_old_version < "0.2.0" and our_mod_new_version >= "0.2.0" then
+ for _, data in ipairs(storage.creative_mode.item_source_data) do
+ if data.can_insert_to_vehicle == nil then
+ data.can_insert_to_vehicle = true
+ end
+ if data.can_insert_to_player == nil then
+ data.can_insert_to_player = true
+ end
+ if data.insert_only_once_to_player == nil then
+ data.insert_only_once_to_player = true
+ end
+ if data.insert_to_player_amount == nil then
+ data.insert_to_player_amount = 1
+ end
+ if data.insert_to_player_by_stack == nil then
+ data.insert_to_player_by_stack = true
+ end
+ if data.can_drop_on_ground == nil then
+ data.can_drop_on_ground = false
+ end
+ end
+ for _, data in ipairs(storage.creative_mode.duplicator_data) do
+ if data.can_duplicate_in_vehicle == nil then
+ data.can_duplicate_in_vehicle = true
+ end
+ if data.can_duplicate_in_player == nil then
+ data.can_duplicate_in_player = false
+ end
+ end
+ for _, data in ipairs(storage.creative_mode.item_void_data) do
+ if data.can_remove_from_vehicle == nil then
+ data.can_remove_from_vehicle = false
+ end
+ if data.can_remove_from_player == nil then
+ data.can_remove_from_player = false
+ end
+ if data.can_remove_from_ground == nil then
+ data.can_remove_from_ground = true
+ end
+ end
+ end
+
+ if our_mod_old_version >= "0.2.0" and our_mod_old_version < "0.2.2" and our_mod_new_version >= "0.2.2" then
+ -- v0.2.0 ~ v0.2.1 -> v0.2.2+
+ -- log events --- renamed to ---> write events. Keep the original array.
+ if storage.creative_mode.log_events then
+ for player_index, value in ipairs(storage.creative_mode.log_events) do
+ storage.creative_mode.write_events[player_index] = value
+ end
+ end
+ -- Fixed typo.
+ if storage.creative_mode.also_log_even_params then
+ for player_index, value in ipairs(storage.creative_mode.also_log_even_params) do
+ storage.creative_mode.also_write_event_params[player_index] = value
+ end
+ storage.creative_mode.also_log_even_params = nil
+ end
+ end
+
+ if our_mod_old_version <= "0.3.7" and our_mod_new_version >= "0.3.7" then
+ -- v0.3.6- -> v0.3.7+
+ -- duplicating_chest --- updated to ---> duplicating_chest_data.
+ if storage.creative_mode.duplicating_chest then
+ for _, entity in ipairs(storage.creative_mode.duplicating_chest) do
+ global_util.register_entity(entity)
+ end
+ storage.creative_mode.duplicating_chest = nil
+ end
+ -- duplicating_provider_chest --- updated to ---> duplicating_provider_chest_data.
+ if storage.creative_mode.duplicating_provider_chest then
+ for _, entity in ipairs(storage.creative_mode.duplicating_provider_chest) do
+ global_util.register_entity(entity)
+ end
+ storage.creative_mode.duplicating_provider_chest = nil
+ end
+ -- duplicating_cargo_wagon --- updated to ---> duplicating_cargo_wagon_data.
+ if storage.creative_mode.duplicating_cargo_wagon then
+ for _, entity in ipairs(storage.creative_mode.duplicating_cargo_wagon) do
+ global_util.register_entity(entity)
+ end
+ storage.creative_mode.duplicating_cargo_wagon = nil
+ end
+ end
+ end
+end
+
+-- Renews the lists of all in-game items and also the data that is used by the Creative Chest family.
+function global_util.renew_item_lists()
+ -- Unused.
+ storage.item_list = nil
+
+ -- All non-hidden items.
+ storage.non_hidden_item_list = {}
+ -- All hidden items, but not include our creative items.
+ storage.non_creative_hidden_item_list = {}
+ -- All enemy items created by us. They are hidden as well but should be included in the creative chests even if they do not contain hidden items.
+ storage.hidden_creative_enemy_item_list = {}
+
+ -- List of items with type equals to "tool"
+ storage.tool_item_list = {}
+
+ for _, item in pairs(prototypes.item) do
+ if item.hidden then
+ local is_our_enemy_item = util.string_starts_with(item.name, creative_mode_defines.names.enemy_item_prefix)
+ if is_our_enemy_item then
+ -- Our enemy item.
+ table.insert(storage.hidden_creative_enemy_item_list, item)
+ elseif
+ not util.array_contains_val(
+ creative_mode_defines.values.creative_provider_chest_additional_content_names,
+ item.name
+ )
+ then
+ -- Not our hidden item.
+ table.insert(storage.non_creative_hidden_item_list, item)
+ end
+ else
+ -- Non-hidden item.
+ table.insert(storage.non_hidden_item_list, item)
+ end
+
+ if item.type == "tool" then
+ -- Tool item.
+ table.insert(storage.tool_item_list, item)
+ end
+ end
+
+ global_util.remove_obsolete_items(storage.non_hidden_item_list)
+ global_util.remove_obsolete_items(storage.non_creative_hidden_item_list)
+ global_util.remove_obsolete_items(storage.hidden_creative_enemy_item_list)
+ global_util.remove_obsolete_items(storage.tool_item_list)
+
+ -- Update data for the Creative Chest family.
+ creative_chest_util.update_item_lists_data()
+end
+
+function global_util.remove_obsolete_items(item_list)
+ local i = 1
+ while i <= #item_list do
+ if item_list[i].type == "mining-tool" then
+ table.remove(item_list, i)
+ else
+ i = i + 1
+ end
+ end
+end
+
+-- Returns whether all of the item lists are already exist.
+function global_util.item_lists_exist()
+ if not storage.non_hidden_item_list or not storage.non_creative_hidden_item_list or not storage.tool_item_list then
+ return false
+ end
+ return true
+end
+
+-- Initializes the lists of all in-game items if it doesn't not exist.
+function global_util.initialize_item_lists_if_not_exist()
+ if not global_util.item_lists_exist() then
+ global_util.renew_item_lists()
+ end
+end
+
+----
+
+-- Look up table for matching entity-register functions according to the entity name.
+local register_entity_look_up_functions = {
+ [creative_mode_defines.names.entities.autofill_requester_chest] = function(entity)
+ table.insert(storage.creative_mode.autofill_requester_chest, entity)
+ end,
+ [creative_mode_defines.names.entities.new_creative_chest] = function(entity)
+ entity.remove_unfiltered_items = true -- We don't want anything except our set items in these
+ chest_data = {
+ entity = entity, -- The creative-chest entity.
+ group = storage.creative_mode.creative_chest_next_place_group, -- Group is now a number stored in the data
+ filtered_slots = {}, -- The slot indexes that are filtered out in this chest.
+ inventory_display_mode = creative_chest_util.inventory_display_modes.original_mode, -- The inventory display mode.
+ is_cargo_wagon = false, -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
+ }
+ table.insert(storage.creative_mode.new_creative_chests, chest_data)
+ creative_chest_util.set_chest_filter(chest_data)
+ -- Increase the group number for the next chest.
+ if
+ storage.creative_mode.creative_chest_next_place_group
+ < storage.creative_mode.creative_provider_chest_num_in_cycle
+ then
+ storage.creative_mode.creative_chest_next_place_group = storage.creative_mode.creative_chest_next_place_group + 1
+ else
+ storage.creative_mode.creative_chest_next_place_group = 1
+ end
+ end,
+ [creative_mode_defines.names.entities.new_creative_provider_chest] = function(entity)
+ entity.remove_unfiltered_items = true -- We don't want anything except our filters in these
+ local chest_data = {
+ entity = entity, -- The creative-chest entity.
+ group = storage.creative_mode.creative_provider_chest_next_place_group, -- Group is now a number stored in the data
+ filtered_slots = {}, -- The slot indexes that are filtered out in this chest.
+ inventory_display_mode = creative_chest_util.inventory_display_modes.original_mode, -- The inventory display mode.
+ is_cargo_wagon = false, -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
+ }
+ table.insert(storage.creative_mode.new_creative_provider_chests, chest_data)
+ creative_chest_util.set_chest_filter(chest_data)
+ -- Increase the group number for the next chest.
+ if
+ storage.creative_mode.creative_provider_chest_next_place_group
+ < storage.creative_mode.creative_provider_chest_num_in_cycle
+ then
+ storage.creative_mode.creative_provider_chest_next_place_group = storage.creative_mode.creative_provider_chest_next_place_group
+ + 1
+ else
+ storage.creative_mode.creative_provider_chest_next_place_group = 1
+ end
+ end,
+ [creative_mode_defines.names.entities.new_autofill_requester_chest] = function(entity)
+ table.insert(storage.creative_mode.autofill_requester_chest, entity)
+ end,
+ [creative_mode_defines.names.entities.duplicating_chest] = function(entity)
+ table.insert(storage.creative_mode.duplicating_chest_data, {
+ entity = entity,
+ lock_item = false, -- Whether the item to be duplicated is locked.
+ locked_item_name = nil, -- Name of the item to be duplicated even if the first slot is empty.
+ })
+ end,
+ [creative_mode_defines.names.entities.duplicating_provider_chest] = function(entity)
+ table.insert(storage.creative_mode.duplicating_provider_chest_data, {
+ entity = entity,
+ lock_item = false, -- Whether the item to be duplicated is locked.
+ locked_item_name = nil, -- Name of the item to be duplicated even if the first slot is empty.
+ })
+ end,
+ [creative_mode_defines.names.entities.void_requester_chest] = function(entity)
+ entity.remove_unfiltered_items = true
+ end,
+ [creative_mode_defines.names.entities.void_chest] = function(entity)
+ entity.remove_unfiltered_items = true
+ end,
+ [creative_mode_defines.names.entities.void_storage_chest] = function(entity)
+ entity.remove_unfiltered_items = true
+ end,
+ [creative_mode_defines.names.entities.creative_cargo_wagon] = function(entity)
+ -- Creative Cargo Wagons are divided into groups.
+ if
+ not storage.creative_mode.creative_cargo_wagon_data_groups[storage.creative_mode.creative_cargo_wagon_next_place_group]
+ then
+ storage.creative_mode.creative_cargo_wagon_data_groups[storage.creative_mode.creative_cargo_wagon_next_place_group] =
+ {}
+ end
+ table.insert(
+ storage.creative_mode.creative_cargo_wagon_data_groups[storage.creative_mode.creative_cargo_wagon_next_place_group],
+ {
+ entity = entity, -- The creative-cargo-wagon entity.
+ filtered_slots = {}, -- The slot indexes that are filtered out in this wagon.
+ inventory_display_mode = creative_chest_util.inventory_display_modes.original_mode, -- The inventory display mode.
+ is_cargo_wagon = true, -- Whether the entity is cargo wagon, such that when its speed is not 0, we should find the cargo-wagon inventory if output inventory is nil (when it is moving).
+ }
+ )
+ -- Increase the group number for the next cargo wagon.
+ if
+ storage.creative_mode.creative_cargo_wagon_next_place_group
+ < storage.creative_mode.creative_cargo_wagon_num_in_cycle
+ then
+ storage.creative_mode.creative_cargo_wagon_next_place_group = storage.creative_mode.creative_cargo_wagon_next_place_group
+ + 1
+ else
+ storage.creative_mode.creative_cargo_wagon_next_place_group = 1
+ end
+ end,
+ [creative_mode_defines.names.entities.duplicating_cargo_wagon] = function(entity)
+ table.insert(storage.creative_mode.duplicating_cargo_wagon_data, {
+ entity = entity,
+ lock_item = false, -- Whether the item to be duplicated is locked.
+ locked_item_name = nil, -- Name of the item to be duplicated even if the first slot is empty.
+ })
+ end,
+ [creative_mode_defines.names.entities.void_cargo_wagon] = function(entity)
+ table.insert(storage.creative_mode.void_cargo_wagon, entity)
+ end,
+ [creative_mode_defines.names.entities.super_boiler] = function(entity)
+ table.insert(storage.creative_mode.super_boiler, entity)
+ end,
+ [creative_mode_defines.names.entities.super_cooler] = function(entity)
+ table.insert(storage.creative_mode.super_cooler, entity)
+ end,
+ [creative_mode_defines.names.entities.configurable_super_boiler] = function(entity)
+ table.insert(storage.creative_mode.configurable_super_boiler_data, {
+ entity = entity,
+ temperature = 100.0,
+ })
+ end,
+ [creative_mode_defines.names.entities.heat_source] = function(entity)
+ entity.set_heat_setting({ temperature = 1000, mode = "exactly" })
+ end,
+ [creative_mode_defines.names.entities.heat_void] = function(entity)
+ entity.set_heat_setting({ temperature = 0, mode = "exactly" })
+ end,
+ [creative_mode_defines.names.entities.item_source] = function(entity)
+ table.insert(storage.creative_mode.item_source_data, {
+ entity = entity, -- The matter-source entity.
+ slot1_inserted_players = nil, -- The players who have been inserted the item in the first slot.
+ slot1_last_item_position_on_belt = nil, -- The position of the last inserted item to a transport belt by the first slot.
+ slot2_inserted_players = nil, -- The players who have been inserted the item in the second slot.
+ slot2_last_item_position_on_belt = nil, -- The position of the last inserted item to a transport belt by the second slot.
+ last_working_transport_belt = nil, -- The transport belt it is working for since the last tick. This cache is used for reducing the needs for calling LuaSurface::find_entity.
+ last_working_transport_belt_type = 0, -- The type of the transport belt.
+ last_working_static_container = nil, -- The non-movable container (chest, logistic chest, pipe, assembling machine, rocket silo, furnace, roboport, etc.) it is working for since the last tick.
+ last_working_static_container_inventories = nil, -- The table of inventories that the static container have.
+ last_working_static_container_type = static_item_container_type.unknown, -- Type of the container.
+ last_direction = entity.direction, -- The direction of the matter source since the last tick. Of course we need this to verify the last working entity.
+ can_insert_to_vehicle = true, -- Whether it can insert items into vehicles.
+ can_insert_to_player = true, -- Whether it can insert items into players.
+ insert_only_once_to_player = true, -- Whether it will insert the items only once into the same player before he/she moves away and comes back.
+ insert_to_player_amount = 1, -- Number of items to be inserted into the player in each time. Only works if insert_only_once_to_player is true.
+ insert_to_player_by_stack = true, -- If true, insert_to_player_amount means number of item stacks. Otherwise, it means the number of individual items.
+ can_drop_on_ground = false, -- Whether it can drop items to the ground if nothing is in front of it.
+ })
+ end,
+ [creative_mode_defines.names.entities.duplicator] = function(entity)
+ table.insert(storage.creative_mode.duplicator_data, {
+ entity = entity, -- The duplicator entity.
+ line1_last_item_position_on_belt = nil, -- The position of the last inserted item on the first line of a transport belt.
+ line2_last_item_position_on_belt = nil, -- The position of the last inserted item on the second line of a transport belt.
+ last_working_transport_belt = nil, -- The transport belt it is working for since the last tick. This cache is used for reducing the needs for calling LuaSurface::find_entity.
+ last_working_transport_belt_type = 0, -- The type of the transport belt.
+ last_working_static_container = nil, -- The non-movable container (chest, logistic chest, assembling machine, rocket silo, furnace, roboport, etc.) it is working for since the last tick.
+ last_working_static_container_inventories = nil, -- The table of inventories that the static container have.
+ last_working_static_fluidbox = nil, -- The non-movable fluidbox (pipe, storage tank, boiler, generator, fluid-turret, etc.) it is working for since the last tick.
+ last_direction = entity.direction, -- The direction of the duplicator since the last tick. Of course we need this to verify the last working entity.
+ can_duplicate_in_vehicle = true, -- Whether it can duplicate items in vehicles.
+ can_duplicate_in_player = false, -- Whether it can duplicate items in players.
+ })
+ end,
+ [creative_mode_defines.names.entities.item_void] = function(entity)
+ table.insert(storage.creative_mode.item_void_data, {
+ entity = entity, -- The matter-void entity.
+ last_working_transport_belt = nil, -- The transport belt it is working for since the last tick. This cache is used for reducing the needs for calling LuaSurface::find_entity.
+ last_working_transport_belt_type = 0, -- The type of the transport belt.
+ last_working_static_container = nil, -- The non-movable container (chest, logistic chest, pipe, assembling machine, rocket silo, furnace, roboport, etc.) it is working for since the last tick.
+ last_working_static_container_inventories = nil, -- The table of inventories that the static container have.
+ last_working_static_fluidbox = nil, -- The non-movable fluidbox (pipe, storage tank, boiler, generator, fluid-turret, etc.) it is working for since the last tick.
+ last_direction = entity.direction, -- The direction of the matter void since the last tick. Of course we need this to verify the last working entity.
+ can_remove_from_vehicle = false, -- Whether it can remove items from vehicles.
+ can_remove_from_player = false, -- Whether it can remove items from players.
+ can_remove_from_ground = true, -- Whether it can remove items from ground.
+ })
+ end,
+ [creative_mode_defines.names.entities.random_item_source] = function(entity)
+ -- The same structure as matter source data.
+ table.insert(storage.creative_mode.random_item_source_data, {
+ entity = entity, -- The random-item-source entity.
+ slot1_inserted_players = nil, -- The players who have been inserted the item in the first slot.
+ slot1_last_item_position_on_belt = nil, -- The position of the last inserted item to a transport belt by the first slot.
+ slot2_inserted_players = nil, -- The players who have been inserted the item in the second slot.
+ slot2_last_item_position_on_belt = nil, -- The position of the last inserted item to a transport belt by the second slot.
+ last_working_transport_belt = nil, -- The transport belt it is working for since the last tick. This cache is used for reducing the needs for calling LuaSurface::find_entity.
+ last_working_transport_belt_type = 0, -- The type of the transport belt.
+ last_working_static_container = nil, -- The non-movable container (chest, logistic chest, pipe, assembling machine, rocket silo, furnace, roboport, etc.) it is working for since the last tick.
+ last_working_static_container_inventories = nil, -- The table of inventories that the static container have.
+ last_working_static_container_type = static_item_container_type.unknown, -- Type of the container.
+ last_direction = entity.direction, -- The direction of the random item source since the last tick. Of course we need this to verify the last working entity.
+ can_insert_to_vehicle = true, -- Whether it can insert items into vehicles.
+ can_insert_to_player = true, -- Whether it can insert items into players.
+ insert_only_once_to_player = true, -- Whether it will insert the items only once into the same player before he/she moves away and comes back.
+ insert_to_player_amount = 1, -- Number of items to be inserted into the player in each time. Only works if insert_only_once_to_player is true.
+ insert_to_player_by_stack = true, -- If true, insert_to_player_amount means number of item stacks. Otherwise, it means the number of individual items.
+ can_drop_on_ground = false, -- Whether it can drop items to the ground if nothing is in front of it.
+ })
+ end,
+ [creative_mode_defines.names.entities.creative_lab] = function(entity)
+ table.insert(storage.creative_mode.creative_lab, entity)
+ end,
+ [creative_mode_defines.names.entities.void_lab] = function(entity)
+ table.insert(storage.creative_mode.void_lab, entity)
+ end,
+ [creative_mode_defines.names.entities.alien_attractor_proxy_small] = function(entity)
+ entity.surface.build_enemy_base(entity.position, 5)
+ end,
+ [creative_mode_defines.names.entities.alien_attractor_proxy_medium] = function(entity)
+ entity.surface.build_enemy_base(entity.position, 20)
+ end,
+ [creative_mode_defines.names.entities.alien_attractor_proxy_large] = function(entity)
+ entity.surface.build_enemy_base(entity.position, 100)
+ end,
+}
+
+-- Registers the given entity if needed.
+function global_util.register_entity(entity)
+ if register_entity_look_up_functions[entity.name] then
+ register_entity_look_up_functions[entity.name](entity)
+ end
+end
diff --git a/scripts/gui-entity.lua b/scripts/gui-entity.lua
index c7f7492..86f23bf 100644
--- a/scripts/gui-entity.lua
+++ b/scripts/gui-entity.lua
@@ -2,680 +2,678 @@ local mod_gui = require("mod-gui")
-- This file contains variables and functions related to entity GUI.
if not gui_entity then
- gui_entity = {}
+ gui_entity = {}
end
-- Creates the GUI frame (for opened entity GUI) for the given entity if the frame has not been created. Otherwise, destroys the element.
-- Returns the frame container and the frame if they are created.
local function create_or_destroy_entity_gui_frame(entity_gui_container, entity, use_frame_container)
- local element_name
- if use_frame_container then
- element_name = creative_mode_defines.names.gui.entity_gui_frame_container
- else
- element_name = creative_mode_defines.names.gui.entity_gui_frame
- end
- if entity_gui_container[element_name] then
- entity_gui_container[element_name].destroy()
- return nil
- end
-
- if use_frame_container then
- -- Don't use table, as it will be repositioned when any child is destroyed.
- local frame_container =
- entity_gui_container.add {
- type = "flow",
- name = creative_mode_defines.names.gui.entity_gui_frame_container,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical"
- }
- frame_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.entity_gui_frame,
- direction = "vertical",
- caption = entity.localised_name
- }
- return frame_container, frame_container[creative_mode_defines.names.gui.entity_gui_frame]
- else
- entity_gui_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.entity_gui_frame,
- direction = "vertical",
- caption = entity.localised_name
- }
- return nil, entity_gui_container[creative_mode_defines.names.gui.entity_gui_frame]
- end
+ local element_name
+ if use_frame_container then
+ element_name = creative_mode_defines.names.gui.entity_gui_frame_container
+ else
+ element_name = creative_mode_defines.names.gui.entity_gui_frame
+ end
+ if entity_gui_container[element_name] then
+ entity_gui_container[element_name].destroy()
+ return nil
+ end
+
+ if use_frame_container then
+ -- Don't use table, as it will be repositioned when any child is destroyed.
+ local frame_container = entity_gui_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.entity_gui_frame_container,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+ frame_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.entity_gui_frame,
+ direction = "vertical",
+ caption = entity.localised_name,
+ })
+ return frame_container, frame_container[creative_mode_defines.names.gui.entity_gui_frame]
+ else
+ entity_gui_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.entity_gui_frame,
+ direction = "vertical",
+ caption = entity.localised_name,
+ })
+ return nil, entity_gui_container[creative_mode_defines.names.gui.entity_gui_frame]
+ end
end
-- Returns the frame and frame container for the given player and entity GUI of the given entity.
-- 2 nils will be returned if the player has not opened the entity GUI.
-- @param use_frame_container Whether an additional container was used outside the entity GUI frame when creating the entity GUI.
local function get_frame_and_frame_container_for_entity_gui(player, entity, use_frame_container)
- local entity_gui_container = mod_gui.get_frame_flow(player)[creative_mode_defines.names.gui.entity_gui_container]
- if not entity_gui_container then
- return nil, nil
- end
- if use_frame_container then
- local frame_container = entity_gui_container[creative_mode_defines.names.gui.entity_gui_frame_container]
- if not frame_container then
- return nil, nil
- end
- return frame_container, frame_container[creative_mode_defines.names.gui.entity_gui_frame]
- else
- return nil, entity_gui_container[creative_mode_defines.names.gui.entity_gui_frame]
- end
+ local entity_gui_container = mod_gui.get_frame_flow(player)[creative_mode_defines.names.gui.entity_gui_container]
+ if not entity_gui_container then
+ return nil, nil
+ end
+ if use_frame_container then
+ local frame_container = entity_gui_container[creative_mode_defines.names.gui.entity_gui_frame_container]
+ if not frame_container then
+ return nil, nil
+ end
+ return frame_container, frame_container[creative_mode_defines.names.gui.entity_gui_frame]
+ else
+ return nil, entity_gui_container[creative_mode_defines.names.gui.entity_gui_frame]
+ end
end
-- Updates the entity GUI for all players who are checking the given entity using the given update delegate.
-- @param use_frame_container Whether an additional container was used outside the entity GUI frame when creating the entity GUI.
local function update_entity_gui_for_all_players_checking_the_entity(entity, use_frame_container, update_delegate)
- for _, player in pairs(game.players) do
- if storage.creative_mode.player_opened_entities[player.index] == entity then
- local frame_container, frame = get_frame_and_frame_container_for_entity_gui(player, entity, use_frame_container)
- update_delegate(player, frame_container, frame)
- end
- end
+ for _, player in pairs(game.players) do
+ if storage.creative_mode.player_opened_entities[player.index] == entity then
+ local frame_container, frame = get_frame_and_frame_container_for_entity_gui(player, entity, use_frame_container)
+ update_delegate(player, frame_container, frame)
+ end
+ end
end
--------------------------------------------------------------------
-- Returns the caption for the creative chest group number label according to the given group number.
local function get_caption_for_creative_chest_group_number_label(group_number, max_group_number)
- return group_number .. "/" .. max_group_number
+ return group_number .. "/" .. max_group_number
end
-- Creates the filter table for the given creative chest GUI frame according to the given chest data and group number.
local function create_filter_table_for_creative_chest_gui_frame(chest_data, group_number, contain_hidden_items, frame)
- -- Slot table wrapped inside a scroll-pane.
- local scroll_pane =
- frame.add {type = "scroll-pane", name = creative_mode_defines.names.gui.creative_chest_filter_scroll_pane}
- scroll_pane.style.maximal_height = 465
- local filter_table =
- scroll_pane.add {
- type = "table",
- name = creative_mode_defines.names.gui.creative_chest_filter_table,
- column_count = 10,
- style = creative_mode_defines.names.gui_styles.slot_table
- }
- -- The slots.
- local inventory = creative_chest_util.get_inventory_from_data(chest_data)
- local slot = 1
- local inventory_size = #inventory
- local filtered_slots = chest_data.filtered_slots
- local filtered_slots_count = #filtered_slots
- local next_filtered_slot_to_check = 1
- if filtered_slots_count <= 0 then
- next_filtered_slot_to_check = 0
- end
- local start_item_index, end_item_index =
- creative_chest_util.get_start_end_item_index_for_group(group_number, inventory_size - 1, contain_hidden_items)
- for i = start_item_index, end_item_index, 1 do
- local item = creative_chest_util.get_item_at(i, contain_hidden_items)
- local style
- -- Check whether the slot has been filtered out.
- if next_filtered_slot_to_check <= 0 or filtered_slots[next_filtered_slot_to_check] ~= slot then
- style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
- else
- style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
- -- Check for the next index of filtered slot if possible.
- if filtered_slots_count >= next_filtered_slot_to_check + 1 then
- next_filtered_slot_to_check = next_filtered_slot_to_check + 1
- else
- next_filtered_slot_to_check = 0
- end
- end
-
- filter_table.add {
- type = "sprite-button",
- name = creative_mode_defines.names.gui.creative_chest_filter_slot_prefix .. slot,
- sprite = "item/" .. item.name,
- style = style,
- tooltip = item.localised_name
- }
-
- -- Next slot.
- slot = slot + 1
- -- Though it is unlikely to happen... (caused by mod version change?) Break the loop if slot exceeds.
- if slot > inventory_size then
- break
- end
- end
+ -- Slot table wrapped inside a scroll-pane.
+ local scroll_pane =
+ frame.add({ type = "scroll-pane", name = creative_mode_defines.names.gui.creative_chest_filter_scroll_pane })
+ scroll_pane.style.maximal_height = 465
+ local filter_table = scroll_pane.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.creative_chest_filter_table,
+ column_count = 10,
+ style = creative_mode_defines.names.gui_styles.slot_table,
+ })
+ -- The slots.
+ local inventory = creative_chest_util.get_inventory_from_data(chest_data)
+ local slot = 1
+ local inventory_size = #inventory
+ local filtered_slots = chest_data.filtered_slots
+ local filtered_slots_count = #filtered_slots
+ local next_filtered_slot_to_check = 1
+ if filtered_slots_count <= 0 then
+ next_filtered_slot_to_check = 0
+ end
+ local start_item_index, end_item_index =
+ creative_chest_util.get_start_end_item_index_for_group(group_number, inventory_size - 1, contain_hidden_items)
+ for i = start_item_index, end_item_index, 1 do
+ local item = creative_chest_util.get_item_at(i, contain_hidden_items)
+ local style
+ -- Check whether the slot has been filtered out.
+ if next_filtered_slot_to_check <= 0 or filtered_slots[next_filtered_slot_to_check] ~= slot then
+ style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
+ else
+ style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
+ -- Check for the next index of filtered slot if possible.
+ if filtered_slots_count >= next_filtered_slot_to_check + 1 then
+ next_filtered_slot_to_check = next_filtered_slot_to_check + 1
+ else
+ next_filtered_slot_to_check = 0
+ end
+ end
+
+ filter_table.add({
+ type = "sprite-button",
+ name = creative_mode_defines.names.gui.creative_chest_filter_slot_prefix .. slot,
+ sprite = "item/" .. item.name,
+ style = style,
+ tooltip = item.localised_name,
+ })
+
+ -- Next slot.
+ slot = slot + 1
+ -- Though it is unlikely to happen... (caused by mod version change?) Break the loop if slot exceeds.
+ if slot > inventory_size then
+ break
+ end
+ end
end
-- Creates or destroys the Creative Chest GUI for the given player. Returns whether the GUI is created.
local function create_or_destroy_creative_chest_gui(player, entity, entity_gui_container)
- -- Creative chest open button.
- local chest_groups, max_group_number, contain_hidden_items = creative_chest_util.get_creative_chest_data_groups(entity)
- local chest_data, group_number = creative_chest_util.get_creative_chest_data_group_number(entity, chest_groups)
- if chest_data and group_number > 0 then
- -- Frame.
- local _, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, false)
-
- if frame then
- -- Item group label.
- local item_group_container =
- frame.add {
- type = "table",
- name = creative_mode_defines.names.gui.creative_chest_item_group_container,
- style = creative_mode_defines.names.gui_styles.unscalable_no_spacing_table,
- column_count = 4
- }
- item_group_container.add {
- type = "label",
- name = creative_mode_defines.names.gui.creative_chest_item_group_label,
- style = creative_mode_defines.names.gui_styles.creative_chest_item_group_label,
- caption = {"gui.creative-mode_item-group"},
- tooltip = {"gui.creative-mode_item-group-tooltip"}
- }
- -- Item group left button.
- item_group_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.creative_chest_item_group_left_button,
- style = creative_mode_defines.names.gui_styles.creative_chest_item_group_left_right_button,
- caption = "<"
- }
- -- Item group number label.
- item_group_container.add {
- type = "label",
- name = creative_mode_defines.names.gui.creative_chest_item_group_number_label,
- style = creative_mode_defines.names.gui_styles.creative_chest_item_group_number_label,
- caption = get_caption_for_creative_chest_group_number_label(group_number, max_group_number)
- }
- -- Item group right button.
- item_group_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.creative_chest_item_group_right_button,
- style = creative_mode_defines.names.gui_styles.creative_chest_item_group_left_right_button,
- caption = ">"
- }
-
- -- Filter items label.
- local label_container =
- frame.add {
- type = "table",
- name = creative_mode_defines.names.gui.creative_chest_filter_container,
- style = creative_mode_defines.names.gui_styles.unscalable_no_spacing_table,
- column_count = 3
- }
- label_container.add {
- type = "label",
- name = creative_mode_defines.names.gui.creative_chest_filter_label,
- style = creative_mode_defines.names.gui_styles.creative_chest_select_slot_label,
- caption = {"gui.creative-mode_select-slots-to-filter"},
- tooltip = {"gui.creative-mode_select-slots-to-filter-tooltip"}
- }
- -- Inventory display mode button.
- local display_mode_style
- local display_mode_tooltip
- if chest_data.inventory_display_mode == creative_chest_util.inventory_display_modes.original_mode then
- display_mode_style = creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_original
- display_mode_tooltip = creative_mode_defines.names.gui_captions.creative_chest_display_mode_original
- else
- display_mode_style = creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_compact
- display_mode_tooltip = creative_mode_defines.names.gui_captions.creative_chest_display_mode_compact
- end
- label_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.creative_chest_display_mode_button,
- style = display_mode_style,
- tooltip = display_mode_tooltip
- }
- -- Toggle all button.
- label_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.creative_chest_toggle_all_button,
- style = creative_mode_defines.names.gui_styles.inventory_toggle_all_button,
- tooltip = {"gui.creative-mode_toggle-all-filtered-slots-tooltip"}
- }
-
- -- Filter table.
- create_filter_table_for_creative_chest_gui_frame(chest_data, group_number, contain_hidden_items, frame)
-
- return true
- end
- end
- return false
+ -- Creative chest open button.
+ local chest_groups, max_group_number, contain_hidden_items =
+ creative_chest_util.get_creative_chest_data_groups(entity)
+ local chest_data, group_number = creative_chest_util.get_creative_chest_data_group_number(entity, chest_groups)
+ if chest_data and group_number > 0 then
+ -- Frame.
+ local _, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, false)
+
+ if frame then
+ -- Item group label.
+ local item_group_container = frame.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.creative_chest_item_group_container,
+ style = creative_mode_defines.names.gui_styles.unscalable_no_spacing_table,
+ column_count = 4,
+ })
+ item_group_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.creative_chest_item_group_label,
+ style = creative_mode_defines.names.gui_styles.creative_chest_item_group_label,
+ caption = { "gui.creative-mode_item-group" },
+ tooltip = { "gui.creative-mode_item-group-tooltip" },
+ })
+ -- Item group left button.
+ item_group_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.creative_chest_item_group_left_button,
+ style = creative_mode_defines.names.gui_styles.creative_chest_item_group_left_right_button,
+ caption = "<",
+ })
+ -- Item group number label.
+ item_group_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.creative_chest_item_group_number_label,
+ style = creative_mode_defines.names.gui_styles.creative_chest_item_group_number_label,
+ caption = get_caption_for_creative_chest_group_number_label(group_number, max_group_number),
+ })
+ -- Item group right button.
+ item_group_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.creative_chest_item_group_right_button,
+ style = creative_mode_defines.names.gui_styles.creative_chest_item_group_left_right_button,
+ caption = ">",
+ })
+
+ -- Filter items label.
+ local label_container = frame.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.creative_chest_filter_container,
+ style = creative_mode_defines.names.gui_styles.unscalable_no_spacing_table,
+ column_count = 3,
+ })
+ label_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.creative_chest_filter_label,
+ style = creative_mode_defines.names.gui_styles.creative_chest_select_slot_label,
+ caption = { "gui.creative-mode_select-slots-to-filter" },
+ tooltip = { "gui.creative-mode_select-slots-to-filter-tooltip" },
+ })
+ -- Inventory display mode button.
+ local display_mode_style
+ local display_mode_tooltip
+ if chest_data.inventory_display_mode == creative_chest_util.inventory_display_modes.original_mode then
+ display_mode_style = creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_original
+ display_mode_tooltip = creative_mode_defines.names.gui_captions.creative_chest_display_mode_original
+ else
+ display_mode_style = creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_compact
+ display_mode_tooltip = creative_mode_defines.names.gui_captions.creative_chest_display_mode_compact
+ end
+ label_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.creative_chest_display_mode_button,
+ style = display_mode_style,
+ tooltip = display_mode_tooltip,
+ })
+ -- Toggle all button.
+ label_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.creative_chest_toggle_all_button,
+ style = creative_mode_defines.names.gui_styles.inventory_toggle_all_button,
+ tooltip = { "gui.creative-mode_toggle-all-filtered-slots-tooltip" },
+ })
+
+ -- Filter table.
+ create_filter_table_for_creative_chest_gui_frame(chest_data, group_number, contain_hidden_items, frame)
+
+ return true
+ end
+ end
+ return false
end
-- Adds the group number of the given creative chest and updates the GUI about its contents.
local function add_creative_chest_group_number_and_update_gui(creative_chest_entity, add_amount)
- local chest_groups, max_group_number, contain_hidden_items =
- creative_chest_util.get_creative_chest_data_groups(creative_chest_entity)
- local chest_data, group_number, index_in_group =
- creative_chest_util.get_creative_chest_data_group_number(creative_chest_entity, chest_groups)
- if chest_data and group_number > 0 then
- -- Change group number.
- local new_group_number = group_number + add_amount
- new_group_number = util.repeat_index(new_group_number, 1, max_group_number)
- if
- creative_chest_util.change_creative_chest_group_number(
- chest_data,
- chest_groups,
- group_number,
- index_in_group,
- new_group_number,
- creative_chest_entity
- )
- then
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- creative_chest_entity,
- false,
- function(p, _, frame)
- if frame then
- -- Update item group number.
- local item_group_container = frame[creative_mode_defines.names.gui.creative_chest_item_group_container]
- local item_group_number_label =
- item_group_container[creative_mode_defines.names.gui.creative_chest_item_group_number_label]
- item_group_number_label.caption =
- get_caption_for_creative_chest_group_number_label(new_group_number, max_group_number)
-
- -- Update filter table.
- local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
- -- Destroy the original scroll pane and re-create it and its contents.
- scroll_pane.destroy()
- create_filter_table_for_creative_chest_gui_frame(chest_data, new_group_number, contain_hidden_items, frame)
- end
- end
- )
- end
- end
+ local chest_groups, max_group_number, contain_hidden_items =
+ creative_chest_util.get_creative_chest_data_groups(creative_chest_entity)
+ local chest_data, group_number, index_in_group =
+ creative_chest_util.get_creative_chest_data_group_number(creative_chest_entity, chest_groups)
+ if chest_data and group_number > 0 then
+ -- Change group number.
+ local new_group_number = group_number + add_amount
+ new_group_number = util.repeat_index(new_group_number, 1, max_group_number)
+ if
+ creative_chest_util.change_creative_chest_group_number(
+ chest_data,
+ chest_groups,
+ group_number,
+ index_in_group,
+ new_group_number,
+ creative_chest_entity
+ )
+ then
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(creative_chest_entity, false, function(p, _, frame)
+ if frame then
+ -- Update item group number.
+ local item_group_container = frame[creative_mode_defines.names.gui.creative_chest_item_group_container]
+ local item_group_number_label =
+ item_group_container[creative_mode_defines.names.gui.creative_chest_item_group_number_label]
+ item_group_number_label.caption =
+ get_caption_for_creative_chest_group_number_label(new_group_number, max_group_number)
+
+ -- Update filter table.
+ local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
+ -- Destroy the original scroll pane and re-create it and its contents.
+ scroll_pane.destroy()
+ create_filter_table_for_creative_chest_gui_frame(chest_data, new_group_number, contain_hidden_items, frame)
+ end
+ end)
+ end
+ end
end
--------------------------------------------------------------------
-- Creates or destroys the duplicating chest GUI for the given player. Returns whether the GUI is created.
local function create_or_destroy_duplicating_chest_gui(player, entity, entity_gui_container)
- local data = duplicating_chest_util.get_data_for_entity(entity)
- if data then
- -- Frame.
- local _, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, false)
-
- if frame then
- -- Checkbox.
- frame.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.duplicating_chest_lock_item_checkbox,
- state = data.lock_item,
- caption = {"gui.creative-mode_lock-item"},
- tooltip = {"gui.creative-mode_lock-item-tooltip"}
- }
-
- return true
- end
- end
- return false
+ local data = duplicating_chest_util.get_data_for_entity(entity)
+ if data then
+ -- Frame.
+ local _, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, false)
+
+ if frame then
+ -- Checkbox.
+ frame.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.duplicating_chest_lock_item_checkbox,
+ state = data.lock_item,
+ caption = { "gui.creative-mode_lock-item" },
+ tooltip = { "gui.creative-mode_lock-item-tooltip" },
+ })
+
+ return true
+ end
+ end
+ return false
end
--------------------------------------------------------------------
-- Creates or destroys the Configurable Super Boiler GUI for the given player. Returns whether the GUI is created.
local function create_or_destroy_configurable_super_boiler_gui(player, entity, entity_gui_container)
- local data = configurable_super_boiler.get_data_for_entity(entity)
- if data then
- -- Frame.
- local _, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, false)
-
- if frame then
- -- Container.
- local set_temp_container =
- frame.add {
- type = "flow",
- name = creative_mode_defines.names.gui.configurable_super_boiler_set_temp_container,
- direction = "horizontal"
- }
- -- Label.
- set_temp_container.add {
- type = "label",
- name = creative_mode_defines.names.gui.configurable_super_boiler_set_temp_label,
- caption = {"gui.creative-mode_set-temperature"}
- }
- -- Textfield.
- set_temp_container.add {
- type = "textfield",
- name = creative_mode_defines.names.gui.configurable_super_boiler_set_temp_textfield,
- style = creative_mode_defines.names.gui_styles.item_count_textfield,
- text = data.temperature
- }
- -- Button.
- set_temp_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.configurable_super_boiler_set_temp_button,
- style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
- caption = creative_mode_defines.names.gui_captions.ok
- }
-
- return true
- end
- end
- return false
+ local data = configurable_super_boiler.get_data_for_entity(entity)
+ if data then
+ -- Frame.
+ local _, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, false)
+
+ if frame then
+ -- Container.
+ local set_temp_container = frame.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.configurable_super_boiler_set_temp_container,
+ direction = "horizontal",
+ })
+ -- Label.
+ set_temp_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.configurable_super_boiler_set_temp_label,
+ caption = { "gui.creative-mode_set-temperature" },
+ })
+ -- Textfield.
+ set_temp_container.add({
+ type = "textfield",
+ name = creative_mode_defines.names.gui.configurable_super_boiler_set_temp_textfield,
+ style = creative_mode_defines.names.gui_styles.item_count_textfield,
+ text = data.temperature,
+ })
+ -- Button.
+ set_temp_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.configurable_super_boiler_set_temp_button,
+ style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
+ caption = creative_mode_defines.names.gui_captions.ok,
+ })
+
+ return true
+ end
+ end
+ return false
end
--------------------------------------------------------------------
-- Adds or removes the GUI about options for Matter Source insert only once to player according to the given Matter Source entity data.
local function add_or_remove_item_source_insert_only_once_to_player_options_gui(frame_container, entity_data)
- if entity_data.insert_only_once_to_player then
- if not frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame] then
- -- Insert only once to player frame.
- local insert_once_to_player_frame =
- frame_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.item_source_insert_once_to_player_frame,
- direction = "vertical"
- }
- -- Container.
- local insert_once_to_player_container =
- insert_once_to_player_frame.add {
- type = "table",
- name = creative_mode_defines.names.gui.item_source_insert_once_to_player_container,
- column_count = 1
- }
- -- Insert to player amount.
- local insert_to_player_amount_container =
- insert_once_to_player_container.add {
- type = "flow",
- name = creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_container,
- direction = "horizontal"
- }
- insert_to_player_amount_container.add {
- type = "label",
- name = creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_label,
- caption = {"gui.creative-mode_insert-to-player-amount"},
- tooltip = {"gui.creative-mode_insert-to-player-amount-tooltip"}
- }
- insert_to_player_amount_container.add {
- type = "textfield",
- name = creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_field,
- style = creative_mode_defines.names.gui_styles.item_count_textfield,
- text = entity_data.insert_to_player_amount
- }
- -- Insert to player by stack.
- insert_once_to_player_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.item_source_insert_once_to_player_by_stack_checkbox,
- state = entity_data.insert_to_player_by_stack,
- caption = {"gui.creative-mode_by-stack"},
- tooltip = {"gui.creative-mode_by-stack-tooltip"}
- }
- end
- else
- if frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame] then
- frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame].destroy()
- end
- end
+ if entity_data.insert_only_once_to_player then
+ if not frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame] then
+ -- Insert only once to player frame.
+ local insert_once_to_player_frame = frame_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.item_source_insert_once_to_player_frame,
+ direction = "vertical",
+ })
+ -- Container.
+ local insert_once_to_player_container = insert_once_to_player_frame.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.item_source_insert_once_to_player_container,
+ column_count = 1,
+ })
+ -- Insert to player amount.
+ local insert_to_player_amount_container = insert_once_to_player_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_container,
+ direction = "horizontal",
+ })
+ insert_to_player_amount_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_label,
+ caption = { "gui.creative-mode_insert-to-player-amount" },
+ tooltip = { "gui.creative-mode_insert-to-player-amount-tooltip" },
+ })
+ insert_to_player_amount_container.add({
+ type = "textfield",
+ name = creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_field,
+ style = creative_mode_defines.names.gui_styles.item_count_textfield,
+ text = entity_data.insert_to_player_amount,
+ })
+ -- Insert to player by stack.
+ insert_once_to_player_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.item_source_insert_once_to_player_by_stack_checkbox,
+ state = entity_data.insert_to_player_by_stack,
+ caption = { "gui.creative-mode_by-stack" },
+ tooltip = { "gui.creative-mode_by-stack-tooltip" },
+ })
+ end
+ else
+ if frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame] then
+ frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame].destroy()
+ end
+ end
end
-- Adds or removes the GUI about options for Matter Source insert to player according to the given Matter Source entity data.
local function add_or_remove_item_source_insert_to_player_options_gui(frame_container, entity_data)
- if entity_data.can_insert_to_player then
- if not frame_container[creative_mode_defines.names.gui.item_source_insert_to_player_frame] then
- -- Insert to player frame.
- local insert_to_player_frame =
- frame_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.item_source_insert_to_player_frame,
- direction = "vertical"
- }
- -- Insert to player only once.
- insert_to_player_frame.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.item_source_insert_only_once_to_player_checkbox,
- state = entity_data.insert_only_once_to_player,
- caption = {"gui.creative-mode_insert_only_once_to_player"},
- tooltip = {"gui.creative-mode_insert_only_once_to_player-tooltip"}
- }
-
- -- Insert only once to player GUI.
- add_or_remove_item_source_insert_only_once_to_player_options_gui(frame_container, entity_data)
- end
- else
- if frame_container[creative_mode_defines.names.gui.item_source_insert_to_player_frame] then
- frame_container[creative_mode_defines.names.gui.item_source_insert_to_player_frame].destroy()
- end
- if frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame] then
- frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame].destroy()
- end
- end
+ if entity_data.can_insert_to_player then
+ if not frame_container[creative_mode_defines.names.gui.item_source_insert_to_player_frame] then
+ -- Insert to player frame.
+ local insert_to_player_frame = frame_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.item_source_insert_to_player_frame,
+ direction = "vertical",
+ })
+ -- Insert to player only once.
+ insert_to_player_frame.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.item_source_insert_only_once_to_player_checkbox,
+ state = entity_data.insert_only_once_to_player,
+ caption = { "gui.creative-mode_insert_only_once_to_player" },
+ tooltip = { "gui.creative-mode_insert_only_once_to_player-tooltip" },
+ })
+
+ -- Insert only once to player GUI.
+ add_or_remove_item_source_insert_only_once_to_player_options_gui(frame_container, entity_data)
+ end
+ else
+ if frame_container[creative_mode_defines.names.gui.item_source_insert_to_player_frame] then
+ frame_container[creative_mode_defines.names.gui.item_source_insert_to_player_frame].destroy()
+ end
+ if frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame] then
+ frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame].destroy()
+ end
+ end
end
-- Creates or destroys the Matter Source GUI for the given player. Returns whether the GUI is created.
local function create_or_destroy_item_source_gui(player, entity, entity_gui_container)
- local data = nil
- if entity.name == creative_mode_defines.names.entities.item_source then
- data = item_source.get_data_for_entity(entity)
- else
- data = random_item_source.get_data_for_entity(entity)
- end
- if data then
- -- Frame.
- local frame_container, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, true)
-
- if frame_container and frame then
- -- Options container.
- local options_container =
- frame.add {type = "table", name = creative_mode_defines.names.gui.item_source_options_container, column_count = 1}
- -- Can insert to vehicle.
- options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.item_source_can_insert_to_vehicle_checkbox,
- state = data.can_insert_to_vehicle,
- caption = {"gui.creative-mode_can-insert-to-vehicle"}
- }
- -- Can insert to player.
- options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.item_source_can_insert_to_player_checkbox,
- state = data.can_insert_to_player,
- caption = {"gui.creative-mode_can-insert-to-player"}
- }
- -- Can drop on ground.
- options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.item_source_can_drop_on_ground_checkbox,
- state = data.can_drop_on_ground,
- caption = {"gui.creative-mode_can-drop-on-ground"}
- }
-
- add_or_remove_item_source_insert_to_player_options_gui(frame_container, data)
-
- return true
- end
- end
- return false
+ local data = nil
+ if entity.name == creative_mode_defines.names.entities.item_source then
+ data = item_source.get_data_for_entity(entity)
+ else
+ data = random_item_source.get_data_for_entity(entity)
+ end
+ if data then
+ -- Frame.
+ local frame_container, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, true)
+
+ if frame_container and frame then
+ -- Options container.
+ local options_container = frame.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.item_source_options_container,
+ column_count = 1,
+ })
+ -- Can insert to vehicle.
+ options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.item_source_can_insert_to_vehicle_checkbox,
+ state = data.can_insert_to_vehicle,
+ caption = { "gui.creative-mode_can-insert-to-vehicle" },
+ })
+ -- Can insert to player.
+ options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.item_source_can_insert_to_player_checkbox,
+ state = data.can_insert_to_player,
+ caption = { "gui.creative-mode_can-insert-to-player" },
+ })
+ -- Can drop on ground.
+ options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.item_source_can_drop_on_ground_checkbox,
+ state = data.can_drop_on_ground,
+ caption = { "gui.creative-mode_can-drop-on-ground" },
+ })
+
+ add_or_remove_item_source_insert_to_player_options_gui(frame_container, data)
+
+ return true
+ end
+ end
+ return false
end
--------------------------------------------------------------------
-- Creates or destroys the Matter Duplicator GUI for the given player. Returns whether the GUI is created.
local function create_or_destroy_duplicator_gui(player, entity, entity_gui_container)
- local data = duplicator.get_data_for_entity(entity)
- if data then
- -- Frame.
- local frame_container, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, true)
-
- if frame_container and frame then
- -- Options container.
- local options_container =
- frame.add {type = "table", name = creative_mode_defines.names.gui.duplicator_options_container, column_count = 1}
- -- Can duplicate in vehicle.
- options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.duplicator_can_duplicate_in_vehicle_checkbox,
- state = data.can_duplicate_in_vehicle,
- caption = {"gui.creative-mode_can-duplicate-in-vehicle"}
- }
- -- Can duplicate in player.
- options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.duplicator_can_duplicate_in_player_checkbox,
- state = data.can_duplicate_in_player,
- caption = {"gui.creative-mode_can-duplicate-in-player"}
- }
-
- return true
- end
- end
- return false
+ local data = duplicator.get_data_for_entity(entity)
+ if data then
+ -- Frame.
+ local frame_container, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, true)
+
+ if frame_container and frame then
+ -- Options container.
+ local options_container = frame.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.duplicator_options_container,
+ column_count = 1,
+ })
+ -- Can duplicate in vehicle.
+ options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.duplicator_can_duplicate_in_vehicle_checkbox,
+ state = data.can_duplicate_in_vehicle,
+ caption = { "gui.creative-mode_can-duplicate-in-vehicle" },
+ })
+ -- Can duplicate in player.
+ options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.duplicator_can_duplicate_in_player_checkbox,
+ state = data.can_duplicate_in_player,
+ caption = { "gui.creative-mode_can-duplicate-in-player" },
+ })
+
+ return true
+ end
+ end
+ return false
end
--------------------------------------------------------------------
-- Creates or destroys the Matter Void GUI for the given player. Returns whether the GUI is created.
local function create_or_destroy_item_void_gui(player, entity, entity_gui_container)
- local data = item_void.get_data_for_entity(entity)
- if data then
- -- Frame.
- local frame_container, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, true)
-
- if frame_container and frame then
- -- Options container.
- local options_container =
- frame.add {type = "table", name = creative_mode_defines.names.gui.item_void_options_container, column_count = 1}
- -- Can remove from vehicle.
- options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.item_void_can_remove_from_vehicle_checkbox,
- state = data.can_remove_from_vehicle,
- caption = {"gui.creative-mode_can-remove-from-vehicle"}
- }
- -- Can remove from player.
- options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.item_void_can_remove_from_player_checkbox,
- state = data.can_remove_from_player,
- caption = {"gui.creative-mode_can-remove-from-player"}
- }
- -- Can remove from ground.
- options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.item_void_can_remove_from_ground_checkbox,
- state = data.can_remove_from_ground,
- caption = {"gui.creative-mode_can-remove-from-ground"}
- }
- end
-
- return true
- end
- return false
+ local data = item_void.get_data_for_entity(entity)
+ if data then
+ -- Frame.
+ local frame_container, frame = create_or_destroy_entity_gui_frame(entity_gui_container, entity, true)
+
+ if frame_container and frame then
+ -- Options container.
+ local options_container = frame.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.item_void_options_container,
+ column_count = 1,
+ })
+ -- Can remove from vehicle.
+ options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.item_void_can_remove_from_vehicle_checkbox,
+ state = data.can_remove_from_vehicle,
+ caption = { "gui.creative-mode_can-remove-from-vehicle" },
+ })
+ -- Can remove from player.
+ options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.item_void_can_remove_from_player_checkbox,
+ state = data.can_remove_from_player,
+ caption = { "gui.creative-mode_can-remove-from-player" },
+ })
+ -- Can remove from ground.
+ options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.item_void_can_remove_from_ground_checkbox,
+ state = data.can_remove_from_ground,
+ caption = { "gui.creative-mode_can-remove-from-ground" },
+ })
+ end
+
+ return true
+ end
+ return false
end
--------------------------------------------------------------------
-- Resets the last action applied on the entity GUI by the player of given index.
local function reset_last_entity_gui_action_by_player_index(player_index)
- if storage.last_entity_gui_actions_by_players then
- storage.last_entity_gui_actions_by_players[player_index] = nil
- end
+ if storage.last_entity_gui_actions_by_players then
+ storage.last_entity_gui_actions_by_players[player_index] = nil
+ end
end
-- Fixes sprite names for the new creative chests
local function get_sprite_name(entity_name)
- if entity_name == creative_mode_defines.names.entities.new_creative_chest then
- return creative_mode_defines.names.entities.creative_chest
- elseif entity_name == creative_mode_defines.names.entities.new_creative_provider_chest then
- return creative_mode_defines.names.entities.creative_provider_chest
- end
- return entity_name
+ if entity_name == creative_mode_defines.names.entities.new_creative_chest then
+ return creative_mode_defines.names.entities.creative_chest
+ elseif entity_name == creative_mode_defines.names.entities.new_creative_provider_chest then
+ return creative_mode_defines.names.entities.creative_provider_chest
+ end
+ return entity_name
end
-- Creates or destroys the GUI of given entity on the given player.
-- Nothing will be created if there is no GUI for the entity.
function gui_entity.create_or_destroy_gui_of_entity(player, entity, is_create)
- local left = mod_gui.get_frame_flow(player)
- local top = mod_gui.get_button_flow(player)
- -- Register or deregister the entity.
- if is_create then
- storage.creative_mode.player_opened_entities[player.index] = entity
- else
- storage.creative_mode.player_opened_entities[player.index] = nil
- end
-
- -- Reset action.
- reset_last_entity_gui_action_by_player_index(player.index)
-
- if is_create and player.opened_gui_type == defines.gui_type.entity then
- -- Create GUI.
- local entity_name = entity.name
- -- Get the data about the button that we will created.
- local button_name
- local open_gui_function
- if
- entity_name == creative_mode_defines.names.entities.new_creative_chest or
- entity_name == creative_mode_defines.names.entities.new_creative_provider_chest or
- entity_name == creative_mode_defines.names.entities.creative_cargo_wagon
- then
- -- Button for the creative chest family.
- button_name = creative_mode_defines.names.gui.creative_chest_open_button
- open_gui_function = create_or_destroy_creative_chest_gui
- elseif
- entity_name == creative_mode_defines.names.entities.duplicating_chest or
- entity_name == creative_mode_defines.names.entities.duplicating_provider_chest or
- entity_name == creative_mode_defines.names.entities.duplicating_cargo_wagon
- then
- -- Button for the duplicating chest family.
- button_name = creative_mode_defines.names.gui.duplicating_chest_open_button
- open_gui_function = create_or_destroy_duplicating_chest_gui
- elseif entity_name == creative_mode_defines.names.entities.configurable_super_boiler then
- -- Button for the configurable super boiler.
- button_name = creative_mode_defines.names.gui.configurable_super_boiler_open_button
- open_gui_function = create_or_destroy_configurable_super_boiler_gui
- elseif
- entity_name == creative_mode_defines.names.entities.item_source or
- entity_name == creative_mode_defines.names.entities.random_item_source
- then
- -- Button for the matter source and random item source.
- button_name = creative_mode_defines.names.gui.item_source_open_button
- open_gui_function = create_or_destroy_item_source_gui
- elseif entity_name == creative_mode_defines.names.entities.duplicator then
- -- Button for the matter duplicator.
- button_name = creative_mode_defines.names.gui.duplicator_open_button
- open_gui_function = create_or_destroy_duplicator_gui
- elseif entity_name == creative_mode_defines.names.entities.item_void then
- -- Button for the matter void.
- button_name = creative_mode_defines.names.gui.item_void_open_button
- open_gui_function = create_or_destroy_item_void_gui
- else
- -- No GUI for the entity.
- return
- end
-
- -- Container.
- local container =
- left.add {type = "table", name = creative_mode_defines.names.gui.entity_gui_container, column_count = 2}
- container.style.top_padding = 8
- container.style.horizontal_spacing = 0
-
- -- Button container.
- local button_container = top.add {type = "flow", name = creative_mode_defines.names.gui.entity_gui_button_container}
-
- -- Button.
- button_container.add {
- type = "sprite-button",
- name = button_name,
- style = creative_mode_defines.names.gui_styles.entity_open_button,
- sprite = "item/" .. get_sprite_name(entity_name),
- tooltip = {"gui.creative-mode_entity-button-tooltip", entity.localised_name}
- }
-
- -- Open the detailed GUI if necessary.
- if
- storage.creative_mode.player_opened_entity_gui[player.index] == nil or
- storage.creative_mode.player_opened_entity_gui[player.index]
- then
- open_gui_function(player, entity, container)
- end
- else
- -- Destroy GUI.
- storage.creative_mode.player_opened_entities[player.index] = nil
- local container = left[creative_mode_defines.names.gui.entity_gui_container]
- if container then
- container.destroy()
- end
- local button_container = top[creative_mode_defines.names.gui.entity_gui_button_container]
- if button_container then
- button_container.destroy()
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local top = mod_gui.get_button_flow(player)
+ -- Register or deregister the entity.
+ if is_create then
+ storage.creative_mode.player_opened_entities[player.index] = entity
+ else
+ storage.creative_mode.player_opened_entities[player.index] = nil
+ end
+
+ -- Reset action.
+ reset_last_entity_gui_action_by_player_index(player.index)
+
+ if is_create and player.opened_gui_type == defines.gui_type.entity then
+ -- Create GUI.
+ local entity_name = entity.name
+ -- Get the data about the button that we will created.
+ local button_name
+ local open_gui_function
+ if
+ entity_name == creative_mode_defines.names.entities.new_creative_chest
+ or entity_name == creative_mode_defines.names.entities.new_creative_provider_chest
+ or entity_name == creative_mode_defines.names.entities.creative_cargo_wagon
+ then
+ -- Button for the creative chest family.
+ button_name = creative_mode_defines.names.gui.creative_chest_open_button
+ open_gui_function = create_or_destroy_creative_chest_gui
+ elseif
+ entity_name == creative_mode_defines.names.entities.duplicating_chest
+ or entity_name == creative_mode_defines.names.entities.duplicating_provider_chest
+ or entity_name == creative_mode_defines.names.entities.duplicating_cargo_wagon
+ then
+ -- Button for the duplicating chest family.
+ button_name = creative_mode_defines.names.gui.duplicating_chest_open_button
+ open_gui_function = create_or_destroy_duplicating_chest_gui
+ elseif entity_name == creative_mode_defines.names.entities.configurable_super_boiler then
+ -- Button for the configurable super boiler.
+ button_name = creative_mode_defines.names.gui.configurable_super_boiler_open_button
+ open_gui_function = create_or_destroy_configurable_super_boiler_gui
+ elseif
+ entity_name == creative_mode_defines.names.entities.item_source
+ or entity_name == creative_mode_defines.names.entities.random_item_source
+ then
+ -- Button for the matter source and random item source.
+ button_name = creative_mode_defines.names.gui.item_source_open_button
+ open_gui_function = create_or_destroy_item_source_gui
+ elseif entity_name == creative_mode_defines.names.entities.duplicator then
+ -- Button for the matter duplicator.
+ button_name = creative_mode_defines.names.gui.duplicator_open_button
+ open_gui_function = create_or_destroy_duplicator_gui
+ elseif entity_name == creative_mode_defines.names.entities.item_void then
+ -- Button for the matter void.
+ button_name = creative_mode_defines.names.gui.item_void_open_button
+ open_gui_function = create_or_destroy_item_void_gui
+ else
+ -- No GUI for the entity.
+ return
+ end
+
+ -- Container.
+ local container =
+ left.add({ type = "table", name = creative_mode_defines.names.gui.entity_gui_container, column_count = 2 })
+ container.style.top_padding = 8
+ container.style.horizontal_spacing = 0
+
+ -- Button container.
+ local button_container =
+ top.add({ type = "flow", name = creative_mode_defines.names.gui.entity_gui_button_container })
+
+ -- Button.
+ button_container.add({
+ type = "sprite-button",
+ name = button_name,
+ style = creative_mode_defines.names.gui_styles.entity_open_button,
+ sprite = "item/" .. get_sprite_name(entity_name),
+ tooltip = { "gui.creative-mode_entity-button-tooltip", entity.localised_name },
+ })
+
+ -- Open the detailed GUI if necessary.
+ if
+ storage.creative_mode.player_opened_entity_gui[player.index] == nil
+ or storage.creative_mode.player_opened_entity_gui[player.index]
+ then
+ open_gui_function(player, entity, container)
+ end
+ else
+ -- Destroy GUI.
+ storage.creative_mode.player_opened_entities[player.index] = nil
+ local container = left[creative_mode_defines.names.gui.entity_gui_container]
+ if container then
+ container.destroy()
+ end
+ local button_container = top[creative_mode_defines.names.gui.entity_gui_button_container]
+ if button_container then
+ button_container.destroy()
+ end
+ end
end
--------------------------------------------------------------------
@@ -683,805 +681,738 @@ end
-- Callback of the on_gui_click event, extended from gui.lua.
-- Returns whether the event is consumed.
function gui_entity.on_gui_click(element, element_name, player, button, alt, control, shift)
- local left = mod_gui.get_frame_flow(player)
- local entity = storage.creative_mode.player_opened_entities[player.index]
- local entity_gui_container = left[creative_mode_defines.names.gui.entity_gui_container]
-
- if element_name == creative_mode_defines.names.gui.creative_chest_open_button then
- -- Creative chest open button.
- if create_or_destroy_creative_chest_gui(player, entity, entity_gui_container) then
- -- UI is opened.
- storage.creative_mode.player_opened_entity_gui[player.index] = true
- else
- -- UI is closed.
- storage.creative_mode.player_opened_entity_gui[player.index] = false
- end
- return true
- elseif element_name == creative_mode_defines.names.gui.creative_chest_item_group_left_button then
- -- Reduce group number by 1 for creative chest.
- add_creative_chest_group_number_and_update_gui(entity, -1)
- return true
- elseif element_name == creative_mode_defines.names.gui.creative_chest_item_group_right_button then
- -- Increase group number by 1 for creative chest.
- add_creative_chest_group_number_and_update_gui(entity, 1)
- return true
- elseif element_name == creative_mode_defines.names.gui.creative_chest_display_mode_button then
- -- Toggle inventory display mode for creative chest.
- local chest_data, group_number =
- creative_chest_util.get_creative_chest_data_group_number(
- entity,
- creative_chest_util.get_creative_chest_data_groups(entity)
- )
- if chest_data and group_number > 0 then
- local display_mode_style
- local display_mode_tooltip
- if chest_data.inventory_display_mode == creative_chest_util.inventory_display_modes.original_mode then
- chest_data.inventory_display_mode = creative_chest_util.inventory_display_modes.compact_mode
- display_mode_style = creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_compact
- display_mode_tooltip = creative_mode_defines.names.gui_captions.creative_chest_display_mode_compact
- else
- chest_data.inventory_display_mode = creative_chest_util.inventory_display_modes.original_mode
- display_mode_style = creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_original
- display_mode_tooltip = creative_mode_defines.names.gui_captions.creative_chest_display_mode_original
- end
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- false,
- function(p, _, frame)
- if frame then
- local label_container = frame[creative_mode_defines.names.gui.creative_chest_filter_container]
- local display_mode_button = label_container[creative_mode_defines.names.gui.creative_chest_display_mode_button]
- display_mode_button.style = display_mode_style
- display_mode_button.tooltip = display_mode_tooltip
- end
- end
- )
- end
- return true
- elseif element_name == creative_mode_defines.names.gui.creative_chest_toggle_all_button then
- ---------------------------------------------------------------------------------------------------
- -- Toggle all button for creative chest.
- local chest_groups, max_group_number, contain_hidden_items =
- creative_chest_util.get_creative_chest_data_groups(entity)
- local chest_data, group_number = creative_chest_util.get_creative_chest_data_group_number(entity, chest_groups)
- if chest_data and group_number > 0 then
- -- Toggle all button -> label container -> frame
- local inventory = creative_chest_util.get_inventory_from_data(chest_data)
- local start_item_index, end_item_index =
- creative_chest_util.get_start_end_item_index_for_group(group_number, #inventory - 1, contain_hidden_items)
- local item_count = end_item_index - start_item_index + 1
- local all_on = #chest_data.filtered_slots >= item_count
- local style
- -- The array of filtered slots is renewed not matter the slots are all filtered or restored.
- chest_data.filtered_slots = {}
- if all_on then
- -- Restore all slots.
- style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
- else
- -- Filter out all slots.
- style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
- for i = 1, item_count, 1 do
- table.insert(chest_data.filtered_slots, i)
- inventory[i].clear()
- end
- end
-
- if creative_chest_util.is_new_creative(chest_data.entity) then
- creative_chest_util.set_chest_filter(chest_data)
+ local left = mod_gui.get_frame_flow(player)
+ local entity = storage.creative_mode.player_opened_entities[player.index]
+ local entity_gui_container = left[creative_mode_defines.names.gui.entity_gui_container]
+
+ if element_name == creative_mode_defines.names.gui.creative_chest_open_button then
+ -- Creative chest open button.
+ if create_or_destroy_creative_chest_gui(player, entity, entity_gui_container) then
+ -- UI is opened.
+ storage.creative_mode.player_opened_entity_gui[player.index] = true
+ else
+ -- UI is closed.
+ storage.creative_mode.player_opened_entity_gui[player.index] = false
+ end
+ return true
+ elseif element_name == creative_mode_defines.names.gui.creative_chest_item_group_left_button then
+ -- Reduce group number by 1 for creative chest.
+ add_creative_chest_group_number_and_update_gui(entity, -1)
+ return true
+ elseif element_name == creative_mode_defines.names.gui.creative_chest_item_group_right_button then
+ -- Increase group number by 1 for creative chest.
+ add_creative_chest_group_number_and_update_gui(entity, 1)
+ return true
+ elseif element_name == creative_mode_defines.names.gui.creative_chest_display_mode_button then
+ -- Toggle inventory display mode for creative chest.
+ local chest_data, group_number = creative_chest_util.get_creative_chest_data_group_number(
+ entity,
+ creative_chest_util.get_creative_chest_data_groups(entity)
+ )
+ if chest_data and group_number > 0 then
+ local display_mode_style
+ local display_mode_tooltip
+ if chest_data.inventory_display_mode == creative_chest_util.inventory_display_modes.original_mode then
+ chest_data.inventory_display_mode = creative_chest_util.inventory_display_modes.compact_mode
+ display_mode_style = creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_compact
+ display_mode_tooltip = creative_mode_defines.names.gui_captions.creative_chest_display_mode_compact
+ else
+ chest_data.inventory_display_mode = creative_chest_util.inventory_display_modes.original_mode
+ display_mode_style = creative_mode_defines.names.gui_styles.creative_chest_display_mode_button_original
+ display_mode_tooltip = creative_mode_defines.names.gui_captions.creative_chest_display_mode_original
+ end
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, false, function(p, _, frame)
+ if frame then
+ local label_container = frame[creative_mode_defines.names.gui.creative_chest_filter_container]
+ local display_mode_button =
+ label_container[creative_mode_defines.names.gui.creative_chest_display_mode_button]
+ display_mode_button.style = display_mode_style
+ display_mode_button.tooltip = display_mode_tooltip
+ end
+ end)
+ end
+ return true
+ elseif element_name == creative_mode_defines.names.gui.creative_chest_toggle_all_button then
+ ---------------------------------------------------------------------------------------------------
+ -- Toggle all button for creative chest.
+ local chest_groups, max_group_number, contain_hidden_items =
+ creative_chest_util.get_creative_chest_data_groups(entity)
+ local chest_data, group_number = creative_chest_util.get_creative_chest_data_group_number(entity, chest_groups)
+ if chest_data and group_number > 0 then
+ -- Toggle all button -> label container -> frame
+ local inventory = creative_chest_util.get_inventory_from_data(chest_data)
+ local start_item_index, end_item_index =
+ creative_chest_util.get_start_end_item_index_for_group(group_number, #inventory - 1, contain_hidden_items)
+ local item_count = end_item_index - start_item_index + 1
+ local all_on = #chest_data.filtered_slots >= item_count
+ local style
+ -- The array of filtered slots is renewed not matter the slots are all filtered or restored.
+ chest_data.filtered_slots = {}
+ if all_on then
+ -- Restore all slots.
+ style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
+ else
+ -- Filter out all slots.
+ style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
+ for i = 1, item_count, 1 do
+ table.insert(chest_data.filtered_slots, i)
+ inventory[i].clear()
+ end
+ end
+
+ if creative_chest_util.is_new_creative(chest_data.entity) then
+ creative_chest_util.set_chest_filter(chest_data)
+ end
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, false, function(p, _, frame)
+ if frame then
+ local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
+ local filter_table = scroll_pane[creative_mode_defines.names.gui.creative_chest_filter_table]
+ for i = 1, item_count, 1 do
+ filter_table[creative_mode_defines.names.gui.creative_chest_filter_slot_prefix .. i].style = style
+ end
+ end
+ end)
+ end
+ -- Reset player action on GUI because toggle-all will affect the toggle action of shift-click on the filter slots.
+ reset_last_entity_gui_action_by_player_index(player.index)
+ return true
+ elseif element_name == creative_mode_defines.names.gui.duplicating_chest_open_button then
+ ---------------------------------------------------------------------------------------------------
+ -- Duplicating chest open button.
+ if create_or_destroy_duplicating_chest_gui(player, entity, entity_gui_container) then
+ -- UI is opened.
+ storage.creative_mode.player_opened_entity_gui[player.index] = true
+ else
+ -- UI is closed.
+ storage.creative_mode.player_opened_entity_gui[player.index] = false
+ end
+ return true
+ elseif element_name == creative_mode_defines.names.gui.configurable_super_boiler_open_button then
+ -- Configurable super boiler open button.
+ if create_or_destroy_configurable_super_boiler_gui(player, entity, entity_gui_container) then
+ -- UI is opened.
+ storage.creative_mode.player_opened_entity_gui[player.index] = true
+ else
+ -- UI is closed.
+ storage.creative_mode.player_opened_entity_gui[player.index] = false
+ end
+ return true
+ elseif element_name == creative_mode_defines.names.gui.configurable_super_boiler_set_temp_button then
+ ---------------------------------------------------------------------------------------------------
+ -- Configurable super boiler set temp button.
+ local data = configurable_super_boiler.get_data_for_entity(entity)
+ if data then
+ -- button -> container.textfield
+ local textfield = element.parent[creative_mode_defines.names.gui.configurable_super_boiler_set_temp_textfield]
+ -- Validate temperature.
+ local temperature = tonumber(textfield.text)
+ if temperature then
+ temperature = util.clamp(temperature, -1000000, 1000000)
+ else
+ temperature = 0
+ end
+ -- Update the boiler's temperature.
+ configurable_super_boiler.update_temperature(data, temperature)
+ -- Update the textfield for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, false, function(p, _, frame)
+ if frame then
+ -- Container.
+ local set_temp_container = frame[creative_mode_defines.names.gui.configurable_super_boiler_set_temp_container]
+ -- Textfield.
+ local set_temp_textfield =
+ set_temp_container[creative_mode_defines.names.gui.configurable_super_boiler_set_temp_textfield]
+ set_temp_textfield.text = tostring(temperature)
+ end
+ end)
+ end
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_source_open_button then
+ ---------------------------------------------------------------------------------------------------
+ -- Matter source open button.
+ if create_or_destroy_item_source_gui(player, entity, entity_gui_container) then
+ -- UI is opened.
+ storage.creative_mode.player_opened_entity_gui[player.index] = true
+ else
+ -- UI is closed.
+ storage.creative_mode.player_opened_entity_gui[player.index] = false
+ end
+ return true
+ elseif element_name == creative_mode_defines.names.gui.duplicator_open_button then
+ ---------------------------------------------------------------------------------------------------
+ -- Matter duplicator open button.
+ if create_or_destroy_duplicator_gui(player, entity, entity_gui_container) then
+ -- UI is opened.
+ storage.creative_mode.player_opened_entity_gui[player.index] = true
+ else
+ -- UI is closed.
+ storage.creative_mode.player_opened_entity_gui[player.index] = false
+ end
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_void_open_button then
+ ---------------------------------------------------------------------------------------------------
+ -- Matter void open button.
+ if create_or_destroy_item_void_gui(player, entity, entity_gui_container) then
+ -- UI is opened.
+ storage.creative_mode.player_opened_entity_gui[player.index] = true
+ else
+ -- UI is closed.
+ storage.creative_mode.player_opened_entity_gui[player.index] = false
+ end
+ return true
+ else
+ if element.parent and element.parent.name == creative_mode_defines.names.gui.creative_chest_filter_table then
+ -- Creative chest filter slot.
+ local slot = string.match(element_name, creative_mode_defines.match_patterns.gui.creative_chest_filter_slot)
+ if slot ~= nil then
+ slot = tonumber(slot)
+ local chest_groups, _, contain_hidden_items = creative_chest_util.get_creative_chest_data_groups(entity)
+ local chest_data, group_number = creative_chest_util.get_creative_chest_data_group_number(entity, chest_groups)
+ if chest_data and group_number > 0 then
+ -- Ctrl click?
+ if control then
+ -- Get a full stack of the item.
+ local inventory = creative_chest_util.get_inventory_from_data(chest_data)
+ local inventory_size = #inventory
+ local start_item_index = creative_chest_util.get_start_end_item_index_for_group(
+ group_number,
+ inventory_size - 1,
+ contain_hidden_items
+ )
+ local item = creative_chest_util.get_item_at(start_item_index + slot - 1, contain_hidden_items)
+ player.clear_cursor()
+ player.cursor_stack.set_stack({ name = item.name, count = item.stack_size })
+
+ -- Record the slot for the next shift-click.
+ storage.last_entity_gui_actions_by_players = storage.last_entity_gui_actions_by_players or {}
+ storage.last_entity_gui_actions_by_players[player.index] = {
+ non_shift = {
+ slot = slot,
+ is_filter = element.style.name == creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off,
+ },
+ }
+ return true
+ end
+
+ -- Shift click?
+ if shift then
+ -- Get the recorded non-shift-clicked slot and action (filter or unfilter).
+ local non_shift_slot
+ local is_filter
+ local has_recorded_action
+ if
+ storage.last_entity_gui_actions_by_players
+ and storage.last_entity_gui_actions_by_players[player.index]
+ and storage.last_entity_gui_actions_by_players[player.index].non_shift
+ then
+ local non_shift = storage.last_entity_gui_actions_by_players[player.index].non_shift
+ non_shift_slot = non_shift.slot
+ is_filter = non_shift.is_filter
+ has_recorded_action = true
+ else
+ -- If there is no recorded action, we make one.
+ non_shift_slot = 1
+ -- Set action according to the current state of the current slot.
+ -- If it is not filtered, filter the slots.
+ is_filter = element.style.name == creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
+ storage.last_entity_gui_actions_by_players = storage.last_entity_gui_actions_by_players or {}
+ storage.last_entity_gui_actions_by_players[player.index] = {
+ non_shift = {
+ slot = non_shift_slot,
+ is_filter = is_filter,
+ },
+ }
+
+ has_recorded_action = false
+ end
+
+ local slot_actions_dict = {} -- true = filter, false = unfilter
+
+ -- In case the player has filtered multiple slots before (i.e. previous shift-clicked slot), they should be restored.
+ if has_recorded_action then
+ local shift_data = storage.last_entity_gui_actions_by_players[player.index].shift
+ if shift_data then
+ local shift_slot = shift_data.slot
+ -- If the current shift-clicked slot is the same as the last shift-clicked slot, nothing to do.
+ if slot == shift_slot then
+ return
+ end
+ -- We care only if the last action is filter.
+ if is_filter then
+ local min_slot, max_slot
+ if non_shift_slot < shift_slot then
+ min_slot = non_shift_slot + 1
+ max_slot = shift_slot
+ else
+ min_slot = shift_slot
+ max_slot = non_shift_slot - 1
+ end
+ -- If the last action is filter, we should unfilter them.
+ -- If the last action is unfilter, we should filter them.
+ for i = min_slot, max_slot, 1 do
+ slot_actions_dict[i] = false
+ end
+ end
+ end
end
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- false,
- function(p, _, frame)
- if frame then
- local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
- local filter_table = scroll_pane[creative_mode_defines.names.gui.creative_chest_filter_table]
- for i = 1, item_count, 1 do
- filter_table[creative_mode_defines.names.gui.creative_chest_filter_slot_prefix .. i].style = style
- end
- end
- end
- )
- end
- -- Reset player action on GUI because toggle-all will affect the toggle action of shift-click on the filter slots.
- reset_last_entity_gui_action_by_player_index(player.index)
- return true
- elseif element_name == creative_mode_defines.names.gui.duplicating_chest_open_button then
- ---------------------------------------------------------------------------------------------------
- -- Duplicating chest open button.
- if create_or_destroy_duplicating_chest_gui(player, entity, entity_gui_container) then
- -- UI is opened.
- storage.creative_mode.player_opened_entity_gui[player.index] = true
- else
- -- UI is closed.
- storage.creative_mode.player_opened_entity_gui[player.index] = false
- end
- return true
- elseif element_name == creative_mode_defines.names.gui.configurable_super_boiler_open_button then
- -- Configurable super boiler open button.
- if create_or_destroy_configurable_super_boiler_gui(player, entity, entity_gui_container) then
- -- UI is opened.
- storage.creative_mode.player_opened_entity_gui[player.index] = true
- else
- -- UI is closed.
- storage.creative_mode.player_opened_entity_gui[player.index] = false
- end
- return true
- elseif element_name == creative_mode_defines.names.gui.configurable_super_boiler_set_temp_button then
- ---------------------------------------------------------------------------------------------------
- -- Configurable super boiler set temp button.
- local data = configurable_super_boiler.get_data_for_entity(entity)
- if data then
- -- button -> container.textfield
- local textfield = element.parent[creative_mode_defines.names.gui.configurable_super_boiler_set_temp_textfield]
- -- Validate temperature.
- local temperature = tonumber(textfield.text)
- if temperature then
- temperature = util.clamp(temperature, -1000000, 1000000)
- else
- temperature = 0
- end
- -- Update the boiler's temperature.
- configurable_super_boiler.update_temperature(data, temperature)
- -- Update the textfield for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- false,
- function(p, _, frame)
- if frame then
- -- Container.
- local set_temp_container = frame[creative_mode_defines.names.gui.configurable_super_boiler_set_temp_container]
- -- Textfield.
- local set_temp_textfield =
- set_temp_container[creative_mode_defines.names.gui.configurable_super_boiler_set_temp_textfield]
- set_temp_textfield.text = tostring(temperature)
- end
- end
- )
- end
- return true
- elseif element_name == creative_mode_defines.names.gui.item_source_open_button then
- ---------------------------------------------------------------------------------------------------
- -- Matter source open button.
- if create_or_destroy_item_source_gui(player, entity, entity_gui_container) then
- -- UI is opened.
- storage.creative_mode.player_opened_entity_gui[player.index] = true
- else
- -- UI is closed.
- storage.creative_mode.player_opened_entity_gui[player.index] = false
- end
- return true
- elseif element_name == creative_mode_defines.names.gui.duplicator_open_button then
- ---------------------------------------------------------------------------------------------------
- -- Matter duplicator open button.
- if create_or_destroy_duplicator_gui(player, entity, entity_gui_container) then
- -- UI is opened.
- storage.creative_mode.player_opened_entity_gui[player.index] = true
- else
- -- UI is closed.
- storage.creative_mode.player_opened_entity_gui[player.index] = false
- end
- return true
- elseif element_name == creative_mode_defines.names.gui.item_void_open_button then
- ---------------------------------------------------------------------------------------------------
- -- Matter void open button.
- if create_or_destroy_item_void_gui(player, entity, entity_gui_container) then
- -- UI is opened.
- storage.creative_mode.player_opened_entity_gui[player.index] = true
- else
- -- UI is closed.
- storage.creative_mode.player_opened_entity_gui[player.index] = false
- end
- return true
- else
- if element.parent and element.parent.name == creative_mode_defines.names.gui.creative_chest_filter_table then
- -- Creative chest filter slot.
- local slot = string.match(element_name, creative_mode_defines.match_patterns.gui.creative_chest_filter_slot)
- if slot ~= nil then
- slot = tonumber(slot)
- local chest_groups, _, contain_hidden_items = creative_chest_util.get_creative_chest_data_groups(entity)
- local chest_data, group_number = creative_chest_util.get_creative_chest_data_group_number(entity, chest_groups)
- if chest_data and group_number > 0 then
- -- Ctrl click?
- if control then
- -- Get a full stack of the item.
- local inventory = creative_chest_util.get_inventory_from_data(chest_data)
- local inventory_size = #inventory
- local start_item_index =
- creative_chest_util.get_start_end_item_index_for_group(group_number, inventory_size - 1, contain_hidden_items)
- local item = creative_chest_util.get_item_at(start_item_index + slot - 1, contain_hidden_items)
- player.clear_cursor()
- player.cursor_stack.set_stack {name = item.name, count = item.stack_size}
-
- -- Record the slot for the next shift-click.
- storage.last_entity_gui_actions_by_players = storage.last_entity_gui_actions_by_players or {}
- storage.last_entity_gui_actions_by_players[player.index] = {
- non_shift = {
- slot = slot,
- is_filter = element.style.name == creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
- }
- }
- return true
- end
-
- -- Shift click?
- if shift then
- -- Get the recorded non-shift-clicked slot and action (filter or unfilter).
- local non_shift_slot
- local is_filter
- local has_recorded_action
- if
- storage.last_entity_gui_actions_by_players and storage.last_entity_gui_actions_by_players[player.index] and
- storage.last_entity_gui_actions_by_players[player.index].non_shift
- then
- local non_shift = storage.last_entity_gui_actions_by_players[player.index].non_shift
- non_shift_slot = non_shift.slot
- is_filter = non_shift.is_filter
- has_recorded_action = true
- else
- -- If there is no recorded action, we make one.
- non_shift_slot = 1
- -- Set action according to the current state of the current slot.
- -- If it is not filtered, filter the slots.
- is_filter = element.style.name == creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
- storage.last_entity_gui_actions_by_players = storage.last_entity_gui_actions_by_players or {}
- storage.last_entity_gui_actions_by_players[player.index] = {
- non_shift = {
- slot = non_shift_slot,
- is_filter = is_filter
- }
- }
-
- has_recorded_action = false
- end
-
- local slot_actions_dict = {} -- true = filter, false = unfilter
-
- -- In case the player has filtered multiple slots before (i.e. previous shift-clicked slot), they should be restored.
- if has_recorded_action then
- local shift_data = storage.last_entity_gui_actions_by_players[player.index].shift
- if shift_data then
- local shift_slot = shift_data.slot
- -- If the current shift-clicked slot is the same as the last shift-clicked slot, nothing to do.
- if slot == shift_slot then
- return
- end
- -- We care only if the last action is filter.
- if is_filter then
- local min_slot, max_slot
- if non_shift_slot < shift_slot then
- min_slot = non_shift_slot + 1
- max_slot = shift_slot
- else
- min_slot = shift_slot
- max_slot = non_shift_slot - 1
- end
- -- If the last action is filter, we should unfilter them.
- -- If the last action is unfilter, we should filter them.
- for i = min_slot, max_slot, 1 do
- slot_actions_dict[i] = false
- end
- end
- end
- end
-
- -- Now, filter or unfilter multiple slots from the last non-shift-clicked slot to the current shift-clicked slot.
- local min_slot, max_slot
- if non_shift_slot < slot then
- if has_recorded_action then
- min_slot = non_shift_slot + 1
- else
- -- No action has been recorded, we made the record, therefore the first slot should also be updated.
- min_slot = non_shift_slot
- end
- max_slot = slot
- else
- min_slot = slot
- if has_recorded_action then
- max_slot = non_shift_slot - 1
- else
- max_slot = non_shift_slot
- end
- end
- for i = min_slot, max_slot, 1 do
- slot_actions_dict[i] = is_filter
- end
-
- -- Finalize the changes. Apply the cached actions to the actual chest filtered slots array.
- -- The records in the slot actions dictionary will be removed once they are applied. We need another dictionary to record the actions for updating GUI.
- local final_slot_actions_dict = {}
- for i = #chest_data.filtered_slots, 1, -1 do
- local filtered_slot = chest_data.filtered_slots[i]
- if slot_actions_dict[filtered_slot] == false then
- -- The slot should be unfiltered but it has been filtered.
- table.remove(chest_data.filtered_slots, i)
- final_slot_actions_dict[filtered_slot] = false
- end
- slot_actions_dict[filtered_slot] = nil
- end
- local inventory = creative_chest_util.get_inventory_from_data(chest_data)
- local need_resort = false
- for slot, is_filter in pairs(slot_actions_dict) do
- if is_filter then
- -- The slot should be filtered but has not been filtered yet.
- table.insert(chest_data.filtered_slots, slot)
- final_slot_actions_dict[slot] = true
- -- Clear slot.
- inventory[slot].clear()
- -- Prepare to sort the array.
- need_resort = true
- end
- end
- if need_resort then
- table.sort(chest_data.filtered_slots)
- end
-
- -- Record the current shift-clicked slot for the next shift-click.
- storage.last_entity_gui_actions_by_players[player.index].shift = {slot = slot}
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- false,
- function(p, _, frame)
- if frame then
- local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
- local filter_table = scroll_pane[creative_mode_defines.names.gui.creative_chest_filter_table]
- for slot, is_filter in pairs(final_slot_actions_dict) do
- local slot_button = filter_table[creative_mode_defines.names.gui.creative_chest_filter_slot_prefix .. slot]
- -- The button will be nil if the chest group is changed such that there are fewer slots then before.
- if slot_button == nil then
- break
- end
- if is_filter then
- slot_button.style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
- else
- slot_button.style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
- end
- end
- end
- end
- )
- return true
- end
- -- Record the slot for the next shift-click.
- storage.last_entity_gui_actions_by_players = storage.last_entity_gui_actions_by_players or {}
- storage.last_entity_gui_actions_by_players[player.index] = {non_shift = {slot = slot}}
-
- for index, filtered_slot in ipairs(chest_data.filtered_slots) do
- if slot == filtered_slot then
- -- The slot was filtered. Now turn it back.
- table.remove(chest_data.filtered_slots, index)
-
- -- Record the action for the next shift-click.
- storage.last_entity_gui_actions_by_players[player.index].non_shift.is_filter = false
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- false,
- function(p, _, frame)
- if frame then
- local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
- local filter_table = scroll_pane[creative_mode_defines.names.gui.creative_chest_filter_table]
- local slot_button = filter_table[element_name]
- slot_button.style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
- end
- end
- )
- -- If this is a new creative chest, update the filters.
- if creative_chest_util.is_new_creative(entity) then
- creative_chest_util.set_chest_filter(chest_data)
- end
- return
- end
- end
-
- -- The slot was not filtered. Now filter it.
- table.insert(chest_data.filtered_slots, slot)
- table.sort(chest_data.filtered_slots)
-
- -- If this is a new creative chest, update the filters.
- if creative_chest_util.is_new_creative(entity) then
- creative_chest_util.set_chest_filter(chest_data)
- end
-
- -- Record the action for the next shift-click.
- storage.last_entity_gui_actions_by_players[player.index].non_shift.is_filter = true
-
- -- Clear the slot.
- local inventory = creative_chest_util.get_inventory_from_data(chest_data)
- inventory[slot].clear()
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- false,
- function(p, _, frame)
- if frame then
- local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
- local filter_table = scroll_pane[creative_mode_defines.names.gui.creative_chest_filter_table]
- local slot_button = filter_table[element_name]
- slot_button.style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
- end
- end
- )
- end
- end
- return true
- end
- end
- return false
+ -- Now, filter or unfilter multiple slots from the last non-shift-clicked slot to the current shift-clicked slot.
+ local min_slot, max_slot
+ if non_shift_slot < slot then
+ if has_recorded_action then
+ min_slot = non_shift_slot + 1
+ else
+ -- No action has been recorded, we made the record, therefore the first slot should also be updated.
+ min_slot = non_shift_slot
+ end
+ max_slot = slot
+ else
+ min_slot = slot
+ if has_recorded_action then
+ max_slot = non_shift_slot - 1
+ else
+ max_slot = non_shift_slot
+ end
+ end
+ for i = min_slot, max_slot, 1 do
+ slot_actions_dict[i] = is_filter
+ end
+
+ -- Finalize the changes. Apply the cached actions to the actual chest filtered slots array.
+ -- The records in the slot actions dictionary will be removed once they are applied. We need another dictionary to record the actions for updating GUI.
+ local final_slot_actions_dict = {}
+ for i = #chest_data.filtered_slots, 1, -1 do
+ local filtered_slot = chest_data.filtered_slots[i]
+ if slot_actions_dict[filtered_slot] == false then
+ -- The slot should be unfiltered but it has been filtered.
+ table.remove(chest_data.filtered_slots, i)
+ final_slot_actions_dict[filtered_slot] = false
+ end
+ slot_actions_dict[filtered_slot] = nil
+ end
+ local inventory = creative_chest_util.get_inventory_from_data(chest_data)
+ local need_resort = false
+ for slot, is_filter in pairs(slot_actions_dict) do
+ if is_filter then
+ -- The slot should be filtered but has not been filtered yet.
+ table.insert(chest_data.filtered_slots, slot)
+ final_slot_actions_dict[slot] = true
+ -- Clear slot.
+ inventory[slot].clear()
+ -- Prepare to sort the array.
+ need_resort = true
+ end
+ end
+ if need_resort then
+ table.sort(chest_data.filtered_slots)
+ end
+
+ -- Record the current shift-clicked slot for the next shift-click.
+ storage.last_entity_gui_actions_by_players[player.index].shift = { slot = slot }
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, false, function(p, _, frame)
+ if frame then
+ local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
+ local filter_table = scroll_pane[creative_mode_defines.names.gui.creative_chest_filter_table]
+ for slot, is_filter in pairs(final_slot_actions_dict) do
+ local slot_button =
+ filter_table[creative_mode_defines.names.gui.creative_chest_filter_slot_prefix .. slot]
+ -- The button will be nil if the chest group is changed such that there are fewer slots then before.
+ if slot_button == nil then
+ break
+ end
+ if is_filter then
+ slot_button.style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
+ else
+ slot_button.style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
+ end
+ end
+ end
+ end)
+ return true
+ end
+ -- Record the slot for the next shift-click.
+ storage.last_entity_gui_actions_by_players = storage.last_entity_gui_actions_by_players or {}
+ storage.last_entity_gui_actions_by_players[player.index] = { non_shift = { slot = slot } }
+
+ for index, filtered_slot in ipairs(chest_data.filtered_slots) do
+ if slot == filtered_slot then
+ -- The slot was filtered. Now turn it back.
+ table.remove(chest_data.filtered_slots, index)
+
+ -- Record the action for the next shift-click.
+ storage.last_entity_gui_actions_by_players[player.index].non_shift.is_filter = false
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, false, function(p, _, frame)
+ if frame then
+ local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
+ local filter_table = scroll_pane[creative_mode_defines.names.gui.creative_chest_filter_table]
+ local slot_button = filter_table[element_name]
+ slot_button.style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
+ end
+ end)
+ -- If this is a new creative chest, update the filters.
+ if creative_chest_util.is_new_creative(entity) then
+ creative_chest_util.set_chest_filter(chest_data)
+ end
+ return
+ end
+ end
+
+ -- The slot was not filtered. Now filter it.
+ table.insert(chest_data.filtered_slots, slot)
+ table.sort(chest_data.filtered_slots)
+
+ -- If this is a new creative chest, update the filters.
+ if creative_chest_util.is_new_creative(entity) then
+ creative_chest_util.set_chest_filter(chest_data)
+ end
+
+ -- Record the action for the next shift-click.
+ storage.last_entity_gui_actions_by_players[player.index].non_shift.is_filter = true
+
+ -- Clear the slot.
+ local inventory = creative_chest_util.get_inventory_from_data(chest_data)
+ inventory[slot].clear()
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, false, function(p, _, frame)
+ if frame then
+ local scroll_pane = frame[creative_mode_defines.names.gui.creative_chest_filter_scroll_pane]
+ local filter_table = scroll_pane[creative_mode_defines.names.gui.creative_chest_filter_table]
+ local slot_button = filter_table[element_name]
+ slot_button.style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_off
+ end
+ end)
+ end
+ end
+ return true
+ end
+ end
+ return false
end
-- Callback of the on_gui_text_changed event, extended from gui.lua.
-- Returns whether the event is consumed.
function gui_entity.on_gui_text_changed(element, element_name, player)
- local entity = storage.creative_mode.player_opened_entities[player.index]
-
- if element_name == creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_field then
- -- Matter source or Random item source - insert to player amount.
- local data = nil
- if entity.name == creative_mode_defines.names.entities.item_source then
- data = item_source.get_data_for_entity(entity)
- else
- data = random_item_source.get_data_for_entity(entity)
- end
- if data then
- local amount = tonumber(element.text)
- if amount then
- amount = util.clamp(math.floor(amount), 0, 1000000)
- else
- amount = 0
- end
- data.insert_to_player_amount = amount
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if frame_container then
- local insert_once_to_player_frame =
- frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame]
- if insert_once_to_player_frame then
- local insert_once_to_player_container =
- insert_once_to_player_frame[creative_mode_defines.names.gui.item_source_insert_once_to_player_container]
- local insert_to_player_amount_container =
- insert_once_to_player_container[
- creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_container
- ]
- local amount_field =
- insert_to_player_amount_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_field]
- amount_field.text = tostring(amount)
- end
- end
- end
- )
- end
- return true
- end
- return false
+ local entity = storage.creative_mode.player_opened_entities[player.index]
+
+ if element_name == creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_field then
+ -- Matter source or Random item source - insert to player amount.
+ local data = nil
+ if entity.name == creative_mode_defines.names.entities.item_source then
+ data = item_source.get_data_for_entity(entity)
+ else
+ data = random_item_source.get_data_for_entity(entity)
+ end
+ if data then
+ local amount = tonumber(element.text)
+ if amount then
+ amount = util.clamp(math.floor(amount), 0, 1000000)
+ else
+ amount = 0
+ end
+ data.insert_to_player_amount = amount
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if frame_container then
+ local insert_once_to_player_frame =
+ frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame]
+ if insert_once_to_player_frame then
+ local insert_once_to_player_container =
+ insert_once_to_player_frame[creative_mode_defines.names.gui.item_source_insert_once_to_player_container]
+ local insert_to_player_amount_container =
+ insert_once_to_player_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_container]
+ local amount_field =
+ insert_to_player_amount_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_amount_field]
+ amount_field.text = tostring(amount)
+ end
+ end
+ end)
+ end
+ return true
+ end
+ return false
end
-- Callback of the on_gui_checked_state_changed event, extended from gui.lua.
-- Returns whether the event is consumed.
function gui_entity.on_gui_checked_state_changed(element, element_name, player)
- local entity = storage.creative_mode.player_opened_entities[player.index]
-
- if element_name == creative_mode_defines.names.gui.duplicating_chest_lock_item_checkbox then
- ---------------------------------------------------------------------------------------------------
- -- Duplicating chest - lock item.
- local data = duplicating_chest_util.get_data_for_entity(entity)
- if data then
- data.lock_item = element.state
- if data.lock_item then
- if not data.locked_item_name then
- -- Set the item in the first slot as the locked item.
- local inventory = duplicating_chest_util.get_inventory(entity)
- local item = inventory[1]
- if item ~= nil and item.valid_for_read then
- data.locked_item_name = item.name
- end
- end
- else
- -- Reset the locked item.
- data.locked_item_name = nil
- end
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- false,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local lock_item_checkbox = frame[creative_mode_defines.names.gui.duplicating_chest_lock_item_checkbox]
- lock_item_checkbox.state = element.state
- end
- end
- end
- )
- return true
- end
- elseif element_name == creative_mode_defines.names.gui.item_source_can_insert_to_vehicle_checkbox then
- -- Matter source or Random item source - can insert to vehicle.
- local data = nil
- if entity.name == creative_mode_defines.names.entities.item_source then
- data = item_source.get_data_for_entity(entity)
- else
- data = random_item_source.get_data_for_entity(entity)
- end
- if data then
- data.can_insert_to_vehicle = element.state
-
- -- Update the GUI for all other players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local options_container = frame[creative_mode_defines.names.gui.item_source_options_container]
- options_container[creative_mode_defines.names.gui.item_source_can_insert_to_vehicle_checkbox].state =
- element.state
- end
- end
- end
- )
- end
-
- return true
- elseif element_name == creative_mode_defines.names.gui.item_source_can_insert_to_player_checkbox then
- -- Matter source or Random item source - can insert to player.
- local data = nil
- if entity.name == creative_mode_defines.names.entities.item_source then
- data = item_source.get_data_for_entity(entity)
- else
- data = random_item_source.get_data_for_entity(entity)
- end
- if data then
- data.can_insert_to_player = element.state
- -- Add or remove GUI for additional options.
- -- checkbox -> options container -> frame -> frame container
- local frame_container = element.parent.parent.parent
- add_or_remove_item_source_insert_to_player_options_gui(frame_container, data)
-
- -- Update the GUI for all other players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local options_container = frame[creative_mode_defines.names.gui.item_source_options_container]
- options_container[creative_mode_defines.names.gui.item_source_can_insert_to_player_checkbox].state =
- element.state
- add_or_remove_item_source_insert_to_player_options_gui(frame_container, data)
- end
- end
- end
- )
- end
-
- return true
- elseif element_name == creative_mode_defines.names.gui.item_source_can_drop_on_ground_checkbox then
- -- Matter source or Random item source - can drop on ground.
- local data = nil
- if entity.name == creative_mode_defines.names.entities.item_source then
- data = item_source.get_data_for_entity(entity)
- else
- data = random_item_source.get_data_for_entity(entity)
- end
- if data then
- data.can_drop_on_ground = element.state
-
- -- Update the GUI for all other players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local options_container = frame[creative_mode_defines.names.gui.item_source_options_container]
- options_container[creative_mode_defines.names.gui.item_source_can_drop_on_ground_checkbox].state = element.state
- end
- end
- end
- )
- end
-
- return true
- elseif element_name == creative_mode_defines.names.gui.item_source_insert_only_once_to_player_checkbox then
- -- Matter source or Random item source - insert only once to player.
- local data = nil
- if entity.name == creative_mode_defines.names.entities.item_source then
- data = item_source.get_data_for_entity(entity)
- else
- data = random_item_source.get_data_for_entity(entity)
- end
- if data then
- data.insert_only_once_to_player = element.state
- -- Add or remove GUI for additional options.
- -- checkbox -> frame -> frame container
- local frame_container = element.parent.parent
- add_or_remove_item_source_insert_only_once_to_player_options_gui(frame_container, data)
-
- -- Update the GUI for all other players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame_container then
- local insert_to_player_frame =
- frame_container[creative_mode_defines.names.gui.item_source_insert_to_player_frame]
- if insert_to_player_frame then
- insert_to_player_frame[creative_mode_defines.names.gui.item_source_insert_only_once_to_player_checkbox].state =
- element.state
- end
- add_or_remove_item_source_insert_only_once_to_player_options_gui(frame_container, data)
- end
- end
- end
- )
- end
-
- return true
- elseif element_name == creative_mode_defines.names.gui.item_source_insert_once_to_player_by_stack_checkbox then
- ---------------------------------------------------------------------------------------------------
- -- Matter source or Random item source - insert to player by stack.
- local data = nil
- if entity.name == creative_mode_defines.names.entities.item_source then
- data = item_source.get_data_for_entity(entity)
- else
- data = random_item_source.get_data_for_entity(entity)
- end
- if data then
- data.insert_to_player_by_stack = element.state
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame_container then
- local insert_once_to_player_frame =
- frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame]
- if insert_once_to_player_frame then
- local insert_once_to_player_container =
- insert_once_to_player_frame[creative_mode_defines.names.gui.item_source_insert_once_to_player_container]
- insert_once_to_player_container[
- creative_mode_defines.names.gui.item_source_insert_once_to_player_by_stack_checkbox
- ].state = element.state
- end
- end
- end
- end
- )
- end
-
- return true
- elseif element_name == creative_mode_defines.names.gui.duplicator_can_duplicate_in_vehicle_checkbox then
- -- Matter duplicator - can duplicate in vehicle.
- local data = duplicator.get_data_for_entity(entity)
- if data then
- data.can_duplicate_in_vehicle = element.state
- end
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local options_container = frame[creative_mode_defines.names.gui.duplicator_options_container]
- options_container[creative_mode_defines.names.gui.duplicator_can_duplicate_in_vehicle_checkbox].state =
- element.state
- end
- end
- end
- )
-
- return true
- elseif element_name == creative_mode_defines.names.gui.duplicator_can_duplicate_in_player_checkbox then
- ---------------------------------------------------------------------------------------------------
- -- Matter duplicator - can duplicate in player.
- local data = duplicator.get_data_for_entity(entity)
- if data then
- data.can_duplicate_in_player = element.state
- end
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local options_container = frame[creative_mode_defines.names.gui.duplicator_options_container]
- options_container[creative_mode_defines.names.gui.duplicator_can_duplicate_in_player_checkbox].state =
- element.state
- end
- end
- end
- )
-
- return true
- elseif element_name == creative_mode_defines.names.gui.item_void_can_remove_from_vehicle_checkbox then
- -- Matter void - can remove from vehicle.
- local data = item_void.get_data_for_entity(entity)
- if data then
- data.can_remove_from_vehicle = element.state
- end
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local options_container = frame[creative_mode_defines.names.gui.item_void_options_container]
- options_container[creative_mode_defines.names.gui.item_void_can_remove_from_vehicle_checkbox].state =
- element.state
- end
- end
- end
- )
-
- return true
- elseif element_name == creative_mode_defines.names.gui.item_void_can_remove_from_player_checkbox then
- -- Matter void - can remove from player.
- local data = item_void.get_data_for_entity(entity)
- if data then
- data.can_remove_from_player = element.state
- end
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local options_container = frame[creative_mode_defines.names.gui.item_void_options_container]
- options_container[creative_mode_defines.names.gui.item_void_can_remove_from_player_checkbox].state = element.state
- end
- end
- end
- )
-
- return true
- elseif element_name == creative_mode_defines.names.gui.item_void_can_remove_from_ground_checkbox then
- -- Matter void - can remove from ground.
- local data = item_void.get_data_for_entity(entity)
- if data then
- data.can_remove_from_ground = element.state
- end
-
- -- Update the GUI for all players who are checking the entity.
- update_entity_gui_for_all_players_checking_the_entity(
- entity,
- true,
- function(p, frame_container, frame)
- if p ~= player then
- if frame then
- local options_container = frame[creative_mode_defines.names.gui.item_void_options_container]
- options_container[creative_mode_defines.names.gui.item_void_can_remove_from_ground_checkbox].state = element.state
- end
- end
- end
- )
-
- return true
- end
-
- return false
+ local entity = storage.creative_mode.player_opened_entities[player.index]
+
+ if element_name == creative_mode_defines.names.gui.duplicating_chest_lock_item_checkbox then
+ ---------------------------------------------------------------------------------------------------
+ -- Duplicating chest - lock item.
+ local data = duplicating_chest_util.get_data_for_entity(entity)
+ if data then
+ data.lock_item = element.state
+ if data.lock_item then
+ if not data.locked_item_name then
+ -- Set the item in the first slot as the locked item.
+ local inventory = duplicating_chest_util.get_inventory(entity)
+ local item = inventory[1]
+ if item ~= nil and item.valid_for_read then
+ data.locked_item_name = item.name
+ end
+ end
+ else
+ -- Reset the locked item.
+ data.locked_item_name = nil
+ end
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, false, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local lock_item_checkbox = frame[creative_mode_defines.names.gui.duplicating_chest_lock_item_checkbox]
+ lock_item_checkbox.state = element.state
+ end
+ end
+ end)
+ return true
+ end
+ elseif element_name == creative_mode_defines.names.gui.item_source_can_insert_to_vehicle_checkbox then
+ -- Matter source or Random item source - can insert to vehicle.
+ local data = nil
+ if entity.name == creative_mode_defines.names.entities.item_source then
+ data = item_source.get_data_for_entity(entity)
+ else
+ data = random_item_source.get_data_for_entity(entity)
+ end
+ if data then
+ data.can_insert_to_vehicle = element.state
+
+ -- Update the GUI for all other players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local options_container = frame[creative_mode_defines.names.gui.item_source_options_container]
+ options_container[creative_mode_defines.names.gui.item_source_can_insert_to_vehicle_checkbox].state =
+ element.state
+ end
+ end
+ end)
+ end
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_source_can_insert_to_player_checkbox then
+ -- Matter source or Random item source - can insert to player.
+ local data = nil
+ if entity.name == creative_mode_defines.names.entities.item_source then
+ data = item_source.get_data_for_entity(entity)
+ else
+ data = random_item_source.get_data_for_entity(entity)
+ end
+ if data then
+ data.can_insert_to_player = element.state
+ -- Add or remove GUI for additional options.
+ -- checkbox -> options container -> frame -> frame container
+ local frame_container = element.parent.parent.parent
+ add_or_remove_item_source_insert_to_player_options_gui(frame_container, data)
+
+ -- Update the GUI for all other players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local options_container = frame[creative_mode_defines.names.gui.item_source_options_container]
+ options_container[creative_mode_defines.names.gui.item_source_can_insert_to_player_checkbox].state =
+ element.state
+ add_or_remove_item_source_insert_to_player_options_gui(frame_container, data)
+ end
+ end
+ end)
+ end
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_source_can_drop_on_ground_checkbox then
+ -- Matter source or Random item source - can drop on ground.
+ local data = nil
+ if entity.name == creative_mode_defines.names.entities.item_source then
+ data = item_source.get_data_for_entity(entity)
+ else
+ data = random_item_source.get_data_for_entity(entity)
+ end
+ if data then
+ data.can_drop_on_ground = element.state
+
+ -- Update the GUI for all other players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local options_container = frame[creative_mode_defines.names.gui.item_source_options_container]
+ options_container[creative_mode_defines.names.gui.item_source_can_drop_on_ground_checkbox].state =
+ element.state
+ end
+ end
+ end)
+ end
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_source_insert_only_once_to_player_checkbox then
+ -- Matter source or Random item source - insert only once to player.
+ local data = nil
+ if entity.name == creative_mode_defines.names.entities.item_source then
+ data = item_source.get_data_for_entity(entity)
+ else
+ data = random_item_source.get_data_for_entity(entity)
+ end
+ if data then
+ data.insert_only_once_to_player = element.state
+ -- Add or remove GUI for additional options.
+ -- checkbox -> frame -> frame container
+ local frame_container = element.parent.parent
+ add_or_remove_item_source_insert_only_once_to_player_options_gui(frame_container, data)
+
+ -- Update the GUI for all other players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame_container then
+ local insert_to_player_frame =
+ frame_container[creative_mode_defines.names.gui.item_source_insert_to_player_frame]
+ if insert_to_player_frame then
+ insert_to_player_frame[creative_mode_defines.names.gui.item_source_insert_only_once_to_player_checkbox].state =
+ element.state
+ end
+ add_or_remove_item_source_insert_only_once_to_player_options_gui(frame_container, data)
+ end
+ end
+ end)
+ end
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_source_insert_once_to_player_by_stack_checkbox then
+ ---------------------------------------------------------------------------------------------------
+ -- Matter source or Random item source - insert to player by stack.
+ local data = nil
+ if entity.name == creative_mode_defines.names.entities.item_source then
+ data = item_source.get_data_for_entity(entity)
+ else
+ data = random_item_source.get_data_for_entity(entity)
+ end
+ if data then
+ data.insert_to_player_by_stack = element.state
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame_container then
+ local insert_once_to_player_frame =
+ frame_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_frame]
+ if insert_once_to_player_frame then
+ local insert_once_to_player_container =
+ insert_once_to_player_frame[creative_mode_defines.names.gui.item_source_insert_once_to_player_container]
+ insert_once_to_player_container[creative_mode_defines.names.gui.item_source_insert_once_to_player_by_stack_checkbox].state =
+ element.state
+ end
+ end
+ end
+ end)
+ end
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.duplicator_can_duplicate_in_vehicle_checkbox then
+ -- Matter duplicator - can duplicate in vehicle.
+ local data = duplicator.get_data_for_entity(entity)
+ if data then
+ data.can_duplicate_in_vehicle = element.state
+ end
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local options_container = frame[creative_mode_defines.names.gui.duplicator_options_container]
+ options_container[creative_mode_defines.names.gui.duplicator_can_duplicate_in_vehicle_checkbox].state =
+ element.state
+ end
+ end
+ end)
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.duplicator_can_duplicate_in_player_checkbox then
+ ---------------------------------------------------------------------------------------------------
+ -- Matter duplicator - can duplicate in player.
+ local data = duplicator.get_data_for_entity(entity)
+ if data then
+ data.can_duplicate_in_player = element.state
+ end
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local options_container = frame[creative_mode_defines.names.gui.duplicator_options_container]
+ options_container[creative_mode_defines.names.gui.duplicator_can_duplicate_in_player_checkbox].state =
+ element.state
+ end
+ end
+ end)
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_void_can_remove_from_vehicle_checkbox then
+ -- Matter void - can remove from vehicle.
+ local data = item_void.get_data_for_entity(entity)
+ if data then
+ data.can_remove_from_vehicle = element.state
+ end
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local options_container = frame[creative_mode_defines.names.gui.item_void_options_container]
+ options_container[creative_mode_defines.names.gui.item_void_can_remove_from_vehicle_checkbox].state =
+ element.state
+ end
+ end
+ end)
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_void_can_remove_from_player_checkbox then
+ -- Matter void - can remove from player.
+ local data = item_void.get_data_for_entity(entity)
+ if data then
+ data.can_remove_from_player = element.state
+ end
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local options_container = frame[creative_mode_defines.names.gui.item_void_options_container]
+ options_container[creative_mode_defines.names.gui.item_void_can_remove_from_player_checkbox].state =
+ element.state
+ end
+ end
+ end)
+
+ return true
+ elseif element_name == creative_mode_defines.names.gui.item_void_can_remove_from_ground_checkbox then
+ -- Matter void - can remove from ground.
+ local data = item_void.get_data_for_entity(entity)
+ if data then
+ data.can_remove_from_ground = element.state
+ end
+
+ -- Update the GUI for all players who are checking the entity.
+ update_entity_gui_for_all_players_checking_the_entity(entity, true, function(p, frame_container, frame)
+ if p ~= player then
+ if frame then
+ local options_container = frame[creative_mode_defines.names.gui.item_void_options_container]
+ options_container[creative_mode_defines.names.gui.item_void_can_remove_from_ground_checkbox].state =
+ element.state
+ end
+ end
+ end)
+
+ return true
+ end
+
+ return false
end
diff --git a/scripts/gui-menu-admin.lua b/scripts/gui-menu-admin.lua
index fd1c424..2dde839 100644
--- a/scripts/gui-menu-admin.lua
+++ b/scripts/gui-menu-admin.lua
@@ -4,538 +4,545 @@ require("scripts.rights")
-- This file contains variables and functions related to Creative Mode menu - admin GUI.
if not gui_menu_admin then
- gui_menu_admin = {}
+ gui_menu_admin = {}
end
-- Gets the name of the admin menu container.
function gui_menu_admin.get_container_name()
- return creative_mode_defines.names.gui.admin_menus_container
+ return creative_mode_defines.names.gui.admin_menus_container
end
------
-- GUI data about access right to different features.
local access_rights_gui_data = {
- personal_cheat = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_personal_cheat_container,
- label_name = creative_mode_defines.names.gui.access_personal_cheat_label,
- label_caption = {"gui.creative-mode_personal-cheats"},
- inner_container_name = creative_mode_defines.names.gui.access_personal_cheat_inner_container,
- access_right_code = rights.access_personal_cheats_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_personal_cheat_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-personal-cheat-admin-only-tooltip"},
- value = rights.access_personal_cheats_level.admin_only,
- message_key = "message.creative-mode_access-right-personal-cheat-admin-only"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_personal_cheat_free_button,
- button_caption = {"gui.creative-mode_access-right-personal-cheat-free"},
- button_tooltip = {"gui.creative-mode_access-right-personal-cheat-free-tooltip"},
- value = rights.access_personal_cheats_level.free,
- message_key = "message.creative-mode_access-right-personal-cheat-free"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.access_personal_cheats
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.access_personal_cheats = value
- end
+ personal_cheat = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_personal_cheat_container,
+ label_name = creative_mode_defines.names.gui.access_personal_cheat_label,
+ label_caption = { "gui.creative-mode_personal-cheats" },
+ inner_container_name = creative_mode_defines.names.gui.access_personal_cheat_inner_container,
+ access_right_code = rights.access_personal_cheats_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_personal_cheat_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-personal-cheat-admin-only-tooltip" },
+ value = rights.access_personal_cheats_level.admin_only,
+ message_key = "message.creative-mode_access-right-personal-cheat-admin-only",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_personal_cheat_free_button,
+ button_caption = { "gui.creative-mode_access-right-personal-cheat-free" },
+ button_tooltip = { "gui.creative-mode_access-right-personal-cheat-free-tooltip" },
+ value = rights.access_personal_cheats_level.free,
+ message_key = "message.creative-mode_access-right-personal-cheat-free",
+ },
},
- team_cheat = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_team_cheat_container,
- label_name = creative_mode_defines.names.gui.access_team_cheat_label,
- label_caption = {"gui.creative-mode_team-cheats"},
- inner_container_name = creative_mode_defines.names.gui.access_team_cheat_inner_container,
- access_right_code = rights.access_team_cheats_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_team_cheat_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-team-cheat-admin-only-tooltip"},
- value = rights.access_team_cheats_level.admin_only,
- message_key = "message.creative-mode_access-right-team-cheat-admin-only"
- },
- own_team = {
- button_name = creative_mode_defines.names.gui.access_team_cheat_own_team_button,
- button_caption = {"gui.creative-mode_access-right-team-cheat-free-own-team"},
- button_tooltip = {"gui.creative-mode_access-right-team-cheat-free-own-team-tooltip"},
- value = rights.access_team_cheats_level.own_team_only,
- message_key = "message.creative-mode_access-right-team-cheat-free-own-team"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_team_cheat_free_button,
- button_caption = {"gui.creative-mode_access-right-team-cheat-free-all-teams"},
- button_tooltip = {"gui.creative-mode_access-right-team-cheat-free-all-teams-tooltip"},
- value = rights.access_team_cheats_level.free,
- message_key = "message.creative-mode_access-right-team-cheat-free-all-teams"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.access_team_cheats
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.access_team_cheats = value
- end
+ get_value_function = function()
+ return storage.creative_mode.player_rights.access_personal_cheats
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.access_personal_cheats = value
+ end,
+ },
+ team_cheat = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_team_cheat_container,
+ label_name = creative_mode_defines.names.gui.access_team_cheat_label,
+ label_caption = { "gui.creative-mode_team-cheats" },
+ inner_container_name = creative_mode_defines.names.gui.access_team_cheat_inner_container,
+ access_right_code = rights.access_team_cheats_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_team_cheat_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-team-cheat-admin-only-tooltip" },
+ value = rights.access_team_cheats_level.admin_only,
+ message_key = "message.creative-mode_access-right-team-cheat-admin-only",
+ },
+ own_team = {
+ button_name = creative_mode_defines.names.gui.access_team_cheat_own_team_button,
+ button_caption = { "gui.creative-mode_access-right-team-cheat-free-own-team" },
+ button_tooltip = { "gui.creative-mode_access-right-team-cheat-free-own-team-tooltip" },
+ value = rights.access_team_cheats_level.own_team_only,
+ message_key = "message.creative-mode_access-right-team-cheat-free-own-team",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_team_cheat_free_button,
+ button_caption = { "gui.creative-mode_access-right-team-cheat-free-all-teams" },
+ button_tooltip = { "gui.creative-mode_access-right-team-cheat-free-all-teams-tooltip" },
+ value = rights.access_team_cheats_level.free,
+ message_key = "message.creative-mode_access-right-team-cheat-free-all-teams",
+ },
},
- surface_cheat = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_surface_cheat_container,
- label_name = creative_mode_defines.names.gui.access_surface_cheat_label,
- label_caption = {"gui.creative-mode_surface-cheats"},
- inner_container_name = creative_mode_defines.names.gui.access_surface_cheat_inner_container,
- access_right_code = rights.access_surface_cheats_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_surface_cheat_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-surface-cheat-admin-only-tooltip"},
- value = rights.access_surface_cheats_level.admin_only,
- message_key = "message.creative-mode_access-right-surface-cheat-admin-only"
- },
- current_surface = {
- button_name = creative_mode_defines.names.gui.access_surface_cheat_current_surface_button,
- button_caption = {"gui.creative-mode_access-right-surface-cheat-free-own-surface"},
- button_tooltip = {"gui.creative-mode_access-right-surface-cheat-free-own-surface-tooltip"},
- value = rights.access_surface_cheats_level.current_surface_only,
- message_key = "message.creative-mode_access-right-surface-cheat-free-own-surface"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_surface_cheat_free_button,
- button_caption = {"gui.creative-mode_access-right-surface-cheat-free-all-surfaces"},
- button_tooltip = {"gui.creative-mode_access-right-surface-cheat-free-all-surfaces-tooltip"},
- value = rights.access_surface_cheats_level.free,
- message_key = "message.creative-mode_access-right-surface-cheat-free-all-surfaces"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.access_surface_cheats
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.access_surface_cheats = value
- end
+ get_value_function = function()
+ return storage.creative_mode.player_rights.access_team_cheats
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.access_team_cheats = value
+ end,
+ },
+ surface_cheat = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_surface_cheat_container,
+ label_name = creative_mode_defines.names.gui.access_surface_cheat_label,
+ label_caption = { "gui.creative-mode_surface-cheats" },
+ inner_container_name = creative_mode_defines.names.gui.access_surface_cheat_inner_container,
+ access_right_code = rights.access_surface_cheats_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_surface_cheat_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-surface-cheat-admin-only-tooltip" },
+ value = rights.access_surface_cheats_level.admin_only,
+ message_key = "message.creative-mode_access-right-surface-cheat-admin-only",
+ },
+ current_surface = {
+ button_name = creative_mode_defines.names.gui.access_surface_cheat_current_surface_button,
+ button_caption = { "gui.creative-mode_access-right-surface-cheat-free-own-surface" },
+ button_tooltip = { "gui.creative-mode_access-right-surface-cheat-free-own-surface-tooltip" },
+ value = rights.access_surface_cheats_level.current_surface_only,
+ message_key = "message.creative-mode_access-right-surface-cheat-free-own-surface",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_surface_cheat_free_button,
+ button_caption = { "gui.creative-mode_access-right-surface-cheat-free-all-surfaces" },
+ button_tooltip = { "gui.creative-mode_access-right-surface-cheat-free-all-surfaces-tooltip" },
+ value = rights.access_surface_cheats_level.free,
+ message_key = "message.creative-mode_access-right-surface-cheat-free-all-surfaces",
+ },
},
- global_cheat = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_global_cheat_container,
- label_name = creative_mode_defines.names.gui.access_global_cheat_label,
- label_caption = {"gui.creative-mode_global-cheats"},
- inner_container_name = creative_mode_defines.names.gui.access_global_cheat_inner_container,
- access_right_code = rights.access_global_cheats_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_global_cheat_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-global-cheat-admin-only-tooltip"},
- value = rights.access_global_cheats_level.admin_only,
- message_key = "message.creative-mode_access-right-global-cheat-admin-only"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_global_cheat_free_button,
- button_caption = {"gui.creative-mode_access-right-global-cheat-free"},
- button_tooltip = {"gui.creative-mode_access-right-global-cheat-free-tooltip"},
- value = rights.access_global_cheats_level.free,
- message_key = "message.creative-mode_access-right-global-cheat-free"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.access_global_cheats
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.access_global_cheats = value
- end
+ get_value_function = function()
+ return storage.creative_mode.player_rights.access_surface_cheats
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.access_surface_cheats = value
+ end,
+ },
+ global_cheat = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_global_cheat_container,
+ label_name = creative_mode_defines.names.gui.access_global_cheat_label,
+ label_caption = { "gui.creative-mode_global-cheats" },
+ inner_container_name = creative_mode_defines.names.gui.access_global_cheat_inner_container,
+ access_right_code = rights.access_global_cheats_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_global_cheat_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-global-cheat-admin-only-tooltip" },
+ value = rights.access_global_cheats_level.admin_only,
+ message_key = "message.creative-mode_access-right-global-cheat-admin-only",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_global_cheat_free_button,
+ button_caption = { "gui.creative-mode_access-right-global-cheat-free" },
+ button_tooltip = { "gui.creative-mode_access-right-global-cheat-free-tooltip" },
+ value = rights.access_global_cheats_level.free,
+ message_key = "message.creative-mode_access-right-global-cheat-free",
+ },
},
- build_options = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_build_options_container,
- label_name = creative_mode_defines.names.gui.access_build_options_label,
- label_caption = {"gui.creative-mode_build-options"},
- inner_container_name = creative_mode_defines.names.gui.access_build_options_inner_container,
- access_right_code = rights.access_build_options_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_build_options_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-build-options-admin-only-tooltip"},
- value = rights.access_build_options_level.admin_only,
- message_key = "message.creative-mode_access-right-build-options-admin-only"
- },
- no_team = {
- button_name = creative_mode_defines.names.gui.access_build_options_no_team_button,
- button_caption = {"gui.creative-mode_access-right-build-options-no-team-options"},
- button_tooltip = {"gui.creative-mode_access-right-build-options-no-team-options-tooltip"},
- value = rights.access_build_options_level.no_team_options,
- message_key = "message.creative-mode_access-right-build-options-no-team-options"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_build_options_free_button,
- button_caption = {"gui.creative-mode_access-right-build-options-free"},
- button_tooltip = {"gui.creative-mode_access-right-build-options-free-tooltip"},
- value = rights.access_build_options_level.free,
- message_key = "message.creative-mode_access-right-build-options-free"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.access_build_options
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.access_build_options = value
- end
+ get_value_function = function()
+ return storage.creative_mode.player_rights.access_global_cheats
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.access_global_cheats = value
+ end,
+ },
+ build_options = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_build_options_container,
+ label_name = creative_mode_defines.names.gui.access_build_options_label,
+ label_caption = { "gui.creative-mode_build-options" },
+ inner_container_name = creative_mode_defines.names.gui.access_build_options_inner_container,
+ access_right_code = rights.access_build_options_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_build_options_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-build-options-admin-only-tooltip" },
+ value = rights.access_build_options_level.admin_only,
+ message_key = "message.creative-mode_access-right-build-options-admin-only",
+ },
+ no_team = {
+ button_name = creative_mode_defines.names.gui.access_build_options_no_team_button,
+ button_caption = { "gui.creative-mode_access-right-build-options-no-team-options" },
+ button_tooltip = { "gui.creative-mode_access-right-build-options-no-team-options-tooltip" },
+ value = rights.access_build_options_level.no_team_options,
+ message_key = "message.creative-mode_access-right-build-options-no-team-options",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_build_options_free_button,
+ button_caption = { "gui.creative-mode_access-right-build-options-free" },
+ button_tooltip = { "gui.creative-mode_access-right-build-options-free-tooltip" },
+ value = rights.access_build_options_level.free,
+ message_key = "message.creative-mode_access-right-build-options-free",
+ },
},
- creator_magic_wand = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_creator_magic_wand_container,
- label_name = creative_mode_defines.names.gui.access_creator_magic_wand_label,
- label_caption = {"gui.creative-mode_access-right-creator-magic-wand"},
- inner_container_name = creative_mode_defines.names.gui.access_creator_magic_wand_inner_container,
- access_right_code = rights.use_creator_magic_wand_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_creator_magic_wand_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-creator-magic-wand-admin-only-tooltip"},
- value = false,
- message_key = "message.creative-mode_access-right-creator-magic-wand-admin-only"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_creator_magic_wand_free_button,
- button_caption = {"gui.creative-mode_access-right-creator-magic-wand-free"},
- button_tooltip = {"gui.creative-mode_access-right-creator-magic-wand-free-tooltip"},
- value = true,
- message_key = "message.creative-mode_access-right-creator-magic-wand-free"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.use_creator_magic_wand
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.use_creator_magic_wand = value
- end
+ get_value_function = function()
+ return storage.creative_mode.player_rights.access_build_options
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.access_build_options = value
+ end,
+ },
+ creator_magic_wand = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_creator_magic_wand_container,
+ label_name = creative_mode_defines.names.gui.access_creator_magic_wand_label,
+ label_caption = { "gui.creative-mode_access-right-creator-magic-wand" },
+ inner_container_name = creative_mode_defines.names.gui.access_creator_magic_wand_inner_container,
+ access_right_code = rights.use_creator_magic_wand_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_creator_magic_wand_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-creator-magic-wand-admin-only-tooltip" },
+ value = false,
+ message_key = "message.creative-mode_access-right-creator-magic-wand-admin-only",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_creator_magic_wand_free_button,
+ button_caption = { "gui.creative-mode_access-right-creator-magic-wand-free" },
+ button_tooltip = { "gui.creative-mode_access-right-creator-magic-wand-free-tooltip" },
+ value = true,
+ message_key = "message.creative-mode_access-right-creator-magic-wand-free",
+ },
},
- healer_magic_wand = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_healer_magic_wand_container,
- label_name = creative_mode_defines.names.gui.access_healer_magic_wand_label,
- label_caption = {"gui.creative-mode_access-right-healer-magic-wand"},
- inner_container_name = creative_mode_defines.names.gui.access_healer_magic_wand_inner_container,
- access_right_code = rights.use_healer_magic_wand_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_healer_magic_wand_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-healer-magic-wand-admin-only-tooltip"},
- value = false,
- message_key = "message.creative-mode_access-right-healer-magic-wand-admin-only"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_healer_magic_wand_free_button,
- button_caption = {"gui.creative-mode_access-right-healer-magic-wand-free"},
- button_tooltip = {"gui.creative-mode_access-right-healer-magic-wand-free-tooltip"},
- value = true,
- message_key = "message.creative-mode_access-right-healer-magic-wand-free"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.use_healer_magic_wand
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.use_healer_magic_wand = value
- end
+ get_value_function = function()
+ return storage.creative_mode.player_rights.use_creator_magic_wand
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.use_creator_magic_wand = value
+ end,
+ },
+ healer_magic_wand = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_healer_magic_wand_container,
+ label_name = creative_mode_defines.names.gui.access_healer_magic_wand_label,
+ label_caption = { "gui.creative-mode_access-right-healer-magic-wand" },
+ inner_container_name = creative_mode_defines.names.gui.access_healer_magic_wand_inner_container,
+ access_right_code = rights.use_healer_magic_wand_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_healer_magic_wand_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-healer-magic-wand-admin-only-tooltip" },
+ value = false,
+ message_key = "message.creative-mode_access-right-healer-magic-wand-admin-only",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_healer_magic_wand_free_button,
+ button_caption = { "gui.creative-mode_access-right-healer-magic-wand-free" },
+ button_tooltip = { "gui.creative-mode_access-right-healer-magic-wand-free-tooltip" },
+ value = true,
+ message_key = "message.creative-mode_access-right-healer-magic-wand-free",
+ },
},
- modifier_magic_wand = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_modifier_magic_wand_container,
- label_name = creative_mode_defines.names.gui.access_modifier_magic_wand_label,
- label_caption = {"gui.creative-mode_access-right-modifier-magic-wand"},
- inner_container_name = creative_mode_defines.names.gui.access_modifier_magic_wand_inner_container,
- access_right_code = rights.use_modifier_magic_wand_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_modifier_magic_wand_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-modifier-magic-wand-admin-only-tooltip"},
- value = false,
- message_key = "message.creative-mode_access-right-modifier-magic-wand-admin-only"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_modifier_magic_wand_free_button,
- button_caption = {"gui.creative-mode_access-right-modifier-magic-wand-free"},
- button_tooltip = {"gui.creative-mode_access-right-modifier-magic-wand-free-tooltip"},
- value = true,
- message_key = "message.creative-mode_access-right-modifier-magic-wand-free"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.use_modifier_magic_wand
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.use_modifier_magic_wand = value
- end
+ get_value_function = function()
+ return storage.creative_mode.player_rights.use_healer_magic_wand
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.use_healer_magic_wand = value
+ end,
+ },
+ modifier_magic_wand = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_modifier_magic_wand_container,
+ label_name = creative_mode_defines.names.gui.access_modifier_magic_wand_label,
+ label_caption = { "gui.creative-mode_access-right-modifier-magic-wand" },
+ inner_container_name = creative_mode_defines.names.gui.access_modifier_magic_wand_inner_container,
+ access_right_code = rights.use_modifier_magic_wand_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_modifier_magic_wand_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-modifier-magic-wand-admin-only-tooltip" },
+ value = false,
+ message_key = "message.creative-mode_access-right-modifier-magic-wand-admin-only",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_modifier_magic_wand_free_button,
+ button_caption = { "gui.creative-mode_access-right-modifier-magic-wand-free" },
+ button_tooltip = { "gui.creative-mode_access-right-modifier-magic-wand-free-tooltip" },
+ value = true,
+ message_key = "message.creative-mode_access-right-modifier-magic-wand-free",
+ },
},
- modding_menu = {
- is_overall = false,
- container_name = creative_mode_defines.names.gui.access_modding_menu_container,
- label_name = creative_mode_defines.names.gui.access_modding_menu_label,
- label_caption = {"gui.creative-mode_modding"},
- inner_container_name = creative_mode_defines.names.gui.access_modding_menu_inner_container,
- access_right_code = rights.access_modding_menu_code,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.access_modding_menu_admin_only_button,
- button_caption = {"gui.creative-mode_access-right-admin-only"},
- button_tooltip = {"gui.creative-mode_access-right-modding-admin-only-tooltip"},
- value = false,
- message_key = "message.creative-mode_access-right-modding-admin-only"
- },
- free = {
- button_name = creative_mode_defines.names.gui.access_modding_menu_free_button,
- button_caption = {"gui.creative-mode_access-right-modding-free"},
- button_tooltip = {"gui.creative-mode_access-right-modding-free-tooltip"},
- value = true,
- message_key = "message.creative-mode_access-right-modding-free"
- }
- },
- get_value_function = function()
- return storage.creative_mode.player_rights.access_modding_menu
- end,
- set_value_function = function(value)
- storage.creative_mode.player_rights.access_modding_menu = value
- end
+ get_value_function = function()
+ return storage.creative_mode.player_rights.use_modifier_magic_wand
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.use_modifier_magic_wand = value
+ end,
+ },
+ modding_menu = {
+ is_overall = false,
+ container_name = creative_mode_defines.names.gui.access_modding_menu_container,
+ label_name = creative_mode_defines.names.gui.access_modding_menu_label,
+ label_caption = { "gui.creative-mode_modding" },
+ inner_container_name = creative_mode_defines.names.gui.access_modding_menu_inner_container,
+ access_right_code = rights.access_modding_menu_code,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.access_modding_menu_admin_only_button,
+ button_caption = { "gui.creative-mode_access-right-admin-only" },
+ button_tooltip = { "gui.creative-mode_access-right-modding-admin-only-tooltip" },
+ value = false,
+ message_key = "message.creative-mode_access-right-modding-admin-only",
+ },
+ free = {
+ button_name = creative_mode_defines.names.gui.access_modding_menu_free_button,
+ button_caption = { "gui.creative-mode_access-right-modding-free" },
+ button_tooltip = { "gui.creative-mode_access-right-modding-free-tooltip" },
+ value = true,
+ message_key = "message.creative-mode_access-right-modding-free",
+ },
},
- overall_access_rights = {
- is_overall = true,
- container_name = creative_mode_defines.names.gui.overall_access_rights_container,
- label_name = creative_mode_defines.names.gui.overall_access_rights_label,
- label_caption = {"gui.creative-mode_overall-access-rights"},
- inner_container_name = creative_mode_defines.names.gui.overall_access_rights_inner_container,
- access_right_code = nil,
- options = {
- admin_only = {
- button_name = creative_mode_defines.names.gui.overall_access_rights_admin_only_button,
- button_caption = {"gui.creative-mode_overall-access-rights-admin-only"},
- button_tooltip = nil,
- value = false, -- Admin-only = false
- message_key = "message.creative-mode_overall-access-rights-admin-only"
- },
- default = {
- button_name = creative_mode_defines.names.gui.overall_access_rights_default_button,
- button_caption = {"gui.creative-mode_overall-access-rights-default"},
- button_tooltip = nil,
- value = true, -- Default = true
- message_key = "message.creative-mode_overall-access-rights-default"
- }
- },
- get_value_function = nil,
- set_value_function = nil
- }
+ get_value_function = function()
+ return storage.creative_mode.player_rights.access_modding_menu
+ end,
+ set_value_function = function(value)
+ storage.creative_mode.player_rights.access_modding_menu = value
+ end,
+ },
+ overall_access_rights = {
+ is_overall = true,
+ container_name = creative_mode_defines.names.gui.overall_access_rights_container,
+ label_name = creative_mode_defines.names.gui.overall_access_rights_label,
+ label_caption = { "gui.creative-mode_overall-access-rights" },
+ inner_container_name = creative_mode_defines.names.gui.overall_access_rights_inner_container,
+ access_right_code = nil,
+ options = {
+ admin_only = {
+ button_name = creative_mode_defines.names.gui.overall_access_rights_admin_only_button,
+ button_caption = { "gui.creative-mode_overall-access-rights-admin-only" },
+ button_tooltip = nil,
+ value = false, -- Admin-only = false
+ message_key = "message.creative-mode_overall-access-rights-admin-only",
+ },
+ default = {
+ button_name = creative_mode_defines.names.gui.overall_access_rights_default_button,
+ button_caption = { "gui.creative-mode_overall-access-rights-default" },
+ button_tooltip = nil,
+ value = true, -- Default = true
+ message_key = "message.creative-mode_overall-access-rights-default",
+ },
+ },
+ get_value_function = nil,
+ set_value_function = nil,
+ },
}
------
-- Creates the GUI elements in the given container for the access right of given GUI data.
local function create_access_right_elements_from_data(access_rights_container, access_right_gui_data)
- -- Container.
- local container = access_rights_container.add {
- type = "flow",
- name = access_right_gui_data.container_name,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical"
- }
- -- Label.
- local label = container.add {
- type = "label",
- name = access_right_gui_data.label_name,
- caption = access_right_gui_data.label_caption
- }
- if access_right_gui_data.is_overall then
- label.style = "caption_label"
- end
- -- Inner container.
- local inner_container = container.add {
- type = "table",
- name = access_right_gui_data.inner_container_name,
- column_count = 1
- }
- inner_container.style.vertical_spacing = 0
- inner_container.style.left_padding = 16
- -- Options.
- local current_value
- if not access_right_gui_data.is_overall then
- current_value = access_right_gui_data.get_value_function()
- end
- for _, option in pairs(access_right_gui_data.options) do
- local style
- if not access_right_gui_data.is_overall and current_value == option.value then
- style = creative_mode_defines.names.gui_styles.access_right_on_off_button_on
- else
- style = creative_mode_defines.names.gui_styles.access_right_on_off_button_off
- end
- inner_container.add {
- type = "button",
- name = option.button_name,
- style = style,
- caption = option.button_caption,
- tooltip = option.button_tooltip
- }
+ -- Container.
+ local container = access_rights_container.add({
+ type = "flow",
+ name = access_right_gui_data.container_name,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+ -- Label.
+ local label = container.add({
+ type = "label",
+ name = access_right_gui_data.label_name,
+ caption = access_right_gui_data.label_caption,
+ })
+ if access_right_gui_data.is_overall then
+ label.style = "caption_label"
+ end
+ -- Inner container.
+ local inner_container = container.add({
+ type = "table",
+ name = access_right_gui_data.inner_container_name,
+ column_count = 1,
+ })
+ inner_container.style.vertical_spacing = 0
+ inner_container.style.left_padding = 16
+ -- Options.
+ local current_value
+ if not access_right_gui_data.is_overall then
+ current_value = access_right_gui_data.get_value_function()
+ end
+ for _, option in pairs(access_right_gui_data.options) do
+ local style
+ if not access_right_gui_data.is_overall and current_value == option.value then
+ style = creative_mode_defines.names.gui_styles.access_right_on_off_button_on
+ else
+ style = creative_mode_defines.names.gui_styles.access_right_on_off_button_off
end
+ inner_container.add({
+ type = "button",
+ name = option.button_name,
+ style = style,
+ caption = option.button_caption,
+ tooltip = option.button_tooltip,
+ })
+ end
end
-- Creates the admin menu for the given player. If the menu already exists, it will be destroyed instead.
function gui_menu_admin.create_or_destroy_menu_for_player(player)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Admin container.
- local admin_menus_container = container[gui_menu_admin.get_container_name()]
- if admin_menus_container then
- admin_menus_container.destroy()
- else
- admin_menus_container = container.add {
- type = "flow",
- name = gui_menu_admin.get_container_name(),
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- direction = "horizontal"
- }
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Admin container.
+ local admin_menus_container = container[gui_menu_admin.get_container_name()]
+ if admin_menus_container then
+ admin_menus_container.destroy()
+ else
+ admin_menus_container = container.add({
+ type = "flow",
+ name = gui_menu_admin.get_container_name(),
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ direction = "horizontal",
+ })
- -- Access right frame.
- local access_right_frame = admin_menus_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.access_right_frame,
- direction = "vertical",
- caption = {"gui.creative-mode_access-right"}
- }
- -- Label.
- access_right_frame.add {
- type = "label",
- name = creative_mode_defines.names.gui.access_right_label,
- caption = {"gui.creative-mode_select-non-admin-player-access-right"}
- }
- -- Scroll-pane.
- local access_rights_scorll_pane = access_right_frame.add {
- type = "scroll-pane",
- name = creative_mode_defines.names.gui.access_rights_scroll_pane,
- style = creative_mode_defines.names.gui_styles.cheat_scroll_pane
- }
- -- Container.
- local access_rights_container = access_rights_scorll_pane.add {
- type = "table",
- name = creative_mode_defines.names.gui.access_rights_container,
- column_count = 2
- }
- access_rights_container.style.horizontal_spacing = 18
- access_rights_container.style.vertical_spacing = 18
- -- Rights.
- for _, data in pairs(access_rights_gui_data) do
- create_access_right_elements_from_data(access_rights_container, data)
- end
+ -- Access right frame.
+ local access_right_frame = admin_menus_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.access_right_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_access-right" },
+ })
+ -- Label.
+ access_right_frame.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.access_right_label,
+ caption = { "gui.creative-mode_select-non-admin-player-access-right" },
+ })
+ -- Scroll-pane.
+ local access_rights_scorll_pane = access_right_frame.add({
+ type = "scroll-pane",
+ name = creative_mode_defines.names.gui.access_rights_scroll_pane,
+ style = creative_mode_defines.names.gui_styles.cheat_scroll_pane,
+ })
+ -- Container.
+ local access_rights_container = access_rights_scorll_pane.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.access_rights_container,
+ column_count = 2,
+ })
+ access_rights_container.style.horizontal_spacing = 18
+ access_rights_container.style.vertical_spacing = 18
+ -- Rights.
+ for _, data in pairs(access_rights_gui_data) do
+ create_access_right_elements_from_data(access_rights_container, data)
+ end
- -- Disable Creative Mode frame.
- local disable_creative_mode_frame = admin_menus_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.disable_creative_mode_frame,
- direction = "vertical",
- caption = {"gui.creative-mode_disable-creative-mode-title"},
- tooltip = {"gui.creative-mode_disable-creative-mode-tooltip"}
- }
- -- Disable button.
- disable_creative_mode_frame.add {
- type = "button",
- name = creative_mode_defines.names.gui.disable_creative_mode_button,
- style = creative_mode_defines.names.gui_styles.disable_creative_mode_button,
- caption = {"gui.creative-mode_disable-creative-mode"}
- }
- -- Disable permanently button.
- disable_creative_mode_frame.add {
- type = "button",
- name = creative_mode_defines.names.gui.disable_creative_mode_permanently_button,
- style = creative_mode_defines.names.gui_styles.disable_creative_mode_button,
- caption = {"gui.creative-mode_disable-creative-mode-permanently"}
- }
- end
+ -- Disable Creative Mode frame.
+ local disable_creative_mode_frame = admin_menus_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.disable_creative_mode_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_disable-creative-mode-title" },
+ tooltip = { "gui.creative-mode_disable-creative-mode-tooltip" },
+ })
+ -- Disable button.
+ disable_creative_mode_frame.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.disable_creative_mode_button,
+ style = creative_mode_defines.names.gui_styles.disable_creative_mode_button,
+ caption = { "gui.creative-mode_disable-creative-mode" },
+ })
+ -- Disable permanently button.
+ disable_creative_mode_frame.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.disable_creative_mode_permanently_button,
+ style = creative_mode_defines.names.gui_styles.disable_creative_mode_button,
+ caption = { "gui.creative-mode_disable-creative-mode-permanently" },
+ })
end
+ end
end
--------------------------------------------------------------------
-- Updates the status of options in the data of given access right GUI data in the given container for the given player.
-local function update_access_right_options_status_in_container_for_player(player, access_rights_container,
- access_right_gui_data)
- if not access_right_gui_data.get_value_function then
- return
- end
+local function update_access_right_options_status_in_container_for_player(
+ player,
+ access_rights_container,
+ access_right_gui_data
+)
+ if not access_right_gui_data.get_value_function then
+ return
+ end
- -- Container.
- local gui_container = access_rights_container[access_right_gui_data.container_name]
- -- Inner container.
- local gui_inner_container = gui_container[access_right_gui_data.inner_container_name]
- -- Options.
- local current_value = access_right_gui_data.get_value_function()
- for _, option in pairs(access_right_gui_data.options) do
- local style
- if current_value == option.value then
- style = creative_mode_defines.names.gui_styles.access_right_on_off_button_on
- else
- style = creative_mode_defines.names.gui_styles.access_right_on_off_button_off
- end
- gui_inner_container[option.button_name].style = style
+ -- Container.
+ local gui_container = access_rights_container[access_right_gui_data.container_name]
+ -- Inner container.
+ local gui_inner_container = gui_container[access_right_gui_data.inner_container_name]
+ -- Options.
+ local current_value = access_right_gui_data.get_value_function()
+ for _, option in pairs(access_right_gui_data.options) do
+ local style
+ if current_value == option.value then
+ style = creative_mode_defines.names.gui_styles.access_right_on_off_button_on
+ else
+ style = creative_mode_defines.names.gui_styles.access_right_on_off_button_off
end
+ gui_inner_container[option.button_name].style = style
+ end
end
-- Updates the status of options in the data of given access right GUI data for all players.
local function update_access_right_options_status_in_gui_data_for_all_players(access_right_gui_data)
- if access_right_gui_data.is_overall then
- return
- end
+ if access_right_gui_data.is_overall then
+ return
+ end
- for _, player in pairs(game.players) do
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local admin_menus_container = container[gui_menu_admin.get_container_name()]
- if admin_menus_container then
- -- Access right frame.
- local access_right_frame = admin_menus_container[creative_mode_defines.names.gui.access_right_frame]
- -- Scroll-pane.
- local access_rights_scorll_pane = access_right_frame[creative_mode_defines.names.gui
- .access_rights_scroll_pane]
- -- Container.
- local access_rights_container = access_rights_scorll_pane[creative_mode_defines.names.gui
- .access_rights_container]
- update_access_right_options_status_in_container_for_player(player, access_rights_container,
- access_right_gui_data)
- end
- end
+ for _, player in pairs(game.players) do
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local admin_menus_container = container[gui_menu_admin.get_container_name()]
+ if admin_menus_container then
+ -- Access right frame.
+ local access_right_frame = admin_menus_container[creative_mode_defines.names.gui.access_right_frame]
+ -- Scroll-pane.
+ local access_rights_scorll_pane = access_right_frame[creative_mode_defines.names.gui.access_rights_scroll_pane]
+ -- Container.
+ local access_rights_container =
+ access_rights_scorll_pane[creative_mode_defines.names.gui.access_rights_container]
+ update_access_right_options_status_in_container_for_player(
+ player,
+ access_rights_container,
+ access_right_gui_data
+ )
+ end
end
+ end
end
-- Updates the status of all access right options for all players.
local function update_all_access_right_options_for_all_players()
- for _, player in pairs(game.players) do
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local admin_menus_container = container[gui_menu_admin.get_container_name()]
- if admin_menus_container then
- -- Access right frame.
- local access_right_frame = admin_menus_container[creative_mode_defines.names.gui.access_right_frame]
- -- Scroll-pane.
- local access_rights_scorll_pane = access_right_frame[creative_mode_defines.names.gui
- .access_rights_scroll_pane]
- -- Container.
- local access_rights_container = access_rights_scorll_pane[creative_mode_defines.names.gui
- .access_rights_container]
- for _, access_right_gui_data in pairs(access_rights_gui_data) do
- update_access_right_options_status_in_container_for_player(player, access_rights_container,
- access_right_gui_data)
- end
- end
+ for _, player in pairs(game.players) do
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local admin_menus_container = container[gui_menu_admin.get_container_name()]
+ if admin_menus_container then
+ -- Access right frame.
+ local access_right_frame = admin_menus_container[creative_mode_defines.names.gui.access_right_frame]
+ -- Scroll-pane.
+ local access_rights_scorll_pane = access_right_frame[creative_mode_defines.names.gui.access_rights_scroll_pane]
+ -- Container.
+ local access_rights_container =
+ access_rights_scorll_pane[creative_mode_defines.names.gui.access_rights_container]
+ for _, access_right_gui_data in pairs(access_rights_gui_data) do
+ update_access_right_options_status_in_container_for_player(
+ player,
+ access_rights_container,
+ access_right_gui_data
+ )
end
+ end
end
+ end
end
--------------------------------------------------------------------
@@ -543,75 +550,74 @@ end
-- Callback of the on_gui_click event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_admin.on_gui_click(element, element_name, player, button, alt, control, shift)
- if element_name == creative_mode_defines.names.gui.disable_creative_mode_button then
- -- Disable Creative Mode button.
- gui.show_main_popup(player, gui.main_popup_content_type.disable_creative_mode)
- return true
- elseif element_name == creative_mode_defines.names.gui.disable_creative_mode_permanently_button then
- -- Disable Creative Mode permanently button.
- gui.show_main_popup(player, gui.main_popup_content_type.permanent_disable_creative_mode)
- return true
- end
+ if element_name == creative_mode_defines.names.gui.disable_creative_mode_button then
+ -- Disable Creative Mode button.
+ gui.show_main_popup(player, gui.main_popup_content_type.disable_creative_mode)
+ return true
+ elseif element_name == creative_mode_defines.names.gui.disable_creative_mode_permanently_button then
+ -- Disable Creative Mode permanently button.
+ gui.show_main_popup(player, gui.main_popup_content_type.permanent_disable_creative_mode)
+ return true
+ end
- for _, data in pairs(access_rights_gui_data) do
- for _, option in pairs(data.options) do
- if element_name == option.button_name then
- -- Access right option button.
- if data.is_overall then
- -- Overall access rights button.
- -- Update values.
- if option.value then
- -- Default.
- rights.set_overall_default()
- else
- -- Admin-only.
- rights.set_overall_admin_only()
- end
+ for _, data in pairs(access_rights_gui_data) do
+ for _, option in pairs(data.options) do
+ if element_name == option.button_name then
+ -- Access right option button.
+ if data.is_overall then
+ -- Overall access rights button.
+ -- Update values.
+ if option.value then
+ -- Default.
+ rights.set_overall_default()
+ else
+ -- Admin-only.
+ rights.set_overall_admin_only()
+ end
- -- Update GUI and print message.
- update_all_access_right_options_for_all_players()
- -- Get all access right codes.
- local updated_access_right_codes = {}
- for _, data2 in pairs(access_rights_gui_data) do
- if not data2.is_overall then
- updated_access_right_codes[data2.access_right_code] = true
- end
- end
- gui_menu.update_menu_accessibility_according_to_access_right_for_all_players(
- updated_access_right_codes)
- game.print {option.message_key, player.name}
- else
- -- Single access right button.
- local old_value = data.get_value_function()
+ -- Update GUI and print message.
+ update_all_access_right_options_for_all_players()
+ -- Get all access right codes.
+ local updated_access_right_codes = {}
+ for _, data2 in pairs(access_rights_gui_data) do
+ if not data2.is_overall then
+ updated_access_right_codes[data2.access_right_code] = true
+ end
+ end
+ gui_menu.update_menu_accessibility_according_to_access_right_for_all_players(updated_access_right_codes)
+ game.print({ option.message_key, player.name })
+ else
+ -- Single access right button.
+ local old_value = data.get_value_function()
- -- Update value.
- data.set_value_function(option.value)
+ -- Update value.
+ data.set_value_function(option.value)
- -- Update GUI and print message if the value is different.
- if old_value ~= option.value then
- update_access_right_options_status_in_gui_data_for_all_players(data)
- gui_menu.update_menu_accessibility_according_to_access_right_for_all_players {
- [data.access_right_code] = true
- }
- game.print {option.message_key, player.name}
- end
- end
- return true
- end
+ -- Update GUI and print message if the value is different.
+ if old_value ~= option.value then
+ update_access_right_options_status_in_gui_data_for_all_players(data)
+ gui_menu.update_menu_accessibility_according_to_access_right_for_all_players({
+ [data.access_right_code] = true,
+ })
+ game.print({ option.message_key, player.name })
+ end
end
+ return true
+ end
end
+ end
- return false
+ return false
end
-- Callback of the on_gui_text_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_admin.on_gui_text_changed(element, element_name, player)
- return false
+ return false
end
-- Callback of the on_gui_checked_state_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_admin.on_gui_checked_state_changed(element, element_name, player)
- return false
+ return false
end
diff --git a/scripts/gui-menu-cheats.lua b/scripts/gui-menu-cheats.lua
index b73148d..45e9d4e 100644
--- a/scripts/gui-menu-cheats.lua
+++ b/scripts/gui-menu-cheats.lua
@@ -2,1498 +2,1498 @@ local mod_gui = require("mod-gui")
-- This file contains variables and functions related to Creative Mode menu - cheats GUI.
if not gui_menu_cheats then
- gui_menu_cheats = {}
+ gui_menu_cheats = {}
end
-- Because the build options menu share the same logic as the cheats menu, we put them together in this file.
if not gui_menu_buildoptions then
- gui_menu_buildoptions = {}
+ gui_menu_buildoptions = {}
end
-- Gets the name of the cheats menu container.
function gui_menu_cheats.get_container_name()
- return creative_mode_defines.names.gui.cheats_menus_container
+ return creative_mode_defines.names.gui.cheats_menus_container
end
-- Gets the name of the build options menu container.
function gui_menu_buildoptions.get_container_name()
- return creative_mode_defines.names.gui.build_options_menus_container
+ return creative_mode_defines.names.gui.build_options_menus_container
end
-----
-- Possible cheat GUI type.
gui_menu_cheats.cheat_gui_type = {
- -- Cheat with on/off buttons.
- on_off = 0,
- -- Cheat with numeric input and then an apply button.
- numeric_apply = 10,
- -- Cheat with string input and then an apply button.
- string_apply = 15,
- -- Cheat with only a single apply button.
- apply = 20,
- -- Cheat with a drop down of team selection without any apply button.
- team_target_auto_apply = 30,
+ -- Cheat with on/off buttons.
+ on_off = 0,
+ -- Cheat with numeric input and then an apply button.
+ numeric_apply = 10,
+ -- Cheat with string input and then an apply button.
+ string_apply = 15,
+ -- Cheat with only a single apply button.
+ apply = 20,
+ -- Cheat with a drop down of team selection without any apply button.
+ team_target_auto_apply = 30,
}
-- GUI data about the whole personal cheats menu.
local personal_cheats_menu_gui_data = {
- -- The cheats menus data this menu data belongs to. It will be set later.
- parent = nil,
- -- Menu structure.
- frame = {
- name = creative_mode_defines.names.gui.personal_cheats_menu_frame,
- caption = { "gui.creative-mode_personal-cheats" },
- outer_container = {
- name = creative_mode_defines.names.gui.personal_cheats_outer_container,
- targets_scroll_pane = {
- name = creative_mode_defines.names.gui.personal_cheats_targets_scroll_pane,
- outer_container = {
- name = creative_mode_defines.names.gui.personal_cheats_targets_container,
- inner_container = {
- name = creative_mode_defines.names.gui.personal_cheats_targets_inner_container,
- target_button = {
- name_prefix = creative_mode_defines.names.gui.personal_cheats_target_index_button_prefix,
- },
- select_all_button = {
- name = creative_mode_defines.names.gui.personal_cheats_targets_select_all_button,
- },
- },
- },
- },
- cheats_scroll_pane = {
- name = creative_mode_defines.names.gui.personal_cheats_cheats_scroll_pane,
- cheats_container = {
- name = creative_mode_defines.names.gui.personal_cheats_cheats_container,
- enable_disable_all_container = { -- Set it to nil if no such buttons.
- name = creative_mode_defines.names.gui.personal_cheats_all_button_container,
- enable_all_button_name = creative_mode_defines.names.gui.personal_cheats_enable_all_button,
- disable_all_button_name = creative_mode_defines.names.gui.personal_cheats_disable_all_button,
- },
- notes = {
- not_included_in_enable_all = {
- name = creative_mode_defines.names.gui.personal_cheats_not_included_in_enable_all_note,
- caption = { "gui.creative-mode_not-included-in-enabled-all" },
- },
- },
- },
- },
- },
- },
- -- GUI data for each of the cheats. No other data except cheat GUI data can be put inside.
- cheats_gui_data = {
- cheat_mode = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.cheat_mode,
- container_name = creative_mode_defines.names.gui.cheat_mode_container,
- label_name = creative_mode_defines.names.gui.cheat_mode_label,
- label_caption = { "gui.creative-mode_cheat-mode" },
- label_tooltip = {
- "gui.creative-mode_cheat-mode-tooltip",
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- },
- on_button_name = creative_mode_defines.names.gui.cheat_mode_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.cheat_mode_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- is_character_cheat = true, -- A character cheat = will update its state when player respawn (also when player die, but we don't do that for now), or when player switch between god mode.
- },
- invincible_player = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.invincible_player,
- container_name = creative_mode_defines.names.gui.invincible_player_container,
- label_name = creative_mode_defines.names.gui.invincible_player_label,
- label_caption = { "gui.creative-mode_invincible-player" },
- label_tooltip = {
- "gui.creative-mode_invincible-player-tooltip",
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- on_button_name = creative_mode_defines.names.gui.invincible_player_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.invincible_player_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- is_character_cheat = true,
- },
- keep_last_item = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.keep_last_item,
- container_name = creative_mode_defines.names.gui.keep_last_item_container,
- label_name = creative_mode_defines.names.gui.keep_last_item_label,
- label_caption = { "gui.creative-mode_keep-last-item" },
- label_tooltip = {
- "gui.creative-mode_keep-last-item-tooltip",
- { "gui.creative-mode_keep-last-item-tooltip2" },
- },
- on_button_name = creative_mode_defines.names.gui.keep_last_item_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.keep_last_item_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- get_player_can_access_function = nil,
- },
- repair_mined_item = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.repair_mined_item,
- container_name = creative_mode_defines.names.gui.repair_mined_item_container,
- label_name = creative_mode_defines.names.gui.repair_mined_item_label,
- label_caption = { "gui.creative-mode_repair-mined-item" },
- label_tooltip = {
- "gui.creative-mode_repair-mined-item-tooltip",
- { "gui.creative-mode_repair-mined-item-tooltip2" },
- },
- on_button_name = creative_mode_defines.names.gui.repair_mined_item_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.repair_mined_item_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- get_player_can_access_function = nil,
- },
- instant_request = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.instant_request,
- container_name = creative_mode_defines.names.gui.instant_request_container,
- label_name = creative_mode_defines.names.gui.instant_request_label,
- label_caption = { "gui.creative-mode_instant-request" },
- label_tooltip = {
- "gui.creative-mode_instant-request-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- on_button_name = creative_mode_defines.names.gui.instant_request_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.instant_request_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- instant_trash = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.instant_trash,
- container_name = creative_mode_defines.names.gui.instant_trash_container,
- label_name = creative_mode_defines.names.gui.instant_trash_label,
- label_caption = { "gui.creative-mode_instant-trash" },
- label_tooltip = { "gui.creative-mode_instant-trash-tooltip", { "gui.creative-mode_no-effect-in-god-mode" } },
- on_button_name = creative_mode_defines.names.gui.instant_trash_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.instant_trash_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- instant_blueprint = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.instant_blueprint,
- container_name = creative_mode_defines.names.gui.instant_blueprint_container,
- label_name = creative_mode_defines.names.gui.instant_blueprint_label,
- label_caption = { "gui.creative-mode_instant-blueprint" },
- label_tooltip = { "gui.creative-mode_instant-blueprint-tooltip" },
- on_button_name = creative_mode_defines.names.gui.instant_blueprint_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.instant_blueprint_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- instant_deconstruction = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.instant_deconstruction,
- container_name = creative_mode_defines.names.gui.instant_deconstruction_container,
- label_name = creative_mode_defines.names.gui.instant_deconstruction_label,
- label_caption = { "gui.creative-mode_instant-deconstruction" },
- label_tooltip = { "gui.creative-mode_instant-deconstruction-tooltip" },
- on_button_name = creative_mode_defines.names.gui.instant_deconstruction_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.instant_deconstruction_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- reach_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.reach_distance,
- container_name = creative_mode_defines.names.gui.reach_distance_container,
- label_name = creative_mode_defines.names.gui.reach_distance_label,
- label_caption = { "gui.creative-mode_reach-distance" },
- label_tooltip = {
- "gui.creative-mode_reach-distance-tooltip",
- cheats.default_cheat_values.reach_distance,
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.reach_distance_textfield,
- separator_name = creative_mode_defines.names.gui.reach_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.reach_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- build_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.build_distance,
- container_name = creative_mode_defines.names.gui.build_distance_container,
- label_name = creative_mode_defines.names.gui.build_distance_label,
- label_caption = { "gui.creative-mode_build-distance" },
- label_tooltip = {
- "gui.creative-mode_build-distance-tooltip",
- cheats.default_cheat_values.reach_distance,
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.build_distance_textfield,
- separator_name = creative_mode_defines.names.gui.build_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.build_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- resource_reach_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.resource_reach_distance,
- container_name = creative_mode_defines.names.gui.resource_reach_distance_container,
- label_name = creative_mode_defines.names.gui.resource_reach_distance_label,
- label_caption = { "gui.creative-mode_resource-reach-distance" },
- label_tooltip = {
- "gui.creative-mode_resource-reach-distance-tooltip",
- cheats.default_cheat_values.reach_distance,
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.resource_reach_distance_textfield,
- separator_name = creative_mode_defines.names.gui.resource_reach_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.resource_reach_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- item_drop_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.item_drop_distance,
- container_name = creative_mode_defines.names.gui.item_drop_distance_container,
- label_name = creative_mode_defines.names.gui.item_drop_distance_label,
- label_caption = { "gui.creative-mode_item-drop-distance" },
- label_tooltip = {
- "gui.creative-mode_item-drop-distance-tooltip",
- cheats.default_cheat_values.reach_distance,
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.item_drop_distance_textfield,
- separator_name = creative_mode_defines.names.gui.item_drop_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.item_drop_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- item_pickup_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.item_pickup_distance,
- container_name = creative_mode_defines.names.gui.item_pickup_distance_container,
- label_name = creative_mode_defines.names.gui.item_pickup_distance_label,
- label_caption = { "gui.creative-mode_item-pickup-distance" },
- label_tooltip = {
- "gui.creative-mode_item-pickup-distance-tooltip",
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.item_pickup_distance_textfield,
- separator_name = creative_mode_defines.names.gui.item_pickup_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.item_pickup_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- loot_pickup_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.loot_pickup_distance,
- container_name = creative_mode_defines.names.gui.loot_pickup_distance_container,
- label_name = creative_mode_defines.names.gui.loot_pickup_distance_label,
- label_caption = { "gui.creative-mode_loot-pickup-distance" },
- label_tooltip = {
- "gui.creative-mode_loot-pickup-distance-tooltip",
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.loot_pickup_distance_textfield,
- separator_name = creative_mode_defines.names.gui.loot_pickup_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.loot_pickup_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- mining_speed = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.mining_speed,
- container_name = creative_mode_defines.names.gui.mining_speed_container,
- label_name = creative_mode_defines.names.gui.mining_speed_label,
- label_caption = { "gui.creative-mode_mining-speed" },
- label_tooltip = {
- "gui.creative-mode_mining-speed-tooltip",
- cheats.default_cheat_values.mining_speed,
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.mining_speed_textfield,
- separator_name = creative_mode_defines.names.gui.mining_speed_separator,
- apply_button_name = creative_mode_defines.names.gui.mining_speed_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- running_speed = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.running_speed,
- container_name = creative_mode_defines.names.gui.running_speed_container,
- label_name = creative_mode_defines.names.gui.running_speed_label,
- label_caption = { "gui.creative-mode_running-speed" },
- label_tooltip = {
- "gui.creative-mode_running-speed-tooltip",
- cheats.default_cheat_values.running_speed,
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.running_speed_textfield,
- separator_name = creative_mode_defines.names.gui.running_speed_separator,
- apply_button_name = creative_mode_defines.names.gui.running_speed_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- crafting_speed = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.crafting_speed,
- container_name = creative_mode_defines.names.gui.crafting_speed_container,
- label_name = creative_mode_defines.names.gui.crafting_speed_label,
- label_caption = { "gui.creative-mode_crafting-speed" },
- label_tooltip = {
- "gui.creative-mode_crafting-speed-tooltip",
- { "gui.creative-mode_no-effect-in-cheat-mode" },
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.crafting_speed_textfield,
- separator_name = creative_mode_defines.names.gui.crafting_speed_separator,
- apply_button_name = creative_mode_defines.names.gui.crafting_speed_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- inventory_bonus = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.inventory_bonus,
- container_name = creative_mode_defines.names.gui.inventory_bonus_container,
- label_name = creative_mode_defines.names.gui.inventory_bonus_label,
- label_caption = { "gui.creative-mode_inventory-bonus" },
- label_tooltip = {
- "gui.creative-mode_inventory-bonus-tooltip",
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.inventory_bonus_textfield,
- separator_name = creative_mode_defines.names.gui.inventory_bonus_separator,
- apply_button_name = creative_mode_defines.names.gui.inventory_bonus_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- health_bonus = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.personal_cheats_data.cheats.health_bonus,
- container_name = creative_mode_defines.names.gui.health_bonus_container,
- label_name = creative_mode_defines.names.gui.health_bonus_label,
- label_caption = { "gui.creative-mode_health-bonus" },
- label_tooltip = {
- "gui.creative-mode_health-bonus-tooltip",
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.health_bonus_textfield,
- separator_name = creative_mode_defines.names.gui.health_bonus_separator,
- apply_button_name = creative_mode_defines.names.gui.health_bonus_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_character_cheat = true,
- },
- god_mode = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.personal_cheats_data.cheats.god_mode,
- container_name = creative_mode_defines.names.gui.god_mode_container,
- label_name = creative_mode_defines.names.gui.god_mode_label,
- label_caption = { "gui.creative-mode_god-mode" },
- label_tooltip = {
- "gui.creative-mode_god-mode-tooltip",
- { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
- },
- on_button_name = creative_mode_defines.names.gui.god_mode_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.god_mode_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- },
- -- All cheat data. It is used for enabling / disabling all.
- cheats_data = cheats.personal_cheats_data,
- -- Function for getting the unverified target list for the given player when constructing the menu.
- get_unverified_targets_function = function(player)
- if rights.can_player_access_other_non_admin_players_cheats(player) then
- return game.connected_players, nil -- 1st param = list. Each candidate will be further verified.
- else
- return nil, player -- 2nd param = single target. It will not be further verified.
- end
- end,
- -- Function for verifying each candidate in the unverified target list. It is called after get_unverified_targets_function, so no need to check the player's access right to that particular target.
- verify_target_function = function(player, target)
- return target.valid and (target == player or not target.admin)
- end,
- -- Function for verifying a single target that is added in the middle of game. The player's access right to that target should be checked here.
- verify_target_for_insert_function = function(player, target)
- if not target.valid then
- return false
- end
- if target == player then
- return true
- end
- if rights.can_player_access_other_non_admin_players_cheats(player) and not target.admin then
- return true
- end
- return false
- end,
- -- Function for getting the postfix for the target button name.
- get_target_button_name_postfix_function = function(player, target)
- return target.index
- end,
- -- Function for getting the caption for the target button.
- get_target_button_caption_function = function(player, target)
- return target.name
- end,
- -- Function for getting the tooltip for the target button.
- get_target_button_tooltip_function = function(player, target)
- return { "gui.creative-mode_player-name-tooltip", target.name }
- end,
- -- Function for detecting if the target should be marked as self (blue font)
- check_is_target_self_function = function(player, target)
- return player == target
- end,
- -- Function to be called after the target button is added to the list.
- post_create_target_button_function = function(player, target, button)
- button.visible = target.connected -- If target is not connected, but he is here before, just hide the button.
- end,
- -- Function for checking whether the target button is a valid option. It will affect whether the target selection scroll pane should be shown or hidden.
- check_is_target_button_valid_function = function(player, target, button)
- return button.visible ~= false
- end,
- -- Function for checking whether the target button is a valid option without knowing the actual target represented by the button.
- check_is_target_button_valid_unknown_target_function = function(player, button)
- return button.visible ~= false
- end,
- -- Function for getting the actual target represented by the given target button.
- get_button_actual_target_function = function(player, button)
- local player_index =
- string.match(button.name, creative_mode_defines.match_patterns.gui.personal_cheats_target_index_button)
- if player_index then
- player_index = tonumber(player_index)
- return game.players[player_index]
- end
- return nil
- end,
- -- Function for removing the target button for the given player. Returns true if the button should be removed from the container.
- remove_target_button_function = function(player, target, button)
- -- Make sure the button is unselected.
- local button_style_name = button.style.name
- if button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- elseif button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- end
- button.visible = false
- -- In case the player will come back, we don't remove the button.
- return false
- end,
+ -- The cheats menus data this menu data belongs to. It will be set later.
+ parent = nil,
+ -- Menu structure.
+ frame = {
+ name = creative_mode_defines.names.gui.personal_cheats_menu_frame,
+ caption = { "gui.creative-mode_personal-cheats" },
+ outer_container = {
+ name = creative_mode_defines.names.gui.personal_cheats_outer_container,
+ targets_scroll_pane = {
+ name = creative_mode_defines.names.gui.personal_cheats_targets_scroll_pane,
+ outer_container = {
+ name = creative_mode_defines.names.gui.personal_cheats_targets_container,
+ inner_container = {
+ name = creative_mode_defines.names.gui.personal_cheats_targets_inner_container,
+ target_button = {
+ name_prefix = creative_mode_defines.names.gui.personal_cheats_target_index_button_prefix,
+ },
+ select_all_button = {
+ name = creative_mode_defines.names.gui.personal_cheats_targets_select_all_button,
+ },
+ },
+ },
+ },
+ cheats_scroll_pane = {
+ name = creative_mode_defines.names.gui.personal_cheats_cheats_scroll_pane,
+ cheats_container = {
+ name = creative_mode_defines.names.gui.personal_cheats_cheats_container,
+ enable_disable_all_container = { -- Set it to nil if no such buttons.
+ name = creative_mode_defines.names.gui.personal_cheats_all_button_container,
+ enable_all_button_name = creative_mode_defines.names.gui.personal_cheats_enable_all_button,
+ disable_all_button_name = creative_mode_defines.names.gui.personal_cheats_disable_all_button,
+ },
+ notes = {
+ not_included_in_enable_all = {
+ name = creative_mode_defines.names.gui.personal_cheats_not_included_in_enable_all_note,
+ caption = { "gui.creative-mode_not-included-in-enabled-all" },
+ },
+ },
+ },
+ },
+ },
+ },
+ -- GUI data for each of the cheats. No other data except cheat GUI data can be put inside.
+ cheats_gui_data = {
+ cheat_mode = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.cheat_mode,
+ container_name = creative_mode_defines.names.gui.cheat_mode_container,
+ label_name = creative_mode_defines.names.gui.cheat_mode_label,
+ label_caption = { "gui.creative-mode_cheat-mode" },
+ label_tooltip = {
+ "gui.creative-mode_cheat-mode-tooltip",
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ },
+ on_button_name = creative_mode_defines.names.gui.cheat_mode_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.cheat_mode_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ is_character_cheat = true, -- A character cheat = will update its state when player respawn (also when player die, but we don't do that for now), or when player switch between god mode.
+ },
+ invincible_player = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.invincible_player,
+ container_name = creative_mode_defines.names.gui.invincible_player_container,
+ label_name = creative_mode_defines.names.gui.invincible_player_label,
+ label_caption = { "gui.creative-mode_invincible-player" },
+ label_tooltip = {
+ "gui.creative-mode_invincible-player-tooltip",
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ on_button_name = creative_mode_defines.names.gui.invincible_player_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.invincible_player_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ is_character_cheat = true,
+ },
+ keep_last_item = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.keep_last_item,
+ container_name = creative_mode_defines.names.gui.keep_last_item_container,
+ label_name = creative_mode_defines.names.gui.keep_last_item_label,
+ label_caption = { "gui.creative-mode_keep-last-item" },
+ label_tooltip = {
+ "gui.creative-mode_keep-last-item-tooltip",
+ { "gui.creative-mode_keep-last-item-tooltip2" },
+ },
+ on_button_name = creative_mode_defines.names.gui.keep_last_item_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.keep_last_item_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ get_player_can_access_function = nil,
+ },
+ repair_mined_item = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.repair_mined_item,
+ container_name = creative_mode_defines.names.gui.repair_mined_item_container,
+ label_name = creative_mode_defines.names.gui.repair_mined_item_label,
+ label_caption = { "gui.creative-mode_repair-mined-item" },
+ label_tooltip = {
+ "gui.creative-mode_repair-mined-item-tooltip",
+ { "gui.creative-mode_repair-mined-item-tooltip2" },
+ },
+ on_button_name = creative_mode_defines.names.gui.repair_mined_item_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.repair_mined_item_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ get_player_can_access_function = nil,
+ },
+ instant_request = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.instant_request,
+ container_name = creative_mode_defines.names.gui.instant_request_container,
+ label_name = creative_mode_defines.names.gui.instant_request_label,
+ label_caption = { "gui.creative-mode_instant-request" },
+ label_tooltip = {
+ "gui.creative-mode_instant-request-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ on_button_name = creative_mode_defines.names.gui.instant_request_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.instant_request_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ instant_trash = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.instant_trash,
+ container_name = creative_mode_defines.names.gui.instant_trash_container,
+ label_name = creative_mode_defines.names.gui.instant_trash_label,
+ label_caption = { "gui.creative-mode_instant-trash" },
+ label_tooltip = { "gui.creative-mode_instant-trash-tooltip", { "gui.creative-mode_no-effect-in-god-mode" } },
+ on_button_name = creative_mode_defines.names.gui.instant_trash_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.instant_trash_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ instant_blueprint = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.instant_blueprint,
+ container_name = creative_mode_defines.names.gui.instant_blueprint_container,
+ label_name = creative_mode_defines.names.gui.instant_blueprint_label,
+ label_caption = { "gui.creative-mode_instant-blueprint" },
+ label_tooltip = { "gui.creative-mode_instant-blueprint-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.instant_blueprint_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.instant_blueprint_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ instant_deconstruction = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.instant_deconstruction,
+ container_name = creative_mode_defines.names.gui.instant_deconstruction_container,
+ label_name = creative_mode_defines.names.gui.instant_deconstruction_label,
+ label_caption = { "gui.creative-mode_instant-deconstruction" },
+ label_tooltip = { "gui.creative-mode_instant-deconstruction-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.instant_deconstruction_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.instant_deconstruction_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ reach_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.reach_distance,
+ container_name = creative_mode_defines.names.gui.reach_distance_container,
+ label_name = creative_mode_defines.names.gui.reach_distance_label,
+ label_caption = { "gui.creative-mode_reach-distance" },
+ label_tooltip = {
+ "gui.creative-mode_reach-distance-tooltip",
+ cheats.default_cheat_values.reach_distance,
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.reach_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.reach_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.reach_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ build_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.build_distance,
+ container_name = creative_mode_defines.names.gui.build_distance_container,
+ label_name = creative_mode_defines.names.gui.build_distance_label,
+ label_caption = { "gui.creative-mode_build-distance" },
+ label_tooltip = {
+ "gui.creative-mode_build-distance-tooltip",
+ cheats.default_cheat_values.reach_distance,
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.build_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.build_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.build_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ resource_reach_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.resource_reach_distance,
+ container_name = creative_mode_defines.names.gui.resource_reach_distance_container,
+ label_name = creative_mode_defines.names.gui.resource_reach_distance_label,
+ label_caption = { "gui.creative-mode_resource-reach-distance" },
+ label_tooltip = {
+ "gui.creative-mode_resource-reach-distance-tooltip",
+ cheats.default_cheat_values.reach_distance,
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.resource_reach_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.resource_reach_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.resource_reach_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ item_drop_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.item_drop_distance,
+ container_name = creative_mode_defines.names.gui.item_drop_distance_container,
+ label_name = creative_mode_defines.names.gui.item_drop_distance_label,
+ label_caption = { "gui.creative-mode_item-drop-distance" },
+ label_tooltip = {
+ "gui.creative-mode_item-drop-distance-tooltip",
+ cheats.default_cheat_values.reach_distance,
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.item_drop_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.item_drop_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.item_drop_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ item_pickup_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.item_pickup_distance,
+ container_name = creative_mode_defines.names.gui.item_pickup_distance_container,
+ label_name = creative_mode_defines.names.gui.item_pickup_distance_label,
+ label_caption = { "gui.creative-mode_item-pickup-distance" },
+ label_tooltip = {
+ "gui.creative-mode_item-pickup-distance-tooltip",
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.item_pickup_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.item_pickup_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.item_pickup_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ loot_pickup_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.loot_pickup_distance,
+ container_name = creative_mode_defines.names.gui.loot_pickup_distance_container,
+ label_name = creative_mode_defines.names.gui.loot_pickup_distance_label,
+ label_caption = { "gui.creative-mode_loot-pickup-distance" },
+ label_tooltip = {
+ "gui.creative-mode_loot-pickup-distance-tooltip",
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.loot_pickup_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.loot_pickup_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.loot_pickup_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ mining_speed = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.mining_speed,
+ container_name = creative_mode_defines.names.gui.mining_speed_container,
+ label_name = creative_mode_defines.names.gui.mining_speed_label,
+ label_caption = { "gui.creative-mode_mining-speed" },
+ label_tooltip = {
+ "gui.creative-mode_mining-speed-tooltip",
+ cheats.default_cheat_values.mining_speed,
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.mining_speed_textfield,
+ separator_name = creative_mode_defines.names.gui.mining_speed_separator,
+ apply_button_name = creative_mode_defines.names.gui.mining_speed_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ running_speed = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.running_speed,
+ container_name = creative_mode_defines.names.gui.running_speed_container,
+ label_name = creative_mode_defines.names.gui.running_speed_label,
+ label_caption = { "gui.creative-mode_running-speed" },
+ label_tooltip = {
+ "gui.creative-mode_running-speed-tooltip",
+ cheats.default_cheat_values.running_speed,
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.running_speed_textfield,
+ separator_name = creative_mode_defines.names.gui.running_speed_separator,
+ apply_button_name = creative_mode_defines.names.gui.running_speed_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ crafting_speed = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.crafting_speed,
+ container_name = creative_mode_defines.names.gui.crafting_speed_container,
+ label_name = creative_mode_defines.names.gui.crafting_speed_label,
+ label_caption = { "gui.creative-mode_crafting-speed" },
+ label_tooltip = {
+ "gui.creative-mode_crafting-speed-tooltip",
+ { "gui.creative-mode_no-effect-in-cheat-mode" },
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.crafting_speed_textfield,
+ separator_name = creative_mode_defines.names.gui.crafting_speed_separator,
+ apply_button_name = creative_mode_defines.names.gui.crafting_speed_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ inventory_bonus = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.inventory_bonus,
+ container_name = creative_mode_defines.names.gui.inventory_bonus_container,
+ label_name = creative_mode_defines.names.gui.inventory_bonus_label,
+ label_caption = { "gui.creative-mode_inventory-bonus" },
+ label_tooltip = {
+ "gui.creative-mode_inventory-bonus-tooltip",
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.inventory_bonus_textfield,
+ separator_name = creative_mode_defines.names.gui.inventory_bonus_separator,
+ apply_button_name = creative_mode_defines.names.gui.inventory_bonus_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ health_bonus = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.personal_cheats_data.cheats.health_bonus,
+ container_name = creative_mode_defines.names.gui.health_bonus_container,
+ label_name = creative_mode_defines.names.gui.health_bonus_label,
+ label_caption = { "gui.creative-mode_health-bonus" },
+ label_tooltip = {
+ "gui.creative-mode_health-bonus-tooltip",
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ { "gui.creative-mode_cannot-apply-this-cheat-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.health_bonus_textfield,
+ separator_name = creative_mode_defines.names.gui.health_bonus_separator,
+ apply_button_name = creative_mode_defines.names.gui.health_bonus_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_character_cheat = true,
+ },
+ god_mode = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.personal_cheats_data.cheats.god_mode,
+ container_name = creative_mode_defines.names.gui.god_mode_container,
+ label_name = creative_mode_defines.names.gui.god_mode_label,
+ label_caption = { "gui.creative-mode_god-mode" },
+ label_tooltip = {
+ "gui.creative-mode_god-mode-tooltip",
+ { "gui.creative-mode_cannot-apply-this-cheat-before-respawned" },
+ },
+ on_button_name = creative_mode_defines.names.gui.god_mode_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.god_mode_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ },
+ -- All cheat data. It is used for enabling / disabling all.
+ cheats_data = cheats.personal_cheats_data,
+ -- Function for getting the unverified target list for the given player when constructing the menu.
+ get_unverified_targets_function = function(player)
+ if rights.can_player_access_other_non_admin_players_cheats(player) then
+ return game.connected_players, nil -- 1st param = list. Each candidate will be further verified.
+ else
+ return nil, player -- 2nd param = single target. It will not be further verified.
+ end
+ end,
+ -- Function for verifying each candidate in the unverified target list. It is called after get_unverified_targets_function, so no need to check the player's access right to that particular target.
+ verify_target_function = function(player, target)
+ return target.valid and (target == player or not target.admin)
+ end,
+ -- Function for verifying a single target that is added in the middle of game. The player's access right to that target should be checked here.
+ verify_target_for_insert_function = function(player, target)
+ if not target.valid then
+ return false
+ end
+ if target == player then
+ return true
+ end
+ if rights.can_player_access_other_non_admin_players_cheats(player) and not target.admin then
+ return true
+ end
+ return false
+ end,
+ -- Function for getting the postfix for the target button name.
+ get_target_button_name_postfix_function = function(player, target)
+ return target.index
+ end,
+ -- Function for getting the caption for the target button.
+ get_target_button_caption_function = function(player, target)
+ return target.name
+ end,
+ -- Function for getting the tooltip for the target button.
+ get_target_button_tooltip_function = function(player, target)
+ return { "gui.creative-mode_player-name-tooltip", target.name }
+ end,
+ -- Function for detecting if the target should be marked as self (blue font)
+ check_is_target_self_function = function(player, target)
+ return player == target
+ end,
+ -- Function to be called after the target button is added to the list.
+ post_create_target_button_function = function(player, target, button)
+ button.visible = target.connected -- If target is not connected, but he is here before, just hide the button.
+ end,
+ -- Function for checking whether the target button is a valid option. It will affect whether the target selection scroll pane should be shown or hidden.
+ check_is_target_button_valid_function = function(player, target, button)
+ return button.visible ~= false
+ end,
+ -- Function for checking whether the target button is a valid option without knowing the actual target represented by the button.
+ check_is_target_button_valid_unknown_target_function = function(player, button)
+ return button.visible ~= false
+ end,
+ -- Function for getting the actual target represented by the given target button.
+ get_button_actual_target_function = function(player, button)
+ local player_index =
+ string.match(button.name, creative_mode_defines.match_patterns.gui.personal_cheats_target_index_button)
+ if player_index then
+ player_index = tonumber(player_index)
+ return game.players[player_index]
+ end
+ return nil
+ end,
+ -- Function for removing the target button for the given player. Returns true if the button should be removed from the container.
+ remove_target_button_function = function(player, target, button)
+ -- Make sure the button is unselected.
+ local button_style_name = button.style.name
+ if button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ elseif button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ end
+ button.visible = false
+ -- In case the player will come back, we don't remove the button.
+ return false
+ end,
}
-- GUI data about the whole team cheats menu.
local team_cheats_menu_gui_data = {
- parent = nil,
- frame = {
- name = creative_mode_defines.names.gui.team_cheats_menu_frame,
- caption = { "gui.creative-mode_team-cheats" },
- outer_container = {
- name = creative_mode_defines.names.gui.team_cheats_outer_container,
- targets_scroll_pane = {
- name = creative_mode_defines.names.gui.team_cheats_targets_scroll_pane,
- outer_container = {
- name = creative_mode_defines.names.gui.team_cheats_targets_container,
- inner_container = {
- name = creative_mode_defines.names.gui.team_cheats_targets_inner_container,
- target_button = {
- name_prefix = creative_mode_defines.names.gui.team_cheats_target_name_button_prefix,
- },
- select_all_button = {
- name = creative_mode_defines.names.gui.team_cheats_targets_select_all_button,
- },
- },
- },
- },
- cheats_scroll_pane = {
- name = creative_mode_defines.names.gui.team_cheats_cheats_scroll_pane,
- cheats_container = {
- name = creative_mode_defines.names.gui.team_cheats_cheats_container,
- enable_disable_all_container = { -- Set it to nil if no such buttons.
- name = creative_mode_defines.names.gui.team_cheats_all_button_container,
- enable_all_button_name = creative_mode_defines.names.gui.team_cheats_enable_all_button,
- disable_all_button_name = creative_mode_defines.names.gui.team_cheats_disable_all_button,
- },
- notes = {
- not_included_in_enable_all = {
- name = creative_mode_defines.names.gui.team_cheats_not_included_in_enable_all_note,
- caption = { "gui.creative-mode_not-included-in-enabled-all" },
- },
- },
- },
- },
- },
- },
- cheats_gui_data = {
- creative_tools_recipes = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.team_cheats_data.cheats.creative_tools_recipes,
- container_name = creative_mode_defines.names.gui.creative_tools_recipes_container,
- label_name = creative_mode_defines.names.gui.creative_tools_recipes_label,
- label_caption = { "gui.creative-mode_creative-tools-recipes" },
- label_tooltip = { "gui.creative-mode_creative-tools-recipes-tooltip" },
- on_button_name = creative_mode_defines.names.gui.creative_tools_recipes_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.creative_tools_recipes_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- loaders_recipes = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.team_cheats_data.cheats.loaders_recipes,
- container_name = creative_mode_defines.names.gui.loaders_recipes_container,
- label_name = creative_mode_defines.names.gui.loaders_recipes_label,
- label_caption = { "gui.creative-mode_loaders-recipes" },
- label_tooltip = { "gui.creative-mode_loaders-recipes-tooltip" },
- on_button_name = creative_mode_defines.names.gui.loaders_recipes_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.loaders_recipes_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- research_all_technologies = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.team_cheats_data.cheats.research_all_technologies,
- container_name = creative_mode_defines.names.gui.all_technologies_container,
- label_name = creative_mode_defines.names.gui.all_technologies_label,
- label_caption = { "gui.creative-mode_all-technologies" },
- label_tooltip = nil,
- on_button_name = creative_mode_defines.names.gui.all_technologies_unlock_button,
- on_button_caption = creative_mode_defines.names.gui_captions.unlock,
- off_button_name = creative_mode_defines.names.gui.all_technologies_reset_button,
- off_button_caption = creative_mode_defines.names.gui_captions.reset,
- },
- instant_research = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.team_cheats_data.cheats.instant_research,
- container_name = creative_mode_defines.names.gui.instant_research_container,
- label_name = creative_mode_defines.names.gui.instant_research_label,
- label_caption = { "gui.creative-mode_instant-research" },
- label_tooltip = { "gui.creative-mode_instant-research-tooltip" },
- on_button_name = creative_mode_defines.names.gui.instant_research_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.instant_research_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- reach_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.reach_distance,
- container_name = creative_mode_defines.names.gui.team_reach_distance_container,
- label_name = creative_mode_defines.names.gui.team_reach_distance_label,
- label_caption = { "gui.creative-mode_team-reach-distance" },
- label_tooltip = {
- "gui.creative-mode_team-reach-distance-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.team_reach_distance_textfield,
- separator_name = creative_mode_defines.names.gui.team_reach_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.team_reach_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- build_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.build_distance,
- container_name = creative_mode_defines.names.gui.team_build_distance_container,
- label_name = creative_mode_defines.names.gui.team_build_distance_label,
- label_caption = { "gui.creative-mode_team-build-distance" },
- label_tooltip = {
- "gui.creative-mode_team-build-distance-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.team_build_distance_textfield,
- separator_name = creative_mode_defines.names.gui.team_build_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.team_build_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- resource_reach_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.resource_reach_distance,
- container_name = creative_mode_defines.names.gui.team_resource_reach_distance_container,
- label_name = creative_mode_defines.names.gui.team_resource_reach_distance_label,
- label_caption = { "gui.creative-mode_team-resource-reach-distance" },
- label_tooltip = {
- "gui.creative-mode_team-resource-reach-distance-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.team_resource_reach_distance_textfield,
- separator_name = creative_mode_defines.names.gui.team_resource_reach_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.team_resource_reach_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- item_drop_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.item_drop_distance,
- container_name = creative_mode_defines.names.gui.team_item_drop_distance_container,
- label_name = creative_mode_defines.names.gui.team_item_drop_distance_label,
- label_caption = { "gui.creative-mode_team-item-drop-distance" },
- label_tooltip = {
- "gui.creative-mode_team-item-drop-distance-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.team_item_drop_distance_textfield,
- separator_name = creative_mode_defines.names.gui.team_item_drop_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.team_item_drop_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- item_pickup_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.item_pickup_distance,
- container_name = creative_mode_defines.names.gui.team_item_pickup_distance_container,
- label_name = creative_mode_defines.names.gui.team_item_pickup_distance_label,
- label_caption = { "gui.creative-mode_team-item-pickup-distance" },
- label_tooltip = {
- "gui.creative-mode_team-item-pickup-distance-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.team_item_pickup_distance_textfield,
- separator_name = creative_mode_defines.names.gui.team_item_pickup_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.team_item_pickup_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- loot_pickup_distance = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.loot_pickup_distance,
- container_name = creative_mode_defines.names.gui.team_loot_pickup_distance_container,
- label_name = creative_mode_defines.names.gui.team_loot_pickup_distance_label,
- label_caption = { "gui.creative-mode_team-loot-pickup-distance" },
- label_tooltip = {
- "gui.creative-mode_team-loot-pickup-distance-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.team_loot_pickup_distance_textfield,
- separator_name = creative_mode_defines.names.gui.team_loot_pickup_distance_separator,
- apply_button_name = creative_mode_defines.names.gui.team_loot_pickup_distance_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- mining_speed = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.mining_speed,
- container_name = creative_mode_defines.names.gui.team_mining_speed_container,
- label_name = creative_mode_defines.names.gui.team_mining_speed_label,
- label_caption = { "gui.creative-mode_team-mining-speed" },
- label_tooltip = { "gui.creative-mode_team-mining-speed-tooltip" },
- textfield_name = creative_mode_defines.names.gui.team_mining_speed_textfield,
- separator_name = creative_mode_defines.names.gui.team_mining_speed_separator,
- apply_button_name = creative_mode_defines.names.gui.team_mining_speed_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- running_speed = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.running_speed,
- container_name = creative_mode_defines.names.gui.team_running_speed_container,
- label_name = creative_mode_defines.names.gui.team_running_speed_label,
- label_caption = { "gui.creative-mode_team-running-speed" },
- label_tooltip = {
- "gui.creative-mode_team-running-speed-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.team_running_speed_textfield,
- separator_name = creative_mode_defines.names.gui.team_running_speed_separator,
- apply_button_name = creative_mode_defines.names.gui.team_running_speed_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- crafting_speed = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.crafting_speed,
- container_name = creative_mode_defines.names.gui.team_crafting_speed_container,
- label_name = creative_mode_defines.names.gui.team_crafting_speed_label,
- label_caption = { "gui.creative-mode_team-crafting-speed" },
- label_tooltip = {
- "gui.creative-mode_team-crafting-speed-tooltip",
- { "gui.creative-mode_no-effect-in-cheat-mode" },
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.team_crafting_speed_textfield,
- separator_name = creative_mode_defines.names.gui.team_crafting_speed_separator,
- apply_button_name = creative_mode_defines.names.gui.team_crafting_speed_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- character_inventory_bonus = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.character_inventory_bonus,
- container_name = creative_mode_defines.names.gui.character_inventory_bonus_container,
- label_name = creative_mode_defines.names.gui.character_inventory_bonus_label,
- label_caption = { "gui.creative-mode_character-inventory-bonus" },
- label_tooltip = { "gui.creative-mode_character-inventory-bonus-tooltip" },
- textfield_name = creative_mode_defines.names.gui.character_inventory_bonus_textfield,
- separator_name = creative_mode_defines.names.gui.character_inventory_bonus_separator,
- apply_button_name = creative_mode_defines.names.gui.character_inventory_bonus_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- health_bonus = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.health_bonus,
- container_name = creative_mode_defines.names.gui.character_health_bonus_container,
- label_name = creative_mode_defines.names.gui.character_health_bonus_label,
- label_caption = { "gui.creative-mode_character-health-bonus" },
- label_tooltip = {
- "gui.creative-mode_character-health-bonus-tooltip",
- { "gui.creative-mode_no-effect-in-god-mode" },
- },
- textfield_name = creative_mode_defines.names.gui.character_health_bonus_textfield,
- separator_name = creative_mode_defines.names.gui.character_health_bonus_separator,
- apply_button_name = creative_mode_defines.names.gui.character_health_bonus_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- inserter_capacity_bonus = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.inserter_capacity_bonus,
- container_name = creative_mode_defines.names.gui.inserter_capacity_bonus_container,
- label_name = creative_mode_defines.names.gui.inserter_capacity_bonus_label,
- label_caption = { "gui.creative-mode_inserter-capacity-bonus" },
- label_tooltip = { "gui.creative-mode_inserter-capacity-bonus-tooltip" },
- textfield_name = creative_mode_defines.names.gui.inserter_capacity_bonus_textfield,
- separator_name = creative_mode_defines.names.gui.inserter_capacity_bonus_separator,
- apply_button_name = creative_mode_defines.names.gui.inserter_capacity_bonus_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- bulk_inserter_capacity_bonus = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.bulk_inserter_capacity_bonus,
- container_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_container,
- label_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_label,
- label_caption = { "gui.creative-mode_bulk-inserter-capacity-bonus" },
- label_tooltip = { "gui.creative-mode_bulk-inserter-capacity-bonus-tooltip" },
- textfield_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_textfield,
- separator_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_separator,
- apply_button_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- evolution_factor = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.team_cheats_data.cheats.evolution_factor,
- container_name = creative_mode_defines.names.gui.evolution_factor_container,
- label_name = creative_mode_defines.names.gui.evolution_factor_label,
- label_caption = { "gui.creative-mode_evolution-factor" },
- label_tooltip = { "gui.creative-mode_evolution-factor-tooltip", 0, 1 },
- textfield_name = creative_mode_defines.names.gui.evolution_factor_textfield,
- separator_name = creative_mode_defines.names.gui.evolution_factor_separator,
- apply_button_name = creative_mode_defines.names.gui.evolution_factor_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- chart_all = {
- type = gui_menu_cheats.cheat_gui_type.apply,
- cheat_data = cheats.team_cheats_data.cheats.chart_all,
- container_name = creative_mode_defines.names.gui.chart_all_container,
- label_name = creative_mode_defines.names.gui.chart_all_label,
- label_caption = { "gui.creative-mode_chart-all" },
- label_tooltip = { "gui.creative-mode_chart-all-tooltip" },
- apply_button_name = creative_mode_defines.names.gui.chart_all_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- kill_all_units = {
- type = gui_menu_cheats.cheat_gui_type.apply,
- cheat_data = cheats.team_cheats_data.cheats.kill_all_units,
- container_name = creative_mode_defines.names.gui.kill_all_units_container,
- label_name = creative_mode_defines.names.gui.kill_all_units_label,
- label_caption = { "gui.creative-mode_kill-all-units" },
- label_tooltip = { "gui.creative-mode_kill-all-units-tooltip" },
- apply_button_name = creative_mode_defines.names.gui.kill_all_units_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- },
- cheats_data = cheats.team_cheats_data,
- get_unverified_targets_function = function(player)
- if rights.can_player_access_other_teams_cheats(player) then
- return game.forces, nil
- else
- return nil, player.force
- end
- end,
- verify_target_function = function(player, target)
- return target.valid
- end,
- verify_target_for_insert_function = function(player, target)
- if not target.valid then
- return false
- end
- if target == player.force then
- return true
- end
- if rights.can_player_access_other_teams_cheats(player) then
- return true
- end
- return false
- end,
- get_target_button_name_postfix_function = function(player, target)
- return target.name
- end,
- get_target_button_caption_function = function(player, target)
- return target.name
- end,
- get_target_button_tooltip_function = function(player, target)
- return { "gui.creative-mode_team-name-tooltip", target.name }
- end,
- check_is_target_self_function = function(player, target)
- return player.force == target
- end,
- post_create_target_button_function = function(player, target, button) end,
- check_is_target_button_valid_function = function(player, target, button)
- return button.visible ~= false
- end,
- check_is_target_button_valid_unknown_target_function = function(player, button)
- return button.visible ~= false
- end,
- get_button_actual_target_function = function(player, button)
- local force_name =
- string.match(button.name, creative_mode_defines.match_patterns.gui.team_cheats_target_name_button)
- if force_name then
- force_name = tostring(force_name)
- return game.forces[force_name]
- end
- return nil
- end,
- remove_target_button_function = function(player, target, button)
- return true
- end,
+ parent = nil,
+ frame = {
+ name = creative_mode_defines.names.gui.team_cheats_menu_frame,
+ caption = { "gui.creative-mode_team-cheats" },
+ outer_container = {
+ name = creative_mode_defines.names.gui.team_cheats_outer_container,
+ targets_scroll_pane = {
+ name = creative_mode_defines.names.gui.team_cheats_targets_scroll_pane,
+ outer_container = {
+ name = creative_mode_defines.names.gui.team_cheats_targets_container,
+ inner_container = {
+ name = creative_mode_defines.names.gui.team_cheats_targets_inner_container,
+ target_button = {
+ name_prefix = creative_mode_defines.names.gui.team_cheats_target_name_button_prefix,
+ },
+ select_all_button = {
+ name = creative_mode_defines.names.gui.team_cheats_targets_select_all_button,
+ },
+ },
+ },
+ },
+ cheats_scroll_pane = {
+ name = creative_mode_defines.names.gui.team_cheats_cheats_scroll_pane,
+ cheats_container = {
+ name = creative_mode_defines.names.gui.team_cheats_cheats_container,
+ enable_disable_all_container = { -- Set it to nil if no such buttons.
+ name = creative_mode_defines.names.gui.team_cheats_all_button_container,
+ enable_all_button_name = creative_mode_defines.names.gui.team_cheats_enable_all_button,
+ disable_all_button_name = creative_mode_defines.names.gui.team_cheats_disable_all_button,
+ },
+ notes = {
+ not_included_in_enable_all = {
+ name = creative_mode_defines.names.gui.team_cheats_not_included_in_enable_all_note,
+ caption = { "gui.creative-mode_not-included-in-enabled-all" },
+ },
+ },
+ },
+ },
+ },
+ },
+ cheats_gui_data = {
+ creative_tools_recipes = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.team_cheats_data.cheats.creative_tools_recipes,
+ container_name = creative_mode_defines.names.gui.creative_tools_recipes_container,
+ label_name = creative_mode_defines.names.gui.creative_tools_recipes_label,
+ label_caption = { "gui.creative-mode_creative-tools-recipes" },
+ label_tooltip = { "gui.creative-mode_creative-tools-recipes-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.creative_tools_recipes_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.creative_tools_recipes_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ loaders_recipes = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.team_cheats_data.cheats.loaders_recipes,
+ container_name = creative_mode_defines.names.gui.loaders_recipes_container,
+ label_name = creative_mode_defines.names.gui.loaders_recipes_label,
+ label_caption = { "gui.creative-mode_loaders-recipes" },
+ label_tooltip = { "gui.creative-mode_loaders-recipes-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.loaders_recipes_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.loaders_recipes_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ research_all_technologies = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.team_cheats_data.cheats.research_all_technologies,
+ container_name = creative_mode_defines.names.gui.all_technologies_container,
+ label_name = creative_mode_defines.names.gui.all_technologies_label,
+ label_caption = { "gui.creative-mode_all-technologies" },
+ label_tooltip = nil,
+ on_button_name = creative_mode_defines.names.gui.all_technologies_unlock_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.unlock,
+ off_button_name = creative_mode_defines.names.gui.all_technologies_reset_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.reset,
+ },
+ instant_research = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.team_cheats_data.cheats.instant_research,
+ container_name = creative_mode_defines.names.gui.instant_research_container,
+ label_name = creative_mode_defines.names.gui.instant_research_label,
+ label_caption = { "gui.creative-mode_instant-research" },
+ label_tooltip = { "gui.creative-mode_instant-research-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.instant_research_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.instant_research_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ reach_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.reach_distance,
+ container_name = creative_mode_defines.names.gui.team_reach_distance_container,
+ label_name = creative_mode_defines.names.gui.team_reach_distance_label,
+ label_caption = { "gui.creative-mode_team-reach-distance" },
+ label_tooltip = {
+ "gui.creative-mode_team-reach-distance-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.team_reach_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.team_reach_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_reach_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ build_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.build_distance,
+ container_name = creative_mode_defines.names.gui.team_build_distance_container,
+ label_name = creative_mode_defines.names.gui.team_build_distance_label,
+ label_caption = { "gui.creative-mode_team-build-distance" },
+ label_tooltip = {
+ "gui.creative-mode_team-build-distance-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.team_build_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.team_build_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_build_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ resource_reach_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.resource_reach_distance,
+ container_name = creative_mode_defines.names.gui.team_resource_reach_distance_container,
+ label_name = creative_mode_defines.names.gui.team_resource_reach_distance_label,
+ label_caption = { "gui.creative-mode_team-resource-reach-distance" },
+ label_tooltip = {
+ "gui.creative-mode_team-resource-reach-distance-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.team_resource_reach_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.team_resource_reach_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_resource_reach_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ item_drop_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.item_drop_distance,
+ container_name = creative_mode_defines.names.gui.team_item_drop_distance_container,
+ label_name = creative_mode_defines.names.gui.team_item_drop_distance_label,
+ label_caption = { "gui.creative-mode_team-item-drop-distance" },
+ label_tooltip = {
+ "gui.creative-mode_team-item-drop-distance-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.team_item_drop_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.team_item_drop_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_item_drop_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ item_pickup_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.item_pickup_distance,
+ container_name = creative_mode_defines.names.gui.team_item_pickup_distance_container,
+ label_name = creative_mode_defines.names.gui.team_item_pickup_distance_label,
+ label_caption = { "gui.creative-mode_team-item-pickup-distance" },
+ label_tooltip = {
+ "gui.creative-mode_team-item-pickup-distance-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.team_item_pickup_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.team_item_pickup_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_item_pickup_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ loot_pickup_distance = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.loot_pickup_distance,
+ container_name = creative_mode_defines.names.gui.team_loot_pickup_distance_container,
+ label_name = creative_mode_defines.names.gui.team_loot_pickup_distance_label,
+ label_caption = { "gui.creative-mode_team-loot-pickup-distance" },
+ label_tooltip = {
+ "gui.creative-mode_team-loot-pickup-distance-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.team_loot_pickup_distance_textfield,
+ separator_name = creative_mode_defines.names.gui.team_loot_pickup_distance_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_loot_pickup_distance_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ mining_speed = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.mining_speed,
+ container_name = creative_mode_defines.names.gui.team_mining_speed_container,
+ label_name = creative_mode_defines.names.gui.team_mining_speed_label,
+ label_caption = { "gui.creative-mode_team-mining-speed" },
+ label_tooltip = { "gui.creative-mode_team-mining-speed-tooltip" },
+ textfield_name = creative_mode_defines.names.gui.team_mining_speed_textfield,
+ separator_name = creative_mode_defines.names.gui.team_mining_speed_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_mining_speed_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ running_speed = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.running_speed,
+ container_name = creative_mode_defines.names.gui.team_running_speed_container,
+ label_name = creative_mode_defines.names.gui.team_running_speed_label,
+ label_caption = { "gui.creative-mode_team-running-speed" },
+ label_tooltip = {
+ "gui.creative-mode_team-running-speed-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.team_running_speed_textfield,
+ separator_name = creative_mode_defines.names.gui.team_running_speed_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_running_speed_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ crafting_speed = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.crafting_speed,
+ container_name = creative_mode_defines.names.gui.team_crafting_speed_container,
+ label_name = creative_mode_defines.names.gui.team_crafting_speed_label,
+ label_caption = { "gui.creative-mode_team-crafting-speed" },
+ label_tooltip = {
+ "gui.creative-mode_team-crafting-speed-tooltip",
+ { "gui.creative-mode_no-effect-in-cheat-mode" },
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.team_crafting_speed_textfield,
+ separator_name = creative_mode_defines.names.gui.team_crafting_speed_separator,
+ apply_button_name = creative_mode_defines.names.gui.team_crafting_speed_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ character_inventory_bonus = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.character_inventory_bonus,
+ container_name = creative_mode_defines.names.gui.character_inventory_bonus_container,
+ label_name = creative_mode_defines.names.gui.character_inventory_bonus_label,
+ label_caption = { "gui.creative-mode_character-inventory-bonus" },
+ label_tooltip = { "gui.creative-mode_character-inventory-bonus-tooltip" },
+ textfield_name = creative_mode_defines.names.gui.character_inventory_bonus_textfield,
+ separator_name = creative_mode_defines.names.gui.character_inventory_bonus_separator,
+ apply_button_name = creative_mode_defines.names.gui.character_inventory_bonus_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ health_bonus = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.health_bonus,
+ container_name = creative_mode_defines.names.gui.character_health_bonus_container,
+ label_name = creative_mode_defines.names.gui.character_health_bonus_label,
+ label_caption = { "gui.creative-mode_character-health-bonus" },
+ label_tooltip = {
+ "gui.creative-mode_character-health-bonus-tooltip",
+ { "gui.creative-mode_no-effect-in-god-mode" },
+ },
+ textfield_name = creative_mode_defines.names.gui.character_health_bonus_textfield,
+ separator_name = creative_mode_defines.names.gui.character_health_bonus_separator,
+ apply_button_name = creative_mode_defines.names.gui.character_health_bonus_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ inserter_capacity_bonus = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.inserter_capacity_bonus,
+ container_name = creative_mode_defines.names.gui.inserter_capacity_bonus_container,
+ label_name = creative_mode_defines.names.gui.inserter_capacity_bonus_label,
+ label_caption = { "gui.creative-mode_inserter-capacity-bonus" },
+ label_tooltip = { "gui.creative-mode_inserter-capacity-bonus-tooltip" },
+ textfield_name = creative_mode_defines.names.gui.inserter_capacity_bonus_textfield,
+ separator_name = creative_mode_defines.names.gui.inserter_capacity_bonus_separator,
+ apply_button_name = creative_mode_defines.names.gui.inserter_capacity_bonus_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ bulk_inserter_capacity_bonus = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.bulk_inserter_capacity_bonus,
+ container_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_container,
+ label_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_label,
+ label_caption = { "gui.creative-mode_bulk-inserter-capacity-bonus" },
+ label_tooltip = { "gui.creative-mode_bulk-inserter-capacity-bonus-tooltip" },
+ textfield_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_textfield,
+ separator_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_separator,
+ apply_button_name = creative_mode_defines.names.gui.bulk_inserter_capacity_bonus_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ evolution_factor = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.team_cheats_data.cheats.evolution_factor,
+ container_name = creative_mode_defines.names.gui.evolution_factor_container,
+ label_name = creative_mode_defines.names.gui.evolution_factor_label,
+ label_caption = { "gui.creative-mode_evolution-factor" },
+ label_tooltip = { "gui.creative-mode_evolution-factor-tooltip", 0, 1 },
+ textfield_name = creative_mode_defines.names.gui.evolution_factor_textfield,
+ separator_name = creative_mode_defines.names.gui.evolution_factor_separator,
+ apply_button_name = creative_mode_defines.names.gui.evolution_factor_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ chart_all = {
+ type = gui_menu_cheats.cheat_gui_type.apply,
+ cheat_data = cheats.team_cheats_data.cheats.chart_all,
+ container_name = creative_mode_defines.names.gui.chart_all_container,
+ label_name = creative_mode_defines.names.gui.chart_all_label,
+ label_caption = { "gui.creative-mode_chart-all" },
+ label_tooltip = { "gui.creative-mode_chart-all-tooltip" },
+ apply_button_name = creative_mode_defines.names.gui.chart_all_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ kill_all_units = {
+ type = gui_menu_cheats.cheat_gui_type.apply,
+ cheat_data = cheats.team_cheats_data.cheats.kill_all_units,
+ container_name = creative_mode_defines.names.gui.kill_all_units_container,
+ label_name = creative_mode_defines.names.gui.kill_all_units_label,
+ label_caption = { "gui.creative-mode_kill-all-units" },
+ label_tooltip = { "gui.creative-mode_kill-all-units-tooltip" },
+ apply_button_name = creative_mode_defines.names.gui.kill_all_units_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ },
+ cheats_data = cheats.team_cheats_data,
+ get_unverified_targets_function = function(player)
+ if rights.can_player_access_other_teams_cheats(player) then
+ return game.forces, nil
+ else
+ return nil, player.force
+ end
+ end,
+ verify_target_function = function(player, target)
+ return target.valid
+ end,
+ verify_target_for_insert_function = function(player, target)
+ if not target.valid then
+ return false
+ end
+ if target == player.force then
+ return true
+ end
+ if rights.can_player_access_other_teams_cheats(player) then
+ return true
+ end
+ return false
+ end,
+ get_target_button_name_postfix_function = function(player, target)
+ return target.name
+ end,
+ get_target_button_caption_function = function(player, target)
+ return target.name
+ end,
+ get_target_button_tooltip_function = function(player, target)
+ return { "gui.creative-mode_team-name-tooltip", target.name }
+ end,
+ check_is_target_self_function = function(player, target)
+ return player.force == target
+ end,
+ post_create_target_button_function = function(player, target, button) end,
+ check_is_target_button_valid_function = function(player, target, button)
+ return button.visible ~= false
+ end,
+ check_is_target_button_valid_unknown_target_function = function(player, button)
+ return button.visible ~= false
+ end,
+ get_button_actual_target_function = function(player, button)
+ local force_name =
+ string.match(button.name, creative_mode_defines.match_patterns.gui.team_cheats_target_name_button)
+ if force_name then
+ force_name = tostring(force_name)
+ return game.forces[force_name]
+ end
+ return nil
+ end,
+ remove_target_button_function = function(player, target, button)
+ return true
+ end,
}
-- GUI data about the whole surface cheats menu.
local surface_cheats_menu_gui_data = {
- parent = nil,
- frame = {
- name = creative_mode_defines.names.gui.surface_cheats_menu_frame,
- caption = { "gui.creative-mode_surface-cheats" },
- outer_container = {
- name = creative_mode_defines.names.gui.surface_cheats_outer_container,
- targets_scroll_pane = {
- name = creative_mode_defines.names.gui.surface_cheats_targets_scroll_pane,
- outer_container = {
- name = creative_mode_defines.names.gui.surface_cheats_targets_container,
- inner_container = {
- name = creative_mode_defines.names.gui.surface_cheats_targets_inner_container,
- target_button = {
- name_prefix = creative_mode_defines.names.gui.surface_cheats_target_name_button_prefix,
- },
- select_all_button = {
- name = creative_mode_defines.names.gui.surface_cheats_targets_select_all_button,
- },
- },
- },
- },
- cheats_scroll_pane = {
- name = creative_mode_defines.names.gui.surface_cheats_cheats_scroll_pane,
- cheats_container = {
- name = creative_mode_defines.names.gui.surface_cheats_cheats_container,
- enable_disable_all_container = nil,
- notes = nil,
- },
- },
- },
- },
- cheats_gui_data = {
- freeze_daytime = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.surface_cheats_data.cheats.freeze_daytime,
- container_name = creative_mode_defines.names.gui.freeze_daytime_container,
- label_name = creative_mode_defines.names.gui.freeze_daytime_label,
- label_caption = { "gui.creative-mode_freeze-daytime" },
- label_tooltip = { "gui.creative-mode_freeze-daytime-tooltip" },
- on_button_name = creative_mode_defines.names.gui.freeze_daytime_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.freeze_daytime_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- daytime = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.surface_cheats_data.cheats.daytime,
- container_name = creative_mode_defines.names.gui.daytime_container,
- label_name = creative_mode_defines.names.gui.daytime_label,
- label_caption = { "gui.creative-mode_daytime" },
- label_tooltip = {
- "gui.creative-mode_daytime-tooltip",
- { "gui.creative-mode_midday" },
- { "gui.creative-mode_midnight" },
- },
- textfield_name = creative_mode_defines.names.gui.daytime_textfield,
- separator_name = creative_mode_defines.names.gui.daytime_separator,
- apply_button_name = creative_mode_defines.names.gui.daytime_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- is_daytime_cheat = true,
- },
- daytime_selection = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.surface_cheats_data.cheats.daytime_selection,
- container_name = creative_mode_defines.names.gui.daytime_selection_container,
- label_name = creative_mode_defines.names.gui.daytime_selection_label,
- label_caption = "",
- label_tooltip = nil,
- on_button_name = creative_mode_defines.names.gui.daytime_selection_midday_button,
- on_button_caption = { "gui.creative-mode_midday" },
- off_button_name = creative_mode_defines.names.gui.daytime_selection_midnight_button,
- off_button_caption = { "gui.creative-mode_midnight" },
- },
- peaceful_mode = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.surface_cheats_data.cheats.peaceful_mode,
- container_name = creative_mode_defines.names.gui.peaceful_mode_container,
- label_name = creative_mode_defines.names.gui.peaceful_mode_label,
- label_caption = { "gui.creative-mode_peaceful-mode" },
- label_tooltip = { "gui.creative-mode_peaceful-mode-tooltip" },
- on_button_name = creative_mode_defines.names.gui.peaceful_mode_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.peaceful_mode_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- destroy_all_enemies = {
- type = gui_menu_cheats.cheat_gui_type.apply,
- cheat_data = cheats.surface_cheats_data.cheats.destroy_all_enemies,
- container_name = creative_mode_defines.names.gui.destroy_all_enemies_container,
- label_name = creative_mode_defines.names.gui.destroy_all_enemies_label,
- label_caption = { "gui.creative-mode_destroy-all-enemies" },
- label_tooltip = { "gui.creative-mode_destroy-all-enemies-tooltip" },
- apply_button_name = creative_mode_defines.names.gui.destroy_all_enemies_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- remove_all_enemies = {
- type = gui_menu_cheats.cheat_gui_type.apply,
- cheat_data = cheats.surface_cheats_data.cheats.remove_all_enemies,
- container_name = creative_mode_defines.names.gui.remove_all_enemies_container,
- label_name = creative_mode_defines.names.gui.remove_all_enemies_label,
- label_caption = { "gui.creative-mode_remove-all-enemies" },
- label_tooltip = { "gui.creative-mode_remove-all-enemies-tooltip" },
- apply_button_name = creative_mode_defines.names.gui.remove_all_enemies_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- dont_generate_enemy = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.surface_cheats_data.cheats.dont_generate_enemy,
- container_name = creative_mode_defines.names.gui.dont_generate_enemy_container,
- label_name = creative_mode_defines.names.gui.dont_generate_enemy_label,
- label_caption = { "gui.creative-mode_dont-generate-enemy" },
- label_tooltip = { "gui.creative-mode_dont-generate-enemy-tooltip" },
- on_button_name = creative_mode_defines.names.gui.dont_generate_enemy_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.dont_generate_enemy_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- surface_pressure = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.surface_cheats_data.cheats.pressure,
- container_name = creative_mode_defines.names.gui.surface_pressure_container,
- label_name = creative_mode_defines.names.gui.surface_pressure_label,
- label_caption = { "gui.creative-mode_surface-pressure" },
- label_tooltip = { "gui.creative-mode_surface-pressure-tooltip" },
- textfield_name = creative_mode_defines.names.gui.surface_pressure_textfield,
- separator_name = creative_mode_defines.names.gui.surface_pressure_separator,
- apply_button_name = creative_mode_defines.names.gui.surface_pressure_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- surface_magnetic_field = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.surface_cheats_data.cheats.magnetic_field,
- container_name = creative_mode_defines.names.gui.surface_magnetic_field_container,
- label_name = creative_mode_defines.names.gui.surface_magnetic_field_label,
- label_caption = { "gui.creative-mode_surface-magnetic-field" },
- label_tooltip = { "gui.creative-mode_surface-magnetic-field-tooltip" },
- textfield_name = creative_mode_defines.names.gui.surface_magnetic_field_textfield,
- separator_name = creative_mode_defines.names.gui.surface_magnetic_field_separator,
- apply_button_name = creative_mode_defines.names.gui.surface_magnetic_field_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- surface_gravity = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.surface_cheats_data.cheats.gravity,
- container_name = creative_mode_defines.names.gui.surface_gravity_container,
- label_name = creative_mode_defines.names.gui.surface_gravity_label,
- label_caption = { "gui.creative-mode_surface-gravity" },
- label_tooltip = { "gui.creative-mode_surface-gravity-tooltip" },
- textfield_name = creative_mode_defines.names.gui.surface_gravity_textfield,
- separator_name = creative_mode_defines.names.gui.surface_gravity_separator,
- apply_button_name = creative_mode_defines.names.gui.surface_gravity_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- },
- cheats_data = cheats.surface_cheats_data,
- get_unverified_targets_function = function(player)
- if rights.can_player_access_other_surfaces_cheats(player) then
- return game.surfaces, nil
- else
- return nil, player.surface
- end
- end,
- verify_target_function = function(player, target)
- return target.valid
- end,
- verify_target_for_insert_function = function(player, target)
- if not target.valid then
- return false
- end
- if target == player.surface then
- return true
- end
- if rights.can_player_access_other_surfaces_cheats(player) then
- return true
- end
- return false
- end,
- get_target_button_name_postfix_function = function(player, target)
- return target.name
- end,
- get_target_button_caption_function = function(player, target)
- return target.name
- end,
- get_target_button_tooltip_function = function(player, target)
- return { "gui.creative-mode_surface-name-tooltip", target.name }
- end,
- check_is_target_self_function = function(player, target)
- return player.surface == target
- end,
- post_create_target_button_function = function(player, target, button) end,
- check_is_target_button_valid_function = function(player, target, button)
- return button.visible ~= false
- end,
- check_is_target_button_valid_unknown_target_function = function(player, button)
- return button.visible ~= false
- end,
- get_button_actual_target_function = function(player, button)
- local surface_name =
- string.match(button.name, creative_mode_defines.match_patterns.gui.surface_cheats_target_name_button)
- if surface_name then
- surface_name = tostring(surface_name)
- return game.surfaces[surface_name]
- end
- return nil
- end,
- remove_target_button_function = function(player, target, button)
- return true
- end,
+ parent = nil,
+ frame = {
+ name = creative_mode_defines.names.gui.surface_cheats_menu_frame,
+ caption = { "gui.creative-mode_surface-cheats" },
+ outer_container = {
+ name = creative_mode_defines.names.gui.surface_cheats_outer_container,
+ targets_scroll_pane = {
+ name = creative_mode_defines.names.gui.surface_cheats_targets_scroll_pane,
+ outer_container = {
+ name = creative_mode_defines.names.gui.surface_cheats_targets_container,
+ inner_container = {
+ name = creative_mode_defines.names.gui.surface_cheats_targets_inner_container,
+ target_button = {
+ name_prefix = creative_mode_defines.names.gui.surface_cheats_target_name_button_prefix,
+ },
+ select_all_button = {
+ name = creative_mode_defines.names.gui.surface_cheats_targets_select_all_button,
+ },
+ },
+ },
+ },
+ cheats_scroll_pane = {
+ name = creative_mode_defines.names.gui.surface_cheats_cheats_scroll_pane,
+ cheats_container = {
+ name = creative_mode_defines.names.gui.surface_cheats_cheats_container,
+ enable_disable_all_container = nil,
+ notes = nil,
+ },
+ },
+ },
+ },
+ cheats_gui_data = {
+ freeze_daytime = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.surface_cheats_data.cheats.freeze_daytime,
+ container_name = creative_mode_defines.names.gui.freeze_daytime_container,
+ label_name = creative_mode_defines.names.gui.freeze_daytime_label,
+ label_caption = { "gui.creative-mode_freeze-daytime" },
+ label_tooltip = { "gui.creative-mode_freeze-daytime-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.freeze_daytime_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.freeze_daytime_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ daytime = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.surface_cheats_data.cheats.daytime,
+ container_name = creative_mode_defines.names.gui.daytime_container,
+ label_name = creative_mode_defines.names.gui.daytime_label,
+ label_caption = { "gui.creative-mode_daytime" },
+ label_tooltip = {
+ "gui.creative-mode_daytime-tooltip",
+ { "gui.creative-mode_midday" },
+ { "gui.creative-mode_midnight" },
+ },
+ textfield_name = creative_mode_defines.names.gui.daytime_textfield,
+ separator_name = creative_mode_defines.names.gui.daytime_separator,
+ apply_button_name = creative_mode_defines.names.gui.daytime_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ is_daytime_cheat = true,
+ },
+ daytime_selection = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.surface_cheats_data.cheats.daytime_selection,
+ container_name = creative_mode_defines.names.gui.daytime_selection_container,
+ label_name = creative_mode_defines.names.gui.daytime_selection_label,
+ label_caption = "",
+ label_tooltip = nil,
+ on_button_name = creative_mode_defines.names.gui.daytime_selection_midday_button,
+ on_button_caption = { "gui.creative-mode_midday" },
+ off_button_name = creative_mode_defines.names.gui.daytime_selection_midnight_button,
+ off_button_caption = { "gui.creative-mode_midnight" },
+ },
+ peaceful_mode = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.surface_cheats_data.cheats.peaceful_mode,
+ container_name = creative_mode_defines.names.gui.peaceful_mode_container,
+ label_name = creative_mode_defines.names.gui.peaceful_mode_label,
+ label_caption = { "gui.creative-mode_peaceful-mode" },
+ label_tooltip = { "gui.creative-mode_peaceful-mode-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.peaceful_mode_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.peaceful_mode_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ destroy_all_enemies = {
+ type = gui_menu_cheats.cheat_gui_type.apply,
+ cheat_data = cheats.surface_cheats_data.cheats.destroy_all_enemies,
+ container_name = creative_mode_defines.names.gui.destroy_all_enemies_container,
+ label_name = creative_mode_defines.names.gui.destroy_all_enemies_label,
+ label_caption = { "gui.creative-mode_destroy-all-enemies" },
+ label_tooltip = { "gui.creative-mode_destroy-all-enemies-tooltip" },
+ apply_button_name = creative_mode_defines.names.gui.destroy_all_enemies_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ remove_all_enemies = {
+ type = gui_menu_cheats.cheat_gui_type.apply,
+ cheat_data = cheats.surface_cheats_data.cheats.remove_all_enemies,
+ container_name = creative_mode_defines.names.gui.remove_all_enemies_container,
+ label_name = creative_mode_defines.names.gui.remove_all_enemies_label,
+ label_caption = { "gui.creative-mode_remove-all-enemies" },
+ label_tooltip = { "gui.creative-mode_remove-all-enemies-tooltip" },
+ apply_button_name = creative_mode_defines.names.gui.remove_all_enemies_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ dont_generate_enemy = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.surface_cheats_data.cheats.dont_generate_enemy,
+ container_name = creative_mode_defines.names.gui.dont_generate_enemy_container,
+ label_name = creative_mode_defines.names.gui.dont_generate_enemy_label,
+ label_caption = { "gui.creative-mode_dont-generate-enemy" },
+ label_tooltip = { "gui.creative-mode_dont-generate-enemy-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.dont_generate_enemy_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.dont_generate_enemy_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ surface_pressure = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.surface_cheats_data.cheats.pressure,
+ container_name = creative_mode_defines.names.gui.surface_pressure_container,
+ label_name = creative_mode_defines.names.gui.surface_pressure_label,
+ label_caption = { "gui.creative-mode_surface-pressure" },
+ label_tooltip = { "gui.creative-mode_surface-pressure-tooltip" },
+ textfield_name = creative_mode_defines.names.gui.surface_pressure_textfield,
+ separator_name = creative_mode_defines.names.gui.surface_pressure_separator,
+ apply_button_name = creative_mode_defines.names.gui.surface_pressure_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ surface_magnetic_field = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.surface_cheats_data.cheats.magnetic_field,
+ container_name = creative_mode_defines.names.gui.surface_magnetic_field_container,
+ label_name = creative_mode_defines.names.gui.surface_magnetic_field_label,
+ label_caption = { "gui.creative-mode_surface-magnetic-field" },
+ label_tooltip = { "gui.creative-mode_surface-magnetic-field-tooltip" },
+ textfield_name = creative_mode_defines.names.gui.surface_magnetic_field_textfield,
+ separator_name = creative_mode_defines.names.gui.surface_magnetic_field_separator,
+ apply_button_name = creative_mode_defines.names.gui.surface_magnetic_field_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ surface_gravity = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.surface_cheats_data.cheats.gravity,
+ container_name = creative_mode_defines.names.gui.surface_gravity_container,
+ label_name = creative_mode_defines.names.gui.surface_gravity_label,
+ label_caption = { "gui.creative-mode_surface-gravity" },
+ label_tooltip = { "gui.creative-mode_surface-gravity-tooltip" },
+ textfield_name = creative_mode_defines.names.gui.surface_gravity_textfield,
+ separator_name = creative_mode_defines.names.gui.surface_gravity_separator,
+ apply_button_name = creative_mode_defines.names.gui.surface_gravity_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ },
+ cheats_data = cheats.surface_cheats_data,
+ get_unverified_targets_function = function(player)
+ if rights.can_player_access_other_surfaces_cheats(player) then
+ return game.surfaces, nil
+ else
+ return nil, player.surface
+ end
+ end,
+ verify_target_function = function(player, target)
+ return target.valid
+ end,
+ verify_target_for_insert_function = function(player, target)
+ if not target.valid then
+ return false
+ end
+ if target == player.surface then
+ return true
+ end
+ if rights.can_player_access_other_surfaces_cheats(player) then
+ return true
+ end
+ return false
+ end,
+ get_target_button_name_postfix_function = function(player, target)
+ return target.name
+ end,
+ get_target_button_caption_function = function(player, target)
+ return target.name
+ end,
+ get_target_button_tooltip_function = function(player, target)
+ return { "gui.creative-mode_surface-name-tooltip", target.name }
+ end,
+ check_is_target_self_function = function(player, target)
+ return player.surface == target
+ end,
+ post_create_target_button_function = function(player, target, button) end,
+ check_is_target_button_valid_function = function(player, target, button)
+ return button.visible ~= false
+ end,
+ check_is_target_button_valid_unknown_target_function = function(player, button)
+ return button.visible ~= false
+ end,
+ get_button_actual_target_function = function(player, button)
+ local surface_name =
+ string.match(button.name, creative_mode_defines.match_patterns.gui.surface_cheats_target_name_button)
+ if surface_name then
+ surface_name = tostring(surface_name)
+ return game.surfaces[surface_name]
+ end
+ return nil
+ end,
+ remove_target_button_function = function(player, target, button)
+ return true
+ end,
}
-- GUI data about the whole global cheats menu.
local global_cheats_menu_gui_data = {
- parent = nil,
- frame = {
- name = creative_mode_defines.names.gui.global_cheats_menu_frame,
- caption = { "gui.creative-mode_global-cheats" },
- outer_container = {
- name = creative_mode_defines.names.gui.global_cheats_table,
- targets_scroll_pane = nil, -- No targets.
- cheats_scroll_pane = {
- name = creative_mode_defines.names.gui.global_cheats_cheats_scroll_pane,
- cheats_container = {
- name = creative_mode_defines.names.gui.global_cheats_cheats_container,
- enable_disable_all_container = nil,
- notes = nil,
- },
- },
- },
- },
- cheats_gui_data = {
- pollution = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.global_cheats_data.cheats.pollution,
- container_name = creative_mode_defines.names.gui.pollution_container,
- label_name = creative_mode_defines.names.gui.pollution_label,
- label_caption = { "gui.creative-mode_pollution" },
- label_tooltip = { "gui.creative-mode_pollution-tooltip" },
- on_button_name = creative_mode_defines.names.gui.pollution_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.pollution_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- enemy_evolution = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.global_cheats_data.cheats.enemy_evolution,
- container_name = creative_mode_defines.names.gui.enemy_evolution_container,
- label_name = creative_mode_defines.names.gui.enemy_evolution_label,
- label_caption = { "gui.creative-mode_enemy-evolution" },
- label_tooltip = { "gui.creative-mode_enemy-evolution-tooltip" },
- on_button_name = creative_mode_defines.names.gui.enemy_evolution_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.enemy_evolution_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- evolution_time_factor = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.global_cheats_data.cheats.evolution_time_factor,
- container_name = creative_mode_defines.names.gui.evolution_time_factor_container,
- label_name = creative_mode_defines.names.gui.evolution_time_factor_label,
- label_caption = { "gui.creative-mode_evolution-time-factor" },
- label_tooltip = { "gui.creative-mode_evolution-time-factor-tooltip", 0.000004 },
- textfield_name = creative_mode_defines.names.gui.evolution_time_factor_textfield,
- separator_name = creative_mode_defines.names.gui.evolution_time_factor_separator,
- apply_button_name = creative_mode_defines.names.gui.evolution_time_factor_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- evolution_destroy_factor = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.global_cheats_data.cheats.evolution_destroy_factor,
- container_name = creative_mode_defines.names.gui.evolution_destroy_factor_container,
- label_name = creative_mode_defines.names.gui.evolution_destroy_factor_label,
- label_caption = { "gui.creative-mode_evolution-destroy-factor" },
- label_tooltip = { "gui.creative-mode_evolution-destroy-factor-tooltip", 0.002 },
- textfield_name = creative_mode_defines.names.gui.evolution_destroy_factor_textfield,
- separator_name = creative_mode_defines.names.gui.evolution_destroy_factor_separator,
- apply_button_name = creative_mode_defines.names.gui.evolution_destroy_factor_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- evolution_pollution_factor = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.global_cheats_data.cheats.evolution_pollution_factor,
- container_name = creative_mode_defines.names.gui.evolution_pollution_factor_container,
- label_name = creative_mode_defines.names.gui.evolution_pollution_factor_label,
- label_caption = { "gui.creative-mode_evolution-pollution-factor" },
- label_tooltip = { "gui.creative-mode_evolution-pollution-factor-tooltip", 0.000015 },
- textfield_name = creative_mode_defines.names.gui.evolution_pollution_factor_textfield,
- separator_name = creative_mode_defines.names.gui.evolution_pollution_factor_separator,
- apply_button_name = creative_mode_defines.names.gui.evolution_pollution_factor_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- enemy_expansion = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.global_cheats_data.cheats.enemy_expansion,
- container_name = creative_mode_defines.names.gui.enemy_expansion_container,
- label_name = creative_mode_defines.names.gui.enemy_expansion_label,
- label_caption = { "gui.creative-mode_enemy-expansion" },
- label_tooltip = { "gui.creative-mode_enemy-expansion-tooltip" },
- on_button_name = creative_mode_defines.names.gui.enemy_expansion_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.enemy_expansion_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- enemy_expansion_min_cooldown = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.global_cheats_data.cheats.enemy_expansion_min_cooldown,
- container_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_container,
- label_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_label,
- label_caption = { "gui.creative-mode_enemy-expansion-min-cooldown" },
- label_tooltip = { "gui.creative-mode_enemy-expansion-min-cooldown-tooltip", 4 * 3600 },
- textfield_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_textfield,
- separator_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_separator,
- apply_button_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- enemy_expansion_max_cooldown = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.global_cheats_data.cheats.enemy_expansion_max_cooldown,
- container_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_container,
- label_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_label,
- label_caption = { "gui.creative-mode_enemy-expansion-max-cooldown" },
- label_tooltip = { "gui.creative-mode_enemy-expansion-max-cooldown-tooltip", 60 * 3600 },
- textfield_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_textfield,
- separator_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_separator,
- apply_button_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- game_speed = {
- type = gui_menu_cheats.cheat_gui_type.numeric_apply,
- cheat_data = cheats.global_cheats_data.cheats.game_speed,
- container_name = creative_mode_defines.names.gui.game_speed_container,
- label_name = creative_mode_defines.names.gui.game_speed_label,
- label_caption = { "gui.creative-mode_game-speed" },
- label_tooltip = { "gui.creative-mode_game-speed-tooltip", 0.1, 1 },
- textfield_name = creative_mode_defines.names.gui.game_speed_textfield,
- separator_name = creative_mode_defines.names.gui.game_speed_separator,
- apply_button_name = creative_mode_defines.names.gui.game_speed_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- },
- },
- cheats_data = cheats.global_cheats_data,
- get_unverified_targets_function = nil,
- verify_target_function = nil,
- verify_target_for_insert_function = nil,
- get_target_button_name_postfix_function = nil,
- get_target_button_caption_function = nil,
- get_target_button_tooltip_function = nil,
- check_is_target_self_function = nil,
- post_create_target_button_function = nil,
- check_is_target_button_valid_function = nil,
- check_is_target_button_valid_unknown_target_function = nil,
- get_button_actual_target_function = nil,
- remove_target_button_function = nil,
+ parent = nil,
+ frame = {
+ name = creative_mode_defines.names.gui.global_cheats_menu_frame,
+ caption = { "gui.creative-mode_global-cheats" },
+ outer_container = {
+ name = creative_mode_defines.names.gui.global_cheats_table,
+ targets_scroll_pane = nil, -- No targets.
+ cheats_scroll_pane = {
+ name = creative_mode_defines.names.gui.global_cheats_cheats_scroll_pane,
+ cheats_container = {
+ name = creative_mode_defines.names.gui.global_cheats_cheats_container,
+ enable_disable_all_container = nil,
+ notes = nil,
+ },
+ },
+ },
+ },
+ cheats_gui_data = {
+ pollution = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.global_cheats_data.cheats.pollution,
+ container_name = creative_mode_defines.names.gui.pollution_container,
+ label_name = creative_mode_defines.names.gui.pollution_label,
+ label_caption = { "gui.creative-mode_pollution" },
+ label_tooltip = { "gui.creative-mode_pollution-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.pollution_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.pollution_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ enemy_evolution = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.global_cheats_data.cheats.enemy_evolution,
+ container_name = creative_mode_defines.names.gui.enemy_evolution_container,
+ label_name = creative_mode_defines.names.gui.enemy_evolution_label,
+ label_caption = { "gui.creative-mode_enemy-evolution" },
+ label_tooltip = { "gui.creative-mode_enemy-evolution-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.enemy_evolution_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.enemy_evolution_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ evolution_time_factor = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.global_cheats_data.cheats.evolution_time_factor,
+ container_name = creative_mode_defines.names.gui.evolution_time_factor_container,
+ label_name = creative_mode_defines.names.gui.evolution_time_factor_label,
+ label_caption = { "gui.creative-mode_evolution-time-factor" },
+ label_tooltip = { "gui.creative-mode_evolution-time-factor-tooltip", 0.000004 },
+ textfield_name = creative_mode_defines.names.gui.evolution_time_factor_textfield,
+ separator_name = creative_mode_defines.names.gui.evolution_time_factor_separator,
+ apply_button_name = creative_mode_defines.names.gui.evolution_time_factor_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ evolution_destroy_factor = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.global_cheats_data.cheats.evolution_destroy_factor,
+ container_name = creative_mode_defines.names.gui.evolution_destroy_factor_container,
+ label_name = creative_mode_defines.names.gui.evolution_destroy_factor_label,
+ label_caption = { "gui.creative-mode_evolution-destroy-factor" },
+ label_tooltip = { "gui.creative-mode_evolution-destroy-factor-tooltip", 0.002 },
+ textfield_name = creative_mode_defines.names.gui.evolution_destroy_factor_textfield,
+ separator_name = creative_mode_defines.names.gui.evolution_destroy_factor_separator,
+ apply_button_name = creative_mode_defines.names.gui.evolution_destroy_factor_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ evolution_pollution_factor = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.global_cheats_data.cheats.evolution_pollution_factor,
+ container_name = creative_mode_defines.names.gui.evolution_pollution_factor_container,
+ label_name = creative_mode_defines.names.gui.evolution_pollution_factor_label,
+ label_caption = { "gui.creative-mode_evolution-pollution-factor" },
+ label_tooltip = { "gui.creative-mode_evolution-pollution-factor-tooltip", 0.000015 },
+ textfield_name = creative_mode_defines.names.gui.evolution_pollution_factor_textfield,
+ separator_name = creative_mode_defines.names.gui.evolution_pollution_factor_separator,
+ apply_button_name = creative_mode_defines.names.gui.evolution_pollution_factor_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ enemy_expansion = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.global_cheats_data.cheats.enemy_expansion,
+ container_name = creative_mode_defines.names.gui.enemy_expansion_container,
+ label_name = creative_mode_defines.names.gui.enemy_expansion_label,
+ label_caption = { "gui.creative-mode_enemy-expansion" },
+ label_tooltip = { "gui.creative-mode_enemy-expansion-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.enemy_expansion_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.enemy_expansion_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ enemy_expansion_min_cooldown = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.global_cheats_data.cheats.enemy_expansion_min_cooldown,
+ container_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_container,
+ label_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_label,
+ label_caption = { "gui.creative-mode_enemy-expansion-min-cooldown" },
+ label_tooltip = { "gui.creative-mode_enemy-expansion-min-cooldown-tooltip", 4 * 3600 },
+ textfield_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_textfield,
+ separator_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_separator,
+ apply_button_name = creative_mode_defines.names.gui.enemy_expansion_min_cooldown_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ enemy_expansion_max_cooldown = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.global_cheats_data.cheats.enemy_expansion_max_cooldown,
+ container_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_container,
+ label_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_label,
+ label_caption = { "gui.creative-mode_enemy-expansion-max-cooldown" },
+ label_tooltip = { "gui.creative-mode_enemy-expansion-max-cooldown-tooltip", 60 * 3600 },
+ textfield_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_textfield,
+ separator_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_separator,
+ apply_button_name = creative_mode_defines.names.gui.enemy_expansion_max_cooldown_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ game_speed = {
+ type = gui_menu_cheats.cheat_gui_type.numeric_apply,
+ cheat_data = cheats.global_cheats_data.cheats.game_speed,
+ container_name = creative_mode_defines.names.gui.game_speed_container,
+ label_name = creative_mode_defines.names.gui.game_speed_label,
+ label_caption = { "gui.creative-mode_game-speed" },
+ label_tooltip = { "gui.creative-mode_game-speed-tooltip", 0.1, 1 },
+ textfield_name = creative_mode_defines.names.gui.game_speed_textfield,
+ separator_name = creative_mode_defines.names.gui.game_speed_separator,
+ apply_button_name = creative_mode_defines.names.gui.game_speed_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ },
+ },
+ cheats_data = cheats.global_cheats_data,
+ get_unverified_targets_function = nil,
+ verify_target_function = nil,
+ verify_target_for_insert_function = nil,
+ get_target_button_name_postfix_function = nil,
+ get_target_button_caption_function = nil,
+ get_target_button_tooltip_function = nil,
+ check_is_target_self_function = nil,
+ post_create_target_button_function = nil,
+ check_is_target_button_valid_function = nil,
+ check_is_target_button_valid_unknown_target_function = nil,
+ get_button_actual_target_function = nil,
+ remove_target_button_function = nil,
}
-- GUI data about all cheats menus.
local cheats_menus_gui_data = {
- get_container_name_function = gui_menu_cheats.get_container_name,
- contents = {
- personal_cheats = {
- button_name = creative_mode_defines.names.gui.personal_cheats_menu_button,
- button_caption = { "gui.creative-mode_personal-cheats" },
- -- The menu needs to be updated only if the access right of this code is changed.
- access_right_code = rights.access_personal_cheats_code,
- get_player_can_access_function = rights.can_player_access_personal_cheats_menu,
- cheats_menu_gui_data = personal_cheats_menu_gui_data,
- },
- team_cheats = {
- button_name = creative_mode_defines.names.gui.team_cheats_menu_button,
- button_caption = { "gui.creative-mode_team-cheats" },
- access_right_code = rights.access_team_cheats_code,
- get_player_can_access_function = rights.can_player_access_team_cheats_menu,
- cheats_menu_gui_data = team_cheats_menu_gui_data,
- },
- surface_cheats = {
- button_name = creative_mode_defines.names.gui.surface_cheats_menu_button,
- button_caption = { "gui.creative-mode_surface-cheats" },
- access_right_code = rights.access_surface_cheats_code,
- get_player_can_access_function = rights.can_player_access_surface_cheats_menu,
- cheats_menu_gui_data = surface_cheats_menu_gui_data,
- },
- global_cheats = {
- button_name = creative_mode_defines.names.gui.global_cheats_menu_button,
- button_caption = { "gui.creative-mode_global-cheats" },
- access_right_code = rights.access_global_cheats_code,
- get_player_can_access_function = rights.can_player_access_global_cheats_menu,
- cheats_menu_gui_data = global_cheats_menu_gui_data,
- },
- },
+ get_container_name_function = gui_menu_cheats.get_container_name,
+ contents = {
+ personal_cheats = {
+ button_name = creative_mode_defines.names.gui.personal_cheats_menu_button,
+ button_caption = { "gui.creative-mode_personal-cheats" },
+ -- The menu needs to be updated only if the access right of this code is changed.
+ access_right_code = rights.access_personal_cheats_code,
+ get_player_can_access_function = rights.can_player_access_personal_cheats_menu,
+ cheats_menu_gui_data = personal_cheats_menu_gui_data,
+ },
+ team_cheats = {
+ button_name = creative_mode_defines.names.gui.team_cheats_menu_button,
+ button_caption = { "gui.creative-mode_team-cheats" },
+ access_right_code = rights.access_team_cheats_code,
+ get_player_can_access_function = rights.can_player_access_team_cheats_menu,
+ cheats_menu_gui_data = team_cheats_menu_gui_data,
+ },
+ surface_cheats = {
+ button_name = creative_mode_defines.names.gui.surface_cheats_menu_button,
+ button_caption = { "gui.creative-mode_surface-cheats" },
+ access_right_code = rights.access_surface_cheats_code,
+ get_player_can_access_function = rights.can_player_access_surface_cheats_menu,
+ cheats_menu_gui_data = surface_cheats_menu_gui_data,
+ },
+ global_cheats = {
+ button_name = creative_mode_defines.names.gui.global_cheats_menu_button,
+ button_caption = { "gui.creative-mode_global-cheats" },
+ access_right_code = rights.access_global_cheats_code,
+ get_player_can_access_function = rights.can_player_access_global_cheats_menu,
+ cheats_menu_gui_data = global_cheats_menu_gui_data,
+ },
+ },
}
-- Set parent.
for _, data in pairs(cheats_menus_gui_data.contents) do
- data.cheats_menu_gui_data.parent = cheats_menus_gui_data
+ data.cheats_menu_gui_data.parent = cheats_menus_gui_data
end
-----
-- GUI data about the whole build options menu.
local build_options_menu_gui_data = {
- parent = nil,
- frame = {
- name = creative_mode_defines.names.gui.build_options_frame,
- caption = { "gui.creative-mode_build-options" },
- outer_container = {
- name = creative_mode_defines.names.gui.build_options_outer_contianer,
- targets_scroll_pane = {
- name = creative_mode_defines.names.gui.build_options_targets_scroll_pane,
- outer_container = {
- name = creative_mode_defines.names.gui.build_options_targets_container,
- inner_container = {
- name = creative_mode_defines.names.gui.build_options_targets_inner_container,
- target_button = {
- name_prefix = creative_mode_defines.names.gui.build_options_target_index_button_prefix,
- },
- select_all_button = {
- name = creative_mode_defines.names.gui.build_options_targets_select_all_button,
- },
- },
- },
- },
- cheats_scroll_pane = {
- name = creative_mode_defines.names.gui.build_options_cheats_scroll_pane,
- cheats_container = {
- name = creative_mode_defines.names.gui.build_options_cheats_container,
- enable_disable_all_container = nil,
- notes = nil,
- },
- },
- },
- },
- -- GUI data for each of the cheats. No other data except cheat GUI data can be put inside.
- cheats_gui_data = {
- active = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.build_options_data.cheats.active,
- container_name = creative_mode_defines.names.gui.build_active_container,
- label_name = creative_mode_defines.names.gui.build_active_label,
- label_caption = { "gui.creative-mode_build-active" },
- label_tooltip = { "gui.creative-mode_build-active-tooltip" },
- on_button_name = creative_mode_defines.names.gui.build_active_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.build_active_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- destructible = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.build_options_data.cheats.destructible,
- container_name = creative_mode_defines.names.gui.build_destructible_container,
- label_name = creative_mode_defines.names.gui.build_destructible_label,
- label_caption = { "gui.creative-mode_build-destructible" },
- label_tooltip = { "gui.creative-mode_build-destructible-tooltip" },
- on_button_name = creative_mode_defines.names.gui.build_destructible_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.build_destructible_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- minable = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.build_options_data.cheats.minable,
- container_name = creative_mode_defines.names.gui.build_minable_container,
- label_name = creative_mode_defines.names.gui.build_minable_label,
- label_caption = { "gui.creative-mode_build-minable" },
- label_tooltip = { "gui.creative-mode_build-minable-tooltip" },
- on_button_name = creative_mode_defines.names.gui.build_minable_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.build_minable_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- rotatable = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.build_options_data.cheats.rotatable,
- container_name = creative_mode_defines.names.gui.build_rotatable_container,
- label_name = creative_mode_defines.names.gui.build_rotatable_label,
- label_caption = { "gui.creative-mode_build-rotatable" },
- label_tooltip = { "gui.creative-mode_build-rotatable-tooltip" },
- on_button_name = creative_mode_defines.names.gui.build_rotatable_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.build_rotatable_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- operable = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.build_options_data.cheats.operable,
- container_name = creative_mode_defines.names.gui.build_operable_container,
- label_name = creative_mode_defines.names.gui.build_operable_label,
- label_caption = { "gui.creative-mode_build-operable" },
- label_tooltip = { "gui.creative-mode_build-operable-tooltip" },
- on_button_name = creative_mode_defines.names.gui.build_operable_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.build_operable_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- full_health = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.build_options_data.cheats.full_health,
- container_name = creative_mode_defines.names.gui.build_full_health_container,
- label_name = creative_mode_defines.names.gui.build_full_health_label,
- label_caption = { "gui.creative-mode_build-full-health" },
- label_tooltip = { "gui.creative-mode_build-full-health-tooltip" },
- on_button_name = creative_mode_defines.names.gui.build_full_health_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.build_full_health_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- },
- team = {
- type = gui_menu_cheats.cheat_gui_type.team_target_auto_apply,
- cheat_data = cheats.build_options_data.cheats.team,
- container_name = creative_mode_defines.names.gui.build_team_container,
- label_name = creative_mode_defines.names.gui.build_team_label,
- label_caption = { "gui.creative-mode_build-team" },
- label_tooltip = { "gui.creative-mode_build-team-tooltip" },
- drop_down_container_name = creative_mode_defines.names.gui.build_team_targets_drop_down_container,
- current_selection_button_name = creative_mode_defines.names.gui.build_team_current_button,
- drop_down_scroll_pane_name = creative_mode_defines.names.gui.build_team_targets_scroll_pane,
- drop_down_inner_frame_name = creative_mode_defines.names.gui.build_team_targets_container,
- drop_down_inner_flow_name = creative_mode_defines.names.gui.build_team_targets_inner_container,
- drop_down_selection_button_name_prefx = creative_mode_defines.names.gui.build_team_target_name_button_prefix,
- drop_down_selection_button_name_pattern = creative_mode_defines.match_patterns.gui.build_team_target_name_button,
- },
- },
- cheats_data = cheats.build_options_data,
- get_unverified_targets_function = function(player)
- if rights.can_player_access_other_non_admin_players_build_options(player) then
- return game.connected_players, nil
- else
- return nil, player
- end
- end,
- verify_target_function = function(player, target)
- return target.valid and (target == player or not target.admin)
- end,
- verify_target_for_insert_function = function(player, target)
- if not target.valid then
- return false
- end
- if target == player then
- return true
- end
- if rights.can_player_access_other_non_admin_players_build_options(player) and not target.admin then
- return true
- end
- return false
- end,
- get_target_button_name_postfix_function = function(player, target)
- return target.index
- end,
- get_target_button_caption_function = function(player, target)
- return target.name
- end,
- get_target_button_tooltip_function = function(player, target)
- return { "gui.creative-mode_player-name-tooltip", target.name }
- end,
- check_is_target_self_function = function(player, target)
- return player == target
- end,
- post_create_target_button_function = function(player, target, button)
- button.visible = target.connected -- If target is not connected, but he is here before, just hide the button.
- end,
- check_is_target_button_valid_function = function(player, target, button)
- return button.visible ~= false
- end,
- check_is_target_button_valid_unknown_target_function = function(player, button)
- return button.visible ~= false
- end,
- get_button_actual_target_function = function(player, button)
- local player_index =
- string.match(button.name, creative_mode_defines.match_patterns.gui.build_options_target_index_button)
- if player_index then
- player_index = tonumber(player_index)
- return game.players[player_index]
- end
- return nil
- end,
- remove_target_button_function = function(player, target, button)
- -- Make sure the button is unselected.
- local button_style_name = button.style.name
- if button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- elseif button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- end
- button.visible = false
- -- In case the player will come back, we don't remove the button.
- return false
- end,
+ parent = nil,
+ frame = {
+ name = creative_mode_defines.names.gui.build_options_frame,
+ caption = { "gui.creative-mode_build-options" },
+ outer_container = {
+ name = creative_mode_defines.names.gui.build_options_outer_contianer,
+ targets_scroll_pane = {
+ name = creative_mode_defines.names.gui.build_options_targets_scroll_pane,
+ outer_container = {
+ name = creative_mode_defines.names.gui.build_options_targets_container,
+ inner_container = {
+ name = creative_mode_defines.names.gui.build_options_targets_inner_container,
+ target_button = {
+ name_prefix = creative_mode_defines.names.gui.build_options_target_index_button_prefix,
+ },
+ select_all_button = {
+ name = creative_mode_defines.names.gui.build_options_targets_select_all_button,
+ },
+ },
+ },
+ },
+ cheats_scroll_pane = {
+ name = creative_mode_defines.names.gui.build_options_cheats_scroll_pane,
+ cheats_container = {
+ name = creative_mode_defines.names.gui.build_options_cheats_container,
+ enable_disable_all_container = nil,
+ notes = nil,
+ },
+ },
+ },
+ },
+ -- GUI data for each of the cheats. No other data except cheat GUI data can be put inside.
+ cheats_gui_data = {
+ active = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.build_options_data.cheats.active,
+ container_name = creative_mode_defines.names.gui.build_active_container,
+ label_name = creative_mode_defines.names.gui.build_active_label,
+ label_caption = { "gui.creative-mode_build-active" },
+ label_tooltip = { "gui.creative-mode_build-active-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.build_active_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.build_active_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ destructible = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.build_options_data.cheats.destructible,
+ container_name = creative_mode_defines.names.gui.build_destructible_container,
+ label_name = creative_mode_defines.names.gui.build_destructible_label,
+ label_caption = { "gui.creative-mode_build-destructible" },
+ label_tooltip = { "gui.creative-mode_build-destructible-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.build_destructible_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.build_destructible_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ minable = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.build_options_data.cheats.minable,
+ container_name = creative_mode_defines.names.gui.build_minable_container,
+ label_name = creative_mode_defines.names.gui.build_minable_label,
+ label_caption = { "gui.creative-mode_build-minable" },
+ label_tooltip = { "gui.creative-mode_build-minable-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.build_minable_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.build_minable_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ rotatable = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.build_options_data.cheats.rotatable,
+ container_name = creative_mode_defines.names.gui.build_rotatable_container,
+ label_name = creative_mode_defines.names.gui.build_rotatable_label,
+ label_caption = { "gui.creative-mode_build-rotatable" },
+ label_tooltip = { "gui.creative-mode_build-rotatable-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.build_rotatable_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.build_rotatable_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ operable = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.build_options_data.cheats.operable,
+ container_name = creative_mode_defines.names.gui.build_operable_container,
+ label_name = creative_mode_defines.names.gui.build_operable_label,
+ label_caption = { "gui.creative-mode_build-operable" },
+ label_tooltip = { "gui.creative-mode_build-operable-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.build_operable_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.build_operable_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ full_health = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.build_options_data.cheats.full_health,
+ container_name = creative_mode_defines.names.gui.build_full_health_container,
+ label_name = creative_mode_defines.names.gui.build_full_health_label,
+ label_caption = { "gui.creative-mode_build-full-health" },
+ label_tooltip = { "gui.creative-mode_build-full-health-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.build_full_health_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.build_full_health_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ },
+ team = {
+ type = gui_menu_cheats.cheat_gui_type.team_target_auto_apply,
+ cheat_data = cheats.build_options_data.cheats.team,
+ container_name = creative_mode_defines.names.gui.build_team_container,
+ label_name = creative_mode_defines.names.gui.build_team_label,
+ label_caption = { "gui.creative-mode_build-team" },
+ label_tooltip = { "gui.creative-mode_build-team-tooltip" },
+ drop_down_container_name = creative_mode_defines.names.gui.build_team_targets_drop_down_container,
+ current_selection_button_name = creative_mode_defines.names.gui.build_team_current_button,
+ drop_down_scroll_pane_name = creative_mode_defines.names.gui.build_team_targets_scroll_pane,
+ drop_down_inner_frame_name = creative_mode_defines.names.gui.build_team_targets_container,
+ drop_down_inner_flow_name = creative_mode_defines.names.gui.build_team_targets_inner_container,
+ drop_down_selection_button_name_prefx = creative_mode_defines.names.gui.build_team_target_name_button_prefix,
+ drop_down_selection_button_name_pattern = creative_mode_defines.match_patterns.gui.build_team_target_name_button,
+ },
+ },
+ cheats_data = cheats.build_options_data,
+ get_unverified_targets_function = function(player)
+ if rights.can_player_access_other_non_admin_players_build_options(player) then
+ return game.connected_players, nil
+ else
+ return nil, player
+ end
+ end,
+ verify_target_function = function(player, target)
+ return target.valid and (target == player or not target.admin)
+ end,
+ verify_target_for_insert_function = function(player, target)
+ if not target.valid then
+ return false
+ end
+ if target == player then
+ return true
+ end
+ if rights.can_player_access_other_non_admin_players_build_options(player) and not target.admin then
+ return true
+ end
+ return false
+ end,
+ get_target_button_name_postfix_function = function(player, target)
+ return target.index
+ end,
+ get_target_button_caption_function = function(player, target)
+ return target.name
+ end,
+ get_target_button_tooltip_function = function(player, target)
+ return { "gui.creative-mode_player-name-tooltip", target.name }
+ end,
+ check_is_target_self_function = function(player, target)
+ return player == target
+ end,
+ post_create_target_button_function = function(player, target, button)
+ button.visible = target.connected -- If target is not connected, but he is here before, just hide the button.
+ end,
+ check_is_target_button_valid_function = function(player, target, button)
+ return button.visible ~= false
+ end,
+ check_is_target_button_valid_unknown_target_function = function(player, button)
+ return button.visible ~= false
+ end,
+ get_button_actual_target_function = function(player, button)
+ local player_index =
+ string.match(button.name, creative_mode_defines.match_patterns.gui.build_options_target_index_button)
+ if player_index then
+ player_index = tonumber(player_index)
+ return game.players[player_index]
+ end
+ return nil
+ end,
+ remove_target_button_function = function(player, target, button)
+ -- Make sure the button is unselected.
+ local button_style_name = button.style.name
+ if button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ elseif button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ end
+ button.visible = false
+ -- In case the player will come back, we don't remove the button.
+ return false
+ end,
}
-- GUI data about all build options menus.
-- Although we have only 1 build option menu, we still need to set it due to the data structure expected by the functions.
local build_options_menus_gui_data = {
- get_container_name_function = gui_menu_buildoptions.get_container_name,
- contents = {
- build_options = {
- cheats_menu_gui_data = build_options_menu_gui_data,
- access_right_code = rights.access_build_options_code,
- },
- },
+ get_container_name_function = gui_menu_buildoptions.get_container_name,
+ contents = {
+ build_options = {
+ cheats_menu_gui_data = build_options_menu_gui_data,
+ access_right_code = rights.access_build_options_code,
+ },
+ },
}
-- Set parent.
for _, data in pairs(build_options_menus_gui_data.contents) do
- data.cheats_menu_gui_data.parent = build_options_menus_gui_data
+ data.cheats_menu_gui_data.parent = build_options_menus_gui_data
end
--------------------------------------------------------------------
-- Creates the cheats menu for the given player. If the menu already exists, it will be destroyed instead.
function gui_menu_cheats.create_or_destroy_menu_for_player(player)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Cheats container.
- local cheats_menus_container = container[gui_menu_cheats.get_container_name()]
- if cheats_menus_container then
- cheats_menus_container.destroy()
- else
- cheats_menus_container = container.add({
- type = "flow",
- name = gui_menu_cheats.get_container_name(),
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- direction = "horizontal",
- })
-
- -- Cheats frame.
- local cheats_menu_frame = cheats_menus_container.add({
- type = "frame",
- name = creative_mode_defines.names.gui.cheats_menu_frame,
- direction = "vertical",
- caption = { "gui.creative-mode_cheats" },
- })
-
- -- Cheats menu butotns.
- for _, data in pairs(cheats_menus_gui_data.contents) do
- local button = cheats_menu_frame.add({
- type = "button",
- name = data.button_name,
- style = creative_mode_defines.names.gui_styles.main_menu_button,
- caption = data.button_caption,
- })
- button.visible = data.get_player_can_access_function(player)
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Cheats container.
+ local cheats_menus_container = container[gui_menu_cheats.get_container_name()]
+ if cheats_menus_container then
+ cheats_menus_container.destroy()
+ else
+ cheats_menus_container = container.add({
+ type = "flow",
+ name = gui_menu_cheats.get_container_name(),
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ direction = "horizontal",
+ })
+
+ -- Cheats frame.
+ local cheats_menu_frame = cheats_menus_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.cheats_menu_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_cheats" },
+ })
+
+ -- Cheats menu butotns.
+ for _, data in pairs(cheats_menus_gui_data.contents) do
+ local button = cheats_menu_frame.add({
+ type = "button",
+ name = data.button_name,
+ style = creative_mode_defines.names.gui_styles.main_menu_button,
+ caption = data.button_caption,
+ })
+ button.visible = data.get_player_can_access_function(player)
+ end
+ end
+ end
end
--------------------------------------------------------------------
@@ -1501,80 +1501,80 @@ end
-- Returns the common Boolean result for all the given targets according to the given function for getting Boolean from each target.
-- If any of the targets has different result from the others, nil will be returned.
local function get_common_boolean_result_for_targets(targets, get_single_boolean_function)
- if not targets or #targets <= 0 then
- return get_single_boolean_function(nil)
- end
- local all_true = true
- local all_false = true
- for _, target in ipairs(targets) do
- local single_result = get_single_boolean_function(target)
- if single_result == nil then
- return nil
- elseif single_result then
- all_false = false
- else
- all_true = false
- end
- end
- if all_true then
- return true
- elseif all_false then
- return false
- else
- return nil
- end
+ if not targets or #targets <= 0 then
+ return get_single_boolean_function(nil)
+ end
+ local all_true = true
+ local all_false = true
+ for _, target in ipairs(targets) do
+ local single_result = get_single_boolean_function(target)
+ if single_result == nil then
+ return nil
+ elseif single_result then
+ all_false = false
+ else
+ all_true = false
+ end
+ end
+ if all_true then
+ return true
+ elseif all_false then
+ return false
+ else
+ return nil
+ end
end
-- Returns the common numeric result for all the given targets according to the given function for getting number from each target.
-- If any of the targets has different result from the others, nil will be returned.
local function get_common_numeric_result_for_targets(targets, get_single_number_function)
- if not targets or #targets <= 0 then
- return tonumber(get_single_number_function(nil))
- end
- local common_number = get_single_number_function(targets[1])
- for i = 2, #targets, 1 do
- if common_number ~= get_single_number_function(targets[i]) then
- return nil
- end
- end
- return tonumber(common_number)
+ if not targets or #targets <= 0 then
+ return tonumber(get_single_number_function(nil))
+ end
+ local common_number = get_single_number_function(targets[1])
+ for i = 2, #targets, 1 do
+ if common_number ~= get_single_number_function(targets[i]) then
+ return nil
+ end
+ end
+ return tonumber(common_number)
end
-- Returns the common string result for all the given targets according to the given function for getting string from each target.
-- If any of the targets has different result from the others, nil will be returned.
local function get_common_string_result_for_targets(targets, get_single_string_function)
- if not targets or #targets <= 0 then
- local val = get_single_string_function(nil)
- if val then
- return tostring(val)
- end
- return nil
- end
- local common_string = get_single_string_function(targets[1])
- for i = 2, #targets, 1 do
- if common_string ~= get_single_string_function(targets[i]) then
- return nil
- end
- end
- if common_string then
- return tostring(common_string)
- end
- return nil
+ if not targets or #targets <= 0 then
+ local val = get_single_string_function(nil)
+ if val then
+ return tostring(val)
+ end
+ return nil
+ end
+ local common_string = get_single_string_function(targets[1])
+ for i = 2, #targets, 1 do
+ if common_string ~= get_single_string_function(targets[i]) then
+ return nil
+ end
+ end
+ if common_string then
+ return tostring(common_string)
+ end
+ return nil
end
-- Returns the common team result for all the given targets according to the given function for getting team from each target.
-- If any of the targets has different result from the others, nil will be returned.
local function get_common_team_result_for_targets(targets, get_single_team_function)
- if not targets or #targets <= 0 then
- return get_single_team_function(nil)
- end
- local common_team = get_single_team_function(targets[1])
- for i = 2, #targets, 1 do
- if common_team ~= get_single_team_function(targets[i]) then
- return nil
- end
- end
- return common_team
+ if not targets or #targets <= 0 then
+ return get_single_team_function(nil)
+ end
+ local common_team = get_single_team_function(targets[1])
+ for i = 2, #targets, 1 do
+ if common_team ~= get_single_team_function(targets[i]) then
+ return nil
+ end
+ end
+ return common_team
end
--------------------------------------------------------------------
@@ -1582,66 +1582,66 @@ end
-- Updates the GUI status for an on/off cheat in the given container according to the given GUI data and targets.
-- Make sure the GUI has been created before calling this method.
local function update_on_off_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- local on_button_style, off_button_style
- if cheat_gui_data.cheat_data.get_value_function == nil then
- on_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off
- off_button_style = on_button_style
- else
- local value = get_common_boolean_result_for_targets(targets, cheat_gui_data.cheat_data.get_value_function)
-
- if value == nil then
- on_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off
- off_button_style = on_button_style
- elseif value then
- on_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_on
- off_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off
- else
- on_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off
- off_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_on
- end
- end
-
- -- Container
- local cheat_container = cheats_container[cheat_gui_data.container_name]
- -- On button
- local on_button = cheat_container[cheat_gui_data.on_button_name]
- on_button.style = on_button_style
- -- Off button
- local off_button = cheat_container[cheat_gui_data.off_button_name]
- off_button.style = off_button_style
+ local on_button_style, off_button_style
+ if cheat_gui_data.cheat_data.get_value_function == nil then
+ on_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off
+ off_button_style = on_button_style
+ else
+ local value = get_common_boolean_result_for_targets(targets, cheat_gui_data.cheat_data.get_value_function)
+
+ if value == nil then
+ on_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off
+ off_button_style = on_button_style
+ elseif value then
+ on_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_on
+ off_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off
+ else
+ on_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off
+ off_button_style = creative_mode_defines.names.gui_styles.cheat_on_off_button_on
+ end
+ end
+
+ -- Container
+ local cheat_container = cheats_container[cheat_gui_data.container_name]
+ -- On button
+ local on_button = cheat_container[cheat_gui_data.on_button_name]
+ on_button.style = on_button_style
+ -- Off button
+ local off_button = cheat_container[cheat_gui_data.off_button_name]
+ off_button.style = off_button_style
end
-- Creates GUI elements for an on/off cheat in the given container according to the given GUI data and targets.
local function create_on_off_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
- -- Container
- local cheat_container = cheats_container.add({
- type = "table",
- name = cheat_gui_data.container_name,
- style = creative_mode_defines.names.gui_styles.cheat_table,
- column_count = 3,
- })
- -- Label
- cheat_container.add({
- type = "label",
- name = cheat_gui_data.label_name,
- style = creative_mode_defines.names.gui_styles.cheat_name_label,
- caption = cheat_gui_data.label_caption,
- tooltip = cheat_gui_data.label_tooltip,
- })
- -- On button
- cheat_container.add({
- type = "button",
- name = cheat_gui_data.on_button_name,
- caption = cheat_gui_data.on_button_caption,
- })
- -- Off button
- cheat_container.add({
- type = "button",
- name = cheat_gui_data.off_button_name,
- caption = cheat_gui_data.off_button_caption,
- })
- -- Update the buttons' status.
- update_on_off_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ -- Container
+ local cheat_container = cheats_container.add({
+ type = "table",
+ name = cheat_gui_data.container_name,
+ style = creative_mode_defines.names.gui_styles.cheat_table,
+ column_count = 3,
+ })
+ -- Label
+ cheat_container.add({
+ type = "label",
+ name = cheat_gui_data.label_name,
+ style = creative_mode_defines.names.gui_styles.cheat_name_label,
+ caption = cheat_gui_data.label_caption,
+ tooltip = cheat_gui_data.label_tooltip,
+ })
+ -- On button
+ cheat_container.add({
+ type = "button",
+ name = cheat_gui_data.on_button_name,
+ caption = cheat_gui_data.on_button_caption,
+ })
+ -- Off button
+ cheat_container.add({
+ type = "button",
+ name = cheat_gui_data.off_button_name,
+ caption = cheat_gui_data.off_button_caption,
+ })
+ -- Update the buttons' status.
+ update_on_off_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
end
-----
@@ -1649,65 +1649,65 @@ end
-- Updates the GUI status for a numeric-apply cheat in the given container according to the given GUI data and targets.
-- Make sure the GUI has been created before calling this method.
local function update_numeric_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- local text
- if cheat_gui_data.cheat_data.get_value_function == nil then
- text = 0
- else
- local value = get_common_numeric_result_for_targets(targets, cheat_gui_data.cheat_data.get_value_function)
- if value == nil then
- text = "---"
- else
- text = value
- end
- end
-
- -- Container
- local cheat_container = cheats_container[cheat_gui_data.container_name]
- -- Textfield
- local textfield = cheat_container[cheat_gui_data.textfield_name]
- textfield.text = tostring(text)
+ local text
+ if cheat_gui_data.cheat_data.get_value_function == nil then
+ text = 0
+ else
+ local value = get_common_numeric_result_for_targets(targets, cheat_gui_data.cheat_data.get_value_function)
+ if value == nil then
+ text = "---"
+ else
+ text = value
+ end
+ end
+
+ -- Container
+ local cheat_container = cheats_container[cheat_gui_data.container_name]
+ -- Textfield
+ local textfield = cheat_container[cheat_gui_data.textfield_name]
+ textfield.text = tostring(text)
end
-- Creates GUI elements for a numeric-apply cheat in the given container according to the given GUI data and targets.
local function create_numeric_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
- -- Container
- local cheat_container = cheats_container.add({
- type = "table",
- name = cheat_gui_data.container_name,
- style = creative_mode_defines.names.gui_styles.cheat_table,
- column_count = 4,
- })
- -- Label
- cheat_container.add({
- type = "label",
- name = cheat_gui_data.label_name,
- style = creative_mode_defines.names.gui_styles.cheat_name_label,
- caption = cheat_gui_data.label_caption,
- tooltip = cheat_gui_data.label_tooltip,
- })
- -- Textfield
- cheat_container.add({
- type = "textfield",
- name = cheat_gui_data.textfield_name,
- style = creative_mode_defines.names.gui_styles.cheat_numeric_textfield,
- text = "",
- })
- -- Separator
- cheat_container.add({
- type = "flow",
- name = cheat_gui_data.separator_name,
- style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
- direction = "horizontal",
- })
- -- Apply button
- cheat_container.add({
- type = "button",
- name = cheat_gui_data.apply_button_name,
- style = creative_mode_defines.names.gui_styles.cheat_apply_button,
- caption = cheat_gui_data.apply_button_caption,
- })
- -- Update the textfield's text.
- update_numeric_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ -- Container
+ local cheat_container = cheats_container.add({
+ type = "table",
+ name = cheat_gui_data.container_name,
+ style = creative_mode_defines.names.gui_styles.cheat_table,
+ column_count = 4,
+ })
+ -- Label
+ cheat_container.add({
+ type = "label",
+ name = cheat_gui_data.label_name,
+ style = creative_mode_defines.names.gui_styles.cheat_name_label,
+ caption = cheat_gui_data.label_caption,
+ tooltip = cheat_gui_data.label_tooltip,
+ })
+ -- Textfield
+ cheat_container.add({
+ type = "textfield",
+ name = cheat_gui_data.textfield_name,
+ style = creative_mode_defines.names.gui_styles.cheat_numeric_textfield,
+ text = "",
+ })
+ -- Separator
+ cheat_container.add({
+ type = "flow",
+ name = cheat_gui_data.separator_name,
+ style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
+ direction = "horizontal",
+ })
+ -- Apply button
+ cheat_container.add({
+ type = "button",
+ name = cheat_gui_data.apply_button_name,
+ style = creative_mode_defines.names.gui_styles.cheat_apply_button,
+ caption = cheat_gui_data.apply_button_caption,
+ })
+ -- Update the textfield's text.
+ update_numeric_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
end
-----
@@ -1715,406 +1715,406 @@ end
-- Updates the GUI status for a string-apply cheat in the given container according to the given GUI data and targets.
-- Make sure the GUI has been created before calling this method.
local function update_string_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- local text
- if cheat_gui_data.cheat_data.get_value_function == nil then
- text = ""
- else
- local value = get_common_string_result_for_targets(targets, cheat_gui_data.cheat_data.get_value_function)
- if value == nil then
- text = "---"
- else
- text = value
- end
- end
-
- -- Container
- local cheat_container = cheats_container[cheat_gui_data.container_name]
- -- Textfield
- local textfield = cheat_container[cheat_gui_data.textfield_name]
- textfield.text = tostring(text)
+ local text
+ if cheat_gui_data.cheat_data.get_value_function == nil then
+ text = ""
+ else
+ local value = get_common_string_result_for_targets(targets, cheat_gui_data.cheat_data.get_value_function)
+ if value == nil then
+ text = "---"
+ else
+ text = value
+ end
+ end
+
+ -- Container
+ local cheat_container = cheats_container[cheat_gui_data.container_name]
+ -- Textfield
+ local textfield = cheat_container[cheat_gui_data.textfield_name]
+ textfield.text = tostring(text)
end
-- Creates GUI elements for a string-apply cheat in the given container according to the given GUI data and targets.
local function create_string_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
- -- Container
- local cheat_container = cheats_container.add({
- type = "table",
- name = cheat_gui_data.container_name,
- style = creative_mode_defines.names.gui_styles.cheat_table,
- column_count = 4,
- })
- -- Label
- cheat_container.add({
- type = "label",
- name = cheat_gui_data.label_name,
- style = creative_mode_defines.names.gui_styles.cheat_name_label,
- caption = cheat_gui_data.label_caption,
- tooltip = cheat_gui_data.label_tooltip,
- })
- -- Textfield
- cheat_container.add({
- type = "textfield",
- name = cheat_gui_data.textfield_name,
- style = creative_mode_defines.names.gui_styles.cheat_numeric_textfield,
- text = "",
- })
- -- Separator
- cheat_container.add({
- type = "flow",
- name = cheat_gui_data.separator_name,
- style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
- direction = "horizontal",
- })
- -- Apply button
- cheat_container.add({
- type = "button",
- name = cheat_gui_data.apply_button_name,
- style = creative_mode_defines.names.gui_styles.cheat_apply_button,
- caption = cheat_gui_data.apply_button_caption,
- })
- -- Update the textfield's text.
- update_string_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ -- Container
+ local cheat_container = cheats_container.add({
+ type = "table",
+ name = cheat_gui_data.container_name,
+ style = creative_mode_defines.names.gui_styles.cheat_table,
+ column_count = 4,
+ })
+ -- Label
+ cheat_container.add({
+ type = "label",
+ name = cheat_gui_data.label_name,
+ style = creative_mode_defines.names.gui_styles.cheat_name_label,
+ caption = cheat_gui_data.label_caption,
+ tooltip = cheat_gui_data.label_tooltip,
+ })
+ -- Textfield
+ cheat_container.add({
+ type = "textfield",
+ name = cheat_gui_data.textfield_name,
+ style = creative_mode_defines.names.gui_styles.cheat_numeric_textfield,
+ text = "",
+ })
+ -- Separator
+ cheat_container.add({
+ type = "flow",
+ name = cheat_gui_data.separator_name,
+ style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
+ direction = "horizontal",
+ })
+ -- Apply button
+ cheat_container.add({
+ type = "button",
+ name = cheat_gui_data.apply_button_name,
+ style = creative_mode_defines.names.gui_styles.cheat_apply_button,
+ caption = cheat_gui_data.apply_button_caption,
+ })
+ -- Update the textfield's text.
+ update_string_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
end
-----
-- Creates GUI elements for an one-button-apply cheat in the given container according to the given GUI data.
local function create_one_button_apply_cheat_elements_from_data(cheats_container, cheat_gui_data)
- -- Container
- local cheat_container = cheats_container.add({
- type = "table",
- name = cheat_gui_data.container_name,
- style = creative_mode_defines.names.gui_styles.cheat_table,
- column_count = 3,
- })
- -- Label
- cheat_container.add({
- type = "label",
- name = cheat_gui_data.label_name,
- style = creative_mode_defines.names.gui_styles.cheat_with_one_button_name_label,
- caption = cheat_gui_data.label_caption,
- tooltip = cheat_gui_data.label_tooltip,
- })
- -- Button
- cheat_container.add({
- type = "button",
- name = cheat_gui_data.apply_button_name,
- style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
- caption = cheat_gui_data.apply_button_caption,
- })
+ -- Container
+ local cheat_container = cheats_container.add({
+ type = "table",
+ name = cheat_gui_data.container_name,
+ style = creative_mode_defines.names.gui_styles.cheat_table,
+ column_count = 3,
+ })
+ -- Label
+ cheat_container.add({
+ type = "label",
+ name = cheat_gui_data.label_name,
+ style = creative_mode_defines.names.gui_styles.cheat_with_one_button_name_label,
+ caption = cheat_gui_data.label_caption,
+ tooltip = cheat_gui_data.label_tooltip,
+ })
+ -- Button
+ cheat_container.add({
+ type = "button",
+ name = cheat_gui_data.apply_button_name,
+ style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
+ caption = cheat_gui_data.apply_button_caption,
+ })
end
-----
-- Adds teams to the given flow of a team-target-auto-apply cheat drop down for the cheat of given GUI data.
local function add_teams_to_team_target_auto_apply_cheat_drop_down(cheat_gui_data, drop_down_inner_flow)
- -- Add teams.
- for _, force in pairs(game.forces) do
- drop_down_inner_flow.add({
- type = "button",
- name = cheat_gui_data.drop_down_selection_button_name_prefx .. force.name,
- style = creative_mode_defines.names.gui_styles.cheat_value_drop_down_selection_button,
- caption = force.name,
- tooltip = { "gui.creative-mode_team-name-tooltip", force.name },
- })
- end
+ -- Add teams.
+ for _, force in pairs(game.forces) do
+ drop_down_inner_flow.add({
+ type = "button",
+ name = cheat_gui_data.drop_down_selection_button_name_prefx .. force.name,
+ style = creative_mode_defines.names.gui_styles.cheat_value_drop_down_selection_button,
+ caption = force.name,
+ tooltip = { "gui.creative-mode_team-name-tooltip", force.name },
+ })
+ end
end
-- Clears all teams in the given flow of a team-target-auto-apply cheat drop down.
local function clear_teams_in_team_target_auto_apply_cheat_drop_down(drop_down_inner_flow)
- for _, child_name in pairs(drop_down_inner_flow.children_names) do
- drop_down_inner_flow[child_name].destroy()
- end
+ for _, child_name in pairs(drop_down_inner_flow.children_names) do
+ drop_down_inner_flow[child_name].destroy()
+ end
end
-- Refreshes the contents in the given flow of a team-target-auto-apply cheat drop down for the cheat of given GUI data.
local function refresh_team_target_auto_apply_cheat_drop_down(cheat_gui_data, drop_down_inner_flow)
- clear_teams_in_team_target_auto_apply_cheat_drop_down(drop_down_inner_flow)
- add_teams_to_team_target_auto_apply_cheat_drop_down(cheat_gui_data, drop_down_inner_flow)
+ clear_teams_in_team_target_auto_apply_cheat_drop_down(drop_down_inner_flow)
+ add_teams_to_team_target_auto_apply_cheat_drop_down(cheat_gui_data, drop_down_inner_flow)
end
-- Shows or hides the drop down for a team-target-auto-apply cheat in the given container according to the given GUI data.
-- If the drop down is already visible, it will be hidden. Otherwise, it will be shown.
local function show_or_hide_team_target_auto_apply_cheat_drop_down_from_data(cheats_container, cheat_gui_data)
- -- Container
- local cheat_container = cheats_container[cheat_gui_data.container_name]
- -- Drop down container.
- local drop_down_container = cheat_container[cheat_gui_data.drop_down_container_name]
- -- Drop down scroll pane.
- local drop_down_scroll_pane = drop_down_container[cheat_gui_data.drop_down_scroll_pane_name]
- -- Drop down inner frame.
- local drop_down_inner_frame = drop_down_scroll_pane[cheat_gui_data.drop_down_inner_frame_name]
- -- Drop down inner flow.
- local drop_down_inner_flow = drop_down_inner_frame[cheat_gui_data.drop_down_inner_flow_name]
-
- if drop_down_scroll_pane.visible ~= false then
- -- Hide.
- drop_down_scroll_pane.visible = false
- -- Clear teams.
- clear_teams_in_team_target_auto_apply_cheat_drop_down(drop_down_inner_flow)
- else
- -- Add teams.
- add_teams_to_team_target_auto_apply_cheat_drop_down(cheat_gui_data, drop_down_inner_flow)
- -- Show.
- drop_down_scroll_pane.visible = true
- end
+ -- Container
+ local cheat_container = cheats_container[cheat_gui_data.container_name]
+ -- Drop down container.
+ local drop_down_container = cheat_container[cheat_gui_data.drop_down_container_name]
+ -- Drop down scroll pane.
+ local drop_down_scroll_pane = drop_down_container[cheat_gui_data.drop_down_scroll_pane_name]
+ -- Drop down inner frame.
+ local drop_down_inner_frame = drop_down_scroll_pane[cheat_gui_data.drop_down_inner_frame_name]
+ -- Drop down inner flow.
+ local drop_down_inner_flow = drop_down_inner_frame[cheat_gui_data.drop_down_inner_flow_name]
+
+ if drop_down_scroll_pane.visible ~= false then
+ -- Hide.
+ drop_down_scroll_pane.visible = false
+ -- Clear teams.
+ clear_teams_in_team_target_auto_apply_cheat_drop_down(drop_down_inner_flow)
+ else
+ -- Add teams.
+ add_teams_to_team_target_auto_apply_cheat_drop_down(cheat_gui_data, drop_down_inner_flow)
+ -- Show.
+ drop_down_scroll_pane.visible = true
+ end
end
-- Updates the GUI status for a team-target-auto-apply cheat in the given container according to the given GUI data and targets.
-- Make sure the GUI has been created before calling this method.
local function update_team_target_auto_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- local text
- if cheat_gui_data.cheat_data.get_value_function == nil then
- text = "---"
- else
- local value = get_common_team_result_for_targets(targets, cheat_gui_data.cheat_data.get_value_function)
- if value == nil then
- text = "---"
- else
- text = value.name
- end
- end
-
- -- Container
- local cheat_container = cheats_container[cheat_gui_data.container_name]
- -- Drop down container.
- local drop_down_container = cheat_container[cheat_gui_data.drop_down_container_name]
- -- Current selection button.
- local button = drop_down_container[cheat_gui_data.current_selection_button_name]
- button.caption = text
-
- -- Also refresh the contents of the drop down, if it is visible.
- -- Drop down scroll pane.
- local drop_down_scroll_pane = drop_down_container[cheat_gui_data.drop_down_scroll_pane_name]
- if drop_down_scroll_pane.visible ~= false then
- -- Drop down inner frame.
- local drop_down_inner_frame = drop_down_scroll_pane[cheat_gui_data.drop_down_inner_frame_name]
- -- Drop down inner flow (vertical spacing doesn't work in frame).
- local drop_down_inner_flow = drop_down_inner_frame[cheat_gui_data.drop_down_inner_flow_name]
- refresh_team_target_auto_apply_cheat_drop_down(cheat_gui_data, drop_down_inner_flow)
- end
+ local text
+ if cheat_gui_data.cheat_data.get_value_function == nil then
+ text = "---"
+ else
+ local value = get_common_team_result_for_targets(targets, cheat_gui_data.cheat_data.get_value_function)
+ if value == nil then
+ text = "---"
+ else
+ text = value.name
+ end
+ end
+
+ -- Container
+ local cheat_container = cheats_container[cheat_gui_data.container_name]
+ -- Drop down container.
+ local drop_down_container = cheat_container[cheat_gui_data.drop_down_container_name]
+ -- Current selection button.
+ local button = drop_down_container[cheat_gui_data.current_selection_button_name]
+ button.caption = text
+
+ -- Also refresh the contents of the drop down, if it is visible.
+ -- Drop down scroll pane.
+ local drop_down_scroll_pane = drop_down_container[cheat_gui_data.drop_down_scroll_pane_name]
+ if drop_down_scroll_pane.visible ~= false then
+ -- Drop down inner frame.
+ local drop_down_inner_frame = drop_down_scroll_pane[cheat_gui_data.drop_down_inner_frame_name]
+ -- Drop down inner flow (vertical spacing doesn't work in frame).
+ local drop_down_inner_flow = drop_down_inner_frame[cheat_gui_data.drop_down_inner_flow_name]
+ refresh_team_target_auto_apply_cheat_drop_down(cheat_gui_data, drop_down_inner_flow)
+ end
end
-- Creates GUI elements for a team-target-auto-apply cheat in the given container according to the given GUI data and targets.
local function create_team_target_auto_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
- -- Container
-
- local cheat_container = cheats_container.add({
- type = "flow",
- name = cheat_gui_data.container_name,
- style = creative_mode_defines.names.gui_styles.cheat_flow,
- direction = "horizontal",
- })
- -- Label
- cheat_container.add({
- type = "label",
- name = cheat_gui_data.label_name,
- style = creative_mode_defines.names.gui_styles.cheat_name_label,
- caption = cheat_gui_data.label_caption,
- tooltip = cheat_gui_data.label_tooltip,
- })
-
- -- Drop down container.
- local drop_down_container = cheat_container.add({
- type = "flow",
- name = cheat_gui_data.drop_down_container_name,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical",
- })
- -- Current selection button.
- drop_down_container.add({
- type = "button",
- name = cheat_gui_data.current_selection_button_name,
- style = creative_mode_defines.names.gui_styles.cheat_value_drop_down_current_target_button,
- caption = "",
- })
- -- Drop down scroll pane.
- local drop_down_scroll_pane = drop_down_container.add({
- type = "scroll-pane",
- name = cheat_gui_data.drop_down_scroll_pane_name,
- style = creative_mode_defines.names.gui_styles.cheat_value_drop_down_scroll_pane,
- horizontal_scroll_policy = "never",
- })
- -- Drop down inner frame.
- local drop_down_inner_frame = drop_down_scroll_pane.add({
- type = "frame",
- name = cheat_gui_data.drop_down_inner_frame_name,
- style = creative_mode_defines.names.gui_styles.cheat_value_drop_down_container_frame,
- direction = "vertical",
- })
- -- Drop down inner flow (vertical spacing doesn't work in frame).
- drop_down_inner_frame.add({
- type = "flow",
- name = cheat_gui_data.drop_down_inner_flow_name,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical",
- })
-
- -- Hide the scorll pane first.
- drop_down_scroll_pane.visible = false
- -- Update the current button.
- update_team_target_auto_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ -- Container
+
+ local cheat_container = cheats_container.add({
+ type = "flow",
+ name = cheat_gui_data.container_name,
+ style = creative_mode_defines.names.gui_styles.cheat_flow,
+ direction = "horizontal",
+ })
+ -- Label
+ cheat_container.add({
+ type = "label",
+ name = cheat_gui_data.label_name,
+ style = creative_mode_defines.names.gui_styles.cheat_name_label,
+ caption = cheat_gui_data.label_caption,
+ tooltip = cheat_gui_data.label_tooltip,
+ })
+
+ -- Drop down container.
+ local drop_down_container = cheat_container.add({
+ type = "flow",
+ name = cheat_gui_data.drop_down_container_name,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+ -- Current selection button.
+ drop_down_container.add({
+ type = "button",
+ name = cheat_gui_data.current_selection_button_name,
+ style = creative_mode_defines.names.gui_styles.cheat_value_drop_down_current_target_button,
+ caption = "",
+ })
+ -- Drop down scroll pane.
+ local drop_down_scroll_pane = drop_down_container.add({
+ type = "scroll-pane",
+ name = cheat_gui_data.drop_down_scroll_pane_name,
+ style = creative_mode_defines.names.gui_styles.cheat_value_drop_down_scroll_pane,
+ horizontal_scroll_policy = "never",
+ })
+ -- Drop down inner frame.
+ local drop_down_inner_frame = drop_down_scroll_pane.add({
+ type = "frame",
+ name = cheat_gui_data.drop_down_inner_frame_name,
+ style = creative_mode_defines.names.gui_styles.cheat_value_drop_down_container_frame,
+ direction = "vertical",
+ })
+ -- Drop down inner flow (vertical spacing doesn't work in frame).
+ drop_down_inner_frame.add({
+ type = "flow",
+ name = cheat_gui_data.drop_down_inner_flow_name,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+
+ -- Hide the scorll pane first.
+ drop_down_scroll_pane.visible = false
+ -- Update the current button.
+ update_team_target_auto_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
end
-----
-- Updates cheat GUI status in the given container according to the given GUI data and targets.
function gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- if cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.on_off then
- update_on_off_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.numeric_apply then
- update_numeric_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.string_apply then
- update_string_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.team_target_auto_apply then
- update_team_target_auto_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- end
+ if cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.on_off then
+ update_on_off_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.numeric_apply then
+ update_numeric_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.string_apply then
+ update_string_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.team_target_auto_apply then
+ update_team_target_auto_apply_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ end
end
-- Updates the visibility of the cheat GUI elements in the given container according to the given GUI data and the given player's access right.
local function update_cheat_visibility_from_data_for_player(player, cheats_container, cheat_gui_data)
- local cheat_container = cheats_container[cheat_gui_data.container_name]
- if cheat_gui_data.cheat_data.get_player_can_access_function == nil then
- cheat_container.visible = true
- else
- cheat_container.visible = cheat_gui_data.cheat_data.get_player_can_access_function(player)
- end
+ local cheat_container = cheats_container[cheat_gui_data.container_name]
+ if cheat_gui_data.cheat_data.get_player_can_access_function == nil then
+ cheat_container.visible = true
+ else
+ cheat_container.visible = cheat_gui_data.cheat_data.get_player_can_access_function(player)
+ end
end
-- Creates cheat GUI elements in the given container according to the given GUI data and targets for the given player.
function gui_menu_cheats.create_cheat_elements_from_data_for_player(
- player,
- cheats_container,
- cheat_gui_data,
- targets,
- check_cheat_visibility_for_player
+ player,
+ cheats_container,
+ cheat_gui_data,
+ targets,
+ check_cheat_visibility_for_player
)
- if cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.on_off then
- create_on_off_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.numeric_apply then
- create_numeric_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.string_apply then
- create_string_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.apply then
- create_one_button_apply_cheat_elements_from_data(cheats_container, cheat_gui_data)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.team_target_auto_apply then
- create_team_target_auto_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
- end
- if check_cheat_visibility_for_player then
- update_cheat_visibility_from_data_for_player(player, cheats_container, cheat_gui_data)
- end
+ if cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.on_off then
+ create_on_off_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.numeric_apply then
+ create_numeric_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.string_apply then
+ create_string_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.apply then
+ create_one_button_apply_cheat_elements_from_data(cheats_container, cheat_gui_data)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.team_target_auto_apply then
+ create_team_target_auto_apply_cheat_elements_from_data(cheats_container, cheat_gui_data, targets)
+ end
+ if check_cheat_visibility_for_player then
+ update_cheat_visibility_from_data_for_player(player, cheats_container, cheat_gui_data)
+ end
end
-- Creates the enable all and disable all buttons in the given container.
local function create_enable_and_disable_all_buttons(
- cheats_container,
- container_name,
- enable_all_button_name,
- disable_all_button_name
+ cheats_container,
+ container_name,
+ enable_all_button_name,
+ disable_all_button_name
)
- -- Container
- local button_container = cheats_container.add({
- type = "table",
- name = container_name,
- style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_table,
- column_count = 2,
- })
- -- Enable all button
- button_container.add({
- type = "button",
- name = enable_all_button_name,
- style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button,
- caption = creative_mode_defines.names.gui_captions.enable_all,
- })
- -- Disable all button
- button_container.add({
- type = "button",
- name = disable_all_button_name,
- style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button,
- caption = creative_mode_defines.names.gui_captions.disable_all,
- })
+ -- Container
+ local button_container = cheats_container.add({
+ type = "table",
+ name = container_name,
+ style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_table,
+ column_count = 2,
+ })
+ -- Enable all button
+ button_container.add({
+ type = "button",
+ name = enable_all_button_name,
+ style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button,
+ caption = creative_mode_defines.names.gui_captions.enable_all,
+ })
+ -- Disable all button
+ button_container.add({
+ type = "button",
+ name = disable_all_button_name,
+ style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button,
+ caption = creative_mode_defines.names.gui_captions.disable_all,
+ })
end
---------------
-- Returns whether there is a target selection list for the cheats of given GUI data.
local function get_cheats_menu_has_targets_selection(cheats_menu_gui_data)
- if cheats_menu_gui_data.has_targets_selection then
- -- Used by the data in the modification popup.
- return true
- end
+ if cheats_menu_gui_data.has_targets_selection then
+ -- Used by the data in the modification popup.
+ return true
+ end
- local targets_scroll_pane_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane
- return targets_scroll_pane_data ~= nil
+ local targets_scroll_pane_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane
+ return targets_scroll_pane_data ~= nil
end
-- Returns the frame according to the given cheats menu GUI data for the given player.
-- If the player has not opened such cheat menu page, nil will be returned.
local function get_cheats_frame_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local cheats_menus_container = container[cheats_menu_gui_data.parent.get_container_name_function()]
- if cheats_menus_container then
- return cheats_menus_container[cheats_menu_gui_data.frame.name]
- end
- end
- return nil
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local cheats_menus_container = container[cheats_menu_gui_data.parent.get_container_name_function()]
+ if cheats_menus_container then
+ return cheats_menus_container[cheats_menu_gui_data.frame.name]
+ end
+ end
+ return nil
end
-- Returns the outer container according to the given cheats menu GUI data for the given player.
-- If the player has not opened such cheat menu page, nil will be returned.
local function get_outer_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- local frame = get_cheats_frame_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if frame then
- return frame[cheats_menu_gui_data.frame.outer_container.name]
- end
- return nil
+ local frame = get_cheats_frame_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if frame then
+ return frame[cheats_menu_gui_data.frame.outer_container.name]
+ end
+ return nil
end
-- Returns the targets scroll pane according to the given cheats menu GUI data for the given player.
-- If the player has not opened such cheat menu page, nil will be returned.
local function get_targets_scroll_pane_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- local outer_container = get_outer_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if outer_container then
- local current_structure_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane
- if current_structure_data then
- return outer_container[current_structure_data.name]
- end
- end
- return nil
+ local outer_container = get_outer_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if outer_container then
+ local current_structure_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane
+ if current_structure_data then
+ return outer_container[current_structure_data.name]
+ end
+ end
+ return nil
end
-- Returns the targets inner container according to the given cheats menu GUI data for the given player.
-- If the player has not opened such cheat menu page, nil will be returned.
local function get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- local targets_scroll_pane = get_targets_scroll_pane_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if targets_scroll_pane then
- local current_structure_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane.outer_container
- local targets_outer_container = targets_scroll_pane[current_structure_data.name]
+ local targets_scroll_pane = get_targets_scroll_pane_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if targets_scroll_pane then
+ local current_structure_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane.outer_container
+ local targets_outer_container = targets_scroll_pane[current_structure_data.name]
- current_structure_data = current_structure_data.inner_container
- return targets_outer_container[current_structure_data.name]
- end
- return nil
+ current_structure_data = current_structure_data.inner_container
+ return targets_outer_container[current_structure_data.name]
+ end
+ return nil
end
-- Returns the cheats container according to the given cheats menu GUI data for the given player.
-- If the player has not opened such cheat menu page, nil will be returned.
local function get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if cheats_menu_gui_data.get_cheats_container_function then
- -- Used by the data in modification popup.
- return cheats_menu_gui_data.get_cheats_container_function(player)
- end
- local outer_container = get_outer_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if outer_container then
- local cheats_scroll_pane_data = cheats_menu_gui_data.frame.outer_container.cheats_scroll_pane
- local cheats_scroll_pane = outer_container[cheats_scroll_pane_data.name]
- if cheats_scroll_pane then
- return cheats_scroll_pane[cheats_scroll_pane_data.cheats_container.name]
- end
- end
- return nil
+ if cheats_menu_gui_data.get_cheats_container_function then
+ -- Used by the data in modification popup.
+ return cheats_menu_gui_data.get_cheats_container_function(player)
+ end
+ local outer_container = get_outer_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if outer_container then
+ local cheats_scroll_pane_data = cheats_menu_gui_data.frame.outer_container.cheats_scroll_pane
+ local cheats_scroll_pane = outer_container[cheats_scroll_pane_data.name]
+ if cheats_scroll_pane then
+ return cheats_scroll_pane[cheats_scroll_pane_data.cheats_container.name]
+ end
+ end
+ return nil
end
---------------
@@ -2122,84 +2122,84 @@ end
-- Adds a target button with the given exact element name referring to the given target for the given player inside the given targets inner container and sets the button according to the given cheats menu GUI data.
-- Returns the created button and whether the target is marked as self.
local function add_target_button_with_exact_name_in_targets_inner_container_for_player(
- player,
- target,
- cheats_menu_gui_data,
- targets_inner_container,
- button_name
+ player,
+ target,
+ cheats_menu_gui_data,
+ targets_inner_container,
+ button_name
)
- local style
- -- Check if the target should be marked as "self" (blue font)
- local is_self = cheats_menu_gui_data.check_is_target_self_function(player, target)
- if is_self then
- style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- else
- style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- end
- local button = targets_inner_container.add({
- type = "button",
- name = button_name,
- style = style,
- caption = cheats_menu_gui_data.get_target_button_caption_function(player, target),
- tooltip = cheats_menu_gui_data.get_target_button_tooltip_function(player, target),
- })
- if cheats_menu_gui_data.post_create_target_button_function then
- cheats_menu_gui_data.post_create_target_button_function(player, target, button)
- end
- return button, is_self
+ local style
+ -- Check if the target should be marked as "self" (blue font)
+ local is_self = cheats_menu_gui_data.check_is_target_self_function(player, target)
+ if is_self then
+ style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ else
+ style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ end
+ local button = targets_inner_container.add({
+ type = "button",
+ name = button_name,
+ style = style,
+ caption = cheats_menu_gui_data.get_target_button_caption_function(player, target),
+ tooltip = cheats_menu_gui_data.get_target_button_tooltip_function(player, target),
+ })
+ if cheats_menu_gui_data.post_create_target_button_function then
+ cheats_menu_gui_data.post_create_target_button_function(player, target, button)
+ end
+ return button, is_self
end
-- Adds a target button referring to the given target for the given player inside the given targets inner container and sets the button according to the given cheats menu GUI data.
-- Returns the created button and whether the target is marked as self.
local function add_target_button_in_targets_inner_container_for_player(
- player,
- target,
- cheats_menu_gui_data,
- targets_inner_container,
- button_name_prefix
+ player,
+ target,
+ cheats_menu_gui_data,
+ targets_inner_container,
+ button_name_prefix
)
- return add_target_button_with_exact_name_in_targets_inner_container_for_player(
- player,
- target,
- cheats_menu_gui_data,
- targets_inner_container,
- button_name_prefix .. cheats_menu_gui_data.get_target_button_name_postfix_function(player, target)
- )
+ return add_target_button_with_exact_name_in_targets_inner_container_for_player(
+ player,
+ target,
+ cheats_menu_gui_data,
+ targets_inner_container,
+ button_name_prefix .. cheats_menu_gui_data.get_target_button_name_postfix_function(player, target)
+ )
end
-- Shows or hides the targets selection scroll pane according to the given GUI elements.
local function show_or_hide_targets_selection(outer_container, targets_scroll_pane, show)
- if show then
- targets_scroll_pane.visible = true
- outer_container.style = "horizontal_flow"
- else
- targets_scroll_pane.visible = false
- outer_container.style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow
- end
+ if show then
+ targets_scroll_pane.visible = true
+ outer_container.style = "horizontal_flow"
+ else
+ targets_scroll_pane.visible = false
+ outer_container.style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow
+ end
end
-- Updates the visibility of targets selection scroll pane represented by the given GUI elements according to the number of valid targets.
local function update_targets_selection_visibility_by_valid_target_count(
- outer_container,
- targets_scroll_pane,
- targets_inner_container
+ outer_container,
+ targets_scroll_pane,
+ targets_inner_container
)
- local show = #targets_inner_container.children_names > 1
- if show then
- -- Some buttons may be hidden.
- local actual_count = 0
- for _, child_name in ipairs(targets_inner_container.children_names) do
- local button = targets_inner_container[child_name]
- if button.visible ~= false then
- actual_count = actual_count + 1
- if actual_count > 1 then
- break
- end
- end
- end
- show = actual_count > 1
- end
- show_or_hide_targets_selection(outer_container, targets_scroll_pane, show)
+ local show = #targets_inner_container.children_names > 1
+ if show then
+ -- Some buttons may be hidden.
+ local actual_count = 0
+ for _, child_name in ipairs(targets_inner_container.children_names) do
+ local button = targets_inner_container[child_name]
+ if button.visible ~= false then
+ actual_count = actual_count + 1
+ if actual_count > 1 then
+ break
+ end
+ end
+ end
+ show = actual_count > 1
+ end
+ show_or_hide_targets_selection(outer_container, targets_scroll_pane, show)
end
---------------
@@ -2208,438 +2208,422 @@ end
-- If the player has not opened such cheats menu, nil will be returend.
-- @param special_target If it is provided, the selected targets are returned only if this target is included. Otherwise, the result will be overridden by nil.
local function get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data, special_target)
- if cheats_menu_gui_data.get_all_selected_targets_function then
- -- Used by the data in modification popup.
- return cheats_menu_gui_data.get_all_selected_targets_function(player)
- end
-
- local targets_scroll_pane = get_targets_scroll_pane_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if targets_scroll_pane then
- local targets_inner_container =
- get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if targets_inner_container then
- -- Preprare to iterate through the selections.
- local targets = {}
- -- Iterate!
- -- If the container is invisible, that means it only contains 1 valid target, e.g. the player himself if it is the personal cheats menu.
- -- In that case, it is impossible for the player to select the button. So, we don't check the style.
- local check_style = not targets_scroll_pane.visible == false
- if special_target ~= nil then
- -- Special target is provided! We should check it.
- local button_name_prefix =
- cheats_menu_gui_data.frame.outer_container.targets_scroll_pane.outer_container.inner_container.target_button.name_prefix
- local button_name = button_name_prefix
- .. cheats_menu_gui_data.get_target_button_name_postfix_function(player, special_target)
- local button = targets_inner_container[button_name]
- if button then
- local button_style_name = button.style.name
- if
- check_style
- and button_style_name ~= creative_mode_defines.names.gui_styles.cheat_target_selected_button
- and button_style_name
- ~= creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- then
- -- Target not selected!
- return nil
- end
- else
- -- No such button. Target not found.
- return nil
- end
- end
- for _, child_name in ipairs(targets_inner_container.children_names) do
- local button = targets_inner_container[child_name]
- local button_style_name = button.style.name
- if
- not check_style
- or (
- button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button
- or button_style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- )
- then
- local target = cheats_menu_gui_data.get_button_actual_target_function(player, button)
- if target then
- if cheats_menu_gui_data.check_is_target_button_valid_function(player, target, button) then
- table.insert(targets, target)
- end
- end
- end
- end
- return targets
- end
- end
- return nil
+ if cheats_menu_gui_data.get_all_selected_targets_function then
+ -- Used by the data in modification popup.
+ return cheats_menu_gui_data.get_all_selected_targets_function(player)
+ end
+
+ local targets_scroll_pane = get_targets_scroll_pane_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if targets_scroll_pane then
+ local targets_inner_container = get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if targets_inner_container then
+ -- Preprare to iterate through the selections.
+ local targets = {}
+ -- Iterate!
+ -- If the container is invisible, that means it only contains 1 valid target, e.g. the player himself if it is the personal cheats menu.
+ -- In that case, it is impossible for the player to select the button. So, we don't check the style.
+ local check_style = targets_scroll_pane.visible ~= false
+ if special_target ~= nil then
+ -- Special target is provided! We should check it.
+ local button_name_prefix =
+ cheats_menu_gui_data.frame.outer_container.targets_scroll_pane.outer_container.inner_container.target_button.name_prefix
+ local button_name = button_name_prefix
+ .. cheats_menu_gui_data.get_target_button_name_postfix_function(player, special_target)
+ local button = targets_inner_container[button_name]
+ if button then
+ local button_style_name = button.style.name
+ if
+ check_style
+ and button_style_name ~= creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ and button_style_name ~= creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ then
+ -- Target not selected!
+ return nil
+ end
+ else
+ -- No such button. Target not found.
+ return nil
+ end
+ end
+ for _, child_name in ipairs(targets_inner_container.children_names) do
+ local button = targets_inner_container[child_name]
+ local button_style_name = button.style.name
+ if
+ not check_style
+ or (
+ button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ or button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ )
+ then
+ local target = cheats_menu_gui_data.get_button_actual_target_function(player, button)
+ if target then
+ if cheats_menu_gui_data.check_is_target_button_valid_function(player, target, button) then
+ table.insert(targets, target)
+ end
+ end
+ end
+ end
+ return targets
+ end
+ end
+ return nil
end
-- Updates the cheat GUI status of given cheat GUI data for all players in the cheats menu of given cheats menu GUI data.
-- @param special_target If it is provided, the GUI status will be updated only if it is selected by the iterated player.
function gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data,
- special_target
+ cheats_menu_gui_data,
+ cheat_gui_data,
+ special_target
)
- for _, player in pairs(game.players) do
- local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if cheats_container then
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- -- There is a target list. Get the selected targets from the list.
- local targets =
- get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data, special_target)
- if targets then
- gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- end
- else
- -- No target list, no target.
- gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, nil)
- end
- end
- end
+ for _, player in pairs(game.players) do
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if cheats_container then
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ -- There is a target list. Get the selected targets from the list.
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data, special_target)
+ if targets then
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ end
+ else
+ -- No target list, no target.
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, nil)
+ end
+ end
+ end
end
-- Updates all cheat GUI status in the cheats menu of given cheats menu GUI data for the given player.
-- @param special_target If it is provided, the GUI status will be updated only if it is selected by the player.
local function update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data, special_target)
- local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if cheats_container then
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- -- There is a target list. Get the selected targets from the list.
- local targets =
- get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data, special_target)
- if targets then
- for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
- gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- end
- end
- else
- -- No target list, no target.
- for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
- gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, nil)
- end
- end
- end
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if cheats_container then
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ -- There is a target list. Get the selected targets from the list.
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data, special_target)
+ if targets then
+ for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ end
+ end
+ else
+ -- No target list, no target.
+ for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, nil)
+ end
+ end
+ end
end
-- Updates all cheat GUI status in the cheats menu of given cheats menu GUI data for the given player according to the given targets.
local function update_all_cheats_status_in_cheats_menu_for_player_with_known_targets(
- player,
- cheats_menu_gui_data,
- targets
+ player,
+ cheats_menu_gui_data,
+ targets
)
- local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if cheats_container then
- for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
- gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- end
- end
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if cheats_container then
+ for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ end
+ end
end
-- Updates all cheat GUI status in the cheats menu of given cheats menu GUI data for all players.
-- @param special_target If it is provided, the GUI status will be updated only if it is selected by the iterated player.
local function update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, special_target)
- for _, player in pairs(game.players) do
- update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data, special_target)
- end
+ for _, player in pairs(game.players) do
+ update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data, special_target)
+ end
end
-- Updates the visibility of the targets selection in the cheats menu of given cheats menu GUI for the given player according to the number of visible targets.
local function update_targets_selection_visibility_for_player(player, cheats_menu_gui_data)
- local outer_container = get_outer_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if outer_container then
- local targets_scroll_pane = get_targets_scroll_pane_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if targets_scroll_pane then
- local targets_inner_container =
- get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if targets_inner_container then
- update_targets_selection_visibility_by_valid_target_count(
- outer_container,
- targets_scroll_pane,
- targets_inner_container
- )
- end
- end
- end
+ local outer_container = get_outer_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if outer_container then
+ local targets_scroll_pane = get_targets_scroll_pane_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if targets_scroll_pane then
+ local targets_inner_container =
+ get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if targets_inner_container then
+ update_targets_selection_visibility_by_valid_target_count(
+ outer_container,
+ targets_scroll_pane,
+ targets_inner_container
+ )
+ end
+ end
+ end
end
-- Adds or removes the given target as a button in the cheats menu of given cheats menu GUI data for all players.
local function add_or_remove_target_in_cheats_menu_for_all_players(target, cheats_menu_gui_data, is_add)
- local targets_scroll_pane_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane
- if targets_scroll_pane_data then
- local button_name_prefix = targets_scroll_pane_data.outer_container.inner_container.target_button.name_prefix
- for _, player in pairs(game.players) do
- -- Check if the given target is valid for the given player, i.e. can player access such target?
- if cheats_menu_gui_data.verify_target_for_insert_function(player, target) then
- local targets_inner_container =
- get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if targets_inner_container then
- local button_name = button_name_prefix
- .. cheats_menu_gui_data.get_target_button_name_postfix_function(player, target)
- -- Check if such option already exists.
- local button = targets_inner_container[button_name]
- if button then
- -- The button exists.
- if is_add then
- -- If such button was just hidden before, reveal it now.
- if button.visible == false then
- -- Make sure it isn't selected.
- local button_style_name = button.style.name
- if
- button_style_name
- == creative_mode_defines.names.gui_styles.cheat_target_selected_button
- then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- elseif
- button_style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- then
- button.style =
- creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- else
- button.visible = true
- end
- -- Make sure we update the state AFTER the visibility of the targets container is updated.
- update_targets_selection_visibility_for_player(player, cheats_menu_gui_data)
- -- Update status.
- -- (There is a case that in a 2P game, if the admin selected the other player, but then that player left and joined back. The admin needs to update the status. So, no if-check before this line.)
- update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- end
- else
- -- Remove the button.
- -- If the button was already selected, we will need to update the cheats status.
- local button_style_name = button.style.name
- local need_update_status = button_style_name
- == creative_mode_defines.names.gui_styles.cheat_target_selected_button
- or button_style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- if cheats_menu_gui_data.remove_target_button_function(player, target, button) then
- button.destroy()
- end
- -- Make sure we update the state AFTER the visibility of the targets container is updated.
- update_targets_selection_visibility_for_player(player, cheats_menu_gui_data)
- -- Update status if necessary.
- if need_update_status then
- update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- end
- end
- else
- -- The button doesn't exist.
- if is_add then
- add_target_button_with_exact_name_in_targets_inner_container_for_player(
- player,
- target,
- cheats_menu_gui_data,
- targets_inner_container,
- button_name
- )
- update_targets_selection_visibility_for_player(player, cheats_menu_gui_data)
- end
- end
- end
- end
- end
- end
+ local targets_scroll_pane_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane
+ if targets_scroll_pane_data then
+ local button_name_prefix = targets_scroll_pane_data.outer_container.inner_container.target_button.name_prefix
+ for _, player in pairs(game.players) do
+ -- Check if the given target is valid for the given player, i.e. can player access such target?
+ if cheats_menu_gui_data.verify_target_for_insert_function(player, target) then
+ local targets_inner_container =
+ get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if targets_inner_container then
+ local button_name = button_name_prefix
+ .. cheats_menu_gui_data.get_target_button_name_postfix_function(player, target)
+ -- Check if such option already exists.
+ local button = targets_inner_container[button_name]
+ if button then
+ -- The button exists.
+ if is_add then
+ -- If such button was just hidden before, reveal it now.
+ if button.visible == false then
+ -- Make sure it isn't selected.
+ local button_style_name = button.style.name
+ if button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ elseif
+ button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ else
+ button.visible = true
+ end
+ -- Make sure we update the state AFTER the visibility of the targets container is updated.
+ update_targets_selection_visibility_for_player(player, cheats_menu_gui_data)
+ -- Update status.
+ -- (There is a case that in a 2P game, if the admin selected the other player, but then that player left and joined back. The admin needs to update the status. So, no if-check before this line.)
+ update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ end
+ else
+ -- Remove the button.
+ -- If the button was already selected, we will need to update the cheats status.
+ local button_style_name = button.style.name
+ local need_update_status = button_style_name
+ == creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ or button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ if cheats_menu_gui_data.remove_target_button_function(player, target, button) then
+ button.destroy()
+ end
+ -- Make sure we update the state AFTER the visibility of the targets container is updated.
+ update_targets_selection_visibility_for_player(player, cheats_menu_gui_data)
+ -- Update status if necessary.
+ if need_update_status then
+ update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ end
+ end
+ else
+ -- The button doesn't exist.
+ if is_add then
+ add_target_button_with_exact_name_in_targets_inner_container_for_player(
+ player,
+ target,
+ cheats_menu_gui_data,
+ targets_inner_container,
+ button_name
+ )
+ update_targets_selection_visibility_for_player(player, cheats_menu_gui_data)
+ end
+ end
+ end
+ end
+ end
+ end
end
----------------
-- Resets the last action applied on the cheats menu GUI by the player of given index.
local function reset_last_cheats_menu_gui_action_by_player_index(player_index)
- if storage.last_cheats_menu_gui_actions_by_players then
- storage.last_cheats_menu_gui_actions_by_players[player_index] = nil
- end
+ if storage.last_cheats_menu_gui_actions_by_players then
+ storage.last_cheats_menu_gui_actions_by_players[player_index] = nil
+ end
end
-- Generic function for creating a cheats menu for the given player according to the given cheats menu GUI data.
-- If the menu already exists, it will be destroyed instead.
local function create_or_destroy_cheats_menu_for_player(player, cheats_menu_gui_data, destroy_only)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local cheats_menus_container = container[cheats_menu_gui_data.parent.get_container_name_function()]
- if cheats_menus_container then
- local current_structure_data = cheats_menu_gui_data.frame
- local frame = cheats_menus_container[current_structure_data.name]
-
- -- Reset recorded action.
- reset_last_cheats_menu_gui_action_by_player_index(player.index)
-
- if frame then
- -- Already opened.
- frame.destroy()
- elseif not destroy_only then
- -- Not yet opened.
- -- Frame.
- frame = cheats_menus_container.add({
- type = "frame",
- name = current_structure_data.name,
- direction = "vertical",
- caption = current_structure_data.caption,
- })
-
- -- Outer container.
- local outer_container_data = current_structure_data.outer_container
- current_structure_data = outer_container_data.targets_scroll_pane
- local column_count
- if current_structure_data then
- column_count = 2
- else
- column_count = 1
- end
- local outer_container = frame.add({
- type = "flow",
- name = outer_container_data.name,
- direction = "horizontal",
- })
-
- -------
-
- -- We will need the selected targets for setting the cheat status.
- local selected_targets = {}
-
- -- Targets scroll pane.
- if current_structure_data then
- local targets_scroll_pane = outer_container.add({
- type = "scroll-pane",
- name = current_structure_data.name,
- style = creative_mode_defines.names.gui_styles.cheat_scroll_pane,
- })
-
- -- Targets outer container.
- current_structure_data = current_structure_data.outer_container
- local targets_outer_container = targets_scroll_pane.add({
- type = "frame",
- name = current_structure_data.name,
- style = creative_mode_defines.names.gui_styles.cheat_target_selection_container_frame,
- direction = "vertical",
- })
-
- -- Targets inner container (vertical spacing doesn't work in frame).
- local inner_container_data = current_structure_data.inner_container
- local targets_inner_container = targets_outer_container.add({
- type = "flow",
- name = inner_container_data.name,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical",
- })
-
- -- Add targets.
- current_structure_data = inner_container_data.target_button
- local button_name_prefix = current_structure_data.name_prefix
- -- We will need the number of valid options for determining whether the target selection scroll pane should be shown or hidden.
- local valid_target_count = 0
- -- Get targets.
- local unverified_target_list, single_target =
- cheats_menu_gui_data.get_unverified_targets_function(player)
- -- Unverified target list.
- if unverified_target_list then
- for _, target in pairs(unverified_target_list) do
- -- Exclude invalid targets.
- if cheats_menu_gui_data.verify_target_function(player, target) then
- local button, is_self = add_target_button_in_targets_inner_container_for_player(
- player,
- target,
- cheats_menu_gui_data,
- targets_inner_container,
- button_name_prefix
- )
- if is_self then
- table.insert(selected_targets, target)
- end
- if
- cheats_menu_gui_data.check_is_target_button_valid_function(player, target, button)
- then
- valid_target_count = valid_target_count + 1
- end
- end
- end
- end
- -- Single, verified target.
- if single_target then
- local button, is_self = add_target_button_in_targets_inner_container_for_player(
- player,
- single_target,
- cheats_menu_gui_data,
- targets_inner_container,
- button_name_prefix
- )
- if is_self then
- table.insert(selected_targets, single_target)
- end
- if
- cheats_menu_gui_data.check_is_target_button_valid_function(player, single_target, button)
- then
- valid_target_count = valid_target_count + 1
- end
- end
-
- -- Select all button.
- current_structure_data = inner_container_data.select_all_button
- targets_scroll_pane.add({
- type = "button",
- name = current_structure_data.name,
- style = creative_mode_defines.names.gui_styles.cheat_select_all_targets_button,
- caption = { "gui.creative-mode_list-select-all" },
- tooltip = { "gui.creative-mode_list-select-all-tooltip" },
- })
-
- -- Show or hide the target selection scroll pane according to the number of valid options.
- show_or_hide_targets_selection(outer_container, targets_scroll_pane, valid_target_count > 1)
- end
-
- -------
-
- -- Cheats scroll pane.
- current_structure_data = outer_container_data.cheats_scroll_pane
- local cheats_scroll_pane = outer_container.add({
- type = "scroll-pane",
- name = current_structure_data.name,
- style = creative_mode_defines.names.gui_styles.cheat_scroll_pane,
- })
-
- -- Cheats container.
- current_structure_data = current_structure_data.cheats_container
- local cheats_container = cheats_scroll_pane.add({
- type = "flow",
- name = current_structure_data.name,
- direction = "vertical",
- })
-
- -- Cheats.
- for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
- gui_menu_cheats.create_cheat_elements_from_data_for_player(
- player,
- cheats_container,
- cheat_gui_data,
- selected_targets,
- true
- )
- end
-
- -- Enable all / Disable all.
- local enable_disable_all_container_data = current_structure_data.enable_disable_all_container
- if enable_disable_all_container_data then
- create_enable_and_disable_all_buttons(
- cheats_container,
- enable_disable_all_container_data.name,
- enable_disable_all_container_data.enable_all_button_name,
- enable_disable_all_container_data.disable_all_button_name
- )
- end
-
- -- Notes.
- if current_structure_data.notes then
- for _, note_data in pairs(current_structure_data.notes) do
- cheats_container.add({
- type = "label",
- name = note_data.name,
- style = creative_mode_defines.names.gui_styles.cheat_note_label,
- caption = note_data.caption,
- })
- end
- end
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local cheats_menus_container = container[cheats_menu_gui_data.parent.get_container_name_function()]
+ if cheats_menus_container then
+ local current_structure_data = cheats_menu_gui_data.frame
+ local frame = cheats_menus_container[current_structure_data.name]
+
+ -- Reset recorded action.
+ reset_last_cheats_menu_gui_action_by_player_index(player.index)
+
+ if frame then
+ -- Already opened.
+ frame.destroy()
+ elseif not destroy_only then
+ -- Not yet opened.
+ -- Frame.
+ frame = cheats_menus_container.add({
+ type = "frame",
+ name = current_structure_data.name,
+ direction = "vertical",
+ caption = current_structure_data.caption,
+ })
+
+ -- Outer container.
+ local outer_container_data = current_structure_data.outer_container
+ current_structure_data = outer_container_data.targets_scroll_pane
+ local column_count
+ if current_structure_data then
+ column_count = 2
+ else
+ column_count = 1
+ end
+ local outer_container = frame.add({
+ type = "flow",
+ name = outer_container_data.name,
+ direction = "horizontal",
+ })
+
+ -------
+
+ -- We will need the selected targets for setting the cheat status.
+ local selected_targets = {}
+
+ -- Targets scroll pane.
+ if current_structure_data then
+ local targets_scroll_pane = outer_container.add({
+ type = "scroll-pane",
+ name = current_structure_data.name,
+ style = creative_mode_defines.names.gui_styles.cheat_scroll_pane,
+ })
+
+ -- Targets outer container.
+ current_structure_data = current_structure_data.outer_container
+ local targets_outer_container = targets_scroll_pane.add({
+ type = "frame",
+ name = current_structure_data.name,
+ style = creative_mode_defines.names.gui_styles.cheat_target_selection_container_frame,
+ direction = "vertical",
+ })
+
+ -- Targets inner container (vertical spacing doesn't work in frame).
+ local inner_container_data = current_structure_data.inner_container
+ local targets_inner_container = targets_outer_container.add({
+ type = "flow",
+ name = inner_container_data.name,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+
+ -- Add targets.
+ current_structure_data = inner_container_data.target_button
+ local button_name_prefix = current_structure_data.name_prefix
+ -- We will need the number of valid options for determining whether the target selection scroll pane should be shown or hidden.
+ local valid_target_count = 0
+ -- Get targets.
+ local unverified_target_list, single_target = cheats_menu_gui_data.get_unverified_targets_function(player)
+ -- Unverified target list.
+ if unverified_target_list then
+ for _, target in pairs(unverified_target_list) do
+ -- Exclude invalid targets.
+ if cheats_menu_gui_data.verify_target_function(player, target) then
+ local button, is_self = add_target_button_in_targets_inner_container_for_player(
+ player,
+ target,
+ cheats_menu_gui_data,
+ targets_inner_container,
+ button_name_prefix
+ )
+ if is_self then
+ table.insert(selected_targets, target)
+ end
+ if cheats_menu_gui_data.check_is_target_button_valid_function(player, target, button) then
+ valid_target_count = valid_target_count + 1
+ end
+ end
+ end
+ end
+ -- Single, verified target.
+ if single_target then
+ local button, is_self = add_target_button_in_targets_inner_container_for_player(
+ player,
+ single_target,
+ cheats_menu_gui_data,
+ targets_inner_container,
+ button_name_prefix
+ )
+ if is_self then
+ table.insert(selected_targets, single_target)
+ end
+ if cheats_menu_gui_data.check_is_target_button_valid_function(player, single_target, button) then
+ valid_target_count = valid_target_count + 1
+ end
+ end
+
+ -- Select all button.
+ current_structure_data = inner_container_data.select_all_button
+ targets_scroll_pane.add({
+ type = "button",
+ name = current_structure_data.name,
+ style = creative_mode_defines.names.gui_styles.cheat_select_all_targets_button,
+ caption = { "gui.creative-mode_list-select-all" },
+ tooltip = { "gui.creative-mode_list-select-all-tooltip" },
+ })
+
+ -- Show or hide the target selection scroll pane according to the number of valid options.
+ show_or_hide_targets_selection(outer_container, targets_scroll_pane, valid_target_count > 1)
+ end
+
+ -------
+
+ -- Cheats scroll pane.
+ current_structure_data = outer_container_data.cheats_scroll_pane
+ local cheats_scroll_pane = outer_container.add({
+ type = "scroll-pane",
+ name = current_structure_data.name,
+ style = creative_mode_defines.names.gui_styles.cheat_scroll_pane,
+ })
+
+ -- Cheats container.
+ current_structure_data = current_structure_data.cheats_container
+ local cheats_container = cheats_scroll_pane.add({
+ type = "flow",
+ name = current_structure_data.name,
+ direction = "vertical",
+ })
+
+ -- Cheats.
+ for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
+ gui_menu_cheats.create_cheat_elements_from_data_for_player(
+ player,
+ cheats_container,
+ cheat_gui_data,
+ selected_targets,
+ true
+ )
+ end
+
+ -- Enable all / Disable all.
+ local enable_disable_all_container_data = current_structure_data.enable_disable_all_container
+ if enable_disable_all_container_data then
+ create_enable_and_disable_all_buttons(
+ cheats_container,
+ enable_disable_all_container_data.name,
+ enable_disable_all_container_data.enable_all_button_name,
+ enable_disable_all_container_data.disable_all_button_name
+ )
+ end
+
+ -- Notes.
+ if current_structure_data.notes then
+ for _, note_data in pairs(current_structure_data.notes) do
+ cheats_container.add({
+ type = "label",
+ name = note_data.name,
+ style = creative_mode_defines.names.gui_styles.cheat_note_label,
+ caption = note_data.caption,
+ })
+ end
+ end
+ end
+ end
+ end
end
--------------------------------------------------------------------
@@ -2648,433 +2632,421 @@ end
-- Returns the targets that are still being selected.
-- Note: the cheats status will not be updated.
local function update_targets_selection_for_player_in_outer_container(
- player,
- cheats_menu_gui_data,
- outer_container_data,
- outer_container
+ player,
+ cheats_menu_gui_data,
+ outer_container_data,
+ outer_container
)
- -- By update, we mean clear the whole target list and add back the valid targets.
-
- -- We will need the selected targets for setting the cheat status.
- local selected_targets = nil
- -- Targets scroll pane. Update only if there is the targets scroll pane.
- local current_structure_data = outer_container_data.targets_scroll_pane
- if current_structure_data then
- local targets_scroll_pane = outer_container[current_structure_data.name]
- selected_targets = {}
- -- Targets outer container.
- current_structure_data = current_structure_data.outer_container
- local targets_outer_container = targets_scroll_pane[current_structure_data.name]
- -- Targets inner container (vertical spacing doesn't work in frame).
- current_structure_data = current_structure_data.inner_container
- local targets_inner_container = targets_outer_container[current_structure_data.name]
- -- Update targets (A little bit different from creating the GUI).
- current_structure_data = current_structure_data.target_button
- local button_name_prefix = current_structure_data.name_prefix
- -- Get the buttons that are currently selected. We will keep selecting them after the target list is updated, so the user will not notice.
- local selected_buttons = {}
- for _, child_name in ipairs(targets_inner_container.children_names) do
- local button = targets_inner_container[child_name]
- local button_style_name = button.style.name
- if
- button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- or button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button
- then
- selected_buttons[button.name] = true
- end
- -- Also clear the buttons at the same time.
- button.destroy()
- end
- -- Add back the targets.
- -- We will need the number of valid options for determining whether the target selection scroll pane should be shown or hidden.
- local valid_target_count = 0
- -- Get targets.
- local unverified_target_list, single_target = cheats_menu_gui_data.get_unverified_targets_function(player)
- -- Unverified target list.
- if unverified_target_list then
- for _, target in pairs(unverified_target_list) do
- -- Exclude invalid targets.
- if cheats_menu_gui_data.verify_target_function(player, target) then
- local button, is_self = add_target_button_in_targets_inner_container_for_player(
- player,
- target,
- cheats_menu_gui_data,
- targets_inner_container,
- button_name_prefix
- )
- if cheats_menu_gui_data.check_is_target_button_valid_function(player, target, button) then
- valid_target_count = valid_target_count + 1
- end
- -- Check whether the button should be selected.
- if selected_buttons[button.name] then
- table.insert(selected_targets, target)
- if is_self then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- else
- button.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
- end
- else
- if is_self then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- else
- button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- end
- end
- end
- end
- end
- -- Single, verified target.
- if single_target then
- local button, is_self = add_target_button_in_targets_inner_container_for_player(
- player,
- single_target,
- cheats_menu_gui_data,
- targets_inner_container,
- button_name_prefix
- )
- if cheats_menu_gui_data.check_is_target_button_valid_function(player, single_target, button) then
- valid_target_count = valid_target_count + 1
- end
- -- Check whether the button should be selected.
- -- If there is only one valid target, make sure this target is selected.
- if selected_buttons[button.name] or valid_target_count <= 1 then
- table.insert(selected_targets, single_target)
- if is_self then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- else
- button.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
- end
- else
- if is_self then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- else
- button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- end
- end
- end
- -- Show or hide the target selection scroll pane according to the number of valid options.
- show_or_hide_targets_selection(outer_container, targets_scroll_pane, valid_target_count > 1)
- end
- return selected_targets
+ -- By update, we mean clear the whole target list and add back the valid targets.
+
+ -- We will need the selected targets for setting the cheat status.
+ local selected_targets = nil
+ -- Targets scroll pane. Update only if there is the targets scroll pane.
+ local current_structure_data = outer_container_data.targets_scroll_pane
+ if current_structure_data then
+ local targets_scroll_pane = outer_container[current_structure_data.name]
+ selected_targets = {}
+ -- Targets outer container.
+ current_structure_data = current_structure_data.outer_container
+ local targets_outer_container = targets_scroll_pane[current_structure_data.name]
+ -- Targets inner container (vertical spacing doesn't work in frame).
+ current_structure_data = current_structure_data.inner_container
+ local targets_inner_container = targets_outer_container[current_structure_data.name]
+ -- Update targets (A little bit different from creating the GUI).
+ current_structure_data = current_structure_data.target_button
+ local button_name_prefix = current_structure_data.name_prefix
+ -- Get the buttons that are currently selected. We will keep selecting them after the target list is updated, so the user will not notice.
+ local selected_buttons = {}
+ for _, child_name in ipairs(targets_inner_container.children_names) do
+ local button = targets_inner_container[child_name]
+ local button_style_name = button.style.name
+ if
+ button_style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ or button_style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ then
+ selected_buttons[button.name] = true
+ end
+ -- Also clear the buttons at the same time.
+ button.destroy()
+ end
+ -- Add back the targets.
+ -- We will need the number of valid options for determining whether the target selection scroll pane should be shown or hidden.
+ local valid_target_count = 0
+ -- Get targets.
+ local unverified_target_list, single_target = cheats_menu_gui_data.get_unverified_targets_function(player)
+ -- Unverified target list.
+ if unverified_target_list then
+ for _, target in pairs(unverified_target_list) do
+ -- Exclude invalid targets.
+ if cheats_menu_gui_data.verify_target_function(player, target) then
+ local button, is_self = add_target_button_in_targets_inner_container_for_player(
+ player,
+ target,
+ cheats_menu_gui_data,
+ targets_inner_container,
+ button_name_prefix
+ )
+ if cheats_menu_gui_data.check_is_target_button_valid_function(player, target, button) then
+ valid_target_count = valid_target_count + 1
+ end
+ -- Check whether the button should be selected.
+ if selected_buttons[button.name] then
+ table.insert(selected_targets, target)
+ if is_self then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ else
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ end
+ else
+ if is_self then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ else
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ end
+ end
+ end
+ end
+ end
+ -- Single, verified target.
+ if single_target then
+ local button, is_self = add_target_button_in_targets_inner_container_for_player(
+ player,
+ single_target,
+ cheats_menu_gui_data,
+ targets_inner_container,
+ button_name_prefix
+ )
+ if cheats_menu_gui_data.check_is_target_button_valid_function(player, single_target, button) then
+ valid_target_count = valid_target_count + 1
+ end
+ -- Check whether the button should be selected.
+ -- If there is only one valid target, make sure this target is selected.
+ if selected_buttons[button.name] or valid_target_count <= 1 then
+ table.insert(selected_targets, single_target)
+ if is_self then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ else
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ end
+ else
+ if is_self then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ else
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ end
+ end
+ end
+ -- Show or hide the target selection scroll pane according to the number of valid options.
+ show_or_hide_targets_selection(outer_container, targets_scroll_pane, valid_target_count > 1)
+ end
+ return selected_targets
end
-- Updates the target list of the cheats menu of given cheats menu GUI data for the given player, then also updates all cheats status in that cheats menu.
-- Returns the targets that are still being selected.
local function update_targets_selection_and_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Cheats container.
- local cheats_menus_container = container[cheats_menu_gui_data.parent.get_container_name_function()]
- if cheats_menus_container then
- local current_structure_data = cheats_menu_gui_data.frame
- -- Frame.
- local frame = cheats_menus_container[current_structure_data.name]
- if frame then
- -- Outer container.
- local outer_container_data = current_structure_data.outer_container
- local outer_container = frame[outer_container_data.name]
- local selected_targets = update_targets_selection_for_player_in_outer_container(
- player,
- cheats_menu_gui_data,
- outer_container_data,
- outer_container
- )
- update_all_cheats_status_in_cheats_menu_for_player_with_known_targets(
- player,
- cheats_menu_gui_data,
- selected_targets
- )
- end
- end
- end
- return nil
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Cheats container.
+ local cheats_menus_container = container[cheats_menu_gui_data.parent.get_container_name_function()]
+ if cheats_menus_container then
+ local current_structure_data = cheats_menu_gui_data.frame
+ -- Frame.
+ local frame = cheats_menus_container[current_structure_data.name]
+ if frame then
+ -- Outer container.
+ local outer_container_data = current_structure_data.outer_container
+ local outer_container = frame[outer_container_data.name]
+ local selected_targets = update_targets_selection_for_player_in_outer_container(
+ player,
+ cheats_menu_gui_data,
+ outer_container_data,
+ outer_container
+ )
+ update_all_cheats_status_in_cheats_menu_for_player_with_known_targets(
+ player,
+ cheats_menu_gui_data,
+ selected_targets
+ )
+ end
+ end
+ end
+ return nil
end
-- Updates the cheats menu accessibility according to the newest access right for the given player after the access rights of the given codes have changed.
function gui_menu_cheats.update_menu_accessibility_according_to_access_right_for_player(
- player,
- updated_access_right_codes
+ player,
+ updated_access_right_codes
)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Cheats container.
- local cheats_menus_container = container[gui_menu_cheats.get_container_name()]
- if cheats_menus_container then
- -- Iterate all submenus.
- for _, data in pairs(cheats_menus_gui_data.contents) do
- if updated_access_right_codes[data.access_right_code] then
- -- Check player access right.
- if data.get_player_can_access_function(player) then
- -- Player can access.
- -- Make sure the button is available for the player.
- local cheats_menu_frame =
- cheats_menus_container[creative_mode_defines.names.gui.cheats_menu_frame]
- local button = cheats_menu_frame[data.button_name]
- button.visible = true
-
- -- Update the targets and contents.
- local cheats_menu_gui_data = data.cheats_menu_gui_data
- local current_structure_data = cheats_menu_gui_data.frame
-
- -- Frame.
- local frame = cheats_menus_container[current_structure_data.name]
- -- Make sure the frame is currently being opened.
- if frame then
- -- Outer container.
- local outer_container_data = current_structure_data.outer_container
- local outer_container = frame[outer_container_data.name]
- -------
- -- Update targets (A little bit different from creating the GUI).
- local selected_targets = update_targets_selection_for_player_in_outer_container(
- player,
- cheats_menu_gui_data,
- outer_container_data,
- outer_container
- )
- -------
- -- Cheats scorll pane.
- current_structure_data = outer_container_data.cheats_scroll_pane
- local cheats_scroll_pane = outer_container[current_structure_data.name]
- -- Cheats container.
- current_structure_data = outer_container_data.cheats_container
- local cheats_container = outer_container[current_structure_data.name]
- -- Cheats.
- for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
- gui_menu_cheats.update_cheat_status_from_data(
- cheats_container,
- cheat_gui_data,
- selected_targets
- )
- update_cheat_visibility_from_data_for_player(player, cheats_container, cheat_gui_data)
- end
- end
- else
- -- Player cannot access.
- -- Hide the menu button.
- local cheats_menu_frame =
- cheats_menus_container[creative_mode_defines.names.gui.cheats_menu_frame]
- local button = cheats_menu_frame[data.button_name]
- button.visible = false
-
- -- Remove the menu.
- create_or_destroy_cheats_menu_for_player(player, data.cheats_menu_gui_data, true)
- end
- end
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Cheats container.
+ local cheats_menus_container = container[gui_menu_cheats.get_container_name()]
+ if cheats_menus_container then
+ -- Iterate all submenus.
+ for _, data in pairs(cheats_menus_gui_data.contents) do
+ if updated_access_right_codes[data.access_right_code] then
+ -- Check player access right.
+ if data.get_player_can_access_function(player) then
+ -- Player can access.
+ -- Make sure the button is available for the player.
+ local cheats_menu_frame = cheats_menus_container[creative_mode_defines.names.gui.cheats_menu_frame]
+ local button = cheats_menu_frame[data.button_name]
+ button.visible = true
+
+ -- Update the targets and contents.
+ local cheats_menu_gui_data = data.cheats_menu_gui_data
+ local current_structure_data = cheats_menu_gui_data.frame
+
+ -- Frame.
+ local frame = cheats_menus_container[current_structure_data.name]
+ -- Make sure the frame is currently being opened.
+ if frame then
+ -- Outer container.
+ local outer_container_data = current_structure_data.outer_container
+ local outer_container = frame[outer_container_data.name]
+ -------
+ -- Update targets (A little bit different from creating the GUI).
+ local selected_targets = update_targets_selection_for_player_in_outer_container(
+ player,
+ cheats_menu_gui_data,
+ outer_container_data,
+ outer_container
+ )
+ -------
+ -- Cheats scorll pane.
+ current_structure_data = outer_container_data.cheats_scroll_pane
+ local cheats_scroll_pane = outer_container[current_structure_data.name]
+ -- Cheats container.
+ current_structure_data = outer_container_data.cheats_container
+ local cheats_container = outer_container[current_structure_data.name]
+ -- Cheats.
+ for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, selected_targets)
+ update_cheat_visibility_from_data_for_player(player, cheats_container, cheat_gui_data)
+ end
+ end
+ else
+ -- Player cannot access.
+ -- Hide the menu button.
+ local cheats_menu_frame = cheats_menus_container[creative_mode_defines.names.gui.cheats_menu_frame]
+ local button = cheats_menu_frame[data.button_name]
+ button.visible = false
+
+ -- Remove the menu.
+ create_or_destroy_cheats_menu_for_player(player, data.cheats_menu_gui_data, true)
+ end
+ end
+ end
+ end
+ end
end
-- Updates the build options menu accessibility according to the newest access right for the given player after the access rights of the given codes have changed.
function gui_menu_buildoptions.update_menu_accessibility_according_to_access_right_for_player(
- player,
- updated_access_right_codes
+ player,
+ updated_access_right_codes
)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Cheats container.
- local cheats_menus_container = container[gui_menu_buildoptions.get_container_name()]
- if cheats_menus_container then
- -- Iterate all submenus.
- for _, data in pairs(build_options_menus_gui_data.contents) do
- if updated_access_right_codes[data.access_right_code] then
- -- Update the targets and contents.
- local cheats_menu_gui_data = data.cheats_menu_gui_data
- local current_structure_data = cheats_menu_gui_data.frame
-
- -- Frame.
- local frame = cheats_menus_container[current_structure_data.name]
- -- Make sure the frame is currently being opened.
- if frame then
- -- Outer container.
- local outer_container_data = current_structure_data.outer_container
- local outer_container = frame[outer_container_data.name]
- -------
- -- Update targets (A little bit different from creating the GUI).
- local selected_targets = update_targets_selection_for_player_in_outer_container(
- player,
- cheats_menu_gui_data,
- outer_container_data,
- outer_container
- )
- -------
- -- Cheats scorll pane.
- current_structure_data = outer_container_data.cheats_scroll_pane
- local cheats_scroll_pane = outer_container[current_structure_data.name]
- -- Cheats container.
- current_structure_data = current_structure_data.cheats_container
- local cheats_container = cheats_scroll_pane[current_structure_data.name]
- -- Cheats.
- for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
- gui_menu_cheats.update_cheat_status_from_data(
- cheats_container,
- cheat_gui_data,
- selected_targets
- )
- update_cheat_visibility_from_data_for_player(player, cheats_container, cheat_gui_data)
- end
- end
- end
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Cheats container.
+ local cheats_menus_container = container[gui_menu_buildoptions.get_container_name()]
+ if cheats_menus_container then
+ -- Iterate all submenus.
+ for _, data in pairs(build_options_menus_gui_data.contents) do
+ if updated_access_right_codes[data.access_right_code] then
+ -- Update the targets and contents.
+ local cheats_menu_gui_data = data.cheats_menu_gui_data
+ local current_structure_data = cheats_menu_gui_data.frame
+
+ -- Frame.
+ local frame = cheats_menus_container[current_structure_data.name]
+ -- Make sure the frame is currently being opened.
+ if frame then
+ -- Outer container.
+ local outer_container_data = current_structure_data.outer_container
+ local outer_container = frame[outer_container_data.name]
+ -------
+ -- Update targets (A little bit different from creating the GUI).
+ local selected_targets = update_targets_selection_for_player_in_outer_container(
+ player,
+ cheats_menu_gui_data,
+ outer_container_data,
+ outer_container
+ )
+ -------
+ -- Cheats scorll pane.
+ current_structure_data = outer_container_data.cheats_scroll_pane
+ local cheats_scroll_pane = outer_container[current_structure_data.name]
+ -- Cheats container.
+ current_structure_data = current_structure_data.cheats_container
+ local cheats_container = cheats_scroll_pane[current_structure_data.name]
+ -- Cheats.
+ for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, selected_targets)
+ update_cheat_visibility_from_data_for_player(player, cheats_container, cheat_gui_data)
+ end
+ end
+ end
+ end
+ end
+ end
end
--------------------------------------------------------------------
-- Creates the build options menu for the given player. If the meun already exists, it will be destroyed instead.
function gui_menu_buildoptions.create_or_destroy_menu_for_player(player)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Build options container.
- local build_options_menus_container = container[gui_menu_buildoptions.get_container_name()]
- if build_options_menus_container then
- build_options_menus_container.destroy()
- else
- build_options_menus_container = container.add({
- type = "flow",
- name = gui_menu_buildoptions.get_container_name(),
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- direction = "horizontal",
- })
-
- -- Create the build options menu by calling the same method for creating cheats menu.
- create_or_destroy_cheats_menu_for_player(
- player,
- build_options_menus_gui_data.contents.build_options.cheats_menu_gui_data,
- false
- )
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Build options container.
+ local build_options_menus_container = container[gui_menu_buildoptions.get_container_name()]
+ if build_options_menus_container then
+ build_options_menus_container.destroy()
+ else
+ build_options_menus_container = container.add({
+ type = "flow",
+ name = gui_menu_buildoptions.get_container_name(),
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ direction = "horizontal",
+ })
+
+ -- Create the build options menu by calling the same method for creating cheats menu.
+ create_or_destroy_cheats_menu_for_player(
+ player,
+ build_options_menus_gui_data.contents.build_options.cheats_menu_gui_data,
+ false
+ )
+ end
+ end
end
--------------------------------------------------------------------
-- Returns the style for the given cheat target selection button after it is clicked.
local function get_reversed_cheat_target_selection_button_style(button)
- local style_name = button.style.name
- if style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
- return creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button then
- return creative_mode_defines.names.gui_styles.cheat_target_selected_button
- elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
- return creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- else
- return creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- end
+ local style_name = button.style.name
+ if style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
+ return creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button then
+ return creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
+ return creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ else
+ return creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ end
end
-- Returns the current numeric value for the given numeric cheat according to the cheat's textfield.
-- If the value is not valid, the textfield will be reset to the given default value.
local function get_numeric_cheat_textfield_value(player, cheats_menu_gui_data, cheat_gui_data, default_value)
- local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if cheats_container then
- -- Container
- local cheat_container = cheats_container[cheat_gui_data.container_name]
- -- Textfield
- local textfield = cheat_container[cheat_gui_data.textfield_name]
- local value = tonumber(textfield.text)
- if value then
- return value
- else
- value = default_value
- textfield.text = tostring(value)
- end
- end
- return default_value
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if cheats_container then
+ -- Container
+ local cheat_container = cheats_container[cheat_gui_data.container_name]
+ -- Textfield
+ local textfield = cheat_container[cheat_gui_data.textfield_name]
+ local value = tonumber(textfield.text)
+ if value then
+ return value
+ else
+ value = default_value
+ textfield.text = tostring(value)
+ end
+ end
+ return default_value
end
-- Returns the current string value for the given string cheat according to the cheat's textfield.
-- If the value is not valid, the textfield will be reset to the given default value.
local function get_string_cheat_textfield_value(player, cheats_menu_gui_data, cheat_gui_data, default_value)
- local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if cheats_container then
- -- Container
- local cheat_container = cheats_container[cheat_gui_data.container_name]
- -- Textfield
- local textfield = cheat_container[cheat_gui_data.textfield_name]
- local value = tostring(textfield.text)
- if value then
- return value
- else
- value = default_value
- textfield.text = tostring(value)
- end
- end
- return default_value
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if cheats_container then
+ -- Container
+ local cheat_container = cheats_container[cheat_gui_data.container_name]
+ -- Textfield
+ local textfield = cheat_container[cheat_gui_data.textfield_name]
+ local value = tostring(textfield.text)
+ if value then
+ return value
+ else
+ value = default_value
+ textfield.text = tostring(value)
+ end
+ end
+ return default_value
end
--------------------------------------------------------------------
-- Updates the status of all character cheats for all players as the given player has updated his cheat status.
function gui_menu_cheats.update_character_cheats_status_for_all_players_as_player_updated_his_status(changed_player)
- for _, player in pairs(game.players) do
- local targets =
- get_all_selected_targets_in_cheats_menu_for_player(player, personal_cheats_menu_gui_data, changed_player)
- if targets then
- local cheats_container =
- get_cheats_container_in_cheats_menu_for_player(player, personal_cheats_menu_gui_data)
- if cheats_container then
- for _, cheat_gui_data in pairs(personal_cheats_menu_gui_data.cheats_gui_data) do
- if cheat_gui_data.is_character_cheat then
- gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- end
- end
- end
- end
- end
+ for _, player in pairs(game.players) do
+ local targets =
+ get_all_selected_targets_in_cheats_menu_for_player(player, personal_cheats_menu_gui_data, changed_player)
+ if targets then
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, personal_cheats_menu_gui_data)
+ if cheats_container then
+ for _, cheat_gui_data in pairs(personal_cheats_menu_gui_data.cheats_gui_data) do
+ if cheat_gui_data.is_character_cheat then
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ end
+ end
+ end
+ end
+ end
end
-- Updates the status of all daytime cheats for all players as the given surface has updated its daytime.
function gui_menu_cheats.update_daytime_cheats_status_for_all_players_as_surface_updated_its_daytime(changed_surface)
- for _, player in pairs(game.players) do
- local targets =
- get_all_selected_targets_in_cheats_menu_for_player(player, surface_cheats_menu_gui_data, changed_surface)
- if targets then
- local cheats_container =
- get_cheats_container_in_cheats_menu_for_player(player, surface_cheats_menu_gui_data)
- if cheats_container then
- for _, cheat_gui_data in pairs(surface_cheats_menu_gui_data.cheats_gui_data) do
- if cheat_gui_data.is_daytime_cheat then
- gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
- end
- end
- end
- end
- end
+ for _, player in pairs(game.players) do
+ local targets =
+ get_all_selected_targets_in_cheats_menu_for_player(player, surface_cheats_menu_gui_data, changed_surface)
+ if targets then
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, surface_cheats_menu_gui_data)
+ if cheats_container then
+ for _, cheat_gui_data in pairs(surface_cheats_menu_gui_data.cheats_gui_data) do
+ if cheat_gui_data.is_daytime_cheat then
+ gui_menu_cheats.update_cheat_status_from_data(cheats_container, cheat_gui_data, targets)
+ end
+ end
+ end
+ end
+ end
end
--------------------------------------------------------------------
-- Updates GUI when a player joined the game.
function gui_menu_cheats.on_player_joined_game(event)
- local player = game.players[event.player_index]
- -- Add the player as an option in personal cheats menu.
- add_or_remove_target_in_cheats_menu_for_all_players(player, personal_cheats_menu_gui_data, true)
- -- Add the player as an option in build cheats menu.
- add_or_remove_target_in_cheats_menu_for_all_players(player, build_options_menu_gui_data, true)
+ local player = game.players[event.player_index]
+ -- Add the player as an option in personal cheats menu.
+ add_or_remove_target_in_cheats_menu_for_all_players(player, personal_cheats_menu_gui_data, true)
+ -- Add the player as an option in build cheats menu.
+ add_or_remove_target_in_cheats_menu_for_all_players(player, build_options_menu_gui_data, true)
end
-- Updates GUI when a player left the game.
function gui_menu_cheats.on_player_left_game(event)
- local player = game.players[event.player_index]
- -- Remove the player as an option in personal cheats menu.
- add_or_remove_target_in_cheats_menu_for_all_players(player, personal_cheats_menu_gui_data, false)
- -- Remove the player as an option in build cheats menu.
- add_or_remove_target_in_cheats_menu_for_all_players(player, build_options_menu_gui_data, false)
+ local player = game.players[event.player_index]
+ -- Remove the player as an option in personal cheats menu.
+ add_or_remove_target_in_cheats_menu_for_all_players(player, personal_cheats_menu_gui_data, false)
+ -- Remove the player as an option in build cheats menu.
+ add_or_remove_target_in_cheats_menu_for_all_players(player, build_options_menu_gui_data, false)
end
-- Updates GUI when a player went to another surface.
function gui_menu_cheats.on_player_changed_surface(event)
- -- Update the target list and cheats status in surface cheats menu.
- update_targets_selection_and_all_cheats_status_in_cheats_menu_for_player(
- game.players[event.player_index],
- surface_cheats_menu_gui_data
- )
+ -- Update the target list and cheats status in surface cheats menu.
+ update_targets_selection_and_all_cheats_status_in_cheats_menu_for_player(
+ game.players[event.player_index],
+ surface_cheats_menu_gui_data
+ )
end
-- Detects on_gui_click event on the toggles of the cheats menu of given cheats menu GUI data for the given player.
@@ -3085,726 +3057,630 @@ end
-- @param pre_applied_function Optional. This function is called after a button of a cheat GUI data is clicked, but before it is applied. It contains the targets, cheat GUI data as well as the applied value.
-- It is useful for accessing data of entities before they are destroyed by the cheat.
function gui_menu_cheats.on_gui_click_in_cheats_menu_toggles(
- element,
- element_name,
- player,
- cheats_menu_gui_data,
- pre_applied_function
+ element,
+ element_name,
+ player,
+ cheats_menu_gui_data,
+ pre_applied_function
)
- for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
- local applied_cheat_gui_data = nil
- local applied_value = nil
- if cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.on_off then
- -- On/off cheats.
- if element_name == cheat_gui_data.on_button_name then
- -- On
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- -- Apply only if there is any target.
- if targets and #targets > 0 then
- applied_cheat_gui_data = cheat_gui_data
- applied_value = true
- if pre_applied_function then
- pre_applied_function(targets, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- targets,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- true,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- else
- applied_cheat_gui_data = cheat_gui_data
- applied_value = true
- if pre_applied_function then
- pre_applied_function(nil, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- nil,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- true,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- return true, applied_cheat_gui_data, applied_value
- end
-
- if element_name == cheat_gui_data.off_button_name then
- -- Off
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- -- Apply only if there is any target.
- if targets and #targets > 0 then
- applied_cheat_gui_data = cheat_gui_data
- applied_value = false
- if pre_applied_function then
- pre_applied_function(targets, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- targets,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- false,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- else
- applied_cheat_gui_data = cheat_gui_data
- applied_value = false
- if pre_applied_function then
- pre_applied_function(nil, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- nil,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- false,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- return true, applied_cheat_gui_data, applied_value
- end
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.numeric_apply then
- -- Numeric apply cheats.
- if element_name == cheat_gui_data.apply_button_name then
- -- Apply
- local current_value = get_numeric_cheat_textfield_value(player, cheats_menu_gui_data, cheat_gui_data, 0)
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- -- Apply only if there is any target.
- if targets and #targets > 0 and current_value ~= nil then
- applied_cheat_gui_data = cheat_gui_data
- applied_value = current_value
- if pre_applied_function then
- pre_applied_function(targets, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- targets,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- current_value,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- else
- applied_cheat_gui_data = cheat_gui_data
- applied_value = current_value
- if pre_applied_function then
- pre_applied_function(nil, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- nil,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- current_value,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- return true, applied_cheat_gui_data, applied_value
- end
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.string_apply then
- -- String apply cheats.
- if element_name == cheat_gui_data.apply_button_name then
- -- Apply
- local current_value = get_string_cheat_textfield_value(player, cheats_menu_gui_data, cheat_gui_data, "")
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- -- Apply only if there is any target.
- if targets and #targets > 0 and current_value ~= nil then
- applied_cheat_gui_data = cheat_gui_data
- applied_value = current_value
- if pre_applied_function then
- pre_applied_function(targets, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- targets,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- current_value,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- else
- applied_cheat_gui_data = cheat_gui_data
- applied_value = current_value
- if pre_applied_function then
- pre_applied_function(nil, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- nil,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- current_value,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- return true, applied_cheat_gui_data, applied_value
- end
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.apply then
- -- Apply cheats.
- if element_name == cheat_gui_data.apply_button_name then
- -- Apply
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- -- Apply only if there is any target.
- if targets and #targets > 0 then
- applied_cheat_gui_data = cheat_gui_data
- if pre_applied_function then
- pre_applied_function(targets, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- targets,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- nil,
- true
- )
- end
- else
- applied_cheat_gui_data = cheat_gui_data
- if pre_applied_function then
- pre_applied_function(nil, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- nil,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- nil,
- true
- )
- end
- return true, applied_cheat_gui_data, nil
- end
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.team_target_auto_apply then
- -- Team target auto apply cheats.
- if element_name == cheat_gui_data.current_selection_button_name then
- -- Current selectio button.
- local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- show_or_hide_team_target_auto_apply_cheat_drop_down_from_data(cheats_container, cheat_gui_data)
- return true
- elseif element.parent and element.parent.name == cheat_gui_data.drop_down_inner_flow_name then
- -- Drop down target selection button.
- local selected_team_name =
- string.match(element_name, cheat_gui_data.drop_down_selection_button_name_pattern)
- if selected_team_name then
- local selected_team = game.forces[selected_team_name]
- if selected_team then
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- local targets =
- get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- -- Apply only if there is any target.
- if targets and #targets > 0 then
- applied_cheat_gui_data = cheat_gui_data
- applied_value = selected_team_name
- if pre_applied_function then
- pre_applied_function(targets, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- targets,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- selected_team,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- else
- applied_cheat_gui_data = cheat_gui_data
- applied_value = selected_team_name
- if pre_applied_function then
- pre_applied_function(nil, applied_cheat_gui_data, applied_value)
- end
- cheats.apply_cheat_to_targets(
- player,
- nil,
- cheats_menu_gui_data.cheats_data,
- cheat_gui_data.cheat_data,
- selected_team,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- cheats_menu_gui_data,
- cheat_gui_data
- )
- end
- -- Hide the selection.
- local cheats_container =
- get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- show_or_hide_team_target_auto_apply_cheat_drop_down_from_data(cheats_container, cheat_gui_data)
- else
- -- Invalid team.
- element.destroy()
- end
- else
- -- Invalid team.
- element.destroy()
- end
- return true, applied_cheat_gui_data, applied_value
- end
- end
- end
-
- local enable_disable_all_container =
- cheats_menu_gui_data.frame.outer_container.cheats_scroll_pane.cheats_container.enable_disable_all_container
- if enable_disable_all_container then
- if element_name == enable_disable_all_container.enable_all_button_name then
- -- Enable all.
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if targets and #targets > 0 then
- cheats.enable_or_disable_all_cheats_to_targets(
- player,
- targets,
- cheats_menu_gui_data.cheats_data,
- true,
- true
- )
- update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data)
- end
- else
- cheats.enable_or_disable_all_cheats_to_targets(
- player,
- nil,
- cheats_menu_gui_data.cheats_data,
- true,
- true
- )
- update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data)
- end
- return true
- elseif element_name == enable_disable_all_container.disable_all_button_name then
- -- Disable all.
- if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
- local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if targets and #targets > 0 then
- cheats.enable_or_disable_all_cheats_to_targets(
- player,
- targets,
- cheats_menu_gui_data.cheats_data,
- false,
- true
- )
- update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data)
- end
- else
- cheats.enable_or_disable_all_cheats_to_targets(
- player,
- nil,
- cheats_menu_gui_data.cheats_data,
- false,
- true
- )
- update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data)
- end
- return true
- end
- end
-
- return false
+ for _, cheat_gui_data in pairs(cheats_menu_gui_data.cheats_gui_data) do
+ local applied_cheat_gui_data = nil
+ local applied_value = nil
+ if cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.on_off then
+ -- On/off cheats.
+ if element_name == cheat_gui_data.on_button_name then
+ -- On
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ -- Apply only if there is any target.
+ if targets and #targets > 0 then
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = true
+ if pre_applied_function then
+ pre_applied_function(targets, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ targets,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ true,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ else
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = true
+ if pre_applied_function then
+ pre_applied_function(nil, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ nil,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ true,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ return true, applied_cheat_gui_data, applied_value
+ end
+
+ if element_name == cheat_gui_data.off_button_name then
+ -- Off
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ -- Apply only if there is any target.
+ if targets and #targets > 0 then
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = false
+ if pre_applied_function then
+ pre_applied_function(targets, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ targets,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ false,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ else
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = false
+ if pre_applied_function then
+ pre_applied_function(nil, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ nil,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ false,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ return true, applied_cheat_gui_data, applied_value
+ end
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.numeric_apply then
+ -- Numeric apply cheats.
+ if element_name == cheat_gui_data.apply_button_name then
+ -- Apply
+ local current_value = get_numeric_cheat_textfield_value(player, cheats_menu_gui_data, cheat_gui_data, 0)
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ -- Apply only if there is any target.
+ if targets and #targets > 0 and current_value ~= nil then
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = current_value
+ if pre_applied_function then
+ pre_applied_function(targets, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ targets,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ current_value,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ else
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = current_value
+ if pre_applied_function then
+ pre_applied_function(nil, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ nil,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ current_value,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ return true, applied_cheat_gui_data, applied_value
+ end
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.string_apply then
+ -- String apply cheats.
+ if element_name == cheat_gui_data.apply_button_name then
+ -- Apply
+ local current_value = get_string_cheat_textfield_value(player, cheats_menu_gui_data, cheat_gui_data, "")
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ -- Apply only if there is any target.
+ if targets and #targets > 0 and current_value ~= nil then
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = current_value
+ if pre_applied_function then
+ pre_applied_function(targets, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ targets,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ current_value,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ else
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = current_value
+ if pre_applied_function then
+ pre_applied_function(nil, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ nil,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ current_value,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ return true, applied_cheat_gui_data, applied_value
+ end
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.apply then
+ -- Apply cheats.
+ if element_name == cheat_gui_data.apply_button_name then
+ -- Apply
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ -- Apply only if there is any target.
+ if targets and #targets > 0 then
+ applied_cheat_gui_data = cheat_gui_data
+ if pre_applied_function then
+ pre_applied_function(targets, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ targets,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ nil,
+ true
+ )
+ end
+ else
+ applied_cheat_gui_data = cheat_gui_data
+ if pre_applied_function then
+ pre_applied_function(nil, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ nil,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ nil,
+ true
+ )
+ end
+ return true, applied_cheat_gui_data, nil
+ end
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.team_target_auto_apply then
+ -- Team target auto apply cheats.
+ if element_name == cheat_gui_data.current_selection_button_name then
+ -- Current selectio button.
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ show_or_hide_team_target_auto_apply_cheat_drop_down_from_data(cheats_container, cheat_gui_data)
+ return true
+ elseif element.parent and element.parent.name == cheat_gui_data.drop_down_inner_flow_name then
+ -- Drop down target selection button.
+ local selected_team_name = string.match(element_name, cheat_gui_data.drop_down_selection_button_name_pattern)
+ if selected_team_name then
+ local selected_team = game.forces[selected_team_name]
+ if selected_team then
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ -- Apply only if there is any target.
+ if targets and #targets > 0 then
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = selected_team_name
+ if pre_applied_function then
+ pre_applied_function(targets, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ targets,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ selected_team,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ else
+ applied_cheat_gui_data = cheat_gui_data
+ applied_value = selected_team_name
+ if pre_applied_function then
+ pre_applied_function(nil, applied_cheat_gui_data, applied_value)
+ end
+ cheats.apply_cheat_to_targets(
+ player,
+ nil,
+ cheats_menu_gui_data.cheats_data,
+ cheat_gui_data.cheat_data,
+ selected_team,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(cheats_menu_gui_data, cheat_gui_data)
+ end
+ -- Hide the selection.
+ local cheats_container = get_cheats_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ show_or_hide_team_target_auto_apply_cheat_drop_down_from_data(cheats_container, cheat_gui_data)
+ else
+ -- Invalid team.
+ element.destroy()
+ end
+ else
+ -- Invalid team.
+ element.destroy()
+ end
+ return true, applied_cheat_gui_data, applied_value
+ end
+ end
+ end
+
+ local enable_disable_all_container =
+ cheats_menu_gui_data.frame.outer_container.cheats_scroll_pane.cheats_container.enable_disable_all_container
+ if enable_disable_all_container then
+ if element_name == enable_disable_all_container.enable_all_button_name then
+ -- Enable all.
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if targets and #targets > 0 then
+ cheats.enable_or_disable_all_cheats_to_targets(player, targets, cheats_menu_gui_data.cheats_data, true, true)
+ update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data)
+ end
+ else
+ cheats.enable_or_disable_all_cheats_to_targets(player, nil, cheats_menu_gui_data.cheats_data, true, true)
+ update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data)
+ end
+ return true
+ elseif element_name == enable_disable_all_container.disable_all_button_name then
+ -- Disable all.
+ if get_cheats_menu_has_targets_selection(cheats_menu_gui_data) then
+ local targets = get_all_selected_targets_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if targets and #targets > 0 then
+ cheats.enable_or_disable_all_cheats_to_targets(player, targets, cheats_menu_gui_data.cheats_data, false, true)
+ update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data)
+ end
+ else
+ cheats.enable_or_disable_all_cheats_to_targets(player, nil, cheats_menu_gui_data.cheats_data, false, true)
+ update_all_cheats_status_in_cheats_menu_for_all_players(cheats_menu_gui_data)
+ end
+ return true
+ end
+ end
+
+ return false
end
-- Detects on_gui_click event on the select-all-targets button of the cheats menu of given cheats menu GUI data for the given player.
local function on_gui_click_in_cheats_menu_select_all_button(element, element_name, player, cheats_menu_gui_data)
- local targets_scroll_pane_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane
- if targets_scroll_pane_data then
- if element_name == targets_scroll_pane_data.outer_container.inner_container.select_all_button.name then
- -- Select all targets button.
- local inner_container = get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if inner_container then
- -- Select all or deselect all?
- local deselect_all = true
- for _, child_name in ipairs(inner_container.children_names) do
- local button = inner_container[child_name]
- if cheats_menu_gui_data.check_is_target_button_valid_unknown_target_function(player, button) then
- local style_name = button.style.name
- if
- style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- or style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- then
- deselect_all = false
- break
- end
- end
- end
- -- Apply!
- for _, child_name in ipairs(inner_container.children_names) do
- local button = inner_container[child_name]
- if cheats_menu_gui_data.check_is_target_button_valid_unknown_target_function(player, button) then
- local style_name = button.style.name
- if deselect_all then
- -- Deselect all.
- if style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- elseif
- style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- then
- button.style =
- creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- end
- else
- -- Select all.
- if style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
- elseif
- style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- then
- button.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- end
- end
- end
- end
- -- Update cheats status.
- if deselect_all then
- update_all_cheats_status_in_cheats_menu_for_player_with_known_targets(
- player,
- cheats_menu_gui_data,
- nil
- )
- else
- update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- end
- end
- return true
- end
- end
+ local targets_scroll_pane_data = cheats_menu_gui_data.frame.outer_container.targets_scroll_pane
+ if targets_scroll_pane_data then
+ if element_name == targets_scroll_pane_data.outer_container.inner_container.select_all_button.name then
+ -- Select all targets button.
+ local inner_container = get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if inner_container then
+ -- Select all or deselect all?
+ local deselect_all = true
+ for _, child_name in ipairs(inner_container.children_names) do
+ local button = inner_container[child_name]
+ if cheats_menu_gui_data.check_is_target_button_valid_unknown_target_function(player, button) then
+ local style_name = button.style.name
+ if
+ style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ or style_name == creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ then
+ deselect_all = false
+ break
+ end
+ end
+ end
+ -- Apply!
+ for _, child_name in ipairs(inner_container.children_names) do
+ local button = inner_container[child_name]
+ if cheats_menu_gui_data.check_is_target_button_valid_unknown_target_function(player, button) then
+ local style_name = button.style.name
+ if deselect_all then
+ -- Deselect all.
+ if style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ end
+ else
+ -- Select all.
+ if style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button then
+ button.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ end
+ end
+ end
+ end
+ -- Update cheats status.
+ if deselect_all then
+ update_all_cheats_status_in_cheats_menu_for_player_with_known_targets(player, cheats_menu_gui_data, nil)
+ else
+ update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ end
+ end
+ return true
+ end
+ end
end
-- Detects on_gui_click event on the target buttons of the cheats menu of given cheats menu GUI data for the given player.
-- This is the last pass, meaning the element name detection can be complex, e.g. string pattern matching.
local function on_gui_click_in_cheats_menu_target_buttons(
- element,
- element_name,
- player,
- button,
- alt,
- control,
- shift,
- cheats_menu_gui_data
+ element,
+ element_name,
+ player,
+ button,
+ alt,
+ control,
+ shift,
+ cheats_menu_gui_data
)
- local inner_container = get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- if element.parent and element.parent == inner_container then
- if cheats_menu_gui_data.get_button_actual_target_function then
- local target = cheats_menu_gui_data.get_button_actual_target_function(player, element)
- if target then
- -- We need to know the index of the clicked target.
- local slot
- for index, children in ipairs(inner_container.children) do
- if children == element then
- slot = index
- break
- end
- end
-
- -- Ctrl-click?
- if control then
- -- Simply reverse the clicked target without caring other selected targets.
- element.style = get_reversed_cheat_target_selection_button_style(element)
- update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
-
- -- Record the slot for the next shift-click.
- storage.last_cheats_menu_gui_actions_by_players = storage.last_cheats_menu_gui_actions_by_players
- or {}
- storage.last_cheats_menu_gui_actions_by_players[player.index] = {
- non_shift = {
- slot = slot,
- },
- }
- return true
- end
-
- -- Shift-click?
- if shift then
- -- Select multiple targets and deselect the others.
- local non_shift_slot
- if
- storage.last_cheats_menu_gui_actions_by_players
- and storage.last_cheats_menu_gui_actions_by_players[player.index]
- and storage.last_cheats_menu_gui_actions_by_players[player.index].non_shift
- then
- non_shift_slot = storage.last_cheats_menu_gui_actions_by_players[player.index].non_shift.slot
- else
- -- In case there is no recorded non-shift-clicked slot, we make one.
- -- Find the first slot that has been selected. But assume we have the first slot first.
- non_shift_slot = 1
- for index, children in ipairs(inner_container.children) do
- local style_name = children.style.name
- if
- style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button
- or style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- then
- non_shift_slot = index
- break
- end
- end
- storage.last_cheats_menu_gui_actions_by_players = storage.last_cheats_menu_gui_actions_by_players
- or {}
- storage.last_cheats_menu_gui_actions_by_players[player.index] = {
- non_shift = {
- slot = non_shift_slot,
- },
- }
- end
-
- local min_slot, max_slot
- if slot < non_shift_slot then
- min_slot = slot
- max_slot = non_shift_slot
- else
- min_slot = non_shift_slot
- max_slot = slot
- end
-
- -- Select the buttons that are in range and deselect those that are not.
- for index, child in ipairs(inner_container.children) do
- local style = child.style
- local visible = visible
- if visible ~= false then
- local style_name = style.name
- if index >= min_slot and index <= max_slot then
- -- Select.
- if
- style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- then
- child.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
- elseif
- style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- then
- child.style =
- creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- end
- else
- -- Deselect.
- if
- style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button
- then
- child.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- elseif
- style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- then
- child.style =
- creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- end
- end
- end
- end
-
- -- Update cheats status.
- update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
- return true
- end
-
- -- No ctrl, no shift, deselect others and only select the clicked target.
- -- Deselect all.
- for index, child in ipairs(inner_container.children) do
- if child ~= element then
- if cheats_menu_gui_data.check_is_target_button_valid_unknown_target_function(player, child) then
- local style_name = child.style.name
- if style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
- child.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
- elseif
- style_name
- == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- then
- child.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
- end
- end
- end
- end
- -- Select the clicked target.
- local style_name = element.style.name
- if style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button then
- element.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
- elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button then
- element.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
- end
- -- Update cheats status.
- update_all_cheats_status_in_cheats_menu_for_player_with_known_targets(
- player,
- cheats_menu_gui_data,
- { target }
- )
-
- -- Record the slot for the next shift-click.
- storage.last_cheats_menu_gui_actions_by_players = storage.last_cheats_menu_gui_actions_by_players or {}
- storage.last_cheats_menu_gui_actions_by_players[player.index] = {
- non_shift = {
- slot = slot,
- },
- }
- return true
- end
- end
- end
- return false
+ local inner_container = get_targets_inner_container_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ if element.parent and element.parent == inner_container then
+ if cheats_menu_gui_data.get_button_actual_target_function then
+ local target = cheats_menu_gui_data.get_button_actual_target_function(player, element)
+ if target then
+ -- We need to know the index of the clicked target.
+ local slot
+ for index, children in ipairs(inner_container.children) do
+ if children == element then
+ slot = index
+ break
+ end
+ end
+
+ -- Ctrl-click?
+ if control then
+ -- Simply reverse the clicked target without caring other selected targets.
+ element.style = get_reversed_cheat_target_selection_button_style(element)
+ update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+
+ -- Record the slot for the next shift-click.
+ storage.last_cheats_menu_gui_actions_by_players = storage.last_cheats_menu_gui_actions_by_players or {}
+ storage.last_cheats_menu_gui_actions_by_players[player.index] = {
+ non_shift = {
+ slot = slot,
+ },
+ }
+ return true
+ end
+
+ -- Shift-click?
+ if shift then
+ -- Select multiple targets and deselect the others.
+ local non_shift_slot
+ if
+ storage.last_cheats_menu_gui_actions_by_players
+ and storage.last_cheats_menu_gui_actions_by_players[player.index]
+ and storage.last_cheats_menu_gui_actions_by_players[player.index].non_shift
+ then
+ non_shift_slot = storage.last_cheats_menu_gui_actions_by_players[player.index].non_shift.slot
+ else
+ -- In case there is no recorded non-shift-clicked slot, we make one.
+ -- Find the first slot that has been selected. But assume we have the first slot first.
+ non_shift_slot = 1
+ for index, children in ipairs(inner_container.children) do
+ local style_name = children.style.name
+ if
+ style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ or style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ then
+ non_shift_slot = index
+ break
+ end
+ end
+ storage.last_cheats_menu_gui_actions_by_players = storage.last_cheats_menu_gui_actions_by_players or {}
+ storage.last_cheats_menu_gui_actions_by_players[player.index] = {
+ non_shift = {
+ slot = non_shift_slot,
+ },
+ }
+ end
+
+ local min_slot, max_slot
+ if slot < non_shift_slot then
+ min_slot = slot
+ max_slot = non_shift_slot
+ else
+ min_slot = non_shift_slot
+ max_slot = slot
+ end
+
+ -- Select the buttons that are in range and deselect those that are not.
+ for index, child in ipairs(inner_container.children) do
+ local style = child.style
+ local visible = visible
+ if visible ~= false then
+ local style_name = style.name
+ if index >= min_slot and index <= max_slot then
+ -- Select.
+ if style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button then
+ child.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button then
+ child.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ end
+ else
+ -- Deselect.
+ if style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
+ child.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
+ child.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ end
+ end
+ end
+ end
+
+ -- Update cheats status.
+ update_all_cheats_status_in_cheats_menu_for_player(player, cheats_menu_gui_data)
+ return true
+ end
+
+ -- No ctrl, no shift, deselect others and only select the clicked target.
+ -- Deselect all.
+ for index, child in ipairs(inner_container.children) do
+ if child ~= element then
+ if cheats_menu_gui_data.check_is_target_button_valid_unknown_target_function(player, child) then
+ local style_name = child.style.name
+ if style_name == creative_mode_defines.names.gui_styles.cheat_target_selected_button then
+ child.style = creative_mode_defines.names.gui_styles.cheat_target_unselected_button
+ elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_selected_button then
+ child.style = creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button
+ end
+ end
+ end
+ end
+ -- Select the clicked target.
+ local style_name = element.style.name
+ if style_name == creative_mode_defines.names.gui_styles.cheat_target_unselected_button then
+ element.style = creative_mode_defines.names.gui_styles.cheat_target_selected_button
+ elseif style_name == creative_mode_defines.names.gui_styles.cheat_target_self_unselected_button then
+ element.style = creative_mode_defines.names.gui_styles.cheat_target_self_selected_button
+ end
+ -- Update cheats status.
+ update_all_cheats_status_in_cheats_menu_for_player_with_known_targets(player, cheats_menu_gui_data, { target })
+
+ -- Record the slot for the next shift-click.
+ storage.last_cheats_menu_gui_actions_by_players = storage.last_cheats_menu_gui_actions_by_players or {}
+ storage.last_cheats_menu_gui_actions_by_players[player.index] = {
+ non_shift = {
+ slot = slot,
+ },
+ }
+ return true
+ end
+ end
+ end
+ return false
end
-- Detects on_gui_click event in the contents of the given cheats / build-options menus GUI data for the given player.
local function on_gui_click_in_cheats_menus_gui_data_contents(
- element,
- element_name,
- player,
- button,
- alt,
- control,
- shift,
- menus_gui_data
+ element,
+ element_name,
+ player,
+ button,
+ alt,
+ control,
+ shift,
+ menus_gui_data
)
- for _, data in pairs(menus_gui_data.contents) do
- if
- gui_menu_cheats.on_gui_click_in_cheats_menu_toggles(
- element,
- element_name,
- player,
- data.cheats_menu_gui_data
- )
- then
- -- Cheat toggle.
- return true
- end
- end
-
- for _, data in pairs(menus_gui_data.contents) do
- local cheats_menu_gui_data = data.cheats_menu_gui_data
- if on_gui_click_in_cheats_menu_select_all_button(element, element_name, player, cheats_menu_gui_data) then
- -- Select-all-targets button.
- return true
- end
-
- if
- on_gui_click_in_cheats_menu_target_buttons(
- element,
- element_name,
- player,
- button,
- alt,
- control,
- shift,
- cheats_menu_gui_data
- )
- then
- -- Cheat target.
- return true
- end
- end
- return false
+ for _, data in pairs(menus_gui_data.contents) do
+ if
+ gui_menu_cheats.on_gui_click_in_cheats_menu_toggles(element, element_name, player, data.cheats_menu_gui_data)
+ then
+ -- Cheat toggle.
+ return true
+ end
+ end
+
+ for _, data in pairs(menus_gui_data.contents) do
+ local cheats_menu_gui_data = data.cheats_menu_gui_data
+ if on_gui_click_in_cheats_menu_select_all_button(element, element_name, player, cheats_menu_gui_data) then
+ -- Select-all-targets button.
+ return true
+ end
+
+ if
+ on_gui_click_in_cheats_menu_target_buttons(
+ element,
+ element_name,
+ player,
+ button,
+ alt,
+ control,
+ shift,
+ cheats_menu_gui_data
+ )
+ then
+ -- Cheat target.
+ return true
+ end
+ end
+ return false
end
-- Callback of the on_gui_click event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_cheats.on_gui_click(element, element_name, player, button, alt, control, shift)
- for _, data in pairs(cheats_menus_gui_data.contents) do
- if element_name == data.button_name then
- -- Cheats menu button.
- -- Close other menus.
- for _, data2 in pairs(cheats_menus_gui_data.contents) do
- if data ~= data2 then
- create_or_destroy_cheats_menu_for_player(player, data2.cheats_menu_gui_data, true)
- end
- end
- -- Open menu.
- create_or_destroy_cheats_menu_for_player(player, data.cheats_menu_gui_data, false)
- return true
- end
- end
-
- -- Detect for the cheats menus.
- if
- on_gui_click_in_cheats_menus_gui_data_contents(
- element,
- element_name,
- player,
- button,
- alt,
- control,
- shift,
- cheats_menus_gui_data
- )
- then
- return true
- end
-
- -- Detect for the build-options menus.
- if
- on_gui_click_in_cheats_menus_gui_data_contents(
- element,
- element_name,
- player,
- button,
- alt,
- control,
- shift,
- build_options_menus_gui_data
- )
- then
- return true
- end
-
- return false
+ for _, data in pairs(cheats_menus_gui_data.contents) do
+ if element_name == data.button_name then
+ -- Cheats menu button.
+ -- Close other menus.
+ for _, data2 in pairs(cheats_menus_gui_data.contents) do
+ if data ~= data2 then
+ create_or_destroy_cheats_menu_for_player(player, data2.cheats_menu_gui_data, true)
+ end
+ end
+ -- Open menu.
+ create_or_destroy_cheats_menu_for_player(player, data.cheats_menu_gui_data, false)
+ return true
+ end
+ end
+
+ -- Detect for the cheats menus.
+ if
+ on_gui_click_in_cheats_menus_gui_data_contents(
+ element,
+ element_name,
+ player,
+ button,
+ alt,
+ control,
+ shift,
+ cheats_menus_gui_data
+ )
+ then
+ return true
+ end
+
+ -- Detect for the build-options menus.
+ if
+ on_gui_click_in_cheats_menus_gui_data_contents(
+ element,
+ element_name,
+ player,
+ button,
+ alt,
+ control,
+ shift,
+ build_options_menus_gui_data
+ )
+ then
+ return true
+ end
+
+ return false
end
-- Callback of the on_gui_text_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_cheats.on_gui_text_changed(element, element_name, player)
- return false
+ return false
end
-- Callback of the on_gui_checked_state_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_cheats.on_gui_checked_state_changed(element, element_name, player)
- return false
+ return false
end
diff --git a/scripts/gui-menu-magicwand.lua b/scripts/gui-menu-magicwand.lua
index 177054a..7f2681c 100644
--- a/scripts/gui-menu-magicwand.lua
+++ b/scripts/gui-menu-magicwand.lua
@@ -2,7 +2,7 @@ local mod_gui = require("mod-gui")
-- This file contains variables and functions related to Creative Mode menu - magic wand GUI. The Modification popup for the Modifer magic wand is also included here.
if not gui_menu_magicwand then
- gui_menu_magicwand = {}
+ gui_menu_magicwand = {}
end
-- function gui_menu_magicwand.on_player_cursor_stack_changed(event)
@@ -14,1032 +14,1031 @@ end
-- Gets the name of the magic wand menu container.
function gui_menu_magicwand.get_container_name()
- return creative_mode_defines.names.gui.magic_wand_menus_container
+ return creative_mode_defines.names.gui.magic_wand_menus_container
end
----
-- The values of the resource amount slider buttons for the Creator magic wand.
local creator_resource_amount_slider_values =
- { 1, 2, 3, 5, 10, 100, 1000, 2000, 5000, 10000, 100000, 1000000, 10000000 }
+ { 1, 2, 3, 5, 10, 100, 1000, 2000, 5000, 10000, 100000, 1000000, 10000000 }
-- GUI data for each of the cheats on the modification popup, created by the Modifier magic wand.
gui_menu_magicwand.modification_popup_cheats_gui_data = {
- frame = {
- outer_container = {
- cheats_scroll_pane = {
- cheats_container = {
- enable_disable_all_container = nil,
- },
- },
- },
- },
- cheats_data = cheats.magic_wand_modifications,
- cheats_gui_data = {
- active = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.magic_wand_modifications.cheats.active,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_active_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_active_label,
- label_caption = { "gui.creative-mode_build-active" },
- label_tooltip = { "gui.creative-mode_build-active-tooltip" },
- on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_active_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_active_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- action_code = "active",
- action_caption = { "gui.creative-mode_quick-action-active" },
- close_popup_after_applied = false,
- },
- destructible = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.magic_wand_modifications.cheats.destructible,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_destructible_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_destructible_label,
- label_caption = { "gui.creative-mode_build-destructible" },
- label_tooltip = { "gui.creative-mode_build-destructible-tooltip" },
- on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_destructible_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_destructible_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- action_code = "destructible",
- action_caption = { "gui.creative-mode_quick-action-destructible" },
- close_popup_after_applied = false,
- },
- minable = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.magic_wand_modifications.cheats.minable,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_minable_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_minable_label,
- label_caption = { "gui.creative-mode_build-minable" },
- label_tooltip = { "gui.creative-mode_build-minable-tooltip" },
- on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_minable_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_minable_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- action_code = "minable",
- action_caption = { "gui.creative-mode_quick-action-active" },
- close_popup_after_applied = false,
- },
- rotatable = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.magic_wand_modifications.cheats.rotatable,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_rotatable_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_rotatable_label,
- label_caption = { "gui.creative-mode_build-rotatable" },
- label_tooltip = { "gui.creative-mode_build-rotatable-tooltip" },
- on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_rotatable_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_rotatable_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- action_code = "rotatable",
- action_caption = { "gui.creative-mode_quick-action-rotatable" },
- close_popup_after_applied = false,
- },
- operable = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.magic_wand_modifications.cheats.operable,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_operable_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_operable_label,
- label_caption = { "gui.creative-mode_build-operable" },
- label_tooltip = { "gui.creative-mode_build-operable-tooltip" },
- on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_operable_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_operable_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- action_code = "operable",
- action_caption = { "gui.creative-mode_quick-action-operable" },
- close_popup_after_applied = false,
- },
- full_health = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.magic_wand_modifications.cheats.full_health,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_full_health_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_full_health_label,
- label_caption = { "gui.creative-mode_build-full-health" },
- label_tooltip = { "gui.creative-mode_build-full-health-tooltip" },
- on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_full_health_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_full_health_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- action_code = "full-health",
- action_caption = { "gui.creative-mode_quick-action-full-health" },
- close_popup_after_applied = false,
- },
- backer_name = {
- type = gui_menu_cheats.cheat_gui_type.string_apply,
- cheat_data = cheats.magic_wand_modifications.cheats.backer_name,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_label,
- label_caption = { "gui.creative-mode_backer-name" },
- label_tooltip = nil,
- textfield_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_textfield,
- separator_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_separator,
- apply_button_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- action_code = "backer-name",
- action_caption = { "gui.creative-mode_backer-name" },
- close_popup_after_applied = false,
- },
- to_be_looted = {
- type = gui_menu_cheats.cheat_gui_type.on_off,
- cheat_data = cheats.magic_wand_modifications.cheats.to_be_looted,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_to_be_looted_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_to_be_looted_label,
- label_caption = { "gui.creative-mode_to-be-looted" },
- label_tooltip = { "gui.creative-mode_to-be-looted-tooltip" },
- on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_to_be_looted_on_button,
- on_button_caption = creative_mode_defines.names.gui_captions.on,
- off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_to_be_looted_off_button,
- off_button_caption = creative_mode_defines.names.gui_captions.off,
- action_code = "to-be-looted",
- action_caption = { "gui.creative-mode_quick-action-to-be-looted" },
- close_popup_after_applied = false,
- },
- revive = {
- type = gui_menu_cheats.cheat_gui_type.apply,
- cheat_data = cheats.magic_wand_modifications.cheats.revive,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_revive_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_revive_label,
- label_caption = { "gui.creative-mode_revive" },
- label_tooltip = { "gui.creative-mode_revive-tooltip" },
- apply_button_name = creative_mode_defines.names.gui.magic_wand_modifier_revive_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- action_code = "revive",
- action_caption = { "gui.creative-mode_quick-action-revive" },
- close_popup_after_applied = false,
- },
- kill = {
- type = gui_menu_cheats.cheat_gui_type.apply,
- cheat_data = cheats.magic_wand_modifications.cheats.kill,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_kill_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_kill_label,
- label_caption = { "gui.creative-mode_kill" },
- label_tooltip = nil,
- apply_button_name = creative_mode_defines.names.gui.magic_wand_modifier_kill_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- action_code = "kill",
- action_caption = { "gui.creative-mode_kill" },
- close_popup_after_applied = false,
- },
- destroy = {
- type = gui_menu_cheats.cheat_gui_type.apply,
- cheat_data = cheats.magic_wand_modifications.cheats.destroy,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_destroy_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_destroy_label,
- label_caption = { "gui.creative-mode_remove" },
- label_tooltip = nil,
- apply_button_name = creative_mode_defines.names.gui.magic_wand_modifier_destroy_apply_button,
- apply_button_caption = creative_mode_defines.names.gui_captions.ok,
- action_code = "destroy",
- action_caption = { "gui.creative-mode_remove" },
- close_popup_after_applied = true,
- },
- team = {
- type = gui_menu_cheats.cheat_gui_type.team_target_auto_apply,
- cheat_data = cheats.magic_wand_modifications.cheats.team,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_team_container,
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_team_label,
- label_caption = { "gui.creative-mode_build-team" },
- label_tooltip = { "gui.creative-mode_build-team-tooltip" },
- drop_down_container_name = creative_mode_defines.names.gui.magic_wand_modifier_team_targets_drop_down_container,
- current_selection_button_name = creative_mode_defines.names.gui.magic_wand_modifier_team_current_button,
- drop_down_scroll_pane_name = creative_mode_defines.names.gui.magic_wand_modifier_team_targets_scroll_pane,
- drop_down_inner_frame_name = creative_mode_defines.names.gui.magic_wand_modifier_team_targets_container,
- drop_down_inner_flow_name = creative_mode_defines.names.gui.magic_wand_modifier_team_targets_inner_container,
- drop_down_selection_button_name_prefx = creative_mode_defines.names.gui.magic_wand_modifier_team_target_name_button_prefix,
- drop_down_selection_button_name_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_team_target_name_button,
- action_code = "team",
- action_caption = { "gui.creative-mode_quick-action-team" },
- close_popup_after_applied = false,
- },
- },
- has_targets_selection = true,
- get_all_selected_targets_function = function(player)
- return storage.creative_mode.modifier_magic_wand_selection[player.index]
- end,
- get_cheats_container_function = function(player)
- local center = player.gui.center
- -- Container.
- local container = center[creative_mode_defines.names.gui.magic_wand_modifier_popup_container]
- if container then
- -- Actions frame.
- return container[creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame]
- end
- return nil
- end,
+ frame = {
+ outer_container = {
+ cheats_scroll_pane = {
+ cheats_container = {
+ enable_disable_all_container = nil,
+ },
+ },
+ },
+ },
+ cheats_data = cheats.magic_wand_modifications,
+ cheats_gui_data = {
+ active = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.magic_wand_modifications.cheats.active,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_active_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_active_label,
+ label_caption = { "gui.creative-mode_build-active" },
+ label_tooltip = { "gui.creative-mode_build-active-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_active_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_active_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ action_code = "active",
+ action_caption = { "gui.creative-mode_quick-action-active" },
+ close_popup_after_applied = false,
+ },
+ destructible = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.magic_wand_modifications.cheats.destructible,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_destructible_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_destructible_label,
+ label_caption = { "gui.creative-mode_build-destructible" },
+ label_tooltip = { "gui.creative-mode_build-destructible-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_destructible_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_destructible_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ action_code = "destructible",
+ action_caption = { "gui.creative-mode_quick-action-destructible" },
+ close_popup_after_applied = false,
+ },
+ minable = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.magic_wand_modifications.cheats.minable,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_minable_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_minable_label,
+ label_caption = { "gui.creative-mode_build-minable" },
+ label_tooltip = { "gui.creative-mode_build-minable-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_minable_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_minable_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ action_code = "minable",
+ action_caption = { "gui.creative-mode_quick-action-active" },
+ close_popup_after_applied = false,
+ },
+ rotatable = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.magic_wand_modifications.cheats.rotatable,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_rotatable_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_rotatable_label,
+ label_caption = { "gui.creative-mode_build-rotatable" },
+ label_tooltip = { "gui.creative-mode_build-rotatable-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_rotatable_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_rotatable_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ action_code = "rotatable",
+ action_caption = { "gui.creative-mode_quick-action-rotatable" },
+ close_popup_after_applied = false,
+ },
+ operable = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.magic_wand_modifications.cheats.operable,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_operable_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_operable_label,
+ label_caption = { "gui.creative-mode_build-operable" },
+ label_tooltip = { "gui.creative-mode_build-operable-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_operable_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_operable_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ action_code = "operable",
+ action_caption = { "gui.creative-mode_quick-action-operable" },
+ close_popup_after_applied = false,
+ },
+ full_health = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.magic_wand_modifications.cheats.full_health,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_full_health_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_full_health_label,
+ label_caption = { "gui.creative-mode_build-full-health" },
+ label_tooltip = { "gui.creative-mode_build-full-health-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_full_health_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_full_health_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ action_code = "full-health",
+ action_caption = { "gui.creative-mode_quick-action-full-health" },
+ close_popup_after_applied = false,
+ },
+ backer_name = {
+ type = gui_menu_cheats.cheat_gui_type.string_apply,
+ cheat_data = cheats.magic_wand_modifications.cheats.backer_name,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_label,
+ label_caption = { "gui.creative-mode_backer-name" },
+ label_tooltip = nil,
+ textfield_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_textfield,
+ separator_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_separator,
+ apply_button_name = creative_mode_defines.names.gui.magic_wand_modifier_backer_name_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ action_code = "backer-name",
+ action_caption = { "gui.creative-mode_backer-name" },
+ close_popup_after_applied = false,
+ },
+ to_be_looted = {
+ type = gui_menu_cheats.cheat_gui_type.on_off,
+ cheat_data = cheats.magic_wand_modifications.cheats.to_be_looted,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_to_be_looted_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_to_be_looted_label,
+ label_caption = { "gui.creative-mode_to-be-looted" },
+ label_tooltip = { "gui.creative-mode_to-be-looted-tooltip" },
+ on_button_name = creative_mode_defines.names.gui.magic_wand_modifier_to_be_looted_on_button,
+ on_button_caption = creative_mode_defines.names.gui_captions.on,
+ off_button_name = creative_mode_defines.names.gui.magic_wand_modifier_to_be_looted_off_button,
+ off_button_caption = creative_mode_defines.names.gui_captions.off,
+ action_code = "to-be-looted",
+ action_caption = { "gui.creative-mode_quick-action-to-be-looted" },
+ close_popup_after_applied = false,
+ },
+ revive = {
+ type = gui_menu_cheats.cheat_gui_type.apply,
+ cheat_data = cheats.magic_wand_modifications.cheats.revive,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_revive_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_revive_label,
+ label_caption = { "gui.creative-mode_revive" },
+ label_tooltip = { "gui.creative-mode_revive-tooltip" },
+ apply_button_name = creative_mode_defines.names.gui.magic_wand_modifier_revive_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ action_code = "revive",
+ action_caption = { "gui.creative-mode_quick-action-revive" },
+ close_popup_after_applied = false,
+ },
+ kill = {
+ type = gui_menu_cheats.cheat_gui_type.apply,
+ cheat_data = cheats.magic_wand_modifications.cheats.kill,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_kill_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_kill_label,
+ label_caption = { "gui.creative-mode_kill" },
+ label_tooltip = nil,
+ apply_button_name = creative_mode_defines.names.gui.magic_wand_modifier_kill_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ action_code = "kill",
+ action_caption = { "gui.creative-mode_kill" },
+ close_popup_after_applied = false,
+ },
+ destroy = {
+ type = gui_menu_cheats.cheat_gui_type.apply,
+ cheat_data = cheats.magic_wand_modifications.cheats.destroy,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_destroy_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_destroy_label,
+ label_caption = { "gui.creative-mode_remove" },
+ label_tooltip = nil,
+ apply_button_name = creative_mode_defines.names.gui.magic_wand_modifier_destroy_apply_button,
+ apply_button_caption = creative_mode_defines.names.gui_captions.ok,
+ action_code = "destroy",
+ action_caption = { "gui.creative-mode_remove" },
+ close_popup_after_applied = true,
+ },
+ team = {
+ type = gui_menu_cheats.cheat_gui_type.team_target_auto_apply,
+ cheat_data = cheats.magic_wand_modifications.cheats.team,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_team_container,
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_team_label,
+ label_caption = { "gui.creative-mode_build-team" },
+ label_tooltip = { "gui.creative-mode_build-team-tooltip" },
+ drop_down_container_name = creative_mode_defines.names.gui.magic_wand_modifier_team_targets_drop_down_container,
+ current_selection_button_name = creative_mode_defines.names.gui.magic_wand_modifier_team_current_button,
+ drop_down_scroll_pane_name = creative_mode_defines.names.gui.magic_wand_modifier_team_targets_scroll_pane,
+ drop_down_inner_frame_name = creative_mode_defines.names.gui.magic_wand_modifier_team_targets_container,
+ drop_down_inner_flow_name = creative_mode_defines.names.gui.magic_wand_modifier_team_targets_inner_container,
+ drop_down_selection_button_name_prefx = creative_mode_defines.names.gui.magic_wand_modifier_team_target_name_button_prefix,
+ drop_down_selection_button_name_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_team_target_name_button,
+ action_code = "team",
+ action_caption = { "gui.creative-mode_quick-action-team" },
+ close_popup_after_applied = false,
+ },
+ },
+ has_targets_selection = true,
+ get_all_selected_targets_function = function(player)
+ return storage.creative_mode.modifier_magic_wand_selection[player.index]
+ end,
+ get_cheats_container_function = function(player)
+ local center = player.gui.center
+ -- Container.
+ local container = center[creative_mode_defines.names.gui.magic_wand_modifier_popup_container]
+ if container then
+ -- Actions frame.
+ return container[creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame]
+ end
+ return nil
+ end,
}
-- Maps the action code to the corresponding cheat GUI data.
gui_menu_magicwand.action_code_to_cheat_gui_data = {}
for _, cheat_gui_data in pairs(gui_menu_magicwand.modification_popup_cheats_gui_data.cheats_gui_data) do
- gui_menu_magicwand.action_code_to_cheat_gui_data[cheat_gui_data.action_code] = cheat_gui_data
+ gui_menu_magicwand.action_code_to_cheat_gui_data[cheat_gui_data.action_code] = cheat_gui_data
end
----
-- Creates and returns the forces table for the given player in the given container.
local function create_forces_table(
- player,
- forces_table_container,
- forces_table_name,
- force_checkbox_name_prefix,
- get_force_checkbox_state_function,
- select_all_button_name
+ player,
+ forces_table_container,
+ forces_table_name,
+ force_checkbox_name_prefix,
+ get_force_checkbox_state_function,
+ select_all_button_name
)
- -- Force table.
- local force_table = forces_table_container.add({
- type = "table",
- name = forces_table_name,
- column_count = 1,
- })
- -- Forces.
- for _, force in pairs(game.forces) do
- force_table.add({
- type = "checkbox",
- name = force_checkbox_name_prefix .. force.name,
- caption = force.name,
- tooltip = { "gui.creative-mode_team-name-tooltip", force.name },
- state = get_force_checkbox_state_function(player, force),
- })
- end
- -- Select all button.
- force_table.add({
- type = "button",
- name = select_all_button_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_select_all_button,
- caption = creative_mode_defines.names.gui_captions.select_all,
- })
- return force_table
+ -- Force table.
+ local force_table = forces_table_container.add({
+ type = "table",
+ name = forces_table_name,
+ column_count = 1,
+ })
+ -- Forces.
+ for _, force in pairs(game.forces) do
+ force_table.add({
+ type = "checkbox",
+ name = force_checkbox_name_prefix .. force.name,
+ caption = force.name,
+ tooltip = { "gui.creative-mode_team-name-tooltip", force.name },
+ state = get_force_checkbox_state_function(player, force),
+ })
+ end
+ -- Select all button.
+ force_table.add({
+ type = "button",
+ name = select_all_button_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_select_all_button,
+ caption = creative_mode_defines.names.gui_captions.select_all,
+ })
+ return force_table
end
-- Function for creating tile or resource selection UI elements for the Creator magic wand.
local function create_tile_or_resource_selection_for_creator(
- player,
- container,
- get_selected_tile_prototype_function,
- tiles_table_name,
- tile_name_button_prefix,
- get_selected_resource_prototype_function,
- resources_table_name,
- resource_name_button_prefix,
- get_resource_amount_function,
- resource_amount_slider_container_name,
- resource_amount_slider_label_name,
- resource_amount_slider_space_name,
- resource_amount_slider_button_name_prefix,
- resource_amount_slider_space_2_name,
- resource_amount_slider_textfield_name
+ player,
+ container,
+ get_selected_tile_prototype_function,
+ tiles_table_name,
+ tile_name_button_prefix,
+ get_selected_resource_prototype_function,
+ resources_table_name,
+ resource_name_button_prefix,
+ get_resource_amount_function,
+ resource_amount_slider_container_name,
+ resource_amount_slider_label_name,
+ resource_amount_slider_space_name,
+ resource_amount_slider_button_name_prefix,
+ resource_amount_slider_space_2_name,
+ resource_amount_slider_textfield_name
)
- local column_count = 9
-
- -- Get the selected tile.
- local selected_tile = get_selected_tile_prototype_function(player)
- -- Tiles table.
- local tiles_table = container.add({
- type = "table",
- name = tiles_table_name,
- style = creative_mode_defines.names.gui_styles.slot_table,
- column_count = column_count,
- })
- -- Tile slots.
- for _, tile in pairs(prototypes.tile) do
- local style
- if selected_tile == tile then
- style = creative_mode_defines.names.gui_styles.tile_slot_selected
- else
- style = creative_mode_defines.names.gui_styles.tile_slot_deselected
- end
- tiles_table.add({
- type = "sprite-button",
- name = tile_name_button_prefix .. tile.name,
- sprite = "tile/" .. tile.name,
- style = style,
- tooltip = tile.localised_name,
- })
- end
-
- -- Get the selected resource.
- local selected_resource = get_selected_resource_prototype_function(player)
- -- Resources table.
- local resources_table = container.add({
- type = "table",
- name = resources_table_name,
- style = creative_mode_defines.names.gui_styles.slot_table,
- column_count = column_count,
- })
- -- Resource slots.
- for _, resource in pairs(prototypes.entity) do
- if resource.resource_category then
- local style
- if selected_resource == resource then
- style = creative_mode_defines.names.gui_styles.tile_slot_selected
- else
- style = creative_mode_defines.names.gui_styles.tile_slot_deselected
- end
- resources_table.add({
- type = "sprite-button",
- name = resource_name_button_prefix .. resource.name,
- sprite = "entity/" .. resource.name,
- style = style,
- tooltip = resource.localised_name,
- })
- end
- end
-
- -- Get the resource amount.
- local resource_amount = get_resource_amount_function(player)
- -- Resource amount table.
- local resource_amount_container = container.add({
- type = "table",
- name = resource_amount_slider_container_name,
- style = creative_mode_defines.names.gui_styles.unscalable_no_spacing_table,
- column_count = 1 + 1 + 16 + 1 + 1,
- })
- -- Resource amount label.
- resource_amount_container.add({
- type = "label",
- name = resource_amount_slider_label_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_slider_label,
- caption = { "gui.creative-mode_resource-amount" },
- })
- -- Spacing.
- resource_amount_container.add({
- type = "flow",
- name = resource_amount_slider_space_name,
- style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
- direction = "horizontal",
- })
- -- Resource amount buttons.
- for i, value in ipairs(creator_resource_amount_slider_values) do
- local style
- if value <= resource_amount then
- style = creative_mode_defines.names.gui_styles.slider_button_on
- else
- style = creative_mode_defines.names.gui_styles.slider_button_off
- end
- resource_amount_container.add({
- type = "button",
- name = resource_amount_slider_button_name_prefix .. i,
- style = style,
- })
- end
- -- Spacing.
- resource_amount_container.add({
- type = "flow",
- name = resource_amount_slider_space_2_name,
- style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
- direction = "horizontal",
- })
- -- Textfield.
- resource_amount_container.add({
- type = "textfield",
- name = resource_amount_slider_textfield_name,
- style = creative_mode_defines.names.gui_styles.slider_textfield,
- text = resource_amount,
- })
+ local column_count = 9
+
+ -- Get the selected tile.
+ local selected_tile = get_selected_tile_prototype_function(player)
+ -- Tiles table.
+ local tiles_table = container.add({
+ type = "table",
+ name = tiles_table_name,
+ style = creative_mode_defines.names.gui_styles.slot_table,
+ column_count = column_count,
+ })
+ -- Tile slots.
+ for _, tile in pairs(prototypes.tile) do
+ local style
+ if selected_tile == tile then
+ style = creative_mode_defines.names.gui_styles.tile_slot_selected
+ else
+ style = creative_mode_defines.names.gui_styles.tile_slot_deselected
+ end
+ tiles_table.add({
+ type = "sprite-button",
+ name = tile_name_button_prefix .. tile.name,
+ sprite = "tile/" .. tile.name,
+ style = style,
+ tooltip = tile.localised_name,
+ })
+ end
+
+ -- Get the selected resource.
+ local selected_resource = get_selected_resource_prototype_function(player)
+ -- Resources table.
+ local resources_table = container.add({
+ type = "table",
+ name = resources_table_name,
+ style = creative_mode_defines.names.gui_styles.slot_table,
+ column_count = column_count,
+ })
+ -- Resource slots.
+ for _, resource in pairs(prototypes.entity) do
+ if resource.resource_category then
+ local style
+ if selected_resource == resource then
+ style = creative_mode_defines.names.gui_styles.tile_slot_selected
+ else
+ style = creative_mode_defines.names.gui_styles.tile_slot_deselected
+ end
+ resources_table.add({
+ type = "sprite-button",
+ name = resource_name_button_prefix .. resource.name,
+ sprite = "entity/" .. resource.name,
+ style = style,
+ tooltip = resource.localised_name,
+ })
+ end
+ end
+
+ -- Get the resource amount.
+ local resource_amount = get_resource_amount_function(player)
+ -- Resource amount table.
+ local resource_amount_container = container.add({
+ type = "table",
+ name = resource_amount_slider_container_name,
+ style = creative_mode_defines.names.gui_styles.unscalable_no_spacing_table,
+ column_count = 1 + 1 + 16 + 1 + 1,
+ })
+ -- Resource amount label.
+ resource_amount_container.add({
+ type = "label",
+ name = resource_amount_slider_label_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_slider_label,
+ caption = { "gui.creative-mode_resource-amount" },
+ })
+ -- Spacing.
+ resource_amount_container.add({
+ type = "flow",
+ name = resource_amount_slider_space_name,
+ style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
+ direction = "horizontal",
+ })
+ -- Resource amount buttons.
+ for i, value in ipairs(creator_resource_amount_slider_values) do
+ local style
+ if value <= resource_amount then
+ style = creative_mode_defines.names.gui_styles.slider_button_on
+ else
+ style = creative_mode_defines.names.gui_styles.slider_button_off
+ end
+ resource_amount_container.add({
+ type = "button",
+ name = resource_amount_slider_button_name_prefix .. i,
+ style = style,
+ })
+ end
+ -- Spacing.
+ resource_amount_container.add({
+ type = "flow",
+ name = resource_amount_slider_space_2_name,
+ style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
+ direction = "horizontal",
+ })
+ -- Textfield.
+ resource_amount_container.add({
+ type = "textfield",
+ name = resource_amount_slider_textfield_name,
+ style = creative_mode_defines.names.gui_styles.slider_textfield,
+ text = resource_amount,
+ })
end
-- Function for creating common UI elements for either the selection mode or the alternate selection mode of the Modifier magic wand.
local function create_common_elements_for_modifier(
- player,
- container,
- get_ignore_player_characters_function,
- ignore_player_characters_checkbox_name,
- get_ignore_healthless_entities_function,
- ignore_healthless_entities_checkbox_name,
- get_ignore_indestructible_entities_function,
- ignore_indestructible_entities_checkbox_name,
- forces_table_label_name,
- forces_table_name,
- force_checkbox_name_prefix,
- get_force_checkbox_state_function,
- select_all_button_name
+ player,
+ container,
+ get_ignore_player_characters_function,
+ ignore_player_characters_checkbox_name,
+ get_ignore_healthless_entities_function,
+ ignore_healthless_entities_checkbox_name,
+ get_ignore_indestructible_entities_function,
+ ignore_indestructible_entities_checkbox_name,
+ forces_table_label_name,
+ forces_table_name,
+ force_checkbox_name_prefix,
+ get_force_checkbox_state_function,
+ select_all_button_name
)
- -- Gets whether player characters should be ignored.
- local ignore_player_characters = get_ignore_player_characters_function(player)
- -- Checkbox.
- container.add({
- type = "checkbox",
- name = ignore_player_characters_checkbox_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_ignore-player-characters" },
- state = ignore_player_characters,
- })
-
- -- Gets whether healthless entities should be ignored.
- local ignore_healthless_entities = get_ignore_healthless_entities_function(player)
- -- Checkbox.
- container.add({
- type = "checkbox",
- name = ignore_healthless_entities_checkbox_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_ignore-healthless-entities" },
- tooltip = { "gui.creative-mode_ignore-healthless-entities-tooltip" },
- state = ignore_healthless_entities,
- })
-
- -- Gets whether indestructible entities should be ignored.
- local ignore_indestructible_entities = get_ignore_indestructible_entities_function(player)
- -- Checkbox.
- container.add({
- type = "checkbox",
- name = ignore_indestructible_entities_checkbox_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_ignore-indestructible-entities" },
- tooltip = { "gui.creative-mode_ignore-indestructible-entities-tooltip" },
- state = ignore_indestructible_entities,
- })
-
- -- Label.
- local label = container.add({
- type = "label",
- name = forces_table_label_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_label,
- caption = { "gui.creative-mode_selectable-teams-of-entities" },
- })
- label.style.top_padding = 8
- -- Force table.
- create_forces_table(
- player,
- container,
- forces_table_name,
- force_checkbox_name_prefix,
- get_force_checkbox_state_function,
- select_all_button_name
- )
+ -- Gets whether player characters should be ignored.
+ local ignore_player_characters = get_ignore_player_characters_function(player)
+ -- Checkbox.
+ container.add({
+ type = "checkbox",
+ name = ignore_player_characters_checkbox_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_ignore-player-characters" },
+ state = ignore_player_characters,
+ })
+
+ -- Gets whether healthless entities should be ignored.
+ local ignore_healthless_entities = get_ignore_healthless_entities_function(player)
+ -- Checkbox.
+ container.add({
+ type = "checkbox",
+ name = ignore_healthless_entities_checkbox_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_ignore-healthless-entities" },
+ tooltip = { "gui.creative-mode_ignore-healthless-entities-tooltip" },
+ state = ignore_healthless_entities,
+ })
+
+ -- Gets whether indestructible entities should be ignored.
+ local ignore_indestructible_entities = get_ignore_indestructible_entities_function(player)
+ -- Checkbox.
+ container.add({
+ type = "checkbox",
+ name = ignore_indestructible_entities_checkbox_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_ignore-indestructible-entities" },
+ tooltip = { "gui.creative-mode_ignore-indestructible-entities-tooltip" },
+ state = ignore_indestructible_entities,
+ })
+
+ -- Label.
+ local label = container.add({
+ type = "label",
+ name = forces_table_label_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_label,
+ caption = { "gui.creative-mode_selectable-teams-of-entities" },
+ })
+ label.style.top_padding = 8
+ -- Force table.
+ create_forces_table(
+ player,
+ container,
+ forces_table_name,
+ force_checkbox_name_prefix,
+ get_force_checkbox_state_function,
+ select_all_button_name
+ )
end
-- Clears all GUI elements for all recorded actions of the Modifier magic wand in the given actions container.
local function clear_all_elements_for_recorded_actions_of_modifier(actions_container, container)
- for _, child_name in ipairs(actions_container.children_names) do
- actions_container[child_name].destroy()
- end
- -- Also remove the remove all actions button.
- local remove_all_button =
- container[creative_mode_defines.names.gui.magic_wand_modifier_remove_all_quick_actions_button]
- if remove_all_button then
- remove_all_button.destroy()
- end
+ for _, child_name in ipairs(actions_container.children_names) do
+ actions_container[child_name].destroy()
+ end
+ -- Also remove the remove all actions button.
+ local remove_all_button =
+ container[creative_mode_defines.names.gui.magic_wand_modifier_remove_all_quick_actions_button]
+ if remove_all_button then
+ remove_all_button.destroy()
+ end
end
-- Creates the GUI elements for the given recorded action of the Modifier magic wand into the given actions container.
local function create_elements_for_recorded_action_of_modifier(actions_container, action)
- local index = #actions_container.children_names + 1
-
- -- The corresponding cheat GUI data.
- local cheat_gui_data = gui_menu_magicwand.action_code_to_cheat_gui_data[action.code]
-
- -- Container.
- local action_container = actions_container.add({
- type = "flow",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_container_prefix .. index,
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- direction = "horizontal",
- })
-
- -- Remove button.
- action_container.add({
- type = "sprite-button",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_remove_button,
- style = creative_mode_defines.names.gui_styles.magic_wand_quick_action_remove_button,
- sprite = creative_mode_defines.names.sprites.cancel,
- tooltip = { "gui.creative-mode_remove-this-action" },
- })
- -- Separator.
- action_container.add({
- type = "flow",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_separator,
- style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
- direction = "horizontal",
- })
- -- Name label.
- action_container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_name_label,
- caption = cheat_gui_data.action_caption,
- })
-
- if action.value ~= nil then
- -- Convert the value to value str.
- local value_str = nil
- if cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.on_off then
- -- On-off cheat: map to the on/off button captions.
- if action.value then
- value_str = cheat_gui_data.on_button_caption
- else
- value_str = cheat_gui_data.off_button_caption
- end
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.numeric_apply then
- -- Numeric action.
- value_str = tostring(action.value)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.string_apply then
- -- String action.
- value_str = tostring(action.value)
- elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.team_target_auto_apply then
- -- Team selection action.
- value_str = tostring(action.value)
- end
- if value_str ~= nil then
- -- Colon label.
- action_container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_colon_label,
- caption = " : ",
- })
- -- Value label.
- action_container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_value_label,
- caption = value_str,
- })
- end
- end
+ local index = #actions_container.children_names + 1
+
+ -- The corresponding cheat GUI data.
+ local cheat_gui_data = gui_menu_magicwand.action_code_to_cheat_gui_data[action.code]
+
+ -- Container.
+ local action_container = actions_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_container_prefix .. index,
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ direction = "horizontal",
+ })
+
+ -- Remove button.
+ action_container.add({
+ type = "sprite-button",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_remove_button,
+ style = creative_mode_defines.names.gui_styles.magic_wand_quick_action_remove_button,
+ sprite = creative_mode_defines.names.sprites.cancel,
+ tooltip = { "gui.creative-mode_remove-this-action" },
+ })
+ -- Separator.
+ action_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_separator,
+ style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
+ direction = "horizontal",
+ })
+ -- Name label.
+ action_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_name_label,
+ caption = cheat_gui_data.action_caption,
+ })
+
+ if action.value ~= nil then
+ -- Convert the value to value str.
+ local value_str = nil
+ if cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.on_off then
+ -- On-off cheat: map to the on/off button captions.
+ if action.value then
+ value_str = cheat_gui_data.on_button_caption
+ else
+ value_str = cheat_gui_data.off_button_caption
+ end
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.numeric_apply then
+ -- Numeric action.
+ value_str = tostring(action.value)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.string_apply then
+ -- String action.
+ value_str = tostring(action.value)
+ elseif cheat_gui_data.type == gui_menu_cheats.cheat_gui_type.team_target_auto_apply then
+ -- Team selection action.
+ value_str = tostring(action.value)
+ end
+ if value_str ~= nil then
+ -- Colon label.
+ action_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_colon_label,
+ caption = " : ",
+ })
+ -- Value label.
+ action_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_value_label,
+ caption = value_str,
+ })
+ end
+ end
end
-- Creates the remove all recorded actions button in the given container, if such button does not exist.
local function create_remove_all_recorded_actions_button_in_container(container)
- if not container[creative_mode_defines.names.gui.magic_wand_modifier_remove_all_quick_actions_button] then
- container.add({
- type = "button",
- name = creative_mode_defines.names.gui.magic_wand_modifier_remove_all_quick_actions_button,
- style = creative_mode_defines.names.gui_styles.magic_wand_select_all_button,
- caption = creative_mode_defines.names.gui_captions.remove_all,
- })
- end
+ if not container[creative_mode_defines.names.gui.magic_wand_modifier_remove_all_quick_actions_button] then
+ container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_remove_all_quick_actions_button,
+ style = creative_mode_defines.names.gui_styles.magic_wand_select_all_button,
+ caption = creative_mode_defines.names.gui_captions.remove_all,
+ })
+ end
end
-- Creates the GUI elements for all recorded actions of modifier for the given player.
local function create_elements_for_recorded_actions_of_modifier(player, actions_container, container)
- if
- storage.creative_mode.modifier_magic_wand_quick_actions[player.index]
- and storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions
- then
- for _, action in ipairs(storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions) do
- create_elements_for_recorded_action_of_modifier(actions_container, action)
- end
- end
- -- If there is no actions, add a hint about how to record actions.
- if #actions_container.children_names <= 0 then
- actions_container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_name_label,
- caption = { "gui.creative-mode_quick-action-hints" },
- })
- else
- -- There is at least one action. Add the remove-all button.
- create_remove_all_recorded_actions_button_in_container(container)
- end
+ if
+ storage.creative_mode.modifier_magic_wand_quick_actions[player.index]
+ and storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions
+ then
+ for _, action in ipairs(storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions) do
+ create_elements_for_recorded_action_of_modifier(actions_container, action)
+ end
+ end
+ -- If there is no actions, add a hint about how to record actions.
+ if #actions_container.children_names <= 0 then
+ actions_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_action_name_label,
+ caption = { "gui.creative-mode_quick-action-hints" },
+ })
+ else
+ -- There is at least one action. Add the remove-all button.
+ create_remove_all_recorded_actions_button_in_container(container)
+ end
end
-- Refreshes the GUI elements for all recorded actions of modifier for the given player.
local function refresh_elements_for_recorded_actions_of_modifier(player, actions_container, container)
- -- Clear.
- clear_all_elements_for_recorded_actions_of_modifier(actions_container, container)
- -- Actions.
- create_elements_for_recorded_actions_of_modifier(player, actions_container, container)
+ -- Clear.
+ clear_all_elements_for_recorded_actions_of_modifier(actions_container, container)
+ -- Actions.
+ create_elements_for_recorded_actions_of_modifier(player, actions_container, container)
end
-- GUI data about the menus for each magic wand.
gui_menu_magicwand.magic_wand_menus_gui_data = {
- creator = {
- access_right_code = rights.use_creator_magic_wand_code,
- get_player_can_access_function = rights.can_player_use_creator_magic_wand,
- button_name = creative_mode_defines.names.gui.magic_wand_creator_menu_button,
- button_caption = { "gui.creative-mode_magic-wand-short-creator" },
- contents = {
- frame_name = creative_mode_defines.names.gui.magic_wand_creator_frame,
- title_container_name = creative_mode_defines.names.gui.magic_wand_creator_frame_title_container,
- title_name = creative_mode_defines.names.gui.magic_wand_creator_frame_title,
- get_item_button_name = creative_mode_defines.names.gui.magic_wand_creator_get_item_button,
- item_name = creative_mode_defines.names.items.magic_wand_creator,
- scroll_pane_name = creative_mode_defines.names.gui.magic_wand_creator_scroll_pane,
- container_name = creative_mode_defines.names.gui.magic_wand_creator_container,
- select_mode_container_name = creative_mode_defines.names.gui.magic_wand_creator_select_mode_container,
- alt_select_mode_container_name = creative_mode_defines.names.gui.magic_wand_creator_alt_select_mode_container,
- select_mode_label_name = creative_mode_defines.names.gui.magic_wand_creator_select_mode_label,
- select_mode_label_caption = { "gui.creative-mode_create-tiles-or-resources" },
- alt_select_mode_label_name = creative_mode_defines.names.gui.magic_wand_creator_alt_select_mode_label,
- alt_select_mode_label_caption = { "gui.creative-mode_remove-entities" },
- ----
- create_select_mode_gui_function = function(player, container)
- -- Get whether tile edges should be corrected.
- local tile_correction = magic_wand_creator.get_tile_correction(player)
- -- Correct tiles checkbox.
- container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_creator_correct_tiles_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_correct-tiles" },
- tooltip = { "gui.creative-mode_correct-tiles-tooltip" },
- state = tile_correction,
- })
-
- -- Get whether the don't-kill-players-by-tiles option is turned on.
- local dont_kill_players_by_tiles = magic_wand_creator.get_dont_kill_players_by_tiles(player)
- -- Don't kill players by tiles checkbox.
- container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_creator_dont_kill_by_tiles_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_dont-kill-players-by-tiles" },
- tooltip = { "gui.creative-mode_dont-kill-players-by-tiles-tooltip" },
- state = dont_kill_players_by_tiles,
- })
-
- -- Tile or resource selection.
- create_tile_or_resource_selection_for_creator(
- player,
- container,
- magic_wand_creator.get_selected_tile_prototype,
- creative_mode_defines.names.gui.magic_wand_creator_tiles_table,
- creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_prefix,
- magic_wand_creator.get_selected_resource_prototype,
- creative_mode_defines.names.gui.magic_wand_creator_resources_table,
- creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_prefix,
- magic_wand_creator.get_resource_amount,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_container,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_label,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_spacing_1,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_prefix,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_spacing_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield
- )
-
- -- Get the index of used pattern.
- local pattern_index = magic_wand_creator.get_use_pattern(player)
- -- Create use pattern container.
- local use_pattern_container = container.add({
- type = "flow",
- name = creative_mode_defines.names.gui_styles.magic_wand_creator_use_pattern_container,
- direction = "horizontal",
- })
- -- Create use pattern lable.
- use_pattern_container.add({
- type = "label",
- name = creative_mode_defines.names.gui_styles.magic_wand_creator_use_pattern_label,
- style = creative_mode_defines.names.gui_styles.magic_wand_drop_down_label,
- caption = { "gui.creative-mode_use-pattern" },
- tooltip = { "gui.creative-mode_use-pattern-tooltip" },
- })
- -- Create use pattern drop-down.
- use_pattern_container.add({
- type = "drop-down",
- name = creative_mode_defines.names.gui.magic_wand_creator_use_pattern_drop_down,
- style = creative_mode_defines.names.gui_styles.magic_wand_drop_down,
- items = {
- { "gui.creative-mode_no-pattern" },
- { "gui.creative-mode_horizontal-stripe-pattern" },
- { "gui.creative-mode_vertical-stripe-pattern" },
- { "gui.creative-mode_checker-pattern" },
- { "gui.creative-mode_random-pattern" },
- },
- selected_index = pattern_index,
- })
-
- -- Second tile or resource selection.
- -- Container.
- local tile_or_resource_2_container = container.add({
- type = "flow",
- name = creative_mode_defines.names.gui.magic_wand_creator_tile_or_resource_2_container,
- direction = "vertical",
- })
- -- UI.
- create_tile_or_resource_selection_for_creator(
- player,
- tile_or_resource_2_container,
- magic_wand_creator.get_selected_tile_prototype_2,
- creative_mode_defines.names.gui.magic_wand_creator_tiles_table_2,
- creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_2_prefix,
- magic_wand_creator.get_selected_resource_prototype_2,
- creative_mode_defines.names.gui.magic_wand_creator_resources_table_2,
- creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_2_prefix,
- magic_wand_creator.get_resource_amount_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_container_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_label_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_spacing_1_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_2_prefix,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_spacing_2_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield_2
- )
- -- Set visibilitiy.
- -- tile_or_resource_2_container.visible = selected_index > 1
- -- Known issue: making it invisible will bug the scroll-pane.
- end,
- ----
- create_alt_select_mode_gui_function = function(player, container)
- -- Get whether the also-remove-decoratives option is turned on.
- local also_remove_decoratives = magic_wand_creator.get_also_remove_decoratives(player)
- -- Checkbox.
- container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_creator_also_remove_decoratives_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_also-remove-decoratives" },
- state = also_remove_decoratives,
- })
-
- -- Get whether the don't-remove-player-characters option is turned on.
- local dont_remove_player_characters = magic_wand_creator.get_dont_remove_player_characters(player)
- -- Checkbox.
- container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_creator_dont_remove_characters_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_dont-remove-player-characters" },
- tooltip = { "gui.creative-mode_dont-remove-player-characters-tooltip" },
- state = dont_remove_player_characters,
- })
-
- -- Get whether tile removal should not be performed if any entity is selected.
- local dont_remove_tiles_if_any_entity_is_selected =
- magic_wand_creator.get_dont_remove_tiles_if_any_entity_is_selected(player)
- -- Checkbox.
- container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_creator_dont_remove_tiles_with_entities_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_dont-remove-tiles-if-any-entity-is-selected" },
- tooltip = { "gui.creative-mode_dont-remove-tiles-if-any-entity-is-selected-tooltip" },
- state = dont_remove_tiles_if_any_entity_is_selected,
- })
-
- -- Get whether the don't-kill-players-by-removing-tiles option is turned on.
- local dont_kill_players_by_removing_tiles =
- magic_wand_creator.get_dont_kill_players_by_removing_tiles(player)
- -- Checkbox.
- container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_creator_dont_kill_by_removing_tiles_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_dont-kill-players-by-removing-tiles" },
- tooltip = { "gui.creative-mode_dont-kill-players-by-removing-tiles-tooltip" },
- state = dont_kill_players_by_removing_tiles,
- })
-
- -- Label.
- local label = container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_creator_alt_forces_label,
- style = creative_mode_defines.names.gui_styles.magic_wand_label,
- caption = { "gui.creative-mode_select-teams-of-entities-to-remove" },
- })
- label.style.top_padding = 8
- -- Force table.
- create_forces_table(
- player,
- container,
- creative_mode_defines.names.gui.magic_wand_creator_alt_forces_table,
- creative_mode_defines.names.gui.magic_wand_creator_alt_force_name_checkbox_prefix,
- magic_wand_creator.get_alt_mode_apply_on_force,
- creative_mode_defines.names.gui.magic_wand_creator_alt_forces_select_all_button
- )
- end,
- },
- },
- healer = {
- access_right_code = rights.use_healer_magic_wand_code,
- get_player_can_access_function = rights.can_player_use_healer_magic_wand,
- button_name = creative_mode_defines.names.gui.magic_wand_healer_menu_button,
- button_caption = { "gui.creative-mode_magic-wand-short-healer" },
- contents = {
- frame_name = creative_mode_defines.names.gui.magic_wand_healer_frame,
- title_container_name = creative_mode_defines.names.gui.magic_wand_healer_frame_title_container,
- title_name = creative_mode_defines.names.gui.magic_wand_healer_frame_title,
- get_item_button_name = creative_mode_defines.names.gui.magic_wand_healer_get_item_button,
- item_name = creative_mode_defines.names.items.magic_wand_healer,
- scroll_pane_name = creative_mode_defines.names.gui.magic_wand_healer_scroll_pane,
- container_name = creative_mode_defines.names.gui.magic_wand_healer_container,
- select_mode_container_name = creative_mode_defines.names.gui.magic_wand_healer_select_mode_container,
- alt_select_mode_container_name = creative_mode_defines.names.gui.magic_wand_healer_alt_select_mode_container,
- select_mode_label_name = creative_mode_defines.names.gui.magic_wand_healer_select_mode_label,
- select_mode_label_caption = { "gui.creative-mode_revive-ghosts-and-heal-entities" },
- alt_select_mode_label_name = creative_mode_defines.names.gui.magic_wand_healer_alt_select_mode_label,
- alt_select_mode_label_caption = { "gui.creative-mode_lower-hp-or-kill-entities" },
- ----
- create_select_mode_gui_function = function(player, container)
- -- Gets whether ghost entities can be revived.
- local revive_ghosts = magic_wand_healer.get_revive_ghosts(player)
- -- Revive ghosts checkbox.
- container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_healer_revive_ghosts_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_revive-ghosts" },
- tooltip = { "gui.creative-mode_revive-ghosts-tooltip" },
- state = revive_ghosts,
- })
-
- -- Label.
- local label = container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_healer_heal_forces_label,
- style = creative_mode_defines.names.gui_styles.magic_wand_label,
- caption = { "gui.creative-mode_select-teams-of-entities-to-heal" },
- })
- label.style.top_padding = 8
- -- Force table.
- create_forces_table(
- player,
- container,
- creative_mode_defines.names.gui.magic_wand_healer_heal_forces_table,
- creative_mode_defines.names.gui.magic_wand_healer_heal_force_name_checkbox_prefix,
- magic_wand_healer.get_heal_entities_on_force,
- creative_mode_defines.names.gui.magic_wand_healer_heal_forces_select_all_button
- )
- end,
- ----
- create_alt_select_mode_gui_function = function(player, container)
- -- Gets the alt-mode action.
- local alt_mode_action = magic_wand_healer.get_alt_mode_action(player)
- -- Alt-mode actions container.
- local alt_mode_actions_container = container.add({
- type = "flow",
- name = creative_mode_defines.names.gui.magic_wand_healer_alt_actions_container,
- direction = "vertical",
- })
- -- Set-HP radiobutton.
- alt_mode_actions_container.add({
- type = "radiobutton",
- name = creative_mode_defines.names.gui.magic_wand_healer_alt_set_hp_radiobutton,
- style = creative_mode_defines.names.gui_styles.magic_wand_radiobutton,
- caption = { "gui.creative-mode_lower-hp" },
- tooltip = { "gui.creative-mode_lower-hp-tooltip" },
- state = alt_mode_action == magic_wand_healer.alt_mode_action.set_hp_to_one,
- })
- -- Kill radiobutton.
- alt_mode_actions_container.add({
- type = "radiobutton",
- name = creative_mode_defines.names.gui.magic_wand_healer_alt_kill_radiobutton,
- style = creative_mode_defines.names.gui_styles.magic_wand_radiobutton,
- caption = { "gui.creative-mode_kill" },
- state = alt_mode_action == magic_wand_healer.alt_mode_action.kill,
- })
-
- -- Get don't-affect-player-characters.
- local alt_mode_dont_affect_player_characters =
- magic_wand_healer.get_alt_mode_dont_affect_player_characters(player)
- -- Checkbox.
- local alt_mode_dont_affect_player_characters_checkbox = container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_healer_alt_dont_affect_characters_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_dont-affect-player-characters" },
- tooltip = { "gui.creative-mode_dont-affect-player-characters-tooltip" },
- state = alt_mode_dont_affect_player_characters,
- })
- alt_mode_dont_affect_player_characters_checkbox.style.top_padding = 8
-
- -- Get don't-affect-indestructible-entities.
- local alt_mode_dont_affect_indestructible_entities =
- magic_wand_healer.get_alt_mode_dont_affect_indestructible_entities(player)
- -- Checkbox.
- container.add({
- type = "checkbox",
- name = creative_mode_defines.names.gui.magic_wand_healer_alt_dont_affect_indestructible_checkbox,
- style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
- caption = { "gui.creative-mode_dont-affect-indestructible-entities" },
- tooltip = { "gui.creative-mode_dont-affect-indestructible-entities-tooltip" },
- state = alt_mode_dont_affect_indestructible_entities,
- })
-
- -- Label.
- local label = container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_healer_alt_forces_label,
- style = creative_mode_defines.names.gui_styles.magic_wand_label,
- caption = { "gui.creative-mode_select-teams-of-entities-to-be-affected" },
- })
- label.style.top_padding = 8
- -- Force table.
- create_forces_table(
- player,
- container,
- creative_mode_defines.names.gui.magic_wand_healer_alt_forces_table,
- creative_mode_defines.names.gui.magic_wand_healer_alt_force_name_checkbox_prefix,
- magic_wand_healer.get_alt_mode_apply_on_force,
- creative_mode_defines.names.gui.magic_wand_healer_alt_forces_select_all_button
- )
- end,
- },
- },
- modifier = {
- access_right_code = rights.use_modifier_magic_wand_code,
- get_player_can_access_function = rights.can_player_use_modifier_magic_wand,
- button_name = creative_mode_defines.names.gui.magic_wand_modifier_menu_button,
- button_caption = { "gui.creative-mode_magic-wand-short-modifier" },
- contents = {
- frame_name = creative_mode_defines.names.gui.magic_wand_modifier_frame,
- title_container_name = creative_mode_defines.names.gui.magic_wand_modifier_frame_title_container,
- title_name = creative_mode_defines.names.gui.magic_wand_modifier_frame_title,
- get_item_button_name = creative_mode_defines.names.gui.magic_wand_modifier_get_item_button,
- item_name = creative_mode_defines.names.items.magic_wand_modifier,
- scroll_pane_name = creative_mode_defines.names.gui.magic_wand_modifier_scroll_pane,
- container_name = creative_mode_defines.names.gui.magic_wand_modifier_container,
- select_mode_container_name = creative_mode_defines.names.gui.magic_wand_modifier_select_mode_container,
- alt_select_mode_container_name = creative_mode_defines.names.gui.magic_wand_modifier_alt_select_mode_container,
- select_mode_label_name = creative_mode_defines.names.gui.magic_wand_modifier_select_mode_label,
- select_mode_label_caption = { "gui.creative-mode_select-and-modify" },
- alt_select_mode_label_name = creative_mode_defines.names.gui.magic_wand_modifier_alt_select_mode_label,
- alt_select_mode_label_caption = { "gui.creative-mode_select-and-modify-alt" },
- ----
- create_select_mode_gui_function = function(player, container)
- create_common_elements_for_modifier(
- player,
- container,
- magic_wand_modifier.get_std_ignore_player_characters,
- creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_characters_checkbox,
- magic_wand_modifier.get_std_ignore_healthess_entities,
- creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_healthless_checkbox,
- magic_wand_modifier.get_std_ignore_indestructible_entities,
- creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_indestructible_checkbox,
- creative_mode_defines.names.gui.magic_wand_modifier_std_forces_label,
- creative_mode_defines.names.gui.magic_wand_modifier_std_forces_table,
- creative_mode_defines.names.gui.magic_wand_modifier_std_force_name_checkbox_prefix,
- magic_wand_modifier.get_std_select_entities_on_force,
- creative_mode_defines.names.gui.magic_wand_modifier_std_forces_select_all_button
- )
- end,
- ----
- create_alt_select_mode_gui_function = function(player, container)
- create_common_elements_for_modifier(
- player,
- container,
- magic_wand_modifier.get_alt_ignore_player_characters,
- creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_characters_checkbox,
- magic_wand_modifier.get_alt_ignore_healthess_entities,
- creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_healthless_checkbox,
- magic_wand_modifier.get_alt_ignore_indestructible_entities,
- creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_indestructible_checkbox,
- creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_label,
- creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_table,
- creative_mode_defines.names.gui.magic_wand_modifier_alt_force_name_checkbox_prefix,
- magic_wand_modifier.get_alt_select_entities_on_force,
- creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_select_all_button
- )
-
- -- Actions label.
- local actions_label = container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_actions_label,
- style = creative_mode_defines.names.gui_styles.magic_wand_label,
- caption = { "gui.creative-mode_quick-action-actions" },
- })
- actions_label.style.top_padding = 8
- -- Actions container.
- local actions_container = container.add({
- type = "table",
- name = creative_mode_defines.names.gui.magic_wand_modifier_quick_actions_container,
- column_count = 1,
- })
- -- Refresh actions.
- refresh_elements_for_recorded_actions_of_modifier(player, actions_container, container)
- end,
- },
- },
+ creator = {
+ access_right_code = rights.use_creator_magic_wand_code,
+ get_player_can_access_function = rights.can_player_use_creator_magic_wand,
+ button_name = creative_mode_defines.names.gui.magic_wand_creator_menu_button,
+ button_caption = { "gui.creative-mode_magic-wand-short-creator" },
+ contents = {
+ frame_name = creative_mode_defines.names.gui.magic_wand_creator_frame,
+ title_container_name = creative_mode_defines.names.gui.magic_wand_creator_frame_title_container,
+ title_name = creative_mode_defines.names.gui.magic_wand_creator_frame_title,
+ get_item_button_name = creative_mode_defines.names.gui.magic_wand_creator_get_item_button,
+ item_name = creative_mode_defines.names.items.magic_wand_creator,
+ scroll_pane_name = creative_mode_defines.names.gui.magic_wand_creator_scroll_pane,
+ container_name = creative_mode_defines.names.gui.magic_wand_creator_container,
+ select_mode_container_name = creative_mode_defines.names.gui.magic_wand_creator_select_mode_container,
+ alt_select_mode_container_name = creative_mode_defines.names.gui.magic_wand_creator_alt_select_mode_container,
+ select_mode_label_name = creative_mode_defines.names.gui.magic_wand_creator_select_mode_label,
+ select_mode_label_caption = { "gui.creative-mode_create-tiles-or-resources" },
+ alt_select_mode_label_name = creative_mode_defines.names.gui.magic_wand_creator_alt_select_mode_label,
+ alt_select_mode_label_caption = { "gui.creative-mode_remove-entities" },
+ ----
+ create_select_mode_gui_function = function(player, container)
+ -- Get whether tile edges should be corrected.
+ local tile_correction = magic_wand_creator.get_tile_correction(player)
+ -- Correct tiles checkbox.
+ container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_creator_correct_tiles_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_correct-tiles" },
+ tooltip = { "gui.creative-mode_correct-tiles-tooltip" },
+ state = tile_correction,
+ })
+
+ -- Get whether the don't-kill-players-by-tiles option is turned on.
+ local dont_kill_players_by_tiles = magic_wand_creator.get_dont_kill_players_by_tiles(player)
+ -- Don't kill players by tiles checkbox.
+ container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_creator_dont_kill_by_tiles_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_dont-kill-players-by-tiles" },
+ tooltip = { "gui.creative-mode_dont-kill-players-by-tiles-tooltip" },
+ state = dont_kill_players_by_tiles,
+ })
+
+ -- Tile or resource selection.
+ create_tile_or_resource_selection_for_creator(
+ player,
+ container,
+ magic_wand_creator.get_selected_tile_prototype,
+ creative_mode_defines.names.gui.magic_wand_creator_tiles_table,
+ creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_prefix,
+ magic_wand_creator.get_selected_resource_prototype,
+ creative_mode_defines.names.gui.magic_wand_creator_resources_table,
+ creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_prefix,
+ magic_wand_creator.get_resource_amount,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_container,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_label,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_spacing_1,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_prefix,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_spacing_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield
+ )
+
+ -- Get the index of used pattern.
+ local pattern_index = magic_wand_creator.get_use_pattern(player)
+ -- Create use pattern container.
+ local use_pattern_container = container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui_styles.magic_wand_creator_use_pattern_container,
+ direction = "horizontal",
+ })
+ -- Create use pattern lable.
+ use_pattern_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui_styles.magic_wand_creator_use_pattern_label,
+ style = creative_mode_defines.names.gui_styles.magic_wand_drop_down_label,
+ caption = { "gui.creative-mode_use-pattern" },
+ tooltip = { "gui.creative-mode_use-pattern-tooltip" },
+ })
+ -- Create use pattern drop-down.
+ use_pattern_container.add({
+ type = "drop-down",
+ name = creative_mode_defines.names.gui.magic_wand_creator_use_pattern_drop_down,
+ style = creative_mode_defines.names.gui_styles.magic_wand_drop_down,
+ items = {
+ { "gui.creative-mode_no-pattern" },
+ { "gui.creative-mode_horizontal-stripe-pattern" },
+ { "gui.creative-mode_vertical-stripe-pattern" },
+ { "gui.creative-mode_checker-pattern" },
+ { "gui.creative-mode_random-pattern" },
+ },
+ selected_index = pattern_index,
+ })
+
+ -- Second tile or resource selection.
+ -- Container.
+ local tile_or_resource_2_container = container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.magic_wand_creator_tile_or_resource_2_container,
+ direction = "vertical",
+ })
+ -- UI.
+ create_tile_or_resource_selection_for_creator(
+ player,
+ tile_or_resource_2_container,
+ magic_wand_creator.get_selected_tile_prototype_2,
+ creative_mode_defines.names.gui.magic_wand_creator_tiles_table_2,
+ creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_2_prefix,
+ magic_wand_creator.get_selected_resource_prototype_2,
+ creative_mode_defines.names.gui.magic_wand_creator_resources_table_2,
+ creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_2_prefix,
+ magic_wand_creator.get_resource_amount_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_container_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_label_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_spacing_1_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_2_prefix,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_spacing_2_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield_2
+ )
+ -- Set visibilitiy.
+ -- tile_or_resource_2_container.visible = selected_index > 1
+ -- Known issue: making it invisible will bug the scroll-pane.
+ end,
+ ----
+ create_alt_select_mode_gui_function = function(player, container)
+ -- Get whether the also-remove-decoratives option is turned on.
+ local also_remove_decoratives = magic_wand_creator.get_also_remove_decoratives(player)
+ -- Checkbox.
+ container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_creator_also_remove_decoratives_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_also-remove-decoratives" },
+ state = also_remove_decoratives,
+ })
+
+ -- Get whether the don't-remove-player-characters option is turned on.
+ local dont_remove_player_characters = magic_wand_creator.get_dont_remove_player_characters(player)
+ -- Checkbox.
+ container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_creator_dont_remove_characters_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_dont-remove-player-characters" },
+ tooltip = { "gui.creative-mode_dont-remove-player-characters-tooltip" },
+ state = dont_remove_player_characters,
+ })
+
+ -- Get whether tile removal should not be performed if any entity is selected.
+ local dont_remove_tiles_if_any_entity_is_selected =
+ magic_wand_creator.get_dont_remove_tiles_if_any_entity_is_selected(player)
+ -- Checkbox.
+ container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_creator_dont_remove_tiles_with_entities_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_dont-remove-tiles-if-any-entity-is-selected" },
+ tooltip = { "gui.creative-mode_dont-remove-tiles-if-any-entity-is-selected-tooltip" },
+ state = dont_remove_tiles_if_any_entity_is_selected,
+ })
+
+ -- Get whether the don't-kill-players-by-removing-tiles option is turned on.
+ local dont_kill_players_by_removing_tiles = magic_wand_creator.get_dont_kill_players_by_removing_tiles(player)
+ -- Checkbox.
+ container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_creator_dont_kill_by_removing_tiles_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_dont-kill-players-by-removing-tiles" },
+ tooltip = { "gui.creative-mode_dont-kill-players-by-removing-tiles-tooltip" },
+ state = dont_kill_players_by_removing_tiles,
+ })
+
+ -- Label.
+ local label = container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_creator_alt_forces_label,
+ style = creative_mode_defines.names.gui_styles.magic_wand_label,
+ caption = { "gui.creative-mode_select-teams-of-entities-to-remove" },
+ })
+ label.style.top_padding = 8
+ -- Force table.
+ create_forces_table(
+ player,
+ container,
+ creative_mode_defines.names.gui.magic_wand_creator_alt_forces_table,
+ creative_mode_defines.names.gui.magic_wand_creator_alt_force_name_checkbox_prefix,
+ magic_wand_creator.get_alt_mode_apply_on_force,
+ creative_mode_defines.names.gui.magic_wand_creator_alt_forces_select_all_button
+ )
+ end,
+ },
+ },
+ healer = {
+ access_right_code = rights.use_healer_magic_wand_code,
+ get_player_can_access_function = rights.can_player_use_healer_magic_wand,
+ button_name = creative_mode_defines.names.gui.magic_wand_healer_menu_button,
+ button_caption = { "gui.creative-mode_magic-wand-short-healer" },
+ contents = {
+ frame_name = creative_mode_defines.names.gui.magic_wand_healer_frame,
+ title_container_name = creative_mode_defines.names.gui.magic_wand_healer_frame_title_container,
+ title_name = creative_mode_defines.names.gui.magic_wand_healer_frame_title,
+ get_item_button_name = creative_mode_defines.names.gui.magic_wand_healer_get_item_button,
+ item_name = creative_mode_defines.names.items.magic_wand_healer,
+ scroll_pane_name = creative_mode_defines.names.gui.magic_wand_healer_scroll_pane,
+ container_name = creative_mode_defines.names.gui.magic_wand_healer_container,
+ select_mode_container_name = creative_mode_defines.names.gui.magic_wand_healer_select_mode_container,
+ alt_select_mode_container_name = creative_mode_defines.names.gui.magic_wand_healer_alt_select_mode_container,
+ select_mode_label_name = creative_mode_defines.names.gui.magic_wand_healer_select_mode_label,
+ select_mode_label_caption = { "gui.creative-mode_revive-ghosts-and-heal-entities" },
+ alt_select_mode_label_name = creative_mode_defines.names.gui.magic_wand_healer_alt_select_mode_label,
+ alt_select_mode_label_caption = { "gui.creative-mode_lower-hp-or-kill-entities" },
+ ----
+ create_select_mode_gui_function = function(player, container)
+ -- Gets whether ghost entities can be revived.
+ local revive_ghosts = magic_wand_healer.get_revive_ghosts(player)
+ -- Revive ghosts checkbox.
+ container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_healer_revive_ghosts_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_revive-ghosts" },
+ tooltip = { "gui.creative-mode_revive-ghosts-tooltip" },
+ state = revive_ghosts,
+ })
+
+ -- Label.
+ local label = container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_healer_heal_forces_label,
+ style = creative_mode_defines.names.gui_styles.magic_wand_label,
+ caption = { "gui.creative-mode_select-teams-of-entities-to-heal" },
+ })
+ label.style.top_padding = 8
+ -- Force table.
+ create_forces_table(
+ player,
+ container,
+ creative_mode_defines.names.gui.magic_wand_healer_heal_forces_table,
+ creative_mode_defines.names.gui.magic_wand_healer_heal_force_name_checkbox_prefix,
+ magic_wand_healer.get_heal_entities_on_force,
+ creative_mode_defines.names.gui.magic_wand_healer_heal_forces_select_all_button
+ )
+ end,
+ ----
+ create_alt_select_mode_gui_function = function(player, container)
+ -- Gets the alt-mode action.
+ local alt_mode_action = magic_wand_healer.get_alt_mode_action(player)
+ -- Alt-mode actions container.
+ local alt_mode_actions_container = container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.magic_wand_healer_alt_actions_container,
+ direction = "vertical",
+ })
+ -- Set-HP radiobutton.
+ alt_mode_actions_container.add({
+ type = "radiobutton",
+ name = creative_mode_defines.names.gui.magic_wand_healer_alt_set_hp_radiobutton,
+ style = creative_mode_defines.names.gui_styles.magic_wand_radiobutton,
+ caption = { "gui.creative-mode_lower-hp" },
+ tooltip = { "gui.creative-mode_lower-hp-tooltip" },
+ state = alt_mode_action == magic_wand_healer.alt_mode_action.set_hp_to_one,
+ })
+ -- Kill radiobutton.
+ alt_mode_actions_container.add({
+ type = "radiobutton",
+ name = creative_mode_defines.names.gui.magic_wand_healer_alt_kill_radiobutton,
+ style = creative_mode_defines.names.gui_styles.magic_wand_radiobutton,
+ caption = { "gui.creative-mode_kill" },
+ state = alt_mode_action == magic_wand_healer.alt_mode_action.kill,
+ })
+
+ -- Get don't-affect-player-characters.
+ local alt_mode_dont_affect_player_characters =
+ magic_wand_healer.get_alt_mode_dont_affect_player_characters(player)
+ -- Checkbox.
+ local alt_mode_dont_affect_player_characters_checkbox = container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_healer_alt_dont_affect_characters_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_dont-affect-player-characters" },
+ tooltip = { "gui.creative-mode_dont-affect-player-characters-tooltip" },
+ state = alt_mode_dont_affect_player_characters,
+ })
+ alt_mode_dont_affect_player_characters_checkbox.style.top_padding = 8
+
+ -- Get don't-affect-indestructible-entities.
+ local alt_mode_dont_affect_indestructible_entities =
+ magic_wand_healer.get_alt_mode_dont_affect_indestructible_entities(player)
+ -- Checkbox.
+ container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.magic_wand_healer_alt_dont_affect_indestructible_checkbox,
+ style = creative_mode_defines.names.gui_styles.magic_wand_checkbox,
+ caption = { "gui.creative-mode_dont-affect-indestructible-entities" },
+ tooltip = { "gui.creative-mode_dont-affect-indestructible-entities-tooltip" },
+ state = alt_mode_dont_affect_indestructible_entities,
+ })
+
+ -- Label.
+ local label = container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_healer_alt_forces_label,
+ style = creative_mode_defines.names.gui_styles.magic_wand_label,
+ caption = { "gui.creative-mode_select-teams-of-entities-to-be-affected" },
+ })
+ label.style.top_padding = 8
+ -- Force table.
+ create_forces_table(
+ player,
+ container,
+ creative_mode_defines.names.gui.magic_wand_healer_alt_forces_table,
+ creative_mode_defines.names.gui.magic_wand_healer_alt_force_name_checkbox_prefix,
+ magic_wand_healer.get_alt_mode_apply_on_force,
+ creative_mode_defines.names.gui.magic_wand_healer_alt_forces_select_all_button
+ )
+ end,
+ },
+ },
+ modifier = {
+ access_right_code = rights.use_modifier_magic_wand_code,
+ get_player_can_access_function = rights.can_player_use_modifier_magic_wand,
+ button_name = creative_mode_defines.names.gui.magic_wand_modifier_menu_button,
+ button_caption = { "gui.creative-mode_magic-wand-short-modifier" },
+ contents = {
+ frame_name = creative_mode_defines.names.gui.magic_wand_modifier_frame,
+ title_container_name = creative_mode_defines.names.gui.magic_wand_modifier_frame_title_container,
+ title_name = creative_mode_defines.names.gui.magic_wand_modifier_frame_title,
+ get_item_button_name = creative_mode_defines.names.gui.magic_wand_modifier_get_item_button,
+ item_name = creative_mode_defines.names.items.magic_wand_modifier,
+ scroll_pane_name = creative_mode_defines.names.gui.magic_wand_modifier_scroll_pane,
+ container_name = creative_mode_defines.names.gui.magic_wand_modifier_container,
+ select_mode_container_name = creative_mode_defines.names.gui.magic_wand_modifier_select_mode_container,
+ alt_select_mode_container_name = creative_mode_defines.names.gui.magic_wand_modifier_alt_select_mode_container,
+ select_mode_label_name = creative_mode_defines.names.gui.magic_wand_modifier_select_mode_label,
+ select_mode_label_caption = { "gui.creative-mode_select-and-modify" },
+ alt_select_mode_label_name = creative_mode_defines.names.gui.magic_wand_modifier_alt_select_mode_label,
+ alt_select_mode_label_caption = { "gui.creative-mode_select-and-modify-alt" },
+ ----
+ create_select_mode_gui_function = function(player, container)
+ create_common_elements_for_modifier(
+ player,
+ container,
+ magic_wand_modifier.get_std_ignore_player_characters,
+ creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_characters_checkbox,
+ magic_wand_modifier.get_std_ignore_healthess_entities,
+ creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_healthless_checkbox,
+ magic_wand_modifier.get_std_ignore_indestructible_entities,
+ creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_indestructible_checkbox,
+ creative_mode_defines.names.gui.magic_wand_modifier_std_forces_label,
+ creative_mode_defines.names.gui.magic_wand_modifier_std_forces_table,
+ creative_mode_defines.names.gui.magic_wand_modifier_std_force_name_checkbox_prefix,
+ magic_wand_modifier.get_std_select_entities_on_force,
+ creative_mode_defines.names.gui.magic_wand_modifier_std_forces_select_all_button
+ )
+ end,
+ ----
+ create_alt_select_mode_gui_function = function(player, container)
+ create_common_elements_for_modifier(
+ player,
+ container,
+ magic_wand_modifier.get_alt_ignore_player_characters,
+ creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_characters_checkbox,
+ magic_wand_modifier.get_alt_ignore_healthess_entities,
+ creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_healthless_checkbox,
+ magic_wand_modifier.get_alt_ignore_indestructible_entities,
+ creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_indestructible_checkbox,
+ creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_label,
+ creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_table,
+ creative_mode_defines.names.gui.magic_wand_modifier_alt_force_name_checkbox_prefix,
+ magic_wand_modifier.get_alt_select_entities_on_force,
+ creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_select_all_button
+ )
+
+ -- Actions label.
+ local actions_label = container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_actions_label,
+ style = creative_mode_defines.names.gui_styles.magic_wand_label,
+ caption = { "gui.creative-mode_quick-action-actions" },
+ })
+ actions_label.style.top_padding = 8
+ -- Actions container.
+ local actions_container = container.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_quick_actions_container,
+ column_count = 1,
+ })
+ -- Refresh actions.
+ refresh_elements_for_recorded_actions_of_modifier(player, actions_container, container)
+ end,
+ },
+ },
}
----
-- Creates the magic wands menu for the given player. If the meun already exists, it will be destroyed instead.
function gui_menu_magicwand.create_or_destroy_menu_for_player(player, allow_destroy)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Magic wands container.
- local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
- if magic_wand_menus_container then
- if allow_destroy == nil or allow_destroy then
- magic_wand_menus_container.destroy()
- end
- else
- magic_wand_menus_container = container.add({
- type = "flow",
- name = gui_menu_magicwand.get_container_name(),
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- direction = "horizontal",
- })
-
- -- Magic wands frame.
- local magic_wand_frame = magic_wand_menus_container.add({
- type = "frame",
- name = creative_mode_defines.names.gui.magic_wand_frame,
- direction = "vertical",
- caption = { "gui.creative-mode_magic-wand" },
- })
-
- -- Buttons for each magic wand.
- for _, data in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
- local button = magic_wand_frame.add({
- type = "button",
- name = data.button_name,
- style = creative_mode_defines.names.gui_styles.main_menu_button,
- caption = data.button_caption,
- })
- button.visible = data.get_player_can_access_function(player)
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Magic wands container.
+ local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
+ if magic_wand_menus_container then
+ if allow_destroy == nil or allow_destroy then
+ magic_wand_menus_container.destroy()
+ end
+ else
+ magic_wand_menus_container = container.add({
+ type = "flow",
+ name = gui_menu_magicwand.get_container_name(),
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ direction = "horizontal",
+ })
+
+ -- Magic wands frame.
+ local magic_wand_frame = magic_wand_menus_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.magic_wand_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_magic-wand" },
+ })
+
+ -- Buttons for each magic wand.
+ for _, data in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
+ local button = magic_wand_frame.add({
+ type = "button",
+ name = data.button_name,
+ style = creative_mode_defines.names.gui_styles.main_menu_button,
+ caption = data.button_caption,
+ })
+ button.visible = data.get_player_can_access_function(player)
+ end
+ end
+ end
end
--------------------------------------------------------------------
@@ -1047,668 +1046,665 @@ end
-- Creates the magic wand menu of the given GUI data for the given player. If it already exists, nothing will be done.
-- Returns whether such menu has not been opened and is opened now.
local function create_magic_wand_menu_for_player(player, magic_wand_menu_gui_data)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
- if magic_wand_menus_container then
- local contents_data = magic_wand_menu_gui_data.contents
- -- Frame.
- local frame = magic_wand_menus_container[contents_data.frame_name]
- if not frame then
- frame = magic_wand_menus_container.add({
- type = "frame",
- name = contents_data.frame_name,
- direction = "vertical",
- })
-
- -- Frame title container.
- local title_container = frame.add({
- type = "flow",
- name = contents_data.title_container_name,
- direction = "horizontal",
- })
- -- Frame title.
- title_container.add({
- type = "label",
- name = contents_data.title_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_frame_caption_label,
- caption = magic_wand_menu_gui_data.button_caption,
- })
- -- Get item button.
- title_container.add({
- type = "sprite-button",
- name = contents_data.get_item_button_name,
- sprite = "item/" .. contents_data.item_name,
- style = creative_mode_defines.names.gui_styles.tile_slot_deselected,
- tooltip = { "gui.creative-mode_click-this-to-get-the-magic-wand" },
- })
-
- -- Scroll-pane.
- local scroll_pane = frame.add({
- type = "scroll-pane",
- name = contents_data.scroll_pane_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_scroll_pane,
- horizontal_scroll_policy = "never",
- })
-
- -- Container.
- local flow = scroll_pane.add({
- type = "flow",
- name = contents_data.container_name,
- style = creative_mode_defines.names.gui_styles.resize_col_flow,
- direction = "horizontal",
- })
-
- -- Select mode container.
- local select_mode_container = flow.add({
- type = "frame",
- name = contents_data.select_mode_container_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_select_mode_frame,
- caption = { "gui.creative-mode_standard-mode" },
- direction = "vertical",
- })
- -- Label.
- select_mode_container.add({
- type = "label",
- name = contents_data.select_mode_label_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_label,
- caption = contents_data.select_mode_label_caption,
- })
- -- Contents.
- contents_data.create_select_mode_gui_function(player, select_mode_container)
-
- -- Alt select mode container.
- local alt_select_mode_container = flow.add({
- type = "frame",
- name = contents_data.alt_select_mode_container_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_alt_select_mode_frame,
- caption = { "gui.creative-mode_alternate-mode" },
- direction = "vertical",
- })
- -- Label.
- alt_select_mode_container.add({
- type = "label",
- name = contents_data.alt_select_mode_label_name,
- style = creative_mode_defines.names.gui_styles.magic_wand_label,
- caption = contents_data.alt_select_mode_label_caption,
- })
- -- Contents.
- contents_data.create_alt_select_mode_gui_function(player, alt_select_mode_container)
-
- return true
- end
- end
- end
- return false
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
+ if magic_wand_menus_container then
+ local contents_data = magic_wand_menu_gui_data.contents
+ -- Frame.
+ local frame = magic_wand_menus_container[contents_data.frame_name]
+ if not frame then
+ frame = magic_wand_menus_container.add({
+ type = "frame",
+ name = contents_data.frame_name,
+ direction = "vertical",
+ })
+
+ -- Frame title container.
+ local title_container = frame.add({
+ type = "flow",
+ name = contents_data.title_container_name,
+ direction = "horizontal",
+ })
+ -- Frame title.
+ title_container.add({
+ type = "label",
+ name = contents_data.title_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_frame_caption_label,
+ caption = magic_wand_menu_gui_data.button_caption,
+ })
+ -- Get item button.
+ title_container.add({
+ type = "sprite-button",
+ name = contents_data.get_item_button_name,
+ sprite = "item/" .. contents_data.item_name,
+ style = creative_mode_defines.names.gui_styles.tile_slot_deselected,
+ tooltip = { "gui.creative-mode_click-this-to-get-the-magic-wand" },
+ })
+
+ -- Scroll-pane.
+ local scroll_pane = frame.add({
+ type = "scroll-pane",
+ name = contents_data.scroll_pane_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_scroll_pane,
+ horizontal_scroll_policy = "never",
+ })
+
+ -- Container.
+ local flow = scroll_pane.add({
+ type = "flow",
+ name = contents_data.container_name,
+ style = creative_mode_defines.names.gui_styles.resize_col_flow,
+ direction = "horizontal",
+ })
+
+ -- Select mode container.
+ local select_mode_container = flow.add({
+ type = "frame",
+ name = contents_data.select_mode_container_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_select_mode_frame,
+ caption = { "gui.creative-mode_standard-mode" },
+ direction = "vertical",
+ })
+ -- Label.
+ select_mode_container.add({
+ type = "label",
+ name = contents_data.select_mode_label_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_label,
+ caption = contents_data.select_mode_label_caption,
+ })
+ -- Contents.
+ contents_data.create_select_mode_gui_function(player, select_mode_container)
+
+ -- Alt select mode container.
+ local alt_select_mode_container = flow.add({
+ type = "frame",
+ name = contents_data.alt_select_mode_container_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_alt_select_mode_frame,
+ caption = { "gui.creative-mode_alternate-mode" },
+ direction = "vertical",
+ })
+ -- Label.
+ alt_select_mode_container.add({
+ type = "label",
+ name = contents_data.alt_select_mode_label_name,
+ style = creative_mode_defines.names.gui_styles.magic_wand_label,
+ caption = contents_data.alt_select_mode_label_caption,
+ })
+ -- Contents.
+ contents_data.create_alt_select_mode_gui_function(player, alt_select_mode_container)
+
+ return true
+ end
+ end
+ end
+ return false
end
-- Creates the magic wand menu of the given GUI data for the given player. If it is already opened, it will be destroyed instead.
local function create_or_destroy_magic_wand_menu_for_player(player, magic_wand_menu_gui_data, destroy_only)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
- if magic_wand_menus_container then
- local contents_data = magic_wand_menu_gui_data.contents
- -- Frame.
- local frame = magic_wand_menus_container[contents_data.frame_name]
- if frame then
- frame.destroy()
- elseif not destroy_only then
- create_magic_wand_menu_for_player(player, magic_wand_menu_gui_data)
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
+ if magic_wand_menus_container then
+ local contents_data = magic_wand_menu_gui_data.contents
+ -- Frame.
+ local frame = magic_wand_menus_container[contents_data.frame_name]
+ if frame then
+ frame.destroy()
+ elseif not destroy_only then
+ create_magic_wand_menu_for_player(player, magic_wand_menu_gui_data)
+ end
+ end
+ end
end
-- Opens the magic wand menu of the given GUI data for the given player and closes other menus.
-- Returns whether the such menu has not been opened and is opened now.
function gui_menu_magicwand.open_magic_wand_menu_for_player_and_close_others(player, magic_wand_menu_gui_data)
- -- Close the other magic wand menus if they are already opened.
- for _, data in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
- if data ~= magic_wand_menu_gui_data then
- create_or_destroy_magic_wand_menu_for_player(player, data, true)
- end
- end
- -- Open the given magic wand menu.
- return create_magic_wand_menu_for_player(player, magic_wand_menu_gui_data)
+ -- Close the other magic wand menus if they are already opened.
+ for _, data in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
+ if data ~= magic_wand_menu_gui_data then
+ create_or_destroy_magic_wand_menu_for_player(player, data, true)
+ end
+ end
+ -- Open the given magic wand menu.
+ return create_magic_wand_menu_for_player(player, magic_wand_menu_gui_data)
end
--------------------------------------------------------------------
-- Returns the string for showing each item in the given array, under the given maximum number of visible items.
local function get_string_for_info_array(info_array, max_count)
- if info_array == nil or #info_array <= 0 then
- return "---"
- end
- local result = tostring(info_array[1])
- for i = 2, math.min(max_count, #info_array), 1 do
- result = result .. ", " .. tostring(info_array[i])
- end
- if #info_array > max_count then
- result = result .. ", ..."
- end
- return result
+ if info_array == nil or #info_array <= 0 then
+ return "---"
+ end
+ local result = tostring(info_array[1])
+ for i = 2, math.min(max_count, #info_array), 1 do
+ result = result .. ", " .. tostring(info_array[i])
+ end
+ if #info_array > max_count then
+ result = result .. ", ..."
+ end
+ return result
end
-- Creates or destroys the modification popup for the given player according to the selected entities.
function gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, is_create)
- local player_gui = player.gui
- local center = player_gui.center
- -- Container.
- local container = center[creative_mode_defines.names.gui.magic_wand_modifier_popup_container]
- if container then
- -- Already exists. Destroy it.
- container.destroy()
- end
-
- if is_create then
- container = center.add({
- type = "flow",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_container,
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_resize_col_flow,
- direction = "horizontal",
- })
-
- -- Entities frame.
- local entities_frame = container.add({
- type = "frame",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame,
- direction = "vertical",
- })
- -- Title container.
- local entities_frame_title_container = entities_frame.add({
- type = "flow",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame_title_container,
- direction = "horizontal",
- })
- -- Title label.
- entities_frame_title_container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame_title_label,
- style = creative_mode_defines.names.gui_styles.magic_wand_popup_left_frame_caption_label,
- caption = { "gui.creative-mode_magic-wand-short-modifier" },
- })
- -- Refresh button.
- entities_frame_title_container.add({
- type = "sprite-button",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame_refresh_button,
- style = creative_mode_defines.names.gui_styles.frame_caption_button,
- sprite = creative_mode_defines.names.sprites.reset,
- tooltip = { "gui.creative-mode_refresh" },
- })
-
- -- Entities scroll-pane.
- local entities_scroll_pane = entities_frame.add({
- type = "scroll-pane",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_sroll_pane,
- style = creative_mode_defines.names.gui_styles.magic_wand_popup_slot_scroll_pane,
- })
- -- Entities table.
- local entities_table = entities_scroll_pane.add({
- type = "table",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_table,
- style = creative_mode_defines.names.gui_styles.magic_wand_popup_slot_table,
- column_count = 10,
- })
- -- Group entities by their names. At the same time, remove invalid entities.
- local sorted_entities = {}
- local i = 1
- local i_max = #storage.creative_mode.modifier_magic_wand_selection[player.index]
- while i <= i_max do
- local entity = storage.creative_mode.modifier_magic_wand_selection[player.index][i]
- if entity.valid then
- local final_entity_name
- local stack = nil
- local item_name = nil
- local ghosted_entity_name = nil
- local ghosted_tile_name = nil
- local unit_number = entity.unit_number
- if entity.name == "item-on-ground" then
- -- If it is item-on-ground, further divide it accounding to its stack.
- stack = entity.stack
- final_entity_name = "item-on-ground_" .. stack.name
- item_name = stack.name
- elseif entity.name == "entity-ghost" then
- -- Entity ghost.
- final_entity_name = "entity-ghost_" .. entity.ghost_name
- ghosted_entity_name = entity.ghost_name
- elseif entity.name == "tile-ghost" then
- -- Tile ghost.
- final_entity_name = "tile-ghost_" .. entity.ghost_name
- ghosted_tile_name = entity.ghost_name
- else
- -- Just a common entity.
- final_entity_name = entity.name
- end
- if not sorted_entities[final_entity_name] then
- sorted_entities[final_entity_name] = {}
- sorted_entities[final_entity_name].item_name = item_name
- sorted_entities[final_entity_name].ghosted_entity_name = ghosted_entity_name
- sorted_entities[final_entity_name].ghosted_tile_name = ghosted_tile_name
- sorted_entities[final_entity_name].entities = {}
- if item_name then
- sorted_entities[final_entity_name].stack_counts = {}
- end
- if unit_number then
- sorted_entities[final_entity_name].unit_numbers = {}
- end
- end
-
- table.insert(sorted_entities[final_entity_name].entities, entity)
- if item_name then
- -- We show 10, but insert 11, so we can determine whether we should show "...".
- if #sorted_entities[final_entity_name].stack_counts < 11 then
- table.insert(sorted_entities[final_entity_name].stack_counts, stack.count)
- end
- end
- if unit_number then
- if #sorted_entities[final_entity_name].unit_numbers < 11 then
- table.insert(sorted_entities[final_entity_name].unit_numbers, unit_number)
- end
- end
- i = i + 1
- else
- table.remove(storage.creative_mode.modifier_magic_wand_selection[player.index], i)
- i_max = i_max - 1
- end
- end
- -- Add entity buttons by entity names.
- for entity_name, data in pairs(sorted_entities) do
- local item_name = data.item_name
- local ghosted_entity_name = data.ghosted_entity_name
- local ghosted_tile_name = data.ghosted_tile_name
- local entities = data.entities
- local count = #entities
- if count > 0 then
- -- Sprite button.
- local button_name
- local button_sprite
- local button_style
- local button_tooltip
- local label_name
- if item_name then
- -- item-on-ground
- local item_prototype = prototypes.item[item_name]
- local stack_counts = data.stack_counts
- button_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_item_on_ground_name_slot_prefix
- .. item_name
- button_sprite = "item/" .. item_name
- button_style = creative_mode_defines.names.gui_styles.magic_wand_popup_item_on_ground_slot_button
- button_tooltip = {
- "gui.creative-mode_item-on-ground-slot-tooltip",
- item_prototype.localised_name,
- { "gui.creative-mode_item-type", item_prototype.type },
- { "gui.creative-mode_item-name", item_name },
- { "gui.creative-mode_stack-count", get_string_for_info_array(stack_counts, 10) },
- }
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_item_on_ground_count_label_prefix
- .. item_name
- elseif ghosted_entity_name then
- -- entity-ghost
- local entity_prototype = prototypes.entity[ghosted_entity_name]
- local unit_numbers = data.unit_numbers
- button_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_entity_name_slot_prefix
- .. ghosted_entity_name
- button_sprite = "entity/" .. ghosted_entity_name
- button_style = creative_mode_defines.names.gui_styles.magic_wand_popup_ghost_slot_button
- button_tooltip = {
- "gui.creative-mode_ghost-entity-slot-tooltip",
- entity_prototype.localised_name,
- { "gui.creative-mode_entity-type", entity_prototype.type },
- { "gui.creative-mode_entity-name", ghosted_entity_name },
- { "gui.creative-mode_unit-number", get_string_for_info_array(unit_numbers, 10) },
- }
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_entity_count_label_prefix
- .. ghosted_entity_name
- elseif ghosted_tile_name then
- -- tile-ghost
- local tile_prototype = prototypes.tile[ghosted_tile_name]
- local unit_numbers = data.unit_numbers
- button_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_tile_name_slot_prefix
- .. ghosted_tile_name
- button_sprite = "tile/" .. ghosted_tile_name
- button_style = creative_mode_defines.names.gui_styles.magic_wand_popup_ghost_slot_button
- button_tooltip = {
- "gui.creative-mode_ghost-tile-slot-tooltip",
- tile_prototype.localised_name,
- { "gui.creative-mode_tile-name", ghosted_tile_name },
- { "gui.creative-mode_unit-number", get_string_for_info_array(unit_numbers, 10) },
- }
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_tile_count_label_prefix
- .. ghosted_tile_name
- else
- -- common entity
- local entity_prototype = prototypes.entity[entity_name]
- local unit_numbers = data.unit_numbers
- button_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entity_name_slot_prefix
- .. entity_name
- button_sprite = "entity/" .. entity_name
- button_style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
- button_tooltip = {
- "gui.creative-mode_entity-slot-tooltip",
- entity_prototype.localised_name,
- { "gui.creative-mode_entity-type", entity_prototype.type },
- { "gui.creative-mode_entity-name", entity_name },
- { "gui.creative-mode_unit-number", get_string_for_info_array(unit_numbers, 10) },
- }
- label_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entity_count_label_prefix
- .. entity_name
- end
- if not helpers.is_valid_sprite_path(button_sprite) then
- button_sprite = nil
- end
- entities_table.add({
- type = "sprite-button",
- name = button_name,
- sprite = button_sprite,
- style = button_style,
- tooltip = button_tooltip,
- })
- -- Format count string. Give it a suffix if necessary.
- local count_str
- if count >= 1000000000 then
- -- G
- count_str = tostring(util.round(count / 1000000000 * 10) * 0.1) .. "G"
- elseif count >= 1000000 then
- -- M
- count_str = tostring(util.round(count / 1000000 * 10) * 0.1) .. "M"
- elseif count >= 1000 then
- -- k
- count_str = tostring(util.round(count / 1000 * 10) * 0.1) .. "k"
- else
- count_str = tostring(count)
- end
- count_str = "x" .. count_str
- -- Count label.
- entities_table.add({
- type = "label",
- name = label_name,
- style = creative_mode_defines.names.gui_styles.slot_button_label,
- caption = count_str,
- })
- end
- end
-
- -- Actions frame.
- local actions_frame = container.add({
- type = "frame",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame,
- direction = "vertical",
- })
- -- Title container.
- local actions_frame_title_container = actions_frame.add({
- type = "flow",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame_title_container,
- direction = "horizontal",
- })
- -- Title label.
- actions_frame_title_container.add({
- type = "label",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame_title_label,
- style = creative_mode_defines.names.gui_styles.magic_wand_popup_right_frame_caption_label,
- caption = { "gui.creative-mode_actions" },
- })
- -- Close button.
- actions_frame_title_container.add({
- type = "sprite-button",
- name = creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame_close_button,
- style = creative_mode_defines.names.gui_styles.frame_caption_button,
- sprite = creative_mode_defines.names.sprites.cancel,
- tooltip = { "gui.creative-mode_close" },
- })
- -- Actions (cheats).
- local targets = gui_menu_magicwand.modification_popup_cheats_gui_data.get_all_selected_targets_function(player)
- for _, data in pairs(gui_menu_magicwand.modification_popup_cheats_gui_data.cheats_gui_data) do
- gui_menu_cheats.create_cheat_elements_from_data_for_player(player, actions_frame, data, targets, false)
- end
- end
+ local player_gui = player.gui
+ local center = player_gui.center
+ -- Container.
+ local container = center[creative_mode_defines.names.gui.magic_wand_modifier_popup_container]
+ if container then
+ -- Already exists. Destroy it.
+ container.destroy()
+ end
+
+ if is_create then
+ container = center.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_container,
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_resize_col_flow,
+ direction = "horizontal",
+ })
+
+ -- Entities frame.
+ local entities_frame = container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame,
+ direction = "vertical",
+ })
+ -- Title container.
+ local entities_frame_title_container = entities_frame.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame_title_container,
+ direction = "horizontal",
+ })
+ -- Title label.
+ entities_frame_title_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame_title_label,
+ style = creative_mode_defines.names.gui_styles.magic_wand_popup_left_frame_caption_label,
+ caption = { "gui.creative-mode_magic-wand-short-modifier" },
+ })
+ -- Refresh button.
+ entities_frame_title_container.add({
+ type = "sprite-button",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame_refresh_button,
+ style = creative_mode_defines.names.gui_styles.frame_caption_button,
+ sprite = creative_mode_defines.names.sprites.reset,
+ tooltip = { "gui.creative-mode_refresh" },
+ })
+
+ -- Entities scroll-pane.
+ local entities_scroll_pane = entities_frame.add({
+ type = "scroll-pane",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_sroll_pane,
+ style = creative_mode_defines.names.gui_styles.magic_wand_popup_slot_scroll_pane,
+ })
+ -- Entities table.
+ local entities_table = entities_scroll_pane.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_table,
+ style = creative_mode_defines.names.gui_styles.magic_wand_popup_slot_table,
+ column_count = 10,
+ })
+ -- Group entities by their names. At the same time, remove invalid entities.
+ local sorted_entities = {}
+ local i = 1
+ local i_max = #storage.creative_mode.modifier_magic_wand_selection[player.index]
+ while i <= i_max do
+ local entity = storage.creative_mode.modifier_magic_wand_selection[player.index][i]
+ if entity.valid then
+ local final_entity_name
+ local stack = nil
+ local item_name = nil
+ local ghosted_entity_name = nil
+ local ghosted_tile_name = nil
+ local unit_number = entity.unit_number
+ if entity.name == "item-on-ground" then
+ -- If it is item-on-ground, further divide it accounding to its stack.
+ stack = entity.stack
+ final_entity_name = "item-on-ground_" .. stack.name
+ item_name = stack.name
+ elseif entity.name == "entity-ghost" then
+ -- Entity ghost.
+ final_entity_name = "entity-ghost_" .. entity.ghost_name
+ ghosted_entity_name = entity.ghost_name
+ elseif entity.name == "tile-ghost" then
+ -- Tile ghost.
+ final_entity_name = "tile-ghost_" .. entity.ghost_name
+ ghosted_tile_name = entity.ghost_name
+ else
+ -- Just a common entity.
+ final_entity_name = entity.name
+ end
+ if not sorted_entities[final_entity_name] then
+ sorted_entities[final_entity_name] = {}
+ sorted_entities[final_entity_name].item_name = item_name
+ sorted_entities[final_entity_name].ghosted_entity_name = ghosted_entity_name
+ sorted_entities[final_entity_name].ghosted_tile_name = ghosted_tile_name
+ sorted_entities[final_entity_name].entities = {}
+ if item_name then
+ sorted_entities[final_entity_name].stack_counts = {}
+ end
+ if unit_number then
+ sorted_entities[final_entity_name].unit_numbers = {}
+ end
+ end
+
+ table.insert(sorted_entities[final_entity_name].entities, entity)
+ if item_name then
+ -- We show 10, but insert 11, so we can determine whether we should show "...".
+ if #sorted_entities[final_entity_name].stack_counts < 11 then
+ table.insert(sorted_entities[final_entity_name].stack_counts, stack.count)
+ end
+ end
+ if unit_number then
+ if #sorted_entities[final_entity_name].unit_numbers < 11 then
+ table.insert(sorted_entities[final_entity_name].unit_numbers, unit_number)
+ end
+ end
+ i = i + 1
+ else
+ table.remove(storage.creative_mode.modifier_magic_wand_selection[player.index], i)
+ i_max = i_max - 1
+ end
+ end
+ -- Add entity buttons by entity names.
+ for entity_name, data in pairs(sorted_entities) do
+ local item_name = data.item_name
+ local ghosted_entity_name = data.ghosted_entity_name
+ local ghosted_tile_name = data.ghosted_tile_name
+ local entities = data.entities
+ local count = #entities
+ if count > 0 then
+ -- Sprite button.
+ local button_name
+ local button_sprite
+ local button_style
+ local button_tooltip
+ local label_name
+ if item_name then
+ -- item-on-ground
+ local item_prototype = prototypes.item[item_name]
+ local stack_counts = data.stack_counts
+ button_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_item_on_ground_name_slot_prefix
+ .. item_name
+ button_sprite = "item/" .. item_name
+ button_style = creative_mode_defines.names.gui_styles.magic_wand_popup_item_on_ground_slot_button
+ button_tooltip = {
+ "gui.creative-mode_item-on-ground-slot-tooltip",
+ item_prototype.localised_name,
+ { "gui.creative-mode_item-type", item_prototype.type },
+ { "gui.creative-mode_item-name", item_name },
+ { "gui.creative-mode_stack-count", get_string_for_info_array(stack_counts, 10) },
+ }
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_item_on_ground_count_label_prefix
+ .. item_name
+ elseif ghosted_entity_name then
+ -- entity-ghost
+ local entity_prototype = prototypes.entity[ghosted_entity_name]
+ local unit_numbers = data.unit_numbers
+ button_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_entity_name_slot_prefix
+ .. ghosted_entity_name
+ button_sprite = "entity/" .. ghosted_entity_name
+ button_style = creative_mode_defines.names.gui_styles.magic_wand_popup_ghost_slot_button
+ button_tooltip = {
+ "gui.creative-mode_ghost-entity-slot-tooltip",
+ entity_prototype.localised_name,
+ { "gui.creative-mode_entity-type", entity_prototype.type },
+ { "gui.creative-mode_entity-name", ghosted_entity_name },
+ { "gui.creative-mode_unit-number", get_string_for_info_array(unit_numbers, 10) },
+ }
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_entity_count_label_prefix
+ .. ghosted_entity_name
+ elseif ghosted_tile_name then
+ -- tile-ghost
+ local tile_prototype = prototypes.tile[ghosted_tile_name]
+ local unit_numbers = data.unit_numbers
+ button_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_tile_name_slot_prefix
+ .. ghosted_tile_name
+ button_sprite = "tile/" .. ghosted_tile_name
+ button_style = creative_mode_defines.names.gui_styles.magic_wand_popup_ghost_slot_button
+ button_tooltip = {
+ "gui.creative-mode_ghost-tile-slot-tooltip",
+ tile_prototype.localised_name,
+ { "gui.creative-mode_tile-name", ghosted_tile_name },
+ { "gui.creative-mode_unit-number", get_string_for_info_array(unit_numbers, 10) },
+ }
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_tile_count_label_prefix
+ .. ghosted_tile_name
+ else
+ -- common entity
+ local entity_prototype = prototypes.entity[entity_name]
+ local unit_numbers = data.unit_numbers
+ button_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entity_name_slot_prefix .. entity_name
+ button_sprite = "entity/" .. entity_name
+ button_style = creative_mode_defines.names.gui_styles.creative_chest_filter_slot_on
+ button_tooltip = {
+ "gui.creative-mode_entity-slot-tooltip",
+ entity_prototype.localised_name,
+ { "gui.creative-mode_entity-type", entity_prototype.type },
+ { "gui.creative-mode_entity-name", entity_name },
+ { "gui.creative-mode_unit-number", get_string_for_info_array(unit_numbers, 10) },
+ }
+ label_name = creative_mode_defines.names.gui.magic_wand_modifier_popup_entity_count_label_prefix
+ .. entity_name
+ end
+ if not helpers.is_valid_sprite_path(button_sprite) then
+ button_sprite = nil
+ end
+ entities_table.add({
+ type = "sprite-button",
+ name = button_name,
+ sprite = button_sprite,
+ style = button_style,
+ tooltip = button_tooltip,
+ })
+ -- Format count string. Give it a suffix if necessary.
+ local count_str
+ if count >= 1000000000 then
+ -- G
+ count_str = tostring(util.round(count / 1000000000 * 10) * 0.1) .. "G"
+ elseif count >= 1000000 then
+ -- M
+ count_str = tostring(util.round(count / 1000000 * 10) * 0.1) .. "M"
+ elseif count >= 1000 then
+ -- k
+ count_str = tostring(util.round(count / 1000 * 10) * 0.1) .. "k"
+ else
+ count_str = tostring(count)
+ end
+ count_str = "x" .. count_str
+ -- Count label.
+ entities_table.add({
+ type = "label",
+ name = label_name,
+ style = creative_mode_defines.names.gui_styles.slot_button_label,
+ caption = count_str,
+ })
+ end
+ end
+
+ -- Actions frame.
+ local actions_frame = container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame,
+ direction = "vertical",
+ })
+ -- Title container.
+ local actions_frame_title_container = actions_frame.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame_title_container,
+ direction = "horizontal",
+ })
+ -- Title label.
+ actions_frame_title_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame_title_label,
+ style = creative_mode_defines.names.gui_styles.magic_wand_popup_right_frame_caption_label,
+ caption = { "gui.creative-mode_actions" },
+ })
+ -- Close button.
+ actions_frame_title_container.add({
+ type = "sprite-button",
+ name = creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame_close_button,
+ style = creative_mode_defines.names.gui_styles.frame_caption_button,
+ sprite = creative_mode_defines.names.sprites.cancel,
+ tooltip = { "gui.creative-mode_close" },
+ })
+ -- Actions (cheats).
+ local targets = gui_menu_magicwand.modification_popup_cheats_gui_data.get_all_selected_targets_function(player)
+ for _, data in pairs(gui_menu_magicwand.modification_popup_cheats_gui_data.cheats_gui_data) do
+ gui_menu_cheats.create_cheat_elements_from_data_for_player(player, actions_frame, data, targets, false)
+ end
+ end
end
-- Updates the status of the options on modification popup for the given player according to his selected entities.
local function update_modification_popup_status_for_player(player)
- local actions_frame = gui_menu_magicwand.modification_popup_cheats_gui_data.get_cheats_container_function(player)
- if actions_frame then
- local targets = gui_menu_magicwand.modification_popup_cheats_gui_data.get_all_selected_targets_function(player)
- for _, data in pairs(gui_menu_magicwand.modification_popup_cheats_gui_data.cheats_gui_data) do
- gui_menu_cheats.update_cheat_status_from_data(actions_frame, data, targets)
- end
- end
+ local actions_frame = gui_menu_magicwand.modification_popup_cheats_gui_data.get_cheats_container_function(player)
+ if actions_frame then
+ local targets = gui_menu_magicwand.modification_popup_cheats_gui_data.get_all_selected_targets_function(player)
+ for _, data in pairs(gui_menu_magicwand.modification_popup_cheats_gui_data.cheats_gui_data) do
+ gui_menu_cheats.update_cheat_status_from_data(actions_frame, data, targets)
+ end
+ end
end
--------------------------------------------------------------------
-- Updates the magic wand menu accessibility according to the newest access right for the given player after the access rights of the given codes have changed.
function gui_menu_magicwand.update_menu_accessibility_according_to_access_right_for_player(
- player,
- updated_access_right_codes
+ player,
+ updated_access_right_codes
)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Magic wands container.
- local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
- if magic_wand_menus_container then
- -- Iterate all submenus.
- for _, data in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
- if updated_access_right_codes[data.access_right_code] then
- -- Check player access right.
- if data.get_player_can_access_function(player) then
- -- Player can access.
- -- Make sure the button is available for the player.
- local magic_wand_frame =
- magic_wand_menus_container[creative_mode_defines.names.gui.magic_wand_frame]
- local button = magic_wand_frame[data.button_name]
- button.visible = true
- else
- -- Player cannot access.
- -- Hide the menu button.
- local magic_wand_frame =
- magic_wand_menus_container[creative_mode_defines.names.gui.magic_wand_frame]
- local button = magic_wand_frame[data.button_name]
- button.visible = false
-
- -- Remove the menu.
- create_or_destroy_magic_wand_menu_for_player(player, data, true)
- end
- end
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Magic wands container.
+ local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
+ if magic_wand_menus_container then
+ -- Iterate all submenus.
+ for _, data in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
+ if updated_access_right_codes[data.access_right_code] then
+ -- Check player access right.
+ if data.get_player_can_access_function(player) then
+ -- Player can access.
+ -- Make sure the button is available for the player.
+ local magic_wand_frame = magic_wand_menus_container[creative_mode_defines.names.gui.magic_wand_frame]
+ local button = magic_wand_frame[data.button_name]
+ button.visible = true
+ else
+ -- Player cannot access.
+ -- Hide the menu button.
+ local magic_wand_frame = magic_wand_menus_container[creative_mode_defines.names.gui.magic_wand_frame]
+ local button = magic_wand_frame[data.button_name]
+ button.visible = false
+
+ -- Remove the menu.
+ create_or_destroy_magic_wand_menu_for_player(player, data, true)
+ end
+ end
+ end
+ end
+ end
end
--------------------------------------------------------------------
-- Deselects the currently selected tile or resource slot for the player in the given GUI container.
local function deselect_currently_selected_tile_or_resource_slot_for_player_in_container(
- player,
- select_mode_container,
- tiles_table_name,
- tile_name_button_prefix,
- get_selected_tile_function,
- resources_table_name,
- resource_name_button_prefix,
- get_selected_resource_function
+ player,
+ select_mode_container,
+ tiles_table_name,
+ tile_name_button_prefix,
+ get_selected_tile_function,
+ resources_table_name,
+ resource_name_button_prefix,
+ get_selected_resource_function
)
- local selected_tile = get_selected_tile_function(player)
- if selected_tile then
- local tiles_table = select_mode_container[tiles_table_name]
- tiles_table[tile_name_button_prefix .. selected_tile.name].style =
- creative_mode_defines.names.gui_styles.tile_slot_deselected
- return
- end
- local selected_resource = get_selected_resource_function(player)
- if selected_resource then
- local resources_table = select_mode_container[resources_table_name]
- resources_table[resource_name_button_prefix .. selected_resource.name].style =
- creative_mode_defines.names.gui_styles.tile_slot_deselected
- end
+ local selected_tile = get_selected_tile_function(player)
+ if selected_tile then
+ local tiles_table = select_mode_container[tiles_table_name]
+ tiles_table[tile_name_button_prefix .. selected_tile.name].style =
+ creative_mode_defines.names.gui_styles.tile_slot_deselected
+ return
+ end
+ local selected_resource = get_selected_resource_function(player)
+ if selected_resource then
+ local resources_table = select_mode_container[resources_table_name]
+ resources_table[resource_name_button_prefix .. selected_resource.name].style =
+ creative_mode_defines.names.gui_styles.tile_slot_deselected
+ end
end
-- Forward the on_gui_click event to the tiles selection table of the given name.
-- Returns whether the event is consumed and should no longer forward to other elements.
local function on_gui_click_in_tiles_table(
- element,
- element_name,
- player,
- tiles_table_name,
- set_selected_tile_prototype_function,
- tile_name_button_prefix,
- tile_name_button_pattern,
- get_selected_tile_function,
- resources_table_name,
- resource_name_button_prefix,
- get_selected_resource_function
+ element,
+ element_name,
+ player,
+ tiles_table_name,
+ set_selected_tile_prototype_function,
+ tile_name_button_prefix,
+ tile_name_button_pattern,
+ get_selected_tile_function,
+ resources_table_name,
+ resource_name_button_prefix,
+ get_selected_resource_function
)
- if element.parent and element.parent.name == tiles_table_name then
- -- Creator - tile slot.
- local style = element.style
- if style.name == creative_mode_defines.names.gui_styles.tile_slot_selected then
- -- Alread selected. Just deselect it.
- element.style = creative_mode_defines.names.gui_styles.tile_slot_deselected
- set_selected_tile_prototype_function(player, nil)
- else
- -- Not selected, deselect the currently selected button.
- -- slot -> table -> select-mode container
- local select_mode_container = element.parent.parent
- deselect_currently_selected_tile_or_resource_slot_for_player_in_container(
- player,
- select_mode_container,
- tiles_table_name,
- tile_name_button_prefix,
- get_selected_tile_function,
- resources_table_name,
- resource_name_button_prefix,
- get_selected_resource_function
- )
- local tile_name = string.match(element.name, tile_name_button_pattern)
- if tile_name ~= nil then
- -- Select the tile.
- local tile = prototypes.tile[tile_name]
- if tile then
- element.style = creative_mode_defines.names.gui_styles.tile_slot_selected
- set_selected_tile_prototype_function(player, tile)
- end
- end
- end
- return true
- end
+ if element.parent and element.parent.name == tiles_table_name then
+ -- Creator - tile slot.
+ local style = element.style
+ if style.name == creative_mode_defines.names.gui_styles.tile_slot_selected then
+ -- Alread selected. Just deselect it.
+ element.style = creative_mode_defines.names.gui_styles.tile_slot_deselected
+ set_selected_tile_prototype_function(player, nil)
+ else
+ -- Not selected, deselect the currently selected button.
+ -- slot -> table -> select-mode container
+ local select_mode_container = element.parent.parent
+ deselect_currently_selected_tile_or_resource_slot_for_player_in_container(
+ player,
+ select_mode_container,
+ tiles_table_name,
+ tile_name_button_prefix,
+ get_selected_tile_function,
+ resources_table_name,
+ resource_name_button_prefix,
+ get_selected_resource_function
+ )
+ local tile_name = string.match(element.name, tile_name_button_pattern)
+ if tile_name ~= nil then
+ -- Select the tile.
+ local tile = prototypes.tile[tile_name]
+ if tile then
+ element.style = creative_mode_defines.names.gui_styles.tile_slot_selected
+ set_selected_tile_prototype_function(player, tile)
+ end
+ end
+ end
+ return true
+ end
end
-- Forward the on_gui_click event to the resources selection table of the given name.
-- Returns whether the event is consumed and should no longer forward to other elements.
local function on_gui_click_in_resources_table(
- element,
- element_name,
- player,
- resources_table_name,
- set_selected_resource_prototype_function,
- resource_name_button_prefix,
- resource_name_button_pattern,
- get_selected_resource_function,
- tiles_table_name,
- tile_name_button_prefix,
- get_selected_tile_function
+ element,
+ element_name,
+ player,
+ resources_table_name,
+ set_selected_resource_prototype_function,
+ resource_name_button_prefix,
+ resource_name_button_pattern,
+ get_selected_resource_function,
+ tiles_table_name,
+ tile_name_button_prefix,
+ get_selected_tile_function
)
- if element.parent and element.parent.name == resources_table_name then
- -- Creator - resource slot.
- local style = element.style
- if style.name == creative_mode_defines.names.gui_styles.tile_slot_selected then
- -- Alread selected. Just deselect it.
- element.style = creative_mode_defines.names.gui_styles.tile_slot_deselected
- set_selected_resource_prototype_function(player, nil)
- else
- -- Not selected, deselect the currently selected button.
- -- slot -> table -> select-mode container
- local select_mode_container = element.parent.parent
- deselect_currently_selected_tile_or_resource_slot_for_player_in_container(
- player,
- select_mode_container,
- tiles_table_name,
- tile_name_button_prefix,
- get_selected_tile_function,
- resources_table_name,
- resource_name_button_prefix,
- get_selected_resource_function
- )
- local resource_name = string.match(element.name, resource_name_button_pattern)
- if resource_name ~= nil then
- -- Select the resource.
- local resource = prototypes.entity[resource_name]
- if resource then
- element.style = creative_mode_defines.names.gui_styles.tile_slot_selected
- set_selected_resource_prototype_function(player, resource)
- end
- end
- end
- return true
- end
+ if element.parent and element.parent.name == resources_table_name then
+ -- Creator - resource slot.
+ local style = element.style
+ if style.name == creative_mode_defines.names.gui_styles.tile_slot_selected then
+ -- Alread selected. Just deselect it.
+ element.style = creative_mode_defines.names.gui_styles.tile_slot_deselected
+ set_selected_resource_prototype_function(player, nil)
+ else
+ -- Not selected, deselect the currently selected button.
+ -- slot -> table -> select-mode container
+ local select_mode_container = element.parent.parent
+ deselect_currently_selected_tile_or_resource_slot_for_player_in_container(
+ player,
+ select_mode_container,
+ tiles_table_name,
+ tile_name_button_prefix,
+ get_selected_tile_function,
+ resources_table_name,
+ resource_name_button_prefix,
+ get_selected_resource_function
+ )
+ local resource_name = string.match(element.name, resource_name_button_pattern)
+ if resource_name ~= nil then
+ -- Select the resource.
+ local resource = prototypes.entity[resource_name]
+ if resource then
+ element.style = creative_mode_defines.names.gui_styles.tile_slot_selected
+ set_selected_resource_prototype_function(player, resource)
+ end
+ end
+ end
+ return true
+ end
end
-- Updates all resource amount slider buttons as well as the textfield in the given container according to the given value.
local function update_resource_amount_slider_buttons_and_textfield_in_container(
- resource_amount_container,
- resource_amount,
- slider_button_name_prefix,
- slider_textfield_name
+ resource_amount_container,
+ resource_amount,
+ slider_button_name_prefix,
+ slider_textfield_name
)
- for i, value in ipairs(creator_resource_amount_slider_values) do
- local style
- if value <= resource_amount then
- style = creative_mode_defines.names.gui_styles.slider_button_on
- else
- style = creative_mode_defines.names.gui_styles.slider_button_off
- end
- resource_amount_container[slider_button_name_prefix .. i].style = style
- end
- resource_amount_container[slider_textfield_name].text = tostring(resource_amount)
+ for i, value in ipairs(creator_resource_amount_slider_values) do
+ local style
+ if value <= resource_amount then
+ style = creative_mode_defines.names.gui_styles.slider_button_on
+ else
+ style = creative_mode_defines.names.gui_styles.slider_button_off
+ end
+ resource_amount_container[slider_button_name_prefix .. i].style = style
+ end
+ resource_amount_container[slider_textfield_name].text = tostring(resource_amount)
end
-- Forward the on_gui_click event to the resource amount slider container of the given name.
-- Returns whether the event is consumed and should no longer forward to other elements.
local function on_gui_click_in_resource_amount_slider(
- element,
- element_name,
- player,
- slider_container_name,
- slider_button_name_prefix,
- slider_button_name_pattern,
- set_resource_amount_function,
- slider_textfield_name
+ element,
+ element_name,
+ player,
+ slider_container_name,
+ slider_button_name_prefix,
+ slider_button_name_pattern,
+ set_resource_amount_function,
+ slider_textfield_name
)
- if element.parent and element.parent.name == slider_container_name then
- -- Creator - resource amount slider button.
- if element.type == "button" then
- local button_index = string.match(element_name, slider_button_name_pattern)
- if button_index then
- button_index = tonumber(button_index)
- if button_index and button_index >= 1 and button_index <= #creator_resource_amount_slider_values then
- local resource_amount = creator_resource_amount_slider_values[button_index]
- -- Set amount.
- set_resource_amount_function(player, resource_amount)
- -- Update the slider.
- update_resource_amount_slider_buttons_and_textfield_in_container(
- element.parent,
- resource_amount,
- slider_button_name_prefix,
- slider_textfield_name
- )
- end
- end
- end
- return true
- end
+ if element.parent and element.parent.name == slider_container_name then
+ -- Creator - resource amount slider button.
+ if element.type == "button" then
+ local button_index = string.match(element_name, slider_button_name_pattern)
+ if button_index then
+ button_index = tonumber(button_index)
+ if button_index and button_index >= 1 and button_index <= #creator_resource_amount_slider_values then
+ local resource_amount = creator_resource_amount_slider_values[button_index]
+ -- Set amount.
+ set_resource_amount_function(player, resource_amount)
+ -- Update the slider.
+ update_resource_amount_slider_buttons_and_textfield_in_container(
+ element.parent,
+ resource_amount,
+ slider_button_name_prefix,
+ slider_textfield_name
+ )
+ end
+ end
+ end
+ return true
+ end
end
-- Unchecks all radiobuttons in the given container except the given one.
local function uncheck_other_radiobuttons_in_container(container, exclude_radiobutton)
- for _, child_name in ipairs(container.children_names) do
- local radiobutton = container[child_name]
- if radiobutton ~= exclude_radiobutton then
- radiobutton.state = false
- end
- end
+ for _, child_name in ipairs(container.children_names) do
+ local radiobutton = container[child_name]
+ if radiobutton ~= exclude_radiobutton then
+ radiobutton.state = false
+ end
+ end
end
----
@@ -1717,37 +1713,37 @@ end
-- Returns whether the event is consumed and should no longer forward to other elements.
-- @param set_force_function Function(player, force, enable)
local function on_gui_click_in_forces_table_select_all_button(
- element,
- element_name,
- player,
- select_all_button_name,
- set_force_function
+ element,
+ element_name,
+ player,
+ select_all_button_name,
+ set_force_function
)
- if element.name == select_all_button_name then
- -- button -> table.
- local force_table = element.parent
- -- Select or deselect?
- local select_all = false
- for _, child_name in ipairs(force_table.children_names) do
- local child = force_table[child_name]
- if child.type == "checkbox" and child.state == false then
- select_all = true
- break
- end
- end
- -- Apply.
- for _, child_name in ipairs(force_table.children_names) do
- local child = force_table[child_name]
- if child.type == "checkbox" then
- child.state = select_all
- end
- end
- for _, force in pairs(game.forces) do
- set_force_function(player, force, select_all)
- end
-
- return true
- end
+ if element.name == select_all_button_name then
+ -- button -> table.
+ local force_table = element.parent
+ -- Select or deselect?
+ local select_all = false
+ for _, child_name in ipairs(force_table.children_names) do
+ local child = force_table[child_name]
+ if child.type == "checkbox" and child.state == false then
+ select_all = true
+ break
+ end
+ end
+ -- Apply.
+ for _, child_name in ipairs(force_table.children_names) do
+ local child = force_table[child_name]
+ if child.type == "checkbox" then
+ child.state = select_all
+ end
+ end
+ for _, force in pairs(game.forces) do
+ set_force_function(player, force, select_all)
+ end
+
+ return true
+ end
end
-- Checks and possibly removes the clicked entity slot on the modifier popup according to the given rules for finding entities. Also removes corresponding entries in the player selection.
@@ -1756,31 +1752,31 @@ end
-- label_name_prefix: prefix of the label name for that slot
-- check_entity_is_target_function: function for checking if each selected entity matches the actual target. It should accept the entity and the actual target name.
local function check_and_remove_modifier_popup_slot_by_rules(element, element_name, player, rules)
- for _, rule in pairs(rules) do
- local target_name = string.match(element_name, rule.slot_name_match_pattern)
- if target_name then
- -- Remove the entry from the table.
- local label = element.parent[rule.label_name_prefix .. target_name]
- if label then
- label.destroy()
- element.destroy()
-
- -- Also remove from the selection.
- for i = #storage.creative_mode.modifier_magic_wand_selection[player.index], 1, -1 do
- local entity = storage.creative_mode.modifier_magic_wand_selection[player.index][i]
- if not entity.valid or rule.check_entity_is_target_function(entity, target_name) then
- table.remove(storage.creative_mode.modifier_magic_wand_selection[player.index], i)
- end
- end
-
- -- Update options status.
- update_modification_popup_status_for_player(player)
- end
- return true
- end
- end
-
- return false
+ for _, rule in pairs(rules) do
+ local target_name = string.match(element_name, rule.slot_name_match_pattern)
+ if target_name then
+ -- Remove the entry from the table.
+ local label = element.parent[rule.label_name_prefix .. target_name]
+ if label then
+ label.destroy()
+ element.destroy()
+
+ -- Also remove from the selection.
+ for i = #storage.creative_mode.modifier_magic_wand_selection[player.index], 1, -1 do
+ local entity = storage.creative_mode.modifier_magic_wand_selection[player.index][i]
+ if not entity.valid or rule.check_entity_is_target_function(entity, target_name) then
+ table.remove(storage.creative_mode.modifier_magic_wand_selection[player.index], i)
+ end
+ end
+
+ -- Update options status.
+ update_modification_popup_status_for_player(player)
+ end
+ return true
+ end
+ end
+
+ return false
end
----
@@ -1788,688 +1784,664 @@ end
-- Callback of the on_gui_click event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_magicwand.on_gui_click(element, element_name, player, button, alt, control, shift)
- for _, data in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
- if element_name == data.button_name then
- -- Magic wand menu button.
- -- Close other menus.
- for _, data2 in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
- if data ~= data2 then
- create_or_destroy_magic_wand_menu_for_player(player, data2, true)
- end
- end
- -- Open menu.
- create_or_destroy_magic_wand_menu_for_player(player, data, false)
- return true
- end
-
- if element_name == data.contents.get_item_button_name then
- -- Get magic wand item button.
- player.clear_cursor()
- -- If the player already has the item, destroy it.
- local magic_wand_item_stack = {
- name = data.contents.item_name,
- count = 1,
- }
- player.remove_item(magic_wand_item_stack)
- -- Give one to his cursor stack.
- player.cursor_stack.set_stack(magic_wand_item_stack)
- end
- end
-
- --------------------------------------------------------------------
-
- if
- on_gui_click_in_tiles_table(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_tiles_table,
- magic_wand_creator.set_selected_tile_prototype,
- creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_prefix,
- creative_mode_defines.match_patterns.gui.magic_wand_creator_tile_name_button,
- magic_wand_creator.get_selected_tile_prototype,
- creative_mode_defines.names.gui.magic_wand_creator_resources_table,
- creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_prefix,
- magic_wand_creator.get_selected_resource_prototype
- )
- then
- -- Creator - tile slot.
- return true
- end
-
- if
- on_gui_click_in_resources_table(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_resources_table,
- magic_wand_creator.set_selected_resource_prototype,
- creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_prefix,
- creative_mode_defines.match_patterns.gui.magic_wand_creator_resource_name_button,
- magic_wand_creator.get_selected_resource_prototype,
- creative_mode_defines.names.gui.magic_wand_creator_tiles_table,
- creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_prefix,
- magic_wand_creator.get_selected_tile_prototype
- )
- then
- -- Creator - resource slot.
- return true
- end
-
- if
- on_gui_click_in_resource_amount_slider(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_container,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_prefix,
- creative_mode_defines.match_patterns.gui.magic_wand_creator_rsc_amt_slider_button,
- magic_wand_creator.set_resource_amount,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield
- )
- then
- -- Creator - resource amount slider button.
- return true
- end
-
- if
- on_gui_click_in_forces_table_select_all_button(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_alt_forces_select_all_button,
- magic_wand_creator.set_alt_mode_apply_on_force
- )
- then
- -- Creator - select all forces button for alt mode.
- return true
- end
-
- if
- on_gui_click_in_tiles_table(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_tiles_table_2,
- magic_wand_creator.set_selected_tile_prototype_2,
- creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_2_prefix,
- creative_mode_defines.match_patterns.gui.magic_wand_creator_tile_name_button_2,
- magic_wand_creator.get_selected_tile_prototype_2,
- creative_mode_defines.names.gui.magic_wand_creator_resources_table_2,
- creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_2_prefix,
- magic_wand_creator.get_selected_resource_prototype_2
- )
- then
- -- Creator - tile slot 2.
- return true
- end
-
- if
- on_gui_click_in_resources_table(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_resources_table_2,
- magic_wand_creator.set_selected_resource_prototype_2,
- creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_2_prefix,
- creative_mode_defines.match_patterns.gui.magic_wand_creator_resource_name_button_2,
- magic_wand_creator.get_selected_resource_prototype_2,
- creative_mode_defines.names.gui.magic_wand_creator_tiles_table_2,
- creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_2_prefix,
- magic_wand_creator.get_selected_tile_prototype_2
- )
- then
- -- Creator - resource slot 2.
- return true
- end
-
- if
- on_gui_click_in_resource_amount_slider(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_container_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_2_prefix,
- creative_mode_defines.match_patterns.gui.magic_wand_creator_rsc_amt_slider_button_2,
- magic_wand_creator.set_resource_amount_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield_2
- )
- then
- -- Creator - resource amount slider button 2.
- return true
- end
-
- --------------------------------------------------------------------
-
- if
- on_gui_click_in_forces_table_select_all_button(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_healer_heal_forces_select_all_button,
- magic_wand_healer.set_heal_entities_on_force
- )
- then
- -- Healer - select all forces button for healing.
- return true
- end
-
- if
- on_gui_click_in_forces_table_select_all_button(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_healer_alt_forces_select_all_button,
- magic_wand_healer.set_alt_mode_apply_on_force
- )
- then
- -- Healer - select all forces button for alt mode.
- return true
- end
-
- --------------------------------------------------------------------
-
- if
- on_gui_click_in_forces_table_select_all_button(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_modifier_std_forces_select_all_button,
- magic_wand_modifier.set_std_select_entities_on_force
- )
- then
- -- Modifier - select all forces button for std mode.
- return true
- end
-
- if
- on_gui_click_in_forces_table_select_all_button(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_select_all_button,
- magic_wand_modifier.set_alt_select_entities_on_force
- )
- then
- -- Modifier - select all forces button for alt mode.
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_modifier_quick_action_remove_button then
- -- Modifier - quick action remove button.
- -- remove button -> action container.
- local action_container = element.parent
- -- action container -> actions container.
- local actions_container = action_container.parent
- -- actions container -> alt select mode container.
- local container = actions_container.parent
- local action_index = string.match(
- action_container.name,
- creative_mode_defines.match_patterns.gui.magic_wand_modifier_quick_action_container
- )
- if action_index then
- action_index = tonumber(action_index)
- -- Remove action.
- table.remove(storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions, action_index)
- -- Refresh GUI.
- refresh_elements_for_recorded_actions_of_modifier(player, actions_container, container)
- end
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_modifier_remove_all_quick_actions_button then
- -- Modifier - remove all quick actions button.
- -- button -> alt select mode container.
- local container = element.parent
- local actions_container = container[creative_mode_defines.names.gui.magic_wand_modifier_quick_actions_container]
- -- Remove all actions.
- storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions = nil
- -- Refresh GUI.
- refresh_elements_for_recorded_actions_of_modifier(player, actions_container, container)
- return true
- end
-
- ----
-
- if element.name == creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame_refresh_button then
- -- Modifier popup - refresh.
- -- The best way to do is create the popup again.
- gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, true)
- return true
- end
-
- if element.name == creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame_close_button then
- -- Modifier popup - close.
- gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
- return true
- end
-
- if
- element.parent
- and element.parent.name == creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_table
- then
- if element.type == "sprite-button" then
- -- Modifier popup - entity button.
- check_and_remove_modifier_popup_slot_by_rules(element, element_name, player, {
- common_entity_rule = {
- slot_name_match_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_popup_entity_name_slot,
- label_name_prefix = creative_mode_defines.names.gui.magic_wand_modifier_popup_entity_count_label_prefix,
- check_entity_is_target_function = function(entity, entity_name)
- return entity.name == entity_name
- end,
- },
- item_on_ground_entity_rule = {
- slot_name_match_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_popup_item_on_ground_name_slot,
- label_name_prefix = creative_mode_defines.names.gui.magic_wand_modifier_popup_item_on_ground_count_label_prefix,
- check_entity_is_target_function = function(entity, stack_name)
- return entity.name == "item-on-ground" and entity.stack.name == stack_name
- end,
- },
- ghost_entity_rule = {
- slot_name_match_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_popup_ghost_entity_name_slot,
- label_name_prefix = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_entity_count_label_prefix,
- check_entity_is_target_function = function(entity, ghosted_entity_name)
- return entity.name == "entity-ghost" and entity.ghost_name == ghosted_entity_name
- end,
- },
- ghost_tile_rule = {
- slot_name_match_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_popup_ghost_tile_name_slot,
- label_name_prefix = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_tile_count_label_prefix,
- check_entity_is_target_function = function(entity, ghosted_tile_name)
- return entity.name == "tile-ghost" and entity.ghost_name == ghosted_tile_name
- end,
- },
- })
- return true
- end
- end
-
- -- Check the options in modifier popup.
- local clicked, cheat_gui_data, applied_value = gui_menu_cheats.on_gui_click_in_cheats_menu_toggles(
- element,
- element_name,
- player,
- gui_menu_magicwand.modification_popup_cheats_gui_data,
- function(targets, applied_cheat_gui_data, applied_value)
- -- Create smoke on the affected entities, before the modification is applied, because they will become inaccessible if the modification is destroy.
- for _, entity in ipairs(targets) do
- if entity.valid then
- magic_wand_modifier.create_smoke_effect_at_entity_position(entity)
- end
- end
- end
- )
- if clicked then
- if cheat_gui_data then
- -- We will need to update the actions in the magic wand menu if it is opened.
- local alt_select_mode_container = nil
- local actions_container = nil
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
- if magic_wand_menus_container then
- local contents_data = gui_menu_magicwand.magic_wand_menus_gui_data.modifier.contents
- -- Frame.
- local frame = magic_wand_menus_container[contents_data.frame_name]
- if frame then
- -- Scroll-pane.
- local scroll_pane = frame[contents_data.scroll_pane_name]
- -- Container.
- local flow = scroll_pane[contents_data.container_name]
- -- Alt select mode container.
- alt_select_mode_container = flow[contents_data.alt_select_mode_container_name]
- -- Actions container.
- actions_container =
- alt_select_mode_container[creative_mode_defines.names.gui.magic_wand_modifier_quick_actions_container]
- end
- end
- end
-
- -- A cheat data is activated, record it.
- if storage.creative_mode.modifier_magic_wand_quick_actions[player.index].reset_when_new_action_received then
- -- Reset the stored actions.
- storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions = {}
- storage.creative_mode.modifier_magic_wand_quick_actions[player.index].reset_when_new_action_received =
- false
- -- Update GUI.
- if actions_container then
- clear_all_elements_for_recorded_actions_of_modifier(actions_container, alt_select_mode_container)
- end
- end
-
- -- Record action.
- local new_action = {
- code = cheat_gui_data.action_code,
- value = applied_value,
- }
- table.insert(storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions, new_action)
- -- Update GUI.
- if actions_container then
- create_elements_for_recorded_action_of_modifier(actions_container, new_action)
- create_remove_all_recorded_actions_button_in_container(alt_select_mode_container)
- end
-
- -- Close the popup if necessary.
- if cheat_gui_data.close_popup_after_applied then
- gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
- end
- end
- return true
- end
-
- return false
+ for _, data in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
+ if element_name == data.button_name then
+ -- Magic wand menu button.
+ -- Close other menus.
+ for _, data2 in pairs(gui_menu_magicwand.magic_wand_menus_gui_data) do
+ if data ~= data2 then
+ create_or_destroy_magic_wand_menu_for_player(player, data2, true)
+ end
+ end
+ -- Open menu.
+ create_or_destroy_magic_wand_menu_for_player(player, data, false)
+ return true
+ end
+
+ if element_name == data.contents.get_item_button_name then
+ -- Get magic wand item button.
+ player.clear_cursor()
+ -- If the player already has the item, destroy it.
+ local magic_wand_item_stack = {
+ name = data.contents.item_name,
+ count = 1,
+ }
+ player.remove_item(magic_wand_item_stack)
+ -- Give one to his cursor stack.
+ player.cursor_stack.set_stack(magic_wand_item_stack)
+ end
+ end
+
+ --------------------------------------------------------------------
+
+ if
+ on_gui_click_in_tiles_table(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_tiles_table,
+ magic_wand_creator.set_selected_tile_prototype,
+ creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_prefix,
+ creative_mode_defines.match_patterns.gui.magic_wand_creator_tile_name_button,
+ magic_wand_creator.get_selected_tile_prototype,
+ creative_mode_defines.names.gui.magic_wand_creator_resources_table,
+ creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_prefix,
+ magic_wand_creator.get_selected_resource_prototype
+ )
+ then
+ -- Creator - tile slot.
+ return true
+ end
+
+ if
+ on_gui_click_in_resources_table(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_resources_table,
+ magic_wand_creator.set_selected_resource_prototype,
+ creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_prefix,
+ creative_mode_defines.match_patterns.gui.magic_wand_creator_resource_name_button,
+ magic_wand_creator.get_selected_resource_prototype,
+ creative_mode_defines.names.gui.magic_wand_creator_tiles_table,
+ creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_prefix,
+ magic_wand_creator.get_selected_tile_prototype
+ )
+ then
+ -- Creator - resource slot.
+ return true
+ end
+
+ if
+ on_gui_click_in_resource_amount_slider(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_container,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_prefix,
+ creative_mode_defines.match_patterns.gui.magic_wand_creator_rsc_amt_slider_button,
+ magic_wand_creator.set_resource_amount,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield
+ )
+ then
+ -- Creator - resource amount slider button.
+ return true
+ end
+
+ if
+ on_gui_click_in_forces_table_select_all_button(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_alt_forces_select_all_button,
+ magic_wand_creator.set_alt_mode_apply_on_force
+ )
+ then
+ -- Creator - select all forces button for alt mode.
+ return true
+ end
+
+ if
+ on_gui_click_in_tiles_table(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_tiles_table_2,
+ magic_wand_creator.set_selected_tile_prototype_2,
+ creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_2_prefix,
+ creative_mode_defines.match_patterns.gui.magic_wand_creator_tile_name_button_2,
+ magic_wand_creator.get_selected_tile_prototype_2,
+ creative_mode_defines.names.gui.magic_wand_creator_resources_table_2,
+ creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_2_prefix,
+ magic_wand_creator.get_selected_resource_prototype_2
+ )
+ then
+ -- Creator - tile slot 2.
+ return true
+ end
+
+ if
+ on_gui_click_in_resources_table(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_resources_table_2,
+ magic_wand_creator.set_selected_resource_prototype_2,
+ creative_mode_defines.names.gui.magic_wand_creator_resource_name_button_2_prefix,
+ creative_mode_defines.match_patterns.gui.magic_wand_creator_resource_name_button_2,
+ magic_wand_creator.get_selected_resource_prototype_2,
+ creative_mode_defines.names.gui.magic_wand_creator_tiles_table_2,
+ creative_mode_defines.names.gui.magic_wand_creator_tile_name_button_2_prefix,
+ magic_wand_creator.get_selected_tile_prototype_2
+ )
+ then
+ -- Creator - resource slot 2.
+ return true
+ end
+
+ if
+ on_gui_click_in_resource_amount_slider(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_container_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_2_prefix,
+ creative_mode_defines.match_patterns.gui.magic_wand_creator_rsc_amt_slider_button_2,
+ magic_wand_creator.set_resource_amount_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield_2
+ )
+ then
+ -- Creator - resource amount slider button 2.
+ return true
+ end
+
+ --------------------------------------------------------------------
+
+ if
+ on_gui_click_in_forces_table_select_all_button(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_healer_heal_forces_select_all_button,
+ magic_wand_healer.set_heal_entities_on_force
+ )
+ then
+ -- Healer - select all forces button for healing.
+ return true
+ end
+
+ if
+ on_gui_click_in_forces_table_select_all_button(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_healer_alt_forces_select_all_button,
+ magic_wand_healer.set_alt_mode_apply_on_force
+ )
+ then
+ -- Healer - select all forces button for alt mode.
+ return true
+ end
+
+ --------------------------------------------------------------------
+
+ if
+ on_gui_click_in_forces_table_select_all_button(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_modifier_std_forces_select_all_button,
+ magic_wand_modifier.set_std_select_entities_on_force
+ )
+ then
+ -- Modifier - select all forces button for std mode.
+ return true
+ end
+
+ if
+ on_gui_click_in_forces_table_select_all_button(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_select_all_button,
+ magic_wand_modifier.set_alt_select_entities_on_force
+ )
+ then
+ -- Modifier - select all forces button for alt mode.
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_modifier_quick_action_remove_button then
+ -- Modifier - quick action remove button.
+ -- remove button -> action container.
+ local action_container = element.parent
+ -- action container -> actions container.
+ local actions_container = action_container.parent
+ -- actions container -> alt select mode container.
+ local container = actions_container.parent
+ local action_index = string.match(
+ action_container.name,
+ creative_mode_defines.match_patterns.gui.magic_wand_modifier_quick_action_container
+ )
+ if action_index then
+ action_index = tonumber(action_index)
+ -- Remove action.
+ table.remove(storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions, action_index)
+ -- Refresh GUI.
+ refresh_elements_for_recorded_actions_of_modifier(player, actions_container, container)
+ end
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_modifier_remove_all_quick_actions_button then
+ -- Modifier - remove all quick actions button.
+ -- button -> alt select mode container.
+ local container = element.parent
+ local actions_container = container[creative_mode_defines.names.gui.magic_wand_modifier_quick_actions_container]
+ -- Remove all actions.
+ storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions = nil
+ -- Refresh GUI.
+ refresh_elements_for_recorded_actions_of_modifier(player, actions_container, container)
+ return true
+ end
+
+ ----
+
+ if element.name == creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_frame_refresh_button then
+ -- Modifier popup - refresh.
+ -- The best way to do is create the popup again.
+ gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, true)
+ return true
+ end
+
+ if element.name == creative_mode_defines.names.gui.magic_wand_modifier_popup_actions_frame_close_button then
+ -- Modifier popup - close.
+ gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
+ return true
+ end
+
+ if
+ element.parent and element.parent.name == creative_mode_defines.names.gui.magic_wand_modifier_popup_entities_table
+ then
+ if element.type == "sprite-button" then
+ -- Modifier popup - entity button.
+ check_and_remove_modifier_popup_slot_by_rules(element, element_name, player, {
+ common_entity_rule = {
+ slot_name_match_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_popup_entity_name_slot,
+ label_name_prefix = creative_mode_defines.names.gui.magic_wand_modifier_popup_entity_count_label_prefix,
+ check_entity_is_target_function = function(entity, entity_name)
+ return entity.name == entity_name
+ end,
+ },
+ item_on_ground_entity_rule = {
+ slot_name_match_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_popup_item_on_ground_name_slot,
+ label_name_prefix = creative_mode_defines.names.gui.magic_wand_modifier_popup_item_on_ground_count_label_prefix,
+ check_entity_is_target_function = function(entity, stack_name)
+ return entity.name == "item-on-ground" and entity.stack.name == stack_name
+ end,
+ },
+ ghost_entity_rule = {
+ slot_name_match_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_popup_ghost_entity_name_slot,
+ label_name_prefix = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_entity_count_label_prefix,
+ check_entity_is_target_function = function(entity, ghosted_entity_name)
+ return entity.name == "entity-ghost" and entity.ghost_name == ghosted_entity_name
+ end,
+ },
+ ghost_tile_rule = {
+ slot_name_match_pattern = creative_mode_defines.match_patterns.gui.magic_wand_modifier_popup_ghost_tile_name_slot,
+ label_name_prefix = creative_mode_defines.names.gui.magic_wand_modifier_popup_ghost_tile_count_label_prefix,
+ check_entity_is_target_function = function(entity, ghosted_tile_name)
+ return entity.name == "tile-ghost" and entity.ghost_name == ghosted_tile_name
+ end,
+ },
+ })
+ return true
+ end
+ end
+
+ -- Check the options in modifier popup.
+ local clicked, cheat_gui_data, applied_value = gui_menu_cheats.on_gui_click_in_cheats_menu_toggles(
+ element,
+ element_name,
+ player,
+ gui_menu_magicwand.modification_popup_cheats_gui_data,
+ function(targets, applied_cheat_gui_data, applied_value)
+ -- Create smoke on the affected entities, before the modification is applied, because they will become inaccessible if the modification is destroy.
+ for _, entity in ipairs(targets) do
+ if entity.valid then
+ magic_wand_modifier.create_smoke_effect_at_entity_position(entity)
+ end
+ end
+ end
+ )
+ if clicked then
+ if cheat_gui_data then
+ -- We will need to update the actions in the magic wand menu if it is opened.
+ local alt_select_mode_container = nil
+ local actions_container = nil
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local magic_wand_menus_container = container[gui_menu_magicwand.get_container_name()]
+ if magic_wand_menus_container then
+ local contents_data = gui_menu_magicwand.magic_wand_menus_gui_data.modifier.contents
+ -- Frame.
+ local frame = magic_wand_menus_container[contents_data.frame_name]
+ if frame then
+ -- Scroll-pane.
+ local scroll_pane = frame[contents_data.scroll_pane_name]
+ -- Container.
+ local flow = scroll_pane[contents_data.container_name]
+ -- Alt select mode container.
+ alt_select_mode_container = flow[contents_data.alt_select_mode_container_name]
+ -- Actions container.
+ actions_container =
+ alt_select_mode_container[creative_mode_defines.names.gui.magic_wand_modifier_quick_actions_container]
+ end
+ end
+ end
+
+ -- A cheat data is activated, record it.
+ if storage.creative_mode.modifier_magic_wand_quick_actions[player.index].reset_when_new_action_received then
+ -- Reset the stored actions.
+ storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions = {}
+ storage.creative_mode.modifier_magic_wand_quick_actions[player.index].reset_when_new_action_received = false
+ -- Update GUI.
+ if actions_container then
+ clear_all_elements_for_recorded_actions_of_modifier(actions_container, alt_select_mode_container)
+ end
+ end
+
+ -- Record action.
+ local new_action = {
+ code = cheat_gui_data.action_code,
+ value = applied_value,
+ }
+ table.insert(storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions, new_action)
+ -- Update GUI.
+ if actions_container then
+ create_elements_for_recorded_action_of_modifier(actions_container, new_action)
+ create_remove_all_recorded_actions_button_in_container(alt_select_mode_container)
+ end
+
+ -- Close the popup if necessary.
+ if cheat_gui_data.close_popup_after_applied then
+ gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
+ end
+ end
+ return true
+ end
+
+ return false
end
-- Forward the on_gui_text_changed event to the textfield of the given name in the resource amount slider.
-- Returns whether the event is consumed and should no longer forward to the other elements.
local function on_gui_text_changed_in_resource_amount_slider_textfield(
- element,
- element_name,
- player,
- textfield_name,
- set_resource_amount_function,
- slider_button_name_prefix
+ element,
+ element_name,
+ player,
+ textfield_name,
+ set_resource_amount_function,
+ slider_button_name_prefix
)
- if element_name == textfield_name then
- -- Creator - resource amount textfield.
- -- Clamp amount.
- local resource_amount = tonumber(element.text)
- if resource_amount then
- resource_amount = util.clamp(resource_amount, 1, 1000000000)
- else
- resource_amount = 1
- end
- -- Set amount.
- set_resource_amount_function(player, resource_amount)
- -- Update the slider.
- local resource_amount_container = element.parent
- update_resource_amount_slider_buttons_and_textfield_in_container(
- resource_amount_container,
- resource_amount,
- slider_button_name_prefix,
- textfield_name
- )
- return true
- end
+ if element_name == textfield_name then
+ -- Creator - resource amount textfield.
+ -- Clamp amount.
+ local resource_amount = tonumber(element.text)
+ if resource_amount then
+ resource_amount = util.clamp(resource_amount, 1, 1000000000)
+ else
+ resource_amount = 1
+ end
+ -- Set amount.
+ set_resource_amount_function(player, resource_amount)
+ -- Update the slider.
+ local resource_amount_container = element.parent
+ update_resource_amount_slider_buttons_and_textfield_in_container(
+ resource_amount_container,
+ resource_amount,
+ slider_button_name_prefix,
+ textfield_name
+ )
+ return true
+ end
end
-- Callback of the on_gui_text_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_magicwand.on_gui_text_changed(element, element_name, player)
- if
- on_gui_text_changed_in_resource_amount_slider_textfield(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield,
- magic_wand_creator.set_resource_amount,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_prefix
- )
- then
- -- Creator - resource amount textfield.
- return true
- end
-
- if
- on_gui_text_changed_in_resource_amount_slider_textfield(
- element,
- element_name,
- player,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield_2,
- magic_wand_creator.set_resource_amount_2,
- creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_2_prefix
- )
- then
- -- Creator - resource amount textfield 2.
- return true
- end
-
- return false
+ if
+ on_gui_text_changed_in_resource_amount_slider_textfield(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield,
+ magic_wand_creator.set_resource_amount,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_prefix
+ )
+ then
+ -- Creator - resource amount textfield.
+ return true
+ end
+
+ if
+ on_gui_text_changed_in_resource_amount_slider_textfield(
+ element,
+ element_name,
+ player,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_textfield_2,
+ magic_wand_creator.set_resource_amount_2,
+ creative_mode_defines.names.gui.magic_wand_creator_rsc_amt_slider_button_2_prefix
+ )
+ then
+ -- Creator - resource amount textfield 2.
+ return true
+ end
+
+ return false
end
-- Callback of the on_gui_checked_state_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_magicwand.on_gui_checked_state_changed(element, element_name, player)
- if element_name == creative_mode_defines.names.gui.magic_wand_creator_correct_tiles_checkbox then
- -- Creator - tile correction checkbox.
- magic_wand_creator.set_tile_correction(player, element.state)
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_creator_dont_kill_by_tiles_checkbox then
- -- Creator - don't kill players by tiles checkbox.
- magic_wand_creator.set_dont_kill_players_by_tiles(player, element.state)
- return true
- end
-
- ----
-
- if element_name == creative_mode_defines.names.gui.magic_wand_creator_also_remove_decoratives_checkbox then
- -- Creator - also remove decoratives checkbox.
- magic_wand_creator.set_also_remove_decoratives(player, element.state)
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_creator_dont_remove_characters_checkbox then
- -- Creator - don't remove player characters checkbox.
- magic_wand_creator.set_dont_remove_player_characters(player, element.state)
- return true
- end
-
- if element.name == creative_mode_defines.names.gui.magic_wand_creator_dont_remove_tiles_with_entities_checkbox then
- -- Creator - don't remove tiles if any entity is selected checkbox.
- magic_wand_creator.set_dont_remove_tiles_if_any_entity_is_selected(player, element.state)
- end
-
- if element.name == creative_mode_defines.names.gui.magic_wand_creator_dont_kill_by_removing_tiles_checkbox then
- -- Creator - don't kill players by removing tiles checkbox.
- magic_wand_creator.set_dont_kill_players_by_removing_tiles(player, element.state)
- return true
- end
-
- if
- element.parent
- and element.parent.name == creative_mode_defines.names.gui.magic_wand_creator_alt_forces_table
- then
- -- Creator - alt force checkboxes.
- local force_name = string.match(
- element.name,
- creative_mode_defines.match_patterns.gui.magic_wand_creator_alt_force_name_checkbox
- )
- if force_name then
- local force = game.forces[force_name]
- if force then
- magic_wand_creator.set_alt_mode_apply_on_force(player, force, element.state)
- else
- -- No such force anymore.
- element.destroy()
- end
- end
- return true
- end
-
- --------------------------------------------------------------------
-
- if element_name == creative_mode_defines.names.gui.magic_wand_healer_revive_ghosts_checkbox then
- -- Healer - revive ghosts checkbox.
- magic_wand_healer.set_revive_ghosts(player, element.state)
- return true
- end
-
- if
- element.parent
- and element.parent.name == creative_mode_defines.names.gui.magic_wand_healer_heal_forces_table
- then
- -- Healer - heal force checkboxes.
- local force_name = string.match(
- element.name,
- creative_mode_defines.match_patterns.gui.magic_wand_healer_heal_force_name_checkbox
- )
- if force_name then
- local force = game.forces[force_name]
- if force then
- magic_wand_healer.set_heal_entities_on_force(player, force, element.state)
- else
- -- No such force anymore.
- element.destroy()
- end
- end
- return true
- end
-
- ----
-
- if element_name == creative_mode_defines.names.gui.magic_wand_healer_alt_set_hp_radiobutton then
- -- Healer - set HP to 1 radiobutton
- if element.state then
- -- radiobutton -> container.
- local container = element.parent
- uncheck_other_radiobuttons_in_container(container, element)
- magic_wand_healer.set_alt_mode_action(player, magic_wand_healer.alt_mode_action.set_hp_to_one)
- end
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_healer_alt_kill_radiobutton then
- -- Healer - kill radiobutton
- if element.state then
- -- radiobutton -> container.
- local container = element.parent
- uncheck_other_radiobuttons_in_container(container, element)
- magic_wand_healer.set_alt_mode_action(player, magic_wand_healer.alt_mode_action.kill)
- end
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_healer_alt_dont_affect_characters_checkbox then
- -- Healer - alt don't affect characters checkbox.
- magic_wand_healer.set_alt_mode_dont_affect_player_characters(player, element.state)
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_healer_alt_dont_affect_indestructible_checkbox then
- -- Healer - alt don't affect indestructible entities.
- magic_wand_healer.set_alt_mode_dont_affect_indestructible_entities(player, element.state)
- return true
- end
-
- if element.parent and element.parent.name == creative_mode_defines.names.gui.magic_wand_healer_alt_forces_table then
- -- Healer - alt force checkboxes.
- local force_name = string.match(
- element.name,
- creative_mode_defines.match_patterns.gui.magic_wand_healer_alt_force_name_checkbox
- )
- if force_name then
- local force = game.forces[force_name]
- if force then
- magic_wand_healer.set_alt_mode_apply_on_force(player, force, element.state)
- else
- -- No such force anymore.
- element.destroy()
- end
- end
- return true
- end
-
- --------------------------------------------------------------------
-
- if element_name == creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_characters_checkbox then
- -- Modifier - std ignore player characters checkbox.
- magic_wand_modifier.set_std_ignore_player_characters(player, element.state)
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_healthless_checkbox then
- -- Modifier - std ignore healthless entities checkbox.
- magic_wand_modifier.set_std_ignore_healthess_entities(player, element.state)
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_indestructible_checkbox then
- -- Modifier - std ignore indestructible entities checkbox.
- magic_wand_modifier.set_std_ignore_indestructible_entities(player, element.state)
- end
-
- if
- element.parent
- and element.parent.name == creative_mode_defines.names.gui.magic_wand_modifier_std_forces_table
- then
- -- Modifier - std force checkboxes.
- local force_name = string.match(
- element.name,
- creative_mode_defines.match_patterns.gui.magic_wand_modifier_std_force_name_checkbox
- )
- if force_name then
- local force = game.forces[force_name]
- if force then
- magic_wand_modifier.set_std_select_entities_on_force(player, force, element.state)
- else
- -- No such force anymore.
- element.destroy()
- end
- end
- return true
- end
-
- ----
-
- if element_name == creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_characters_checkbox then
- -- Modifier - alt ignore player characters checkbox.
- magic_wand_modifier.set_alt_ignore_player_characters(player, element.state)
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_healthless_checkbox then
- -- Modifier - alt ignore healthless entities checkbox.
- magic_wand_modifier.set_alt_ignore_healthess_entities(player, element.state)
- return true
- end
-
- if element_name == creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_indestructible_checkbox then
- -- Modifier - alt ignore indestructible entities checkbox.
- magic_wand_modifier.set_alt_ignore_indestructible_entities(player, element.state)
- end
-
- if
- element.parent
- and element.parent.name == creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_table
- then
- -- Modifier - alt force checkboxes.
- local force_name = string.match(
- element.name,
- creative_mode_defines.match_patterns.gui.magic_wand_modifier_alt_force_name_checkbox
- )
- if force_name then
- local force = game.forces[force_name]
- if force then
- magic_wand_modifier.set_alt_select_entities_on_force(player, force, element.state)
- else
- -- No such force anymore.
- element.destroy()
- end
- end
- return true
- end
-
- return false
+ if element_name == creative_mode_defines.names.gui.magic_wand_creator_correct_tiles_checkbox then
+ -- Creator - tile correction checkbox.
+ magic_wand_creator.set_tile_correction(player, element.state)
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_creator_dont_kill_by_tiles_checkbox then
+ -- Creator - don't kill players by tiles checkbox.
+ magic_wand_creator.set_dont_kill_players_by_tiles(player, element.state)
+ return true
+ end
+
+ ----
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_creator_also_remove_decoratives_checkbox then
+ -- Creator - also remove decoratives checkbox.
+ magic_wand_creator.set_also_remove_decoratives(player, element.state)
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_creator_dont_remove_characters_checkbox then
+ -- Creator - don't remove player characters checkbox.
+ magic_wand_creator.set_dont_remove_player_characters(player, element.state)
+ return true
+ end
+
+ if element.name == creative_mode_defines.names.gui.magic_wand_creator_dont_remove_tiles_with_entities_checkbox then
+ -- Creator - don't remove tiles if any entity is selected checkbox.
+ magic_wand_creator.set_dont_remove_tiles_if_any_entity_is_selected(player, element.state)
+ end
+
+ if element.name == creative_mode_defines.names.gui.magic_wand_creator_dont_kill_by_removing_tiles_checkbox then
+ -- Creator - don't kill players by removing tiles checkbox.
+ magic_wand_creator.set_dont_kill_players_by_removing_tiles(player, element.state)
+ return true
+ end
+
+ if element.parent and element.parent.name == creative_mode_defines.names.gui.magic_wand_creator_alt_forces_table then
+ -- Creator - alt force checkboxes.
+ local force_name =
+ string.match(element.name, creative_mode_defines.match_patterns.gui.magic_wand_creator_alt_force_name_checkbox)
+ if force_name then
+ local force = game.forces[force_name]
+ if force then
+ magic_wand_creator.set_alt_mode_apply_on_force(player, force, element.state)
+ else
+ -- No such force anymore.
+ element.destroy()
+ end
+ end
+ return true
+ end
+
+ --------------------------------------------------------------------
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_healer_revive_ghosts_checkbox then
+ -- Healer - revive ghosts checkbox.
+ magic_wand_healer.set_revive_ghosts(player, element.state)
+ return true
+ end
+
+ if element.parent and element.parent.name == creative_mode_defines.names.gui.magic_wand_healer_heal_forces_table then
+ -- Healer - heal force checkboxes.
+ local force_name =
+ string.match(element.name, creative_mode_defines.match_patterns.gui.magic_wand_healer_heal_force_name_checkbox)
+ if force_name then
+ local force = game.forces[force_name]
+ if force then
+ magic_wand_healer.set_heal_entities_on_force(player, force, element.state)
+ else
+ -- No such force anymore.
+ element.destroy()
+ end
+ end
+ return true
+ end
+
+ ----
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_healer_alt_set_hp_radiobutton then
+ -- Healer - set HP to 1 radiobutton
+ if element.state then
+ -- radiobutton -> container.
+ local container = element.parent
+ uncheck_other_radiobuttons_in_container(container, element)
+ magic_wand_healer.set_alt_mode_action(player, magic_wand_healer.alt_mode_action.set_hp_to_one)
+ end
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_healer_alt_kill_radiobutton then
+ -- Healer - kill radiobutton
+ if element.state then
+ -- radiobutton -> container.
+ local container = element.parent
+ uncheck_other_radiobuttons_in_container(container, element)
+ magic_wand_healer.set_alt_mode_action(player, magic_wand_healer.alt_mode_action.kill)
+ end
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_healer_alt_dont_affect_characters_checkbox then
+ -- Healer - alt don't affect characters checkbox.
+ magic_wand_healer.set_alt_mode_dont_affect_player_characters(player, element.state)
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_healer_alt_dont_affect_indestructible_checkbox then
+ -- Healer - alt don't affect indestructible entities.
+ magic_wand_healer.set_alt_mode_dont_affect_indestructible_entities(player, element.state)
+ return true
+ end
+
+ if element.parent and element.parent.name == creative_mode_defines.names.gui.magic_wand_healer_alt_forces_table then
+ -- Healer - alt force checkboxes.
+ local force_name =
+ string.match(element.name, creative_mode_defines.match_patterns.gui.magic_wand_healer_alt_force_name_checkbox)
+ if force_name then
+ local force = game.forces[force_name]
+ if force then
+ magic_wand_healer.set_alt_mode_apply_on_force(player, force, element.state)
+ else
+ -- No such force anymore.
+ element.destroy()
+ end
+ end
+ return true
+ end
+
+ --------------------------------------------------------------------
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_characters_checkbox then
+ -- Modifier - std ignore player characters checkbox.
+ magic_wand_modifier.set_std_ignore_player_characters(player, element.state)
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_healthless_checkbox then
+ -- Modifier - std ignore healthless entities checkbox.
+ magic_wand_modifier.set_std_ignore_healthess_entities(player, element.state)
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_modifier_std_ignore_indestructible_checkbox then
+ -- Modifier - std ignore indestructible entities checkbox.
+ magic_wand_modifier.set_std_ignore_indestructible_entities(player, element.state)
+ end
+
+ if element.parent and element.parent.name == creative_mode_defines.names.gui.magic_wand_modifier_std_forces_table then
+ -- Modifier - std force checkboxes.
+ local force_name =
+ string.match(element.name, creative_mode_defines.match_patterns.gui.magic_wand_modifier_std_force_name_checkbox)
+ if force_name then
+ local force = game.forces[force_name]
+ if force then
+ magic_wand_modifier.set_std_select_entities_on_force(player, force, element.state)
+ else
+ -- No such force anymore.
+ element.destroy()
+ end
+ end
+ return true
+ end
+
+ ----
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_characters_checkbox then
+ -- Modifier - alt ignore player characters checkbox.
+ magic_wand_modifier.set_alt_ignore_player_characters(player, element.state)
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_healthless_checkbox then
+ -- Modifier - alt ignore healthless entities checkbox.
+ magic_wand_modifier.set_alt_ignore_healthess_entities(player, element.state)
+ return true
+ end
+
+ if element_name == creative_mode_defines.names.gui.magic_wand_modifier_alt_ignore_indestructible_checkbox then
+ -- Modifier - alt ignore indestructible entities checkbox.
+ magic_wand_modifier.set_alt_ignore_indestructible_entities(player, element.state)
+ end
+
+ if element.parent and element.parent.name == creative_mode_defines.names.gui.magic_wand_modifier_alt_forces_table then
+ -- Modifier - alt force checkboxes.
+ local force_name =
+ string.match(element.name, creative_mode_defines.match_patterns.gui.magic_wand_modifier_alt_force_name_checkbox)
+ if force_name then
+ local force = game.forces[force_name]
+ if force then
+ magic_wand_modifier.set_alt_select_entities_on_force(player, force, element.state)
+ else
+ -- No such force anymore.
+ element.destroy()
+ end
+ end
+ return true
+ end
+
+ return false
end
-- Callback of the on_gui_selection_state_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_magicwand.on_gui_selection_state_changed(element, element_name, player)
- if element_name == creative_mode_defines.names.gui.magic_wand_creator_use_pattern_drop_down then
- -- Creator - use pattern drop-down.
- magic_wand_creator.set_use_pattern(player, element.selected_index)
- -- Update the visibility of the UI elements for selecting the second tile or resource.
- --[[
+ if element_name == creative_mode_defines.names.gui.magic_wand_creator_use_pattern_drop_down then
+ -- Creator - use pattern drop-down.
+ magic_wand_creator.set_use_pattern(player, element.selected_index)
+ -- Update the visibility of the UI elements for selecting the second tile or resource.
+ --[[
local container = element.parent.parent
local tile_or_resource_2_container = container[creative_mode_defines.names.gui.magic_wand_creator_tile_or_resource_2_container]
if tile_or_resource_2_container then
tile_or_resource_2_container.visible = element.selected_index > 1
end
--]]
- -- Known issue: hiding the UI will bug the scroll-pane.
- return true
- end
+ -- Known issue: hiding the UI will bug the scroll-pane.
+ return true
+ end
end
diff --git a/scripts/gui-menu-modding.lua b/scripts/gui-menu-modding.lua
index 344ffca..7788ecb 100644
--- a/scripts/gui-menu-modding.lua
+++ b/scripts/gui-menu-modding.lua
@@ -2,338 +2,336 @@ local mod_gui = require("mod-gui")
-- This file contains variables and functions related to Creative Mode menu - modding GUI.
if not gui_menu_modding then
- gui_menu_modding = {}
+ gui_menu_modding = {}
end
-- Gets the name of the modding menu container.
function gui_menu_modding.get_container_name()
- return creative_mode_defines.names.gui.modding_menus_container
+ return creative_mode_defines.names.gui.modding_menus_container
end
-- Creates the modding menu for the given player. If the menu already exists, it will be destroyed instead.
function gui_menu_modding.create_or_destroy_menu_for_player(player)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- -- Modding container.
- local modding_menus_container = container[gui_menu_modding.get_container_name()]
- if modding_menus_container then
- modding_menus_container.destroy()
- else
- modding_menus_container =
- container.add {
- type = "flow",
- name = gui_menu_modding.get_container_name(),
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- direction = "horizontal",
- resize_row_to_width = true,
- minimal_width = 2000
- }
-
- -- Frame.
- local modding_menu_frame =
- modding_menus_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.modding_menu_frame,
- direction = "vertical",
- caption = {"gui.creative-mode_modding"}
- }
-
- -- Events.
- modding_menu_frame.add {
- type = "button",
- name = creative_mode_defines.names.gui.events_menu_button,
- style = creative_mode_defines.names.gui_styles.main_menu_button,
- caption = {"gui.creative-mode_events"}
- }
-
- -- Interfaces.
- modding_menu_frame.add {
- type = "button",
- name = creative_mode_defines.names.gui.interfaces_menu_button,
- style = creative_mode_defines.names.gui_styles.main_menu_button,
- caption = {"gui.creative-mode_interfaces"}
- }
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ -- Modding container.
+ local modding_menus_container = container[gui_menu_modding.get_container_name()]
+ if modding_menus_container then
+ modding_menus_container.destroy()
+ else
+ modding_menus_container = container.add({
+ type = "flow",
+ name = gui_menu_modding.get_container_name(),
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ direction = "horizontal",
+ resize_row_to_width = true,
+ minimal_width = 2000,
+ })
+
+ -- Frame.
+ local modding_menu_frame = modding_menus_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.modding_menu_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_modding" },
+ })
+
+ -- Events.
+ modding_menu_frame.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.events_menu_button,
+ style = creative_mode_defines.names.gui_styles.main_menu_button,
+ caption = { "gui.creative-mode_events" },
+ })
+
+ -- Interfaces.
+ modding_menu_frame.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.interfaces_menu_button,
+ style = creative_mode_defines.names.gui_styles.main_menu_button,
+ caption = { "gui.creative-mode_interfaces" },
+ })
+ end
+ end
end
--------------------------------------------------------------------
-- Events are separated into different categories.
local event_categories = {
- technology_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_technology_container,
- label_name = creative_mode_defines.names.gui.event_category_technology_label,
- label_caption = {"gui.creative-mode_technology-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_technology_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_technology_hide_button,
- events = {
- defines.events.on_research_cancelled,
- defines.events.on_research_finished,
- defines.events.on_research_reversed,
- defines.events.on_research_started
- }
- },
- item_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_item_container,
- label_name = creative_mode_defines.names.gui.event_category_item_label,
- label_caption = {"gui.creative-mode_item-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_item_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_item_hide_button,
- events = {
- defines.events.on_equipment_inserted,
- defines.events.on_equipment_removed,
- defines.events.on_mod_item_opened,
- defines.events.on_picked_up_item,
- defines.events.on_player_alt_selected_area,
- defines.events.on_player_crafted_item,
- defines.events.on_player_deconstructed_area,
- defines.events.on_player_mined_item,
- defines.events.on_player_placed_equipment,
- defines.events.on_player_removed_equipment,
- defines.events.on_player_selected_area,
- defines.events.on_player_setup_blueprint,
- defines.events.on_robot_mined
- }
- },
- entity_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_entity_container,
- label_name = creative_mode_defines.names.gui.event_category_entity_label,
- label_caption = {"gui.creative-mode_entity-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_entity_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_entity_hide_button,
- events = {
- defines.events.on_biter_base_built,
- defines.events.on_built_entity,
- defines.events.on_cancelled_deconstruction,
- defines.events.on_cancelled_upgrade,
- defines.events.on_combat_robot_expired,
- defines.events.on_entity_cloned,
- defines.events.on_entity_color_changed,
- defines.events.on_entity_damaged,
- defines.events.on_object_destroyed,
- defines.events.on_entity_died,
- defines.events.on_entity_renamed,
- defines.events.on_entity_settings_pasted,
- defines.events.on_entity_spawned,
- defines.events.on_land_mine_armed,
- defines.events.on_marked_for_deconstruction,
- defines.events.on_marked_for_upgrade,
- defines.events.on_market_item_purchased,
- defines.events.on_player_alt_selected_area,
- defines.events.on_player_dropped_item,
- defines.events.on_player_mined_entity,
- defines.events.on_player_rotated_entity,
- defines.events.on_player_selected_area,
- defines.events.on_post_entity_died,
- defines.events.on_pre_entity_settings_pasted,
- defines.events.on_preplayer_mined_item,
- defines.events.on_resource_depleted,
- defines.events.on_robot_mined,
- defines.events.on_robot_mined_entity,
- defines.events.on_rocket_launched,
- defines.events.on_sector_scanned,
- defines.events.on_selected_entity_changed,
- defines.events.on_train_changed_state,
- defines.events.on_train_created,
- defines.events.on_trigger_created_entity,
- defines.events.on_worker_robot_expired,
- defines.events.script_raised_built,
- defines.events.script_raised_destroy,
- defines.events.script_raised_revive,
- defines.events.script_raised_teleported
- }
- },
- tile_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_tile_container,
- label_name = creative_mode_defines.names.gui.event_category_tile_label,
- label_caption = {"gui.creative-mode_tile-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_tile_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_tile_hide_button,
- events = {
- defines.events.on_player_alt_selected_area,
- defines.events.on_player_mined_tile,
- defines.events.on_player_selected_area,
- defines.events.script_raised_built,
- defines.events.script_raised_destroy,
- defines.events.script_raised_revive,
- defines.events.script_raised_set_tiles
- }
- },
- player_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_player_container,
- label_name = creative_mode_defines.names.gui.event_category_player_label,
- label_caption = {"gui.creative-mode_player-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_player_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_player_hide_button,
- events = {
- defines.events.on_built_entity,
- defines.events.on_canceled_deconstruction,
- defines.events.on_console_chat,
- defines.events.on_console_command,
- defines.events.on_gui_checked_state_changed,
- defines.events.on_gui_click,
- defines.events.on_gui_elem_changed,
- defines.events.on_gui_selection_state_changed,
- defines.events.on_gui_text_changed,
- defines.events.on_marked_for_deconstruction,
- defines.events.on_market_item_purchased,
- defines.events.on_picked_up_item,
- defines.events.on_player_alt_selected_area,
- defines.events.on_player_ammo_inventory_changed,
- defines.events.on_player_armor_inventory_changed,
- defines.events.on_player_built_tile,
- defines.events.on_player_cancelled_crafting,
- defines.events.on_player_changed_force,
- defines.events.on_player_changed_position,
- defines.events.on_player_changed_surface,
- defines.events.on_player_configured_blueprint,
- defines.events.on_player_crafted_item,
- defines.events.on_player_created,
- defines.events.on_player_cursor_stack_changed,
- defines.events.on_player_died,
- defines.events.on_player_deconstructed_area,
- defines.events.on_player_driving_changed_state,
- defines.events.on_player_dropped_item,
- defines.events.on_player_gun_inventory_changed,
- defines.events.on_player_input_method_changed,
- defines.events.on_player_joined_game,
- defines.events.on_player_left_game,
- defines.events.on_player_main_inventory_changed,
- defines.events.on_player_mined_entity,
- defines.events.on_player_mined_item,
- defines.events.on_player_mined_tile,
- defines.events.on_player_placed_equipment,
- defines.events.on_player_quickbar_inventory_changed,
- defines.events.on_player_removed,
- defines.events.on_player_removed_equipment,
- defines.events.on_player_respawned,
- defines.events.on_player_rotated_entity,
- defines.events.on_player_selected_area,
- defines.events.on_player_setup_blueprint,
- defines.events.on_player_tool_inventory_changed,
- defines.events.on_pre_entity_settings_pasted,
- defines.events.on_pre_player_died,
- defines.events.on_pre_player_mined_item,
- defines.events.on_pre_build,
- defines.events.on_selected_entity_changed,
- defines.events.script_raised_set_tiles
- }
- },
- force_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_force_container,
- label_name = creative_mode_defines.names.gui.event_category_force_label,
- label_caption = {"gui.creative-mode_force-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_force_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_force_hide_button,
- events = {
- defines.events.on_chunk_charted,
- defines.events.on_force_cease_fire_changed,
- defines.events.on_force_created,
- defines.events.on_force_friends_changed,
- defines.events.on_force_reset,
- defines.events.on_forces_merged,
- defines.events.on_forces_merging,
- defines.events.on_player_changed_force,
- defines.events.script_raised_destroy
- }
- },
- surface_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_surface_container,
- label_name = creative_mode_defines.names.gui.event_category_surface_label,
- label_caption = {"gui.creative-mode_surface-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_surface_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_surface_hide_button,
- events = {
- defines.events.on_chunk_deleted,
- defines.events.on_chunk_generated,
- defines.events.on_player_changed_surface,
- defines.events.on_pre_surface_deleted,
- defines.events.on_surface_cleared,
- defines.events.on_surface_created,
- defines.events.on_surface_deleted,
- defines.events.on_surface_imported,
- defines.events.on_surface_renamed
- }
- },
- position_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_position_container,
- label_name = creative_mode_defines.names.gui.event_category_position_label,
- label_caption = {"gui.creative-mode_position-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_position_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_position_hide_button,
- events = {
- defines.events.on_chunk_generated,
- defines.events.on_player_alt_selected_area,
- defines.events.script_raised_set_tiles,
- defines.events.on_player_deconstructed_area,
- defines.events.on_player_mined_tile,
- defines.events.on_player_selected_area,
- defines.events.on_player_setup_blueprint,
- defines.events.on_pre_build,
- defines.events.script_raised_built,
- defines.events.script_raised_destroy,
- defines.events.on_sector_scanned
- }
- },
- gui_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_gui_container,
- label_name = creative_mode_defines.names.gui.event_category_gui_label,
- label_caption = {"gui.creative-mode_gui-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_gui_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_gui_hide_button,
- events = {
- defines.events.on_gui_checked_state_changed,
- defines.events.on_gui_closed,
- defines.events.on_gui_confirmed,
- defines.events.on_gui_location_changed,
- defines.events.on_gui_elem_changed,
- defines.events.on_gui_opened,
- defines.events.on_gui_selected_tab_changed,
- defines.events.on_gui_selection_state_changed,
- defines.events.on_gui_switch_state_changed,
- defines.events.on_gui_text_changed,
- defines.events.on_gui_value_changed
- }
- },
- settings_related_events = {
- container_name = creative_mode_defines.names.gui.event_category_settings_container,
- label_name = creative_mode_defines.names.gui.event_category_settings_label,
- label_caption = {"gui.creative-mode_settings-related-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_settings_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_settings_hide_button,
- events = {
- defines.events.on_difficulty_settings_changed,
- defines.events.on_runtime_mod_setting_changed
- }
- },
- all_events = {
- container_name = creative_mode_defines.names.gui.event_category_all_container,
- label_name = creative_mode_defines.names.gui.event_category_all_label,
- label_caption = {"gui.creative-mode_all-events"},
- label_tooltip = nil,
- show_button_name = creative_mode_defines.names.gui.event_category_all_show_button,
- hide_button_name = creative_mode_defines.names.gui.event_category_all_hide_button,
- events = nil -- Special operation.
- }
+ technology_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_technology_container,
+ label_name = creative_mode_defines.names.gui.event_category_technology_label,
+ label_caption = { "gui.creative-mode_technology-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_technology_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_technology_hide_button,
+ events = {
+ defines.events.on_research_cancelled,
+ defines.events.on_research_finished,
+ defines.events.on_research_reversed,
+ defines.events.on_research_started,
+ },
+ },
+ item_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_item_container,
+ label_name = creative_mode_defines.names.gui.event_category_item_label,
+ label_caption = { "gui.creative-mode_item-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_item_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_item_hide_button,
+ events = {
+ defines.events.on_equipment_inserted,
+ defines.events.on_equipment_removed,
+ defines.events.on_mod_item_opened,
+ defines.events.on_picked_up_item,
+ defines.events.on_player_alt_selected_area,
+ defines.events.on_player_crafted_item,
+ defines.events.on_player_deconstructed_area,
+ defines.events.on_player_mined_item,
+ defines.events.on_player_placed_equipment,
+ defines.events.on_player_removed_equipment,
+ defines.events.on_player_selected_area,
+ defines.events.on_player_setup_blueprint,
+ defines.events.on_robot_mined,
+ },
+ },
+ entity_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_entity_container,
+ label_name = creative_mode_defines.names.gui.event_category_entity_label,
+ label_caption = { "gui.creative-mode_entity-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_entity_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_entity_hide_button,
+ events = {
+ defines.events.on_biter_base_built,
+ defines.events.on_built_entity,
+ defines.events.on_cancelled_deconstruction,
+ defines.events.on_cancelled_upgrade,
+ defines.events.on_combat_robot_expired,
+ defines.events.on_entity_cloned,
+ defines.events.on_entity_color_changed,
+ defines.events.on_entity_damaged,
+ defines.events.on_object_destroyed,
+ defines.events.on_entity_died,
+ defines.events.on_entity_renamed,
+ defines.events.on_entity_settings_pasted,
+ defines.events.on_entity_spawned,
+ defines.events.on_land_mine_armed,
+ defines.events.on_marked_for_deconstruction,
+ defines.events.on_marked_for_upgrade,
+ defines.events.on_market_item_purchased,
+ defines.events.on_player_alt_selected_area,
+ defines.events.on_player_dropped_item,
+ defines.events.on_player_mined_entity,
+ defines.events.on_player_rotated_entity,
+ defines.events.on_player_selected_area,
+ defines.events.on_post_entity_died,
+ defines.events.on_pre_entity_settings_pasted,
+ defines.events.on_preplayer_mined_item,
+ defines.events.on_resource_depleted,
+ defines.events.on_robot_mined,
+ defines.events.on_robot_mined_entity,
+ defines.events.on_rocket_launched,
+ defines.events.on_sector_scanned,
+ defines.events.on_selected_entity_changed,
+ defines.events.on_train_changed_state,
+ defines.events.on_train_created,
+ defines.events.on_trigger_created_entity,
+ defines.events.on_worker_robot_expired,
+ defines.events.script_raised_built,
+ defines.events.script_raised_destroy,
+ defines.events.script_raised_revive,
+ defines.events.script_raised_teleported,
+ },
+ },
+ tile_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_tile_container,
+ label_name = creative_mode_defines.names.gui.event_category_tile_label,
+ label_caption = { "gui.creative-mode_tile-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_tile_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_tile_hide_button,
+ events = {
+ defines.events.on_player_alt_selected_area,
+ defines.events.on_player_mined_tile,
+ defines.events.on_player_selected_area,
+ defines.events.script_raised_built,
+ defines.events.script_raised_destroy,
+ defines.events.script_raised_revive,
+ defines.events.script_raised_set_tiles,
+ },
+ },
+ player_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_player_container,
+ label_name = creative_mode_defines.names.gui.event_category_player_label,
+ label_caption = { "gui.creative-mode_player-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_player_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_player_hide_button,
+ events = {
+ defines.events.on_built_entity,
+ defines.events.on_canceled_deconstruction,
+ defines.events.on_console_chat,
+ defines.events.on_console_command,
+ defines.events.on_gui_checked_state_changed,
+ defines.events.on_gui_click,
+ defines.events.on_gui_elem_changed,
+ defines.events.on_gui_selection_state_changed,
+ defines.events.on_gui_text_changed,
+ defines.events.on_marked_for_deconstruction,
+ defines.events.on_market_item_purchased,
+ defines.events.on_picked_up_item,
+ defines.events.on_player_alt_selected_area,
+ defines.events.on_player_ammo_inventory_changed,
+ defines.events.on_player_armor_inventory_changed,
+ defines.events.on_player_built_tile,
+ defines.events.on_player_cancelled_crafting,
+ defines.events.on_player_changed_force,
+ defines.events.on_player_changed_position,
+ defines.events.on_player_changed_surface,
+ defines.events.on_player_configured_blueprint,
+ defines.events.on_player_crafted_item,
+ defines.events.on_player_created,
+ defines.events.on_player_cursor_stack_changed,
+ defines.events.on_player_died,
+ defines.events.on_player_deconstructed_area,
+ defines.events.on_player_driving_changed_state,
+ defines.events.on_player_dropped_item,
+ defines.events.on_player_gun_inventory_changed,
+ defines.events.on_player_input_method_changed,
+ defines.events.on_player_joined_game,
+ defines.events.on_player_left_game,
+ defines.events.on_player_main_inventory_changed,
+ defines.events.on_player_mined_entity,
+ defines.events.on_player_mined_item,
+ defines.events.on_player_mined_tile,
+ defines.events.on_player_placed_equipment,
+ defines.events.on_player_quickbar_inventory_changed,
+ defines.events.on_player_removed,
+ defines.events.on_player_removed_equipment,
+ defines.events.on_player_respawned,
+ defines.events.on_player_rotated_entity,
+ defines.events.on_player_selected_area,
+ defines.events.on_player_setup_blueprint,
+ defines.events.on_player_tool_inventory_changed,
+ defines.events.on_pre_entity_settings_pasted,
+ defines.events.on_pre_player_died,
+ defines.events.on_pre_player_mined_item,
+ defines.events.on_pre_build,
+ defines.events.on_selected_entity_changed,
+ defines.events.script_raised_set_tiles,
+ },
+ },
+ force_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_force_container,
+ label_name = creative_mode_defines.names.gui.event_category_force_label,
+ label_caption = { "gui.creative-mode_force-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_force_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_force_hide_button,
+ events = {
+ defines.events.on_chunk_charted,
+ defines.events.on_force_cease_fire_changed,
+ defines.events.on_force_created,
+ defines.events.on_force_friends_changed,
+ defines.events.on_force_reset,
+ defines.events.on_forces_merged,
+ defines.events.on_forces_merging,
+ defines.events.on_player_changed_force,
+ defines.events.script_raised_destroy,
+ },
+ },
+ surface_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_surface_container,
+ label_name = creative_mode_defines.names.gui.event_category_surface_label,
+ label_caption = { "gui.creative-mode_surface-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_surface_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_surface_hide_button,
+ events = {
+ defines.events.on_chunk_deleted,
+ defines.events.on_chunk_generated,
+ defines.events.on_player_changed_surface,
+ defines.events.on_pre_surface_deleted,
+ defines.events.on_surface_cleared,
+ defines.events.on_surface_created,
+ defines.events.on_surface_deleted,
+ defines.events.on_surface_imported,
+ defines.events.on_surface_renamed,
+ },
+ },
+ position_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_position_container,
+ label_name = creative_mode_defines.names.gui.event_category_position_label,
+ label_caption = { "gui.creative-mode_position-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_position_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_position_hide_button,
+ events = {
+ defines.events.on_chunk_generated,
+ defines.events.on_player_alt_selected_area,
+ defines.events.script_raised_set_tiles,
+ defines.events.on_player_deconstructed_area,
+ defines.events.on_player_mined_tile,
+ defines.events.on_player_selected_area,
+ defines.events.on_player_setup_blueprint,
+ defines.events.on_pre_build,
+ defines.events.script_raised_built,
+ defines.events.script_raised_destroy,
+ defines.events.on_sector_scanned,
+ },
+ },
+ gui_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_gui_container,
+ label_name = creative_mode_defines.names.gui.event_category_gui_label,
+ label_caption = { "gui.creative-mode_gui-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_gui_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_gui_hide_button,
+ events = {
+ defines.events.on_gui_checked_state_changed,
+ defines.events.on_gui_closed,
+ defines.events.on_gui_confirmed,
+ defines.events.on_gui_location_changed,
+ defines.events.on_gui_elem_changed,
+ defines.events.on_gui_opened,
+ defines.events.on_gui_selected_tab_changed,
+ defines.events.on_gui_selection_state_changed,
+ defines.events.on_gui_switch_state_changed,
+ defines.events.on_gui_text_changed,
+ defines.events.on_gui_value_changed,
+ },
+ },
+ settings_related_events = {
+ container_name = creative_mode_defines.names.gui.event_category_settings_container,
+ label_name = creative_mode_defines.names.gui.event_category_settings_label,
+ label_caption = { "gui.creative-mode_settings-related-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_settings_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_settings_hide_button,
+ events = {
+ defines.events.on_difficulty_settings_changed,
+ defines.events.on_runtime_mod_setting_changed,
+ },
+ },
+ all_events = {
+ container_name = creative_mode_defines.names.gui.event_category_all_container,
+ label_name = creative_mode_defines.names.gui.event_category_all_label,
+ label_caption = { "gui.creative-mode_all-events" },
+ label_tooltip = nil,
+ show_button_name = creative_mode_defines.names.gui.event_category_all_show_button,
+ hide_button_name = creative_mode_defines.names.gui.event_category_all_hide_button,
+ events = nil, -- Special operation.
+ },
}
-- All event names, sorted in alphabetical order.
local sorted_event_names = {}
for event_name, event_id in pairs(defines.events) do
- -- By doing this, the list is not sorted properly (maybe sorted by event_id), that's why we need to sort it our own.
- table.insert(sorted_event_names, event_name)
+ -- By doing this, the list is not sorted properly (maybe sorted by event_id), that's why we need to sort it our own.
+ table.insert(sorted_event_names, event_name)
end
table.sort(sorted_event_names)
@@ -341,402 +339,391 @@ table.sort(sorted_event_names)
-- Creates the events menu for the given player. If the menu already exists, it will be destroyed instead.
local function create_or_destroy_events_menu_for_player(player)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local modding_menus_container = container[gui_menu_modding.get_container_name()]
- if modding_menus_container then
- -- Events.
- local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
- if events_menu_frame then
- events_menu_frame.destroy()
- else
- -- Make sure the other menus are closed.
- local interfaces_menu_frame = modding_menus_container[creative_mode_defines.names.gui.interfaces_menu_frame]
- if interfaces_menu_frame then
- interfaces_menu_frame.destroy()
- end
- local interface_contents_and_hints_container =
- modding_menus_container[creative_mode_defines.names.gui.interface_contents_and_hints_container]
- if interface_contents_and_hints_container then
- interface_contents_and_hints_container.destroy()
- end
-
- -- Frame.
- events_menu_frame =
- modding_menus_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.events_menu_frame,
- direction = "vertical"
- }
-
- -- Title container.
- local title_container =
- events_menu_frame.add {
- type = "flow",
- name = creative_mode_defines.names.gui.events_menu_title_container,
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- direction = "horizontal"
- }
- -- Title label.
- title_container.add {
- type = "label",
- name = creative_mode_defines.names.gui.events_menu_title_label,
- style = creative_mode_defines.names.gui_styles.events_menu_frame_caption_label,
- caption = {"gui.creative-mode_events"}
- }
- -- Separator.
- title_container.add {
- type = "flow",
- name = creative_mode_defines.names.gui.events_menu_title_separator_1,
- style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow
- }
- -- Search textfield. (Hidden by default)
- local search_textfield =
- title_container.add {
- type = "textfield",
- name = creative_mode_defines.names.gui.events_menu_search_textfield,
- style = creative_mode_defines.names.gui_styles.frame_search_textfield,
- text = ""
- }
- search_textfield.visible = false
- -- Search textfield placeholder.
- title_container.add {
- type = "flow",
- name = creative_mode_defines.names.gui.events_menu_search_textfield_placeholder_flow,
- style = creative_mode_defines.names.gui_styles.frame_search_textfield_placeholder_flow
- }
- -- Separator.
- title_container.add {
- type = "flow",
- name = creative_mode_defines.names.gui.events_menu_title_separator_2,
- style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow
- }
- -- Search button.
- title_container.add {
- type = "sprite-button",
- name = creative_mode_defines.names.gui.events_menu_search_button,
- style = creative_mode_defines.names.gui_styles.frame_caption_button,
- sprite = creative_mode_defines.names.sprites.search,
- tooltip = {"gui.creative-mode_search-events"}
- }
-
- -- Label.
- events_menu_frame.add {
- type = "label",
- name = creative_mode_defines.names.gui.events_menu_label,
- caption = {"gui.creative-mode_select-events-to-print"}
- }
-
- -- Scroll pane.
- local scroll_pane =
- events_menu_frame.add {
- type = "scroll-pane",
- name = creative_mode_defines.names.gui.events_scroll_pane,
- style = creative_mode_defines.names.gui_styles.cheat_scroll_pane
- }
-
- -- Container (no vertical spacing).
- local inner_container =
- scroll_pane.add {
- type = "flow",
- name = creative_mode_defines.names.gui.events_inner_container,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical"
- }
-
- -- Events.
- for _, event_name in ipairs(sorted_event_names) do
- local event_id = defines.events[event_name]
- -- We don't print on_tick as it will be too spammy.
- if event_id ~= defines.events.on_tick then
- -- Container.
- local event_container =
- inner_container.add {
- type = "table",
- name = creative_mode_defines.names.gui.event_container_prefix .. event_id,
- style = creative_mode_defines.names.gui_styles.cheat_table,
- column_count = 1
- }
- -- Checkbox.
- event_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.event_toggle_checkbox_prefix .. event_id,
- caption = event_name,
- state = (storage.creative_mode.selected_events[player.index] and
- storage.creative_mode.selected_events[player.index][event_id]) or
- false
- }
- end
- end
-
- -- Enable all and disable all buttons.
- local button_container =
- inner_container.add {
- type = "table",
- name = creative_mode_defines.names.gui.events_all_button_container,
- style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_table,
- column_count = 2
- }
- button_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.events_enable_all_button,
- style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button,
- caption = creative_mode_defines.names.gui_captions.enable_all
- }
- button_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.events_disable_all_button,
- style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button,
- caption = creative_mode_defines.names.gui_captions.disable_all
- }
- end
-
- -- Event categories and options.
- local event_categories_and_options_container =
- modding_menus_container[creative_mode_defines.names.gui.event_categories_and_options_container]
- if event_categories_and_options_container then
- event_categories_and_options_container.destroy()
- else
- event_categories_and_options_container =
- modding_menus_container.add {
- type = "flow",
- name = creative_mode_defines.names.gui.event_categories_and_options_container,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical"
- }
-
- -- Event categories.
- -- Frame.
- local event_categories_frame =
- event_categories_and_options_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.event_categories_frame,
- direction = "vertical",
- caption = {"gui.creative-mode_categories"}
- }
-
- -- Categories.
- for _, data in pairs(event_categories) do
- -- Container
- local category_container =
- event_categories_frame.add {
- type = "table",
- name = data.container_name,
- style = creative_mode_defines.names.gui_styles.cheat_table,
- column_count = 3
- }
- -- Label
- category_container.add {
- type = "label",
- name = data.label_name,
- style = creative_mode_defines.names.gui_styles.cheat_name_label,
- caption = data.label_caption,
- tooltip = data.label_tooltip
- }
- -- Show button
- category_container.add {
- type = "button",
- name = data.show_button_name,
- style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
- caption = creative_mode_defines.names.gui_captions.show
- }
- -- Hide button
- category_container.add {
- type = "button",
- name = data.hide_button_name,
- style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
- caption = creative_mode_defines.names.gui_captions.hide
- }
- end
-
- -- Options.
- -- Frame.
- local options_frame =
- event_categories_and_options_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.event_options_frame,
- direction = "vertical",
- caption = {"gui.creative-mode_options"}
- }
-
- -- Container.
- local event_options_container =
- options_frame.add {
- type = "table",
- name = creative_mode_defines.names.gui.event_options_container,
- column_count = 2
- }
- -- Print events checkbox.
- local state = true
- if storage.creative_mode.print_events[player.index] ~= nil then
- state = storage.creative_mode.print_events[player.index]
- end
- event_options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.event_option_print_events_checkbox,
- caption = {"gui.creative-mode_print-events"},
- tooltip = {"gui.creative-mode_print-events-tooltip"},
- state = state
- }
- -- Also print event parameters checkbox.
- state = true
- if storage.creative_mode.also_print_event_params[player.index] ~= nil then
- state = storage.creative_mode.also_print_event_params[player.index]
- end
- event_options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.event_option_print_parameters_checkbox,
- caption = {"gui.creative-mode_also-print-parameters"},
- state = state
- }
-
- -- Write events checkbox.
- state = false
- if storage.creative_mode.write_events[player.index] ~= nil then
- state = storage.creative_mode.write_events[player.index]
- end
- event_options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.event_option_write_events_checkbox,
- caption = {"gui.creative-mode_write-events"},
- tooltip = {"gui.creative-mode_write-events-tooltip", "script-output/" .. events.event_write_file_name},
- state = state
- }
- -- Also write event parameters checkbox.
- state = true
- if storage.creative_mode.also_write_event_params[player.index] ~= nil then
- state = storage.creative_mode.also_write_event_params[player.index]
- end
- event_options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.event_option_write_parameters_checkbox,
- caption = {"gui.creative-mode_also-write-parameters"},
- state = state
- }
-
- -- Log events checkbox.
- state = false
- if storage.creative_mode.log_events[player.index] ~= nil then
- state = storage.creative_mode.log_events[player.index]
- end
- event_options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.event_option_log_events_checkbox,
- caption = {"gui.creative-mode_log-events"},
- tooltip = {"gui.creative-mode_log-events-tooltip", "factorio-current.log"},
- state = state
- }
- -- Also log event parameters checkbox.
- state = true
- if storage.creative_mode.also_log_event_params[player.index] ~= nil then
- state = storage.creative_mode.also_log_event_params[player.index]
- end
- event_options_container.add {
- type = "checkbox",
- name = creative_mode_defines.names.gui.event_option_log_parameters_checkbox,
- caption = {"gui.creative-mode_also-log-parameters"},
- state = state
- }
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local modding_menus_container = container[gui_menu_modding.get_container_name()]
+ if modding_menus_container then
+ -- Events.
+ local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
+ if events_menu_frame then
+ events_menu_frame.destroy()
+ else
+ -- Make sure the other menus are closed.
+ local interfaces_menu_frame = modding_menus_container[creative_mode_defines.names.gui.interfaces_menu_frame]
+ if interfaces_menu_frame then
+ interfaces_menu_frame.destroy()
+ end
+ local interface_contents_and_hints_container =
+ modding_menus_container[creative_mode_defines.names.gui.interface_contents_and_hints_container]
+ if interface_contents_and_hints_container then
+ interface_contents_and_hints_container.destroy()
+ end
+
+ -- Frame.
+ events_menu_frame = modding_menus_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.events_menu_frame,
+ direction = "vertical",
+ })
+
+ -- Title container.
+ local title_container = events_menu_frame.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.events_menu_title_container,
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ direction = "horizontal",
+ })
+ -- Title label.
+ title_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.events_menu_title_label,
+ style = creative_mode_defines.names.gui_styles.events_menu_frame_caption_label,
+ caption = { "gui.creative-mode_events" },
+ })
+ -- Separator.
+ title_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.events_menu_title_separator_1,
+ style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
+ })
+ -- Search textfield. (Hidden by default)
+ local search_textfield = title_container.add({
+ type = "textfield",
+ name = creative_mode_defines.names.gui.events_menu_search_textfield,
+ style = creative_mode_defines.names.gui_styles.frame_search_textfield,
+ text = "",
+ })
+ search_textfield.visible = false
+ -- Search textfield placeholder.
+ title_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.events_menu_search_textfield_placeholder_flow,
+ style = creative_mode_defines.names.gui_styles.frame_search_textfield_placeholder_flow,
+ })
+ -- Separator.
+ title_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.events_menu_title_separator_2,
+ style = creative_mode_defines.names.gui_styles.cheat_textfield_and_button_separate_flow,
+ })
+ -- Search button.
+ title_container.add({
+ type = "sprite-button",
+ name = creative_mode_defines.names.gui.events_menu_search_button,
+ style = creative_mode_defines.names.gui_styles.frame_caption_button,
+ sprite = creative_mode_defines.names.sprites.search,
+ tooltip = { "gui.creative-mode_search-events" },
+ })
+
+ -- Label.
+ events_menu_frame.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.events_menu_label,
+ caption = { "gui.creative-mode_select-events-to-print" },
+ })
+
+ -- Scroll pane.
+ local scroll_pane = events_menu_frame.add({
+ type = "scroll-pane",
+ name = creative_mode_defines.names.gui.events_scroll_pane,
+ style = creative_mode_defines.names.gui_styles.cheat_scroll_pane,
+ })
+
+ -- Container (no vertical spacing).
+ local inner_container = scroll_pane.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.events_inner_container,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+
+ -- Events.
+ for _, event_name in ipairs(sorted_event_names) do
+ local event_id = defines.events[event_name]
+ -- We don't print on_tick as it will be too spammy.
+ if event_id ~= defines.events.on_tick then
+ -- Container.
+ local event_container = inner_container.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.event_container_prefix .. event_id,
+ style = creative_mode_defines.names.gui_styles.cheat_table,
+ column_count = 1,
+ })
+ -- Checkbox.
+ event_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.event_toggle_checkbox_prefix .. event_id,
+ caption = event_name,
+ state = (
+ storage.creative_mode.selected_events[player.index]
+ and storage.creative_mode.selected_events[player.index][event_id]
+ ) or false,
+ })
+ end
+ end
+
+ -- Enable all and disable all buttons.
+ local button_container = inner_container.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.events_all_button_container,
+ style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_table,
+ column_count = 2,
+ })
+ button_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.events_enable_all_button,
+ style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button,
+ caption = creative_mode_defines.names.gui_captions.enable_all,
+ })
+ button_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.events_disable_all_button,
+ style = creative_mode_defines.names.gui_styles.cheat_enable_disable_all_button,
+ caption = creative_mode_defines.names.gui_captions.disable_all,
+ })
+ end
+
+ -- Event categories and options.
+ local event_categories_and_options_container =
+ modding_menus_container[creative_mode_defines.names.gui.event_categories_and_options_container]
+ if event_categories_and_options_container then
+ event_categories_and_options_container.destroy()
+ else
+ event_categories_and_options_container = modding_menus_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.event_categories_and_options_container,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+
+ -- Event categories.
+ -- Frame.
+ local event_categories_frame = event_categories_and_options_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.event_categories_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_categories" },
+ })
+
+ -- Categories.
+ for _, data in pairs(event_categories) do
+ -- Container
+ local category_container = event_categories_frame.add({
+ type = "table",
+ name = data.container_name,
+ style = creative_mode_defines.names.gui_styles.cheat_table,
+ column_count = 3,
+ })
+ -- Label
+ category_container.add({
+ type = "label",
+ name = data.label_name,
+ style = creative_mode_defines.names.gui_styles.cheat_name_label,
+ caption = data.label_caption,
+ tooltip = data.label_tooltip,
+ })
+ -- Show button
+ category_container.add({
+ type = "button",
+ name = data.show_button_name,
+ style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
+ caption = creative_mode_defines.names.gui_captions.show,
+ })
+ -- Hide button
+ category_container.add({
+ type = "button",
+ name = data.hide_button_name,
+ style = creative_mode_defines.names.gui_styles.cheat_on_off_button_off,
+ caption = creative_mode_defines.names.gui_captions.hide,
+ })
+ end
+
+ -- Options.
+ -- Frame.
+ local options_frame = event_categories_and_options_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.event_options_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_options" },
+ })
+
+ -- Container.
+ local event_options_container = options_frame.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.event_options_container,
+ column_count = 2,
+ })
+ -- Print events checkbox.
+ local state = true
+ if storage.creative_mode.print_events[player.index] ~= nil then
+ state = storage.creative_mode.print_events[player.index]
+ end
+ event_options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.event_option_print_events_checkbox,
+ caption = { "gui.creative-mode_print-events" },
+ tooltip = { "gui.creative-mode_print-events-tooltip" },
+ state = state,
+ })
+ -- Also print event parameters checkbox.
+ state = true
+ if storage.creative_mode.also_print_event_params[player.index] ~= nil then
+ state = storage.creative_mode.also_print_event_params[player.index]
+ end
+ event_options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.event_option_print_parameters_checkbox,
+ caption = { "gui.creative-mode_also-print-parameters" },
+ state = state,
+ })
+
+ -- Write events checkbox.
+ state = false
+ if storage.creative_mode.write_events[player.index] ~= nil then
+ state = storage.creative_mode.write_events[player.index]
+ end
+ event_options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.event_option_write_events_checkbox,
+ caption = { "gui.creative-mode_write-events" },
+ tooltip = { "gui.creative-mode_write-events-tooltip", "script-output/" .. events.event_write_file_name },
+ state = state,
+ })
+ -- Also write event parameters checkbox.
+ state = true
+ if storage.creative_mode.also_write_event_params[player.index] ~= nil then
+ state = storage.creative_mode.also_write_event_params[player.index]
+ end
+ event_options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.event_option_write_parameters_checkbox,
+ caption = { "gui.creative-mode_also-write-parameters" },
+ state = state,
+ })
+
+ -- Log events checkbox.
+ state = false
+ if storage.creative_mode.log_events[player.index] ~= nil then
+ state = storage.creative_mode.log_events[player.index]
+ end
+ event_options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.event_option_log_events_checkbox,
+ caption = { "gui.creative-mode_log-events" },
+ tooltip = { "gui.creative-mode_log-events-tooltip", "factorio-current.log" },
+ state = state,
+ })
+ -- Also log event parameters checkbox.
+ state = true
+ if storage.creative_mode.also_log_event_params[player.index] ~= nil then
+ state = storage.creative_mode.also_log_event_params[player.index]
+ end
+ event_options_container.add({
+ type = "checkbox",
+ name = creative_mode_defines.names.gui.event_option_log_parameters_checkbox,
+ caption = { "gui.creative-mode_also-log-parameters" },
+ state = state,
+ })
+ end
+ end
+ end
end
-- Enables or disables all visible event log for the given player.
local function enable_or_disable_all_visible_events_for_player(player, is_enable)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local modding_menus_container = container[gui_menu_modding.get_container_name()]
- if modding_menus_container then
- local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
- if events_menu_frame then
- local scroll_pane = events_menu_frame[creative_mode_defines.names.gui.events_scroll_pane]
- local inner_container = scroll_pane[creative_mode_defines.names.gui.events_inner_container]
-
- for event_name, event_id in pairs(defines.events) do
- -- Container
- local event_container = inner_container[creative_mode_defines.names.gui.event_container_prefix .. event_id]
- if event_container and (event_container.visible == nil or event_container.visible == true) then
- if not storage.creative_mode.selected_events[player.index] then
- storage.creative_mode.selected_events[player.index] = {}
- end
- if is_enable then
- storage.creative_mode.selected_events[player.index][event_id] = true
- -- Checkbox.
- event_container[creative_mode_defines.names.gui.event_toggle_checkbox_prefix .. event_id].state = true
- else
- storage.creative_mode.selected_events[player.index][event_id] = nil
- -- Checkbox.
- event_container[creative_mode_defines.names.gui.event_toggle_checkbox_prefix .. event_id].state = false
- end
- end
- end
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local modding_menus_container = container[gui_menu_modding.get_container_name()]
+ if modding_menus_container then
+ local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
+ if events_menu_frame then
+ local scroll_pane = events_menu_frame[creative_mode_defines.names.gui.events_scroll_pane]
+ local inner_container = scroll_pane[creative_mode_defines.names.gui.events_inner_container]
+
+ for event_name, event_id in pairs(defines.events) do
+ -- Container
+ local event_container = inner_container[creative_mode_defines.names.gui.event_container_prefix .. event_id]
+ if event_container and (event_container.visible == nil or event_container.visible == true) then
+ if not storage.creative_mode.selected_events[player.index] then
+ storage.creative_mode.selected_events[player.index] = {}
+ end
+ if is_enable then
+ storage.creative_mode.selected_events[player.index][event_id] = true
+ -- Checkbox.
+ event_container[creative_mode_defines.names.gui.event_toggle_checkbox_prefix .. event_id].state = true
+ else
+ storage.creative_mode.selected_events[player.index][event_id] = nil
+ -- Checkbox.
+ event_container[creative_mode_defines.names.gui.event_toggle_checkbox_prefix .. event_id].state = false
+ end
+ end
+ end
+ end
+ end
+ end
end
-- Shows or hides the given events for the given player.
-- If no events (nil) is given, all events will be affected.
local function show_or_hide_events_for_player(player, events, is_show)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local modding_menus_container = container[gui_menu_modding.get_container_name()]
- if modding_menus_container then
- local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
- if events_menu_frame then
- local scroll_pane = events_menu_frame[creative_mode_defines.names.gui.events_scroll_pane]
- local inner_container = scroll_pane[creative_mode_defines.names.gui.events_inner_container]
-
- if events == nil then
- -- All events.
- events = defines.events
- end
- for event_name, event_id in pairs(events) do
- local event_container = inner_container[creative_mode_defines.names.gui.event_container_prefix .. event_id]
- if event_container then
- event_container.visible = is_show
- end
- end
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local modding_menus_container = container[gui_menu_modding.get_container_name()]
+ if modding_menus_container then
+ local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
+ if events_menu_frame then
+ local scroll_pane = events_menu_frame[creative_mode_defines.names.gui.events_scroll_pane]
+ local inner_container = scroll_pane[creative_mode_defines.names.gui.events_inner_container]
+
+ if events == nil then
+ -- All events.
+ events = defines.events
+ end
+ for event_name, event_id in pairs(events) do
+ local event_container = inner_container[creative_mode_defines.names.gui.event_container_prefix .. event_id]
+ if event_container then
+ event_container.visible = is_show
+ end
+ end
+ end
+ end
+ end
end
-- Shows the events whose names match the given search name for the given player.
-- If no search name (nil or empty string) is given, all events will be shown.
local function show_events_for_player_by_search_name(player, search_name)
- if search_name == nil or search_name == "" then
- show_or_hide_events_for_player(player, nil, true)
- return
- end
-
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local modding_menus_container = container[gui_menu_modding.get_container_name()]
- if modding_menus_container then
- local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
- if events_menu_frame then
- local scroll_pane = events_menu_frame[creative_mode_defines.names.gui.events_scroll_pane]
- local inner_container = scroll_pane[creative_mode_defines.names.gui.events_inner_container]
-
- for event_name, event_id in pairs(defines.events) do
- local event_container = inner_container[creative_mode_defines.names.gui.event_container_prefix .. event_id]
- if event_container then
- if string.find(event_name, search_name) then
- event_container.visible = true
- else
- event_container.visible = false
- end
- end
- end
- end
- end
- end
+ if search_name == nil or search_name == "" then
+ show_or_hide_events_for_player(player, nil, true)
+ return
+ end
+
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local modding_menus_container = container[gui_menu_modding.get_container_name()]
+ if modding_menus_container then
+ local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
+ if events_menu_frame then
+ local scroll_pane = events_menu_frame[creative_mode_defines.names.gui.events_scroll_pane]
+ local inner_container = scroll_pane[creative_mode_defines.names.gui.events_inner_container]
+
+ for event_name, event_id in pairs(defines.events) do
+ local event_container = inner_container[creative_mode_defines.names.gui.event_container_prefix .. event_id]
+ if event_container then
+ if string.find(event_name, search_name) then
+ event_container.visible = true
+ else
+ event_container.visible = false
+ end
+ end
+ end
+ end
+ end
+ end
end
--------------------------------------------------------------------
@@ -763,257 +750,249 @@ local registered_remote_functions = {}
-- Creates the interfaces menu for the given player. If the menu already exists, it will be destroyed instead.
local function create_or_destroy_interfaces_menu_for_player(player)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local modding_menus_container = container[gui_menu_modding.get_container_name()]
- if modding_menus_container then
- -- Interfaces.
- local interfaces_menu_frame = modding_menus_container[creative_mode_defines.names.gui.interfaces_menu_frame]
- if interfaces_menu_frame then
- interfaces_menu_frame.destroy()
- else
- -- Make sure the other menus are closed.
- local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
- if events_menu_frame then
- events_menu_frame.destroy()
- end
- local event_categories_and_options_container =
- modding_menus_container[creative_mode_defines.names.gui.event_categories_and_options_container]
- if event_categories_and_options_container then
- event_categories_and_options_container.destroy()
- end
-
- -- Frame.
- interfaces_menu_frame =
- modding_menus_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.interfaces_menu_frame,
- direction = "vertical",
- caption = {"gui.creative-mode_interfaces"}
- }
-
- -- Label.
- interfaces_menu_frame.add {
- type = "label",
- name = creative_mode_defines.names.gui.interfaces_menu_label,
- caption = {"gui.creative-mode_select-remote-interfaces-to-check-contents"},
- tooltip = {"gui.creative-mode_select-remote-interfaces-to-check-contents-tooltip"}
- }
-
- -- Scroll pane.
- local scroll_pane =
- interfaces_menu_frame.add {
- type = "scroll-pane",
- name = creative_mode_defines.names.gui.interfaces_scroll_pane,
- style = creative_mode_defines.names.gui_styles.interfaces_scroll_pane
- }
-
- -- Container (no vertical spacing).
- local inner_container =
- scroll_pane.add {
- type = "flow",
- name = creative_mode_defines.names.gui.interfaces_inner_container,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical"
- }
-
- -- Interfaces.
- for interface_name, interface_contents in pairs(remote.interfaces) do
- -- Button.
- inner_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.interface_button_prefix .. interface_name,
- style = creative_mode_defines.names.gui_styles.interface_button,
- caption = interface_name
- }
- end
- end
-
- -- Interface contents and hints.
- local interface_contents_and_hints_container =
- modding_menus_container[creative_mode_defines.names.gui.interface_contents_and_hints_container]
- if interface_contents_and_hints_container then
- interface_contents_and_hints_container.destroy()
- else
- -- Container. (Create it first, but hide it.)
- interface_contents_and_hints_container =
- modding_menus_container.add {
- type = "flow",
- name = creative_mode_defines.names.gui.interface_contents_and_hints_container,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical"
- }
- interface_contents_and_hints_container.visible = false
-
- -- Interface contents. (Create the frame first, but hide it.)
- local interface_contents_frame =
- interface_contents_and_hints_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.interface_contents_frame,
- direction = "vertical",
- caption = ""
- }
- interface_contents_frame.style.minimal_width = 300
-
- -- Interface hints.
- local interface_hints_frame =
- interface_contents_and_hints_container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.interface_hints_frame,
- direction = "vertical",
- caption = {"gui.creative-mode_hints"}
- }
- -- Can register remote function hint.
- interface_hints_frame.add {
- type = "label",
- name = creative_mode_defines.names.gui.interface_can_register_remote_function_label,
- caption = {"gui.creative-mode_can-register-remote-function"},
- tooltip = {
- "gui.creative-mode_can-register-remote-function-tooltip-1",
- {"gui.creative-mode_can-register-remote-function-tooltip-2", "creative_mode_"},
- {
- "gui.creative-mode_can-register-remote-function-tooltip-3",
- remote_interface.register_remote_function_name,
- remote_interface.deregister_remote_function_name
- },
- {"gui.creative-mode_can-register-remote-function-tooltip-4"}
- }
- }
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local modding_menus_container = container[gui_menu_modding.get_container_name()]
+ if modding_menus_container then
+ -- Interfaces.
+ local interfaces_menu_frame = modding_menus_container[creative_mode_defines.names.gui.interfaces_menu_frame]
+ if interfaces_menu_frame then
+ interfaces_menu_frame.destroy()
+ else
+ -- Make sure the other menus are closed.
+ local events_menu_frame = modding_menus_container[creative_mode_defines.names.gui.events_menu_frame]
+ if events_menu_frame then
+ events_menu_frame.destroy()
+ end
+ local event_categories_and_options_container =
+ modding_menus_container[creative_mode_defines.names.gui.event_categories_and_options_container]
+ if event_categories_and_options_container then
+ event_categories_and_options_container.destroy()
+ end
+
+ -- Frame.
+ interfaces_menu_frame = modding_menus_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.interfaces_menu_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_interfaces" },
+ })
+
+ -- Label.
+ interfaces_menu_frame.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.interfaces_menu_label,
+ caption = { "gui.creative-mode_select-remote-interfaces-to-check-contents" },
+ tooltip = { "gui.creative-mode_select-remote-interfaces-to-check-contents-tooltip" },
+ })
+
+ -- Scroll pane.
+ local scroll_pane = interfaces_menu_frame.add({
+ type = "scroll-pane",
+ name = creative_mode_defines.names.gui.interfaces_scroll_pane,
+ style = creative_mode_defines.names.gui_styles.interfaces_scroll_pane,
+ })
+
+ -- Container (no vertical spacing).
+ local inner_container = scroll_pane.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.interfaces_inner_container,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+
+ -- Interfaces.
+ for interface_name, interface_contents in pairs(remote.interfaces) do
+ -- Button.
+ inner_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.interface_button_prefix .. interface_name,
+ style = creative_mode_defines.names.gui_styles.interface_button,
+ caption = interface_name,
+ })
+ end
+ end
+
+ -- Interface contents and hints.
+ local interface_contents_and_hints_container =
+ modding_menus_container[creative_mode_defines.names.gui.interface_contents_and_hints_container]
+ if interface_contents_and_hints_container then
+ interface_contents_and_hints_container.destroy()
+ else
+ -- Container. (Create it first, but hide it.)
+ interface_contents_and_hints_container = modding_menus_container.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.interface_contents_and_hints_container,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+ interface_contents_and_hints_container.visible = false
+
+ -- Interface contents. (Create the frame first, but hide it.)
+ local interface_contents_frame = interface_contents_and_hints_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.interface_contents_frame,
+ direction = "vertical",
+ caption = "",
+ })
+ interface_contents_frame.style.minimal_width = 300
+
+ -- Interface hints.
+ local interface_hints_frame = interface_contents_and_hints_container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.interface_hints_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode_hints" },
+ })
+ -- Can register remote function hint.
+ interface_hints_frame.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.interface_can_register_remote_function_label,
+ caption = { "gui.creative-mode_can-register-remote-function" },
+ tooltip = {
+ "gui.creative-mode_can-register-remote-function-tooltip-1",
+ { "gui.creative-mode_can-register-remote-function-tooltip-2", "creative_mode_" },
+ {
+ "gui.creative-mode_can-register-remote-function-tooltip-3",
+ remote_interface.register_remote_function_name,
+ remote_interface.deregister_remote_function_name,
+ },
+ { "gui.creative-mode_can-register-remote-function-tooltip-4" },
+ },
+ })
+ end
+ end
+ end
end
-- Adds the contents of the interface of given name to the given frame for the given player.
-- Make sure the frame is visible before calling this method.
local function add_interface_contents_to_frame_for_player(player, interface_name, frame)
- -- Get the actual interface.
- local interface = remote.interfaces[interface_name]
- if interface then
- -- Scroll pane.
- local scroll_pane =
- frame.add {
- type = "scroll-pane",
- name = creative_mode_defines.names.gui.interface_contents_scroll_pane,
- style = creative_mode_defines.names.gui_styles.interface_contents_scroll_pane
- }
- -- Container.
- local interface_contents_container =
- scroll_pane.add {
- type = "flow",
- name = creative_mode_defines.names.gui.interface_contents_container,
- style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
- direction = "vertical"
- }
-
- -- Show the functions.
- for content_name, content in pairs(interface) do
- -- Note: it is meaningless to check the type of content by type(content). They are all Booleans.
- -- Button or label?
- local registered_remote_function_data = nil
- if registered_remote_functions[interface_name] then
- registered_remote_function_data = registered_remote_functions[interface_name][content_name]
- end
- if util.string_starts_with(content_name, "creative_mode_") or registered_remote_function_data then
- -- Button.
- interface_contents_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.interface_contents_button_prefix .. content_name,
- style = creative_mode_defines.names.gui_styles.interface_content_button,
- caption = (registered_remote_function_data and registered_remote_function_data.caption) or content_name,
- tooltip = registered_remote_function_data and registered_remote_function_data.tooltip
- }
- else
- -- Label.
- interface_contents_container.add {
- type = "label",
- name = creative_mode_defines.names.gui.interface_contents_label_prefix .. content_name,
- caption = content_name
- }
- end
- end
- else
- -- The interface does not exist anymore!
- frame.add {
- type = "label",
- name = creative_mode_defines.names.gui.interface_contents_label_prefix .. 1,
- caption = {"gui.creative-mode_interface-does-not-exist-anymore"}
- }
- end
+ -- Get the actual interface.
+ local interface = remote.interfaces[interface_name]
+ if interface then
+ -- Scroll pane.
+ local scroll_pane = frame.add({
+ type = "scroll-pane",
+ name = creative_mode_defines.names.gui.interface_contents_scroll_pane,
+ style = creative_mode_defines.names.gui_styles.interface_contents_scroll_pane,
+ })
+ -- Container.
+ local interface_contents_container = scroll_pane.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.interface_contents_container,
+ style = creative_mode_defines.names.gui_styles.no_vertical_spacing_resize_row_flow,
+ direction = "vertical",
+ })
+
+ -- Show the functions.
+ for content_name, content in pairs(interface) do
+ -- Note: it is meaningless to check the type of content by type(content). They are all Booleans.
+ -- Button or label?
+ local registered_remote_function_data = nil
+ if registered_remote_functions[interface_name] then
+ registered_remote_function_data = registered_remote_functions[interface_name][content_name]
+ end
+ if util.string_starts_with(content_name, "creative_mode_") or registered_remote_function_data then
+ -- Button.
+ interface_contents_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.interface_contents_button_prefix .. content_name,
+ style = creative_mode_defines.names.gui_styles.interface_content_button,
+ caption = (registered_remote_function_data and registered_remote_function_data.caption) or content_name,
+ tooltip = registered_remote_function_data and registered_remote_function_data.tooltip,
+ })
+ else
+ -- Label.
+ interface_contents_container.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.interface_contents_label_prefix .. content_name,
+ caption = content_name,
+ })
+ end
+ end
+ else
+ -- The interface does not exist anymore!
+ frame.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.interface_contents_label_prefix .. 1,
+ caption = { "gui.creative-mode_interface-does-not-exist-anymore" },
+ })
+ end
end
-- Removes all interface contents on GUI and adds back them for the given player, if he/she has opened such GUI.
local function refresh_interface_contents_on_gui_for_player(player)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local modding_menus_container = container[gui_menu_modding.get_container_name()]
- if modding_menus_container then
- local interface_contents_and_hints_container =
- modding_menus_container[creative_mode_defines.names.gui.interface_contents_and_hints_container]
- if interface_contents_and_hints_container and interface_contents_and_hints_container.visible ~= false then
- local interface_contents_frame =
- interface_contents_and_hints_container[creative_mode_defines.names.gui.interface_contents_frame]
- if interface_contents_frame and interface_contents_frame.visible ~= false then
- -- Remove.
- for _, child_name in pairs(interface_contents_frame.children_names) do
- interface_contents_frame[child_name].destroy()
- end
- -- Add back.
- add_interface_contents_to_frame_for_player(player, interface_contents_frame.caption, interface_contents_frame)
- end
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local modding_menus_container = container[gui_menu_modding.get_container_name()]
+ if modding_menus_container then
+ local interface_contents_and_hints_container =
+ modding_menus_container[creative_mode_defines.names.gui.interface_contents_and_hints_container]
+ if interface_contents_and_hints_container and interface_contents_and_hints_container.visible ~= false then
+ local interface_contents_frame =
+ interface_contents_and_hints_container[creative_mode_defines.names.gui.interface_contents_frame]
+ if interface_contents_frame and interface_contents_frame.visible ~= false then
+ -- Remove.
+ for _, child_name in pairs(interface_contents_frame.children_names) do
+ interface_contents_frame[child_name].destroy()
+ end
+ -- Add back.
+ add_interface_contents_to_frame_for_player(player, interface_contents_frame.caption, interface_contents_frame)
+ end
+ end
+ end
+ end
end
-- Removes all interface contents on GUI and adds back them for all players.
local function refresh_interface_contents_on_gui_for_all_players()
- -- This function may be called before the game is ready.
- if not game or not game.players then
- return
- end
-
- for _, player in pairs(game.players) do
- refresh_interface_contents_on_gui_for_player(player)
- end
+ -- This function may be called before the game is ready.
+ if not game or not game.players then
+ return
+ end
+
+ for _, player in pairs(game.players) do
+ refresh_interface_contents_on_gui_for_player(player)
+ end
end
-- Shows the interface contents UI for the given player. If the UI is already visible, it will be hidden instead.
local function show_or_hide_interface_contents_for_player(player, interface_name)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local modding_menus_container = container[gui_menu_modding.get_container_name()]
- if modding_menus_container then
- local interface_contents_and_hints_container =
- modding_menus_container[creative_mode_defines.names.gui.interface_contents_and_hints_container]
- if interface_contents_and_hints_container then
- local interface_contents_frame =
- interface_contents_and_hints_container[creative_mode_defines.names.gui.interface_contents_frame]
- if interface_contents_and_hints_container.visible ~= false then
- -- It is already visible.
- if interface_contents_frame.caption == interface_name then
- -- It is already showing the given interface.
- -- Hide it.
- interface_contents_and_hints_container.visible = false
- return
- end
- end
-
- -- Update the contents according to the given interface name.
- interface_contents_and_hints_container.visible = true
- interface_contents_frame.caption = interface_name
- -- Remove all children inside the frame.
- for _, child_name in pairs(interface_contents_frame.children_names) do
- interface_contents_frame[child_name].destroy()
- end
- -- Add contents.
- add_interface_contents_to_frame_for_player(player, interface_name, interface_contents_frame)
- end
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local modding_menus_container = container[gui_menu_modding.get_container_name()]
+ if modding_menus_container then
+ local interface_contents_and_hints_container =
+ modding_menus_container[creative_mode_defines.names.gui.interface_contents_and_hints_container]
+ if interface_contents_and_hints_container then
+ local interface_contents_frame =
+ interface_contents_and_hints_container[creative_mode_defines.names.gui.interface_contents_frame]
+ if interface_contents_and_hints_container.visible ~= false then
+ -- It is already visible.
+ if interface_contents_frame.caption == interface_name then
+ -- It is already showing the given interface.
+ -- Hide it.
+ interface_contents_and_hints_container.visible = false
+ return
+ end
+ end
+
+ -- Update the contents according to the given interface name.
+ interface_contents_and_hints_container.visible = true
+ interface_contents_frame.caption = interface_name
+ -- Remove all children inside the frame.
+ for _, child_name in pairs(interface_contents_frame.children_names) do
+ interface_contents_frame[child_name].destroy()
+ end
+ -- Add contents.
+ add_interface_contents_to_frame_for_player(player, interface_name, interface_contents_frame)
+ end
+ end
+ end
end
--------------------------------------------------------------------
@@ -1021,45 +1000,46 @@ end
-- Registers or deregisters the given remote function in the given interface.
-- Returns whether the deregisteration is success.
function gui_menu_modding.register_or_deregister_remote_function(
- interface_name,
- function_name,
- is_register,
- additional_data)
- if is_register then
- -- Register.
- if not registered_remote_functions[interface_name] then
- registered_remote_functions[interface_name] = {}
- end
- registered_remote_functions[interface_name][function_name] = additional_data or {}
- refresh_interface_contents_on_gui_for_all_players()
- return nil
- else
- -- Deregister.
- if not registered_remote_functions[interface_name] then
- -- No such interface.
- return false
- end
- if not registered_remote_functions[interface_name][function_name] then
- -- No such function.
- return false
- end
- registered_remote_functions[interface_name][function_name] = nil
- refresh_interface_contents_on_gui_for_all_players()
- return true
- end
+ interface_name,
+ function_name,
+ is_register,
+ additional_data
+)
+ if is_register then
+ -- Register.
+ if not registered_remote_functions[interface_name] then
+ registered_remote_functions[interface_name] = {}
+ end
+ registered_remote_functions[interface_name][function_name] = additional_data or {}
+ refresh_interface_contents_on_gui_for_all_players()
+ return nil
+ else
+ -- Deregister.
+ if not registered_remote_functions[interface_name] then
+ -- No such interface.
+ return false
+ end
+ if not registered_remote_functions[interface_name][function_name] then
+ -- No such function.
+ return false
+ end
+ registered_remote_functions[interface_name][function_name] = nil
+ refresh_interface_contents_on_gui_for_all_players()
+ return true
+ end
end
-- Returns whether the given remote function in the given function has been registered.
function gui_menu_modding.has_registered_remote_function(interface_name, function_name)
- if not registered_remote_functions[interface_name] then
- -- No such interface.
- return false
- end
- if not registered_remote_functions[interface_name][function_name] then
- -- No such function.
- return false
- end
- return true
+ if not registered_remote_functions[interface_name] then
+ -- No such interface.
+ return false
+ end
+ if not registered_remote_functions[interface_name][function_name] then
+ -- No such function.
+ return false
+ end
+ return true
end
--------------------------------------------------------------------
@@ -1067,172 +1047,169 @@ end
-- Callback of the on_gui_click event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_modding.on_gui_click(element, element_name, player, button, alt, control, shift)
- if element_name == creative_mode_defines.names.gui.events_menu_button then
- -- Events menu button.
- create_or_destroy_events_menu_for_player(player)
- return true
- elseif element_name == creative_mode_defines.names.gui.interfaces_menu_button then
- ---------------------------------------------------------------------------------------------------
- -- Interfaces menu button.
- create_or_destroy_interfaces_menu_for_player(player)
- return true
- elseif element_name == creative_mode_defines.names.gui.events_menu_search_button then
- -- Events - search button.
- -- button -> title container.
- local title_container = element.parent
- local search_textfield = title_container[creative_mode_defines.names.gui.events_menu_search_textfield]
- local search_textfield_placeholder =
- title_container[creative_mode_defines.names.gui.events_menu_search_textfield_placeholder_flow]
-
- if search_textfield.visible then
- -- Hide the search textfield.
- search_textfield.visible = false
- search_textfield_placeholder.visible = true
- -- Reset search text and show all events.
- search_textfield.text = ""
- show_events_for_player_by_search_name(player, nil)
- else
- -- Show the search textfield.
- search_textfield.visible = true
- search_textfield_placeholder.visible = false
- end
- return true
- elseif element_name == creative_mode_defines.names.gui.events_enable_all_button then
- -- Events - enable all button.
- enable_or_disable_all_visible_events_for_player(player, true)
- return true
- elseif element_name == creative_mode_defines.names.gui.events_disable_all_button then
- ---------------------------------------------------------------------------------------------------
- -- Events - disable all button.
- enable_or_disable_all_visible_events_for_player(player, false)
- return true
- else
- for _, data in pairs(event_categories) do
- if element_name == data.show_button_name then
- -- Event category show button.
- show_or_hide_events_for_player(player, data.events, true)
- return true
- elseif element_name == data.hide_button_name then
- -- Event category hide button.
- show_or_hide_events_for_player(player, data.events, false)
- return true
- end
- end
- end
-
- ---------------------------------------------------------------------------------------------------
-
- if element.parent and element.parent.name == creative_mode_defines.names.gui.interfaces_inner_container then
- -- Interface button.
- local interface_name = string.match(element_name, creative_mode_defines.match_patterns.gui.interface_button)
- if interface_name ~= nil then
- interface_name = tostring(interface_name)
- show_or_hide_interface_contents_for_player(player, interface_name)
- return true
- end
- return true
- end
-
- ---------------------------------------------------------------------------------------------------
-
- if element.parent and element.parent.name == creative_mode_defines.names.gui.interface_contents_container then
- -- Interface content button.
- -- button -> table -> scroll-pane -> frame.
- local scroll_pane = element.parent.parent
- if scroll_pane then
- local frame = scroll_pane.parent
- if frame then
- local interface_name = frame.caption
- local interface = remote.interfaces[interface_name]
- if interface then
- local function_name =
- string.match(element_name, creative_mode_defines.match_patterns.gui.interface_contents_button)
- if function_name ~= nil then
- if interface[function_name] then
- -- Call the function.
- remote.call(
- interface_name,
- function_name,
- {
- player_index = player.index,
- creative_mode_modding = true
- }
- )
- else
- -- The function does not exist anymore.
- element.destroy()
- end
- end
- else
- -- The interface does not exists anymore.
- refresh_interface_contents_on_gui_for_player(player)
- end
- end
- end
- return true
- end
-
- return false
+ if element_name == creative_mode_defines.names.gui.events_menu_button then
+ -- Events menu button.
+ create_or_destroy_events_menu_for_player(player)
+ return true
+ elseif element_name == creative_mode_defines.names.gui.interfaces_menu_button then
+ ---------------------------------------------------------------------------------------------------
+ -- Interfaces menu button.
+ create_or_destroy_interfaces_menu_for_player(player)
+ return true
+ elseif element_name == creative_mode_defines.names.gui.events_menu_search_button then
+ -- Events - search button.
+ -- button -> title container.
+ local title_container = element.parent
+ local search_textfield = title_container[creative_mode_defines.names.gui.events_menu_search_textfield]
+ local search_textfield_placeholder =
+ title_container[creative_mode_defines.names.gui.events_menu_search_textfield_placeholder_flow]
+
+ if search_textfield.visible then
+ -- Hide the search textfield.
+ search_textfield.visible = false
+ search_textfield_placeholder.visible = true
+ -- Reset search text and show all events.
+ search_textfield.text = ""
+ show_events_for_player_by_search_name(player, nil)
+ else
+ -- Show the search textfield.
+ search_textfield.visible = true
+ search_textfield_placeholder.visible = false
+ end
+ return true
+ elseif element_name == creative_mode_defines.names.gui.events_enable_all_button then
+ -- Events - enable all button.
+ enable_or_disable_all_visible_events_for_player(player, true)
+ return true
+ elseif element_name == creative_mode_defines.names.gui.events_disable_all_button then
+ ---------------------------------------------------------------------------------------------------
+ -- Events - disable all button.
+ enable_or_disable_all_visible_events_for_player(player, false)
+ return true
+ else
+ for _, data in pairs(event_categories) do
+ if element_name == data.show_button_name then
+ -- Event category show button.
+ show_or_hide_events_for_player(player, data.events, true)
+ return true
+ elseif element_name == data.hide_button_name then
+ -- Event category hide button.
+ show_or_hide_events_for_player(player, data.events, false)
+ return true
+ end
+ end
+ end
+
+ ---------------------------------------------------------------------------------------------------
+
+ if element.parent and element.parent.name == creative_mode_defines.names.gui.interfaces_inner_container then
+ -- Interface button.
+ local interface_name = string.match(element_name, creative_mode_defines.match_patterns.gui.interface_button)
+ if interface_name ~= nil then
+ interface_name = tostring(interface_name)
+ show_or_hide_interface_contents_for_player(player, interface_name)
+ return true
+ end
+ return true
+ end
+
+ ---------------------------------------------------------------------------------------------------
+
+ if element.parent and element.parent.name == creative_mode_defines.names.gui.interface_contents_container then
+ -- Interface content button.
+ -- button -> table -> scroll-pane -> frame.
+ local scroll_pane = element.parent.parent
+ if scroll_pane then
+ local frame = scroll_pane.parent
+ if frame then
+ local interface_name = frame.caption
+ local interface = remote.interfaces[interface_name]
+ if interface then
+ local function_name =
+ string.match(element_name, creative_mode_defines.match_patterns.gui.interface_contents_button)
+ if function_name ~= nil then
+ if interface[function_name] then
+ -- Call the function.
+ remote.call(interface_name, function_name, {
+ player_index = player.index,
+ creative_mode_modding = true,
+ })
+ else
+ -- The function does not exist anymore.
+ element.destroy()
+ end
+ end
+ else
+ -- The interface does not exists anymore.
+ refresh_interface_contents_on_gui_for_player(player)
+ end
+ end
+ end
+ return true
+ end
+
+ return false
end
-- Callback of the on_gui_text_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_modding.on_gui_text_changed(element, element_name, player)
- if element_name == creative_mode_defines.names.gui.events_menu_search_textfield then
- -- Events - search event name.
- show_events_for_player_by_search_name(player, element.text)
- return true
- end
- return false
+ if element_name == creative_mode_defines.names.gui.events_menu_search_textfield then
+ -- Events - search event name.
+ show_events_for_player_by_search_name(player, element.text)
+ return true
+ end
+ return false
end
-- Callback of the on_gui_checked_state_changed event, extended from gui-menu.lua.
-- Returns whether the event is consumed.
function gui_menu_modding.on_gui_checked_state_changed(element, element_name, player)
- if element_name == creative_mode_defines.names.gui.event_option_print_events_checkbox then
- -- Event options - print events.
- storage.creative_mode.print_events[player.index] = element.state
- return true
- elseif element_name == creative_mode_defines.names.gui.event_option_print_parameters_checkbox then
- -- Event options - also print event parameters.
- storage.creative_mode.also_print_event_params[player.index] = element.state
- return true
- elseif element_name == creative_mode_defines.names.gui.event_option_write_events_checkbox then
- -- Event options - write events.
- storage.creative_mode.write_events[player.index] = element.state
- return true
- elseif element_name == creative_mode_defines.names.gui.event_option_write_parameters_checkbox then
- -- Event options - also write event parameters.
- storage.creative_mode.also_write_event_params[player.index] = element.state
- return true
- elseif element_name == creative_mode_defines.names.gui.event_option_log_events_checkbox then
- -- Event options - log events.
- storage.creative_mode.log_events[player.index] = element.state
- return true
- elseif element_name == creative_mode_defines.names.gui.event_option_log_parameters_checkbox then
- ---------------------------------------------------------------------------------------------------
- -- Event options - also log event parameters.
- storage.creative_mode.also_log_event_params[player.index] = element.state
- return true
- elseif
- element.parent and element.parent.parent and
- element.parent.parent.name == creative_mode_defines.names.gui.events_inner_container
- then
- local event_id = string.match(element_name, creative_mode_defines.match_patterns.gui.event_toggle_checkbox)
- if event_id ~= nil then
- -- Event toggle.
- event_id = tonumber(event_id)
- if not storage.creative_mode.selected_events[player.index] then
- storage.creative_mode.selected_events[player.index] = {}
- end
- if element.state then
- storage.creative_mode.selected_events[player.index][event_id] = true
- else
- storage.creative_mode.selected_events[player.index][event_id] = nil
- end
- end
- return true
- end
-
- return false
+ if element_name == creative_mode_defines.names.gui.event_option_print_events_checkbox then
+ -- Event options - print events.
+ storage.creative_mode.print_events[player.index] = element.state
+ return true
+ elseif element_name == creative_mode_defines.names.gui.event_option_print_parameters_checkbox then
+ -- Event options - also print event parameters.
+ storage.creative_mode.also_print_event_params[player.index] = element.state
+ return true
+ elseif element_name == creative_mode_defines.names.gui.event_option_write_events_checkbox then
+ -- Event options - write events.
+ storage.creative_mode.write_events[player.index] = element.state
+ return true
+ elseif element_name == creative_mode_defines.names.gui.event_option_write_parameters_checkbox then
+ -- Event options - also write event parameters.
+ storage.creative_mode.also_write_event_params[player.index] = element.state
+ return true
+ elseif element_name == creative_mode_defines.names.gui.event_option_log_events_checkbox then
+ -- Event options - log events.
+ storage.creative_mode.log_events[player.index] = element.state
+ return true
+ elseif element_name == creative_mode_defines.names.gui.event_option_log_parameters_checkbox then
+ ---------------------------------------------------------------------------------------------------
+ -- Event options - also log event parameters.
+ storage.creative_mode.also_log_event_params[player.index] = element.state
+ return true
+ elseif
+ element.parent
+ and element.parent.parent
+ and element.parent.parent.name == creative_mode_defines.names.gui.events_inner_container
+ then
+ local event_id = string.match(element_name, creative_mode_defines.match_patterns.gui.event_toggle_checkbox)
+ if event_id ~= nil then
+ -- Event toggle.
+ event_id = tonumber(event_id)
+ if not storage.creative_mode.selected_events[player.index] then
+ storage.creative_mode.selected_events[player.index] = {}
+ end
+ if element.state then
+ storage.creative_mode.selected_events[player.index][event_id] = true
+ else
+ storage.creative_mode.selected_events[player.index][event_id] = nil
+ end
+ end
+ return true
+ end
+
+ return false
end
diff --git a/scripts/gui-menu.lua b/scripts/gui-menu.lua
index 328361b..a7d14bb 100644
--- a/scripts/gui-menu.lua
+++ b/scripts/gui-menu.lua
@@ -2,251 +2,248 @@ local mod_gui = require("mod-gui")
-- This file contains variables and functions related to Creative Mode menu GUI.
if not gui_menu then
- gui_menu = {}
+ gui_menu = {}
end
-- Creates or destroys the Creative Mode main menu button for the given player according to the current state of Creative Mode and also the player's access rights.
-- Returns whether the button exists. If false is returned, it means the whole Creative Menu is removed for such player.
function gui_menu.create_or_destroy_main_menu_open_button_for_player(player)
- local top = mod_gui.get_button_flow(player)
- if storage.creative_mode.enabled and rights.can_player_access_creative_mode_menu(player) then
- if not top[creative_mode_defines.names.gui.main_menu_open_button] then
- top.add {
- type = "button",
- name = creative_mode_defines.names.gui.main_menu_open_button,
- style = creative_mode_defines.names.gui_styles.main_menu_open_button,
- tooltip = {"gui.creative-mode_main-menu-open-button-tooltip"}
- }
- end
- return true
- else
- local button = top[creative_mode_defines.names.gui.main_menu_open_button]
- if button then
- button.destroy()
- end
- -- Also destroy the contents.
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- container.destroy()
- end
- return false
- end
+ local top = mod_gui.get_button_flow(player)
+ if storage.creative_mode.enabled and rights.can_player_access_creative_mode_menu(player) then
+ if not top[creative_mode_defines.names.gui.main_menu_open_button] then
+ top.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.main_menu_open_button,
+ style = creative_mode_defines.names.gui_styles.main_menu_open_button,
+ tooltip = { "gui.creative-mode_main-menu-open-button-tooltip" },
+ })
+ end
+ return true
+ else
+ local button = top[creative_mode_defines.names.gui.main_menu_open_button]
+ if button then
+ button.destroy()
+ end
+ -- Also destroy the contents.
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ container.destroy()
+ end
+ return false
+ end
end
-- Creates or destroys the Creative Mode main menu button for all players according to the current state of Creative Mode.
function gui_menu.create_or_destroy_main_menu_open_button_for_all_players()
- for _, player in pairs(game.players) do
- gui_menu.create_or_destroy_main_menu_open_button_for_player(player)
- end
+ for _, player in pairs(game.players) do
+ gui_menu.create_or_destroy_main_menu_open_button_for_player(player)
+ end
end
--------------------------------------------------------------------
-- GUI data about the submenu buttons.
local submenus_gui_data = {
- cheats = {
- button_name = creative_mode_defines.names.gui.main_menu_open_cheats_button,
- button_caption = {"gui.creative-mode_cheats"},
- get_player_can_access_function = rights.can_player_access_cheats_menu,
- get_submenu_container_name_function = gui_menu_cheats.get_container_name,
- open_submenu_for_player_function = gui_menu_cheats.create_or_destroy_menu_for_player,
- update_accessibility_for_player_function = gui_menu_cheats.update_menu_accessibility_according_to_access_right_for_player
- },
- build_options = {
- button_name = creative_mode_defines.names.gui.main_menu_open_build_options_button,
- button_caption = {"gui.creative-mode_build-options"},
- get_player_can_access_function = rights.can_player_access_build_options_menu,
- get_submenu_container_name_function = gui_menu_buildoptions.get_container_name,
- open_submenu_for_player_function = gui_menu_buildoptions.create_or_destroy_menu_for_player,
- update_accessibility_for_player_function = gui_menu_buildoptions.update_menu_accessibility_according_to_access_right_for_player
- },
- magic_wand = {
- button_name = creative_mode_defines.names.gui.main_menu_open_magic_wand_button,
- button_caption = {"gui.creative-mode_magic-wand"},
- get_player_can_access_function = rights.can_player_access_magic_wand_menu,
- get_submenu_container_name_function = gui_menu_magicwand.get_container_name,
- open_submenu_for_player_function = gui_menu_magicwand.create_or_destroy_menu_for_player,
- update_accessibility_for_player_function = gui_menu_magicwand.update_menu_accessibility_according_to_access_right_for_player
- },
- modding = {
- button_name = creative_mode_defines.names.gui.main_menu_open_modding_button,
- button_caption = {"gui.creative-mode_modding"},
- get_player_can_access_function = rights.can_player_access_modding_menu,
- get_submenu_container_name_function = gui_menu_modding.get_container_name,
- open_submenu_for_player_function = gui_menu_modding.create_or_destroy_menu_for_player,
- update_accessibility_for_player_function = nil
- },
- admin = {
- button_name = creative_mode_defines.names.gui.main_menu_open_admin_button,
- button_caption = {"gui.creative-mode_admin"},
- get_player_can_access_function = function(player)
- return player.admin
- end,
- get_submenu_container_name_function = gui_menu_admin.get_container_name,
- open_submenu_for_player_function = gui_menu_admin.create_or_destroy_menu_for_player,
- update_accessibility_for_player_function = nil
- }
+ cheats = {
+ button_name = creative_mode_defines.names.gui.main_menu_open_cheats_button,
+ button_caption = { "gui.creative-mode_cheats" },
+ get_player_can_access_function = rights.can_player_access_cheats_menu,
+ get_submenu_container_name_function = gui_menu_cheats.get_container_name,
+ open_submenu_for_player_function = gui_menu_cheats.create_or_destroy_menu_for_player,
+ update_accessibility_for_player_function = gui_menu_cheats.update_menu_accessibility_according_to_access_right_for_player,
+ },
+ build_options = {
+ button_name = creative_mode_defines.names.gui.main_menu_open_build_options_button,
+ button_caption = { "gui.creative-mode_build-options" },
+ get_player_can_access_function = rights.can_player_access_build_options_menu,
+ get_submenu_container_name_function = gui_menu_buildoptions.get_container_name,
+ open_submenu_for_player_function = gui_menu_buildoptions.create_or_destroy_menu_for_player,
+ update_accessibility_for_player_function = gui_menu_buildoptions.update_menu_accessibility_according_to_access_right_for_player,
+ },
+ magic_wand = {
+ button_name = creative_mode_defines.names.gui.main_menu_open_magic_wand_button,
+ button_caption = { "gui.creative-mode_magic-wand" },
+ get_player_can_access_function = rights.can_player_access_magic_wand_menu,
+ get_submenu_container_name_function = gui_menu_magicwand.get_container_name,
+ open_submenu_for_player_function = gui_menu_magicwand.create_or_destroy_menu_for_player,
+ update_accessibility_for_player_function = gui_menu_magicwand.update_menu_accessibility_according_to_access_right_for_player,
+ },
+ modding = {
+ button_name = creative_mode_defines.names.gui.main_menu_open_modding_button,
+ button_caption = { "gui.creative-mode_modding" },
+ get_player_can_access_function = rights.can_player_access_modding_menu,
+ get_submenu_container_name_function = gui_menu_modding.get_container_name,
+ open_submenu_for_player_function = gui_menu_modding.create_or_destroy_menu_for_player,
+ update_accessibility_for_player_function = nil,
+ },
+ admin = {
+ button_name = creative_mode_defines.names.gui.main_menu_open_admin_button,
+ button_caption = { "gui.creative-mode_admin" },
+ get_player_can_access_function = function(player)
+ return player.admin
+ end,
+ get_submenu_container_name_function = gui_menu_admin.get_container_name,
+ open_submenu_for_player_function = gui_menu_admin.create_or_destroy_menu_for_player,
+ update_accessibility_for_player_function = nil,
+ },
}
-- Destroys the Creative Mode main menu for the given player if it is already opened.
function gui_menu.destroy_main_menu_for_player(player)
- local left = mod_gui.get_frame_flow(player)
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- container.destroy()
- end
+ local left = mod_gui.get_frame_flow(player)
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ container.destroy()
+ end
end
-- Closes the submenu of given name for the given player if the menu is opened.
local function close_submenu_for_player(player, submenu_container_name)
- local left = mod_gui.get_frame_flow(player)
- -- Container.
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local submenu_container = container[submenu_container_name]
- if submenu_container then
- submenu_container.destroy()
- end
- end
+ local left = mod_gui.get_frame_flow(player)
+ -- Container.
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local submenu_container = container[submenu_container_name]
+ if submenu_container then
+ submenu_container.destroy()
+ end
+ end
end
-- Opens the given magic wand menu for the given player. Other submenus will be closed.
-- Returns whether the given menu has not been opened yet and is now opened.
local function show_magic_wand_menu_for_player(player, magic_wand_menu_gui_data)
- local magic_wand_submenu_gui_data = submenus_gui_data.magic_wand
- -- Close other submenus.
- for _, data in pairs(submenus_gui_data) do
- if data ~= magic_wand_submenu_gui_data then
- close_submenu_for_player(player, data.get_submenu_container_name_function())
- end
- end
- -- Open the menu and close other magic wand menus.
- magic_wand_submenu_gui_data.open_submenu_for_player_function(player, false)
- return gui_menu_magicwand.open_magic_wand_menu_for_player_and_close_others(player, magic_wand_menu_gui_data)
+ local magic_wand_submenu_gui_data = submenus_gui_data.magic_wand
+ -- Close other submenus.
+ for _, data in pairs(submenus_gui_data) do
+ if data ~= magic_wand_submenu_gui_data then
+ close_submenu_for_player(player, data.get_submenu_container_name_function())
+ end
+ end
+ -- Open the menu and close other magic wand menus.
+ magic_wand_submenu_gui_data.open_submenu_for_player_function(player, false)
+ return gui_menu_magicwand.open_magic_wand_menu_for_player_and_close_others(player, magic_wand_menu_gui_data)
end
-- If the given player is holding a magic wand, opens the corresponding page for it immediately and closes other submenus.
-- Returns whether the magic wand menu is opened because player is holding the magic wand and such menu has not been opened yet.
local function show_magic_wand_menu_for_player_by_cursor_stack(player)
- local cursor_stack = player.cursor_stack
- if cursor_stack and cursor_stack.valid_for_read then -- cursor_stack is nil if player is respawning.
- local cursor_stack_name = cursor_stack.name
- if cursor_stack_name == creative_mode_defines.names.items.magic_wand_creator then
- return show_magic_wand_menu_for_player(player, gui_menu_magicwand.magic_wand_menus_gui_data.creator)
- elseif cursor_stack_name == creative_mode_defines.names.items.magic_wand_healer then
- return show_magic_wand_menu_for_player(player, gui_menu_magicwand.magic_wand_menus_gui_data.healer)
- elseif cursor_stack_name == creative_mode_defines.names.items.magic_wand_modifier then
- return show_magic_wand_menu_for_player(player, gui_menu_magicwand.magic_wand_menus_gui_data.modifier)
- end
- end
- return false
+ local cursor_stack = player.cursor_stack
+ if cursor_stack and cursor_stack.valid_for_read then -- cursor_stack is nil if player is respawning.
+ local cursor_stack_name = cursor_stack.name
+ if cursor_stack_name == creative_mode_defines.names.items.magic_wand_creator then
+ return show_magic_wand_menu_for_player(player, gui_menu_magicwand.magic_wand_menus_gui_data.creator)
+ elseif cursor_stack_name == creative_mode_defines.names.items.magic_wand_healer then
+ return show_magic_wand_menu_for_player(player, gui_menu_magicwand.magic_wand_menus_gui_data.healer)
+ elseif cursor_stack_name == creative_mode_defines.names.items.magic_wand_modifier then
+ return show_magic_wand_menu_for_player(player, gui_menu_magicwand.magic_wand_menus_gui_data.modifier)
+ end
+ end
+ return false
end
-- Creates the Creative Mode main menu for the given player. If the menu already exists and is visible, it will be hidden instead.
local function create_or_hide_main_menu_for_player(player)
- local left = mod_gui.get_frame_flow(player)
+ local left = mod_gui.get_frame_flow(player)
- -- Container.
- local container = left[creative_mode_defines.names.gui.main_menu_container]
- if container then
- if container.visible ~= false then
- -- The container is visible. If the player is holding a magic wand and its menu is not opened, open it.
- if not show_magic_wand_menu_for_player_by_cursor_stack(player) then
- -- The menu is already opened. Hide the whole main menu.
- container.visible = false
- end
- else
- -- This works, but has the side-effect of the menu closing when the player tries to open inventory.
- --player.opened = container
- -- The container is invisible. Show it.
- container.visible = true
- -- Magic wand menu.
- show_magic_wand_menu_for_player_by_cursor_stack(player)
- end
- else
- container =
- left.add {
- type = "flow",
- name = creative_mode_defines.names.gui.main_menu_container,
- style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
- direction = "horizontal"
- }
- -- This works, but has the side-effect of the menu closing when the player tries to open inventory.
- --player.opened = container
- -- Frame.
- local frame =
- container.add {
- type = "frame",
- name = creative_mode_defines.names.gui.main_menu_frame,
- direction = "vertical",
- caption = {"gui.creative-mode"}
- }
- -- Buttons.
- for _, data in pairs(submenus_gui_data) do
- local button =
- frame.add {
- type = "button",
- name = data.button_name,
- style = creative_mode_defines.names.gui_styles.main_menu_button,
- caption = data.button_caption
- }
- button.visible = data.get_player_can_access_function(player)
- end
+ -- Container.
+ local container = left[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ if container.visible ~= false then
+ -- The container is visible. If the player is holding a magic wand and its menu is not opened, open it.
+ if not show_magic_wand_menu_for_player_by_cursor_stack(player) then
+ -- The menu is already opened. Hide the whole main menu.
+ container.visible = false
+ end
+ else
+ -- This works, but has the side-effect of the menu closing when the player tries to open inventory.
+ --player.opened = container
+ -- The container is invisible. Show it.
+ container.visible = true
+ -- Magic wand menu.
+ show_magic_wand_menu_for_player_by_cursor_stack(player)
+ end
+ else
+ container = left.add({
+ type = "flow",
+ name = creative_mode_defines.names.gui.main_menu_container,
+ style = creative_mode_defines.names.gui_styles.no_horizontal_spacing_flow,
+ direction = "horizontal",
+ })
+ -- This works, but has the side-effect of the menu closing when the player tries to open inventory.
+ --player.opened = container
+ -- Frame.
+ local frame = container.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.main_menu_frame,
+ direction = "vertical",
+ caption = { "gui.creative-mode" },
+ })
+ -- Buttons.
+ for _, data in pairs(submenus_gui_data) do
+ local button = frame.add({
+ type = "button",
+ name = data.button_name,
+ style = creative_mode_defines.names.gui_styles.main_menu_button,
+ caption = data.button_caption,
+ })
+ button.visible = data.get_player_can_access_function(player)
+ end
- -- Magic wand menu.
- show_magic_wand_menu_for_player_by_cursor_stack(player)
- end
+ -- Magic wand menu.
+ show_magic_wand_menu_for_player_by_cursor_stack(player)
+ end
end
--------------------------------------------------------------------
-- Updates the menu accessibility according to the newest access right for all players after the access rights of the given codes have changed.
function gui_menu.update_menu_accessibility_according_to_access_right_for_all_players(updated_access_right_codes)
- for _, player in pairs(game.players) do
- if gui_menu.create_or_destroy_main_menu_open_button_for_player(player) then
- -- The Creative Menu is still available for the player.
- -- Update submenus.
- local container = mod_gui.get_frame_flow(player)[creative_mode_defines.names.gui.main_menu_container]
- if container then
- local frame = container[creative_mode_defines.names.gui.main_menu_frame]
- if frame then
- for _, data in pairs(submenus_gui_data) do
- if data.get_player_can_access_function(player) then
- -- The player can access the menu.
- -- Make sure the button is available for him/her.
- local button = frame[data.button_name]
- if button then
- button.visible = true
- end
- -- Update the accessibility of its contents if necessary.
- local submenu_container = container[data.get_submenu_container_name_function()]
- if submenu_container then
- if data.update_accessibility_for_player_function then
- data.update_accessibility_for_player_function(player, updated_access_right_codes)
- end
- end
- else
- -- It should be destroyed.
- -- Hide menu button.
- local button = frame[data.button_name]
- if button then
- button.visible = false
- end
- -- Destroy menu.
- close_submenu_for_player(player, data.get_submenu_container_name_function())
- end
- end
- end
- end
- end
- end
+ for _, player in pairs(game.players) do
+ if gui_menu.create_or_destroy_main_menu_open_button_for_player(player) then
+ -- The Creative Menu is still available for the player.
+ -- Update submenus.
+ local container = mod_gui.get_frame_flow(player)[creative_mode_defines.names.gui.main_menu_container]
+ if container then
+ local frame = container[creative_mode_defines.names.gui.main_menu_frame]
+ if frame then
+ for _, data in pairs(submenus_gui_data) do
+ if data.get_player_can_access_function(player) then
+ -- The player can access the menu.
+ -- Make sure the button is available for him/her.
+ local button = frame[data.button_name]
+ if button then
+ button.visible = true
+ end
+ -- Update the accessibility of its contents if necessary.
+ local submenu_container = container[data.get_submenu_container_name_function()]
+ if submenu_container then
+ if data.update_accessibility_for_player_function then
+ data.update_accessibility_for_player_function(player, updated_access_right_codes)
+ end
+ end
+ else
+ -- It should be destroyed.
+ -- Hide menu button.
+ local button = frame[data.button_name]
+ if button then
+ button.visible = false
+ end
+ -- Destroy menu.
+ close_submenu_for_player(player, data.get_submenu_container_name_function())
+ end
+ end
+ end
+ end
+ end
+ end
end
--------------------------------------------------------------------
function gui_menu.on_player_cursor_stack_changed(event)
- --[=[
+ --[=[
-- sort-of working way to open the magic wand menu when you pick it up, and close when you put it down, but only works the first time you pick it up
local player = game.players[event.player_index]
local left = mod_gui.get_frame_flow(player)
@@ -267,117 +264,117 @@ end
-- Updates GUI when a player joined the game.
function gui_menu.on_player_joined_game(event)
- -- Closes the Creative Mode main menu if it is opened for that player.
- -- He may have opened it before and now comes back to this game.
- -- Many problems can be solved by this. >:D
- local player = game.players[event.player_index]
- gui_menu.destroy_main_menu_for_player(player)
+ -- Closes the Creative Mode main menu if it is opened for that player.
+ -- He may have opened it before and now comes back to this game.
+ -- Many problems can be solved by this. >:D
+ local player = game.players[event.player_index]
+ gui_menu.destroy_main_menu_for_player(player)
- -- Also destroy the modifier popup.
- gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
+ -- Also destroy the modifier popup.
+ gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
- gui_menu_cheats.on_player_joined_game(event)
+ gui_menu_cheats.on_player_joined_game(event)
end
-- Updates GUI when a player left the game.
function gui_menu.on_player_left_game(event)
- gui_menu_cheats.on_player_left_game(event)
+ gui_menu_cheats.on_player_left_game(event)
end
-- Updates GUI when a player went to another surface.
function gui_menu.on_player_changed_surface(event)
- gui_menu_cheats.on_player_changed_surface(event)
+ gui_menu_cheats.on_player_changed_surface(event)
end
-- Callback of the on_gui_click event, extended from gui.lua.
-- Returns whether the event is consumed.
function gui_menu.on_gui_click(element, element_name, player, button, alt, control, shift)
- if element_name == creative_mode_defines.names.gui.main_menu_open_button then
- -- Main menu open button.
- create_or_hide_main_menu_for_player(player)
- return true
- end
+ if element_name == creative_mode_defines.names.gui.main_menu_open_button then
+ -- Main menu open button.
+ create_or_hide_main_menu_for_player(player)
+ return true
+ end
- --------------------------------------------------------------------
+ --------------------------------------------------------------------
- for _, data in pairs(submenus_gui_data) do
- if element_name == data.button_name then
- -- Submenu button.
+ for _, data in pairs(submenus_gui_data) do
+ if element_name == data.button_name then
+ -- Submenu button.
- -- Close other submenus.
- for _, data2 in pairs(submenus_gui_data) do
- if data ~= data2 then
- close_submenu_for_player(player, data2.get_submenu_container_name_function())
- end
- end
- -- Open the submenu.
- data.open_submenu_for_player_function(player)
- return true
- end
- end
+ -- Close other submenus.
+ for _, data2 in pairs(submenus_gui_data) do
+ if data ~= data2 then
+ close_submenu_for_player(player, data2.get_submenu_container_name_function())
+ end
+ end
+ -- Open the submenu.
+ data.open_submenu_for_player_function(player)
+ return true
+ end
+ end
- ---------------------------------------------------------------------------------------------------
+ ---------------------------------------------------------------------------------------------------
- -- Further extend the event to sub-menus.
- if gui_menu_cheats.on_gui_click(element, element_name, player, button, alt, control, shift) then
- return true
- end
- if gui_menu_magicwand.on_gui_click(element, element_name, player, button, alt, control, shift) then
- return true
- end
- if gui_menu_modding.on_gui_click(element, element_name, player, button, alt, control, shift) then
- return true
- end
- if gui_menu_admin.on_gui_click(element, element_name, player, button, alt, control, shift) then
- return true
- end
- return false
+ -- Further extend the event to sub-menus.
+ if gui_menu_cheats.on_gui_click(element, element_name, player, button, alt, control, shift) then
+ return true
+ end
+ if gui_menu_magicwand.on_gui_click(element, element_name, player, button, alt, control, shift) then
+ return true
+ end
+ if gui_menu_modding.on_gui_click(element, element_name, player, button, alt, control, shift) then
+ return true
+ end
+ if gui_menu_admin.on_gui_click(element, element_name, player, button, alt, control, shift) then
+ return true
+ end
+ return false
end
-- Callback of the on_gui_text_changed event, extended from gui.lua.
-- Returns whether the event is consumed.
function gui_menu.on_gui_text_changed(element, element_name, player)
- -- Further extend the event to sub-menus.
- if gui_menu_cheats.on_gui_text_changed(element, element_name, player) then
- return true
- end
- if gui_menu_magicwand.on_gui_text_changed(element, element_name, player) then
- return true
- end
- if gui_menu_modding.on_gui_text_changed(element, element_name, player) then
- return true
- end
- if gui_menu_admin.on_gui_text_changed(element, element_name, player) then
- return true
- end
- return false
+ -- Further extend the event to sub-menus.
+ if gui_menu_cheats.on_gui_text_changed(element, element_name, player) then
+ return true
+ end
+ if gui_menu_magicwand.on_gui_text_changed(element, element_name, player) then
+ return true
+ end
+ if gui_menu_modding.on_gui_text_changed(element, element_name, player) then
+ return true
+ end
+ if gui_menu_admin.on_gui_text_changed(element, element_name, player) then
+ return true
+ end
+ return false
end
-- Callback of the on_gui_checked_state_changed event, extended from gui.lua.
-- Returns whether the event is consumed.
function gui_menu.on_gui_checked_state_changed(element, element_name, player)
- -- Further extend the event to sub-menus.
- if gui_menu_cheats.on_gui_checked_state_changed(element, element_name, player) then
- return true
- end
- if gui_menu_magicwand.on_gui_checked_state_changed(element, element_name, player) then
- return true
- end
- if gui_menu_modding.on_gui_checked_state_changed(element, element_name, player) then
- return true
- end
- if gui_menu_admin.on_gui_checked_state_changed(element, element_name, player) then
- return true
- end
- return false
+ -- Further extend the event to sub-menus.
+ if gui_menu_cheats.on_gui_checked_state_changed(element, element_name, player) then
+ return true
+ end
+ if gui_menu_magicwand.on_gui_checked_state_changed(element, element_name, player) then
+ return true
+ end
+ if gui_menu_modding.on_gui_checked_state_changed(element, element_name, player) then
+ return true
+ end
+ if gui_menu_admin.on_gui_checked_state_changed(element, element_name, player) then
+ return true
+ end
+ return false
end
-- Callback of the on_gui_selection_state_changed event, extended from gui.lua.
-- Returns whether the event is consumed.
function gui_menu.on_gui_selection_state_changed(element, element_name, player)
- -- Further extend the event to sub-menus.
- if gui_menu_magicwand.on_gui_selection_state_changed(element, element_name, player) then
- return true
- end
- return false
+ -- Further extend the event to sub-menus.
+ if gui_menu_magicwand.on_gui_selection_state_changed(element, element_name, player) then
+ return true
+ end
+ return false
end
diff --git a/scripts/gui.lua b/scripts/gui.lua
index ab7dc39..01e7d34 100644
--- a/scripts/gui.lua
+++ b/scripts/gui.lua
@@ -1,349 +1,368 @@
-- This file contains variables and functions related to generic GUI (e.g. popups) and GUI events.
if not gui then
- gui = {}
+ gui = {}
end
-- Possible main popup content types. Used in show_main_popup function.
gui.main_popup_content_type = {
- enable_creative_mode = 1,
- disable_creative_mode = -1,
- permanent_disable_creative_mode = -2
+ enable_creative_mode = 1,
+ disable_creative_mode = -1,
+ permanent_disable_creative_mode = -2,
}
function gui.on_gui_closed(event)
- local gui_type = event.gui_type
- local element = event.element
- local player = game.players[event.player_index]
- if (gui_type == defines.gui_type.custom) and element then
- local element_name = string.match(element.name, creative_mode_defines.match_patterns.gui.all)
- if element_name then
- element.visible = false
- player.play_sound {
- path = "utility/gui_click"
- }
- end
+ local gui_type = event.gui_type
+ local element = event.element
+ local player = game.players[event.player_index]
+ if (gui_type == defines.gui_type.custom) and element then
+ local element_name = string.match(element.name, creative_mode_defines.match_patterns.gui.all)
+ if element_name then
+ element.visible = false
+ player.play_sound({
+ path = "utility/gui_click",
+ })
end
+ end
end
-- Destroys the more cheats popup for all players.
-- It is a legacy GUI that we don't support anymore.
-- This function is still here for destroying such GUI in case some players are still opening it in old saves.
function gui.destroy_more_cheats_popup()
- for _, player in pairs(game.players) do
- local center = player.gui.center
- local popup = center[creative_mode_defines.names.gui.popup]
- if popup then
- local cheats_table = popup[creative_mode_defines.names.gui.cheats_table]
- if cheats_table then
- popup.destroy()
- end
- end
+ for _, player in pairs(game.players) do
+ local center = player.gui.center
+ local popup = center[creative_mode_defines.names.gui.popup]
+ if popup then
+ local cheats_table = popup[creative_mode_defines.names.gui.cheats_table]
+ if cheats_table then
+ popup.destroy()
+ end
end
+ end
end
-- Shows a generic yes/no popup with elements of given names for the given player.
-local function show_yes_no_popup(player, frame_name, frame_caption, btn_container_name, yes_btn_name, no_btn_name,
- label_1_data, label_2_data)
- local center = player.gui.center
- local popup = center.add {
- type = "frame",
- name = frame_name,
- direction = "vertical",
- caption = frame_caption
- }
-
- if label_1_data then
- local label = popup.add {
- type = "label",
- name = creative_mode_defines.names.gui.popup_label,
- caption = label_1_data.caption
- }
- label.style.font_color = label_1_data.font_color
- end
-
- if label_2_data then
- local label = popup.add {
- type = "label",
- name = creative_mode_defines.names.gui.popup_label2,
- caption = label_2_data.caption
- }
- label.style.font_color = label_2_data.font_color
- end
-
- local buttons_container = popup.add {
- type = "flow",
- name = btn_container_name,
- direction = "horizontal"
- }
-
- if yes_btn_name then
- buttons_container.add {
- type = "button",
- name = yes_btn_name,
- style = "dialog_button",
- caption = creative_mode_defines.names.gui_captions.yes
- }
- end
- if no_btn_name then
- buttons_container.add {
- type = "button",
- name = no_btn_name,
- style = "dialog_button",
- caption = creative_mode_defines.names.gui_captions.no
- }
- end
+local function show_yes_no_popup(
+ player,
+ frame_name,
+ frame_caption,
+ btn_container_name,
+ yes_btn_name,
+ no_btn_name,
+ label_1_data,
+ label_2_data
+)
+ local center = player.gui.center
+ local popup = center.add({
+ type = "frame",
+ name = frame_name,
+ direction = "vertical",
+ caption = frame_caption,
+ })
+
+ if label_1_data then
+ local label = popup.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.popup_label,
+ caption = label_1_data.caption,
+ })
+ label.style.font_color = label_1_data.font_color
+ end
+
+ if label_2_data then
+ local label = popup.add({
+ type = "label",
+ name = creative_mode_defines.names.gui.popup_label2,
+ caption = label_2_data.caption,
+ })
+ label.style.font_color = label_2_data.font_color
+ end
+
+ local buttons_container = popup.add({
+ type = "flow",
+ name = btn_container_name,
+ direction = "horizontal",
+ })
+
+ if yes_btn_name then
+ buttons_container.add({
+ type = "button",
+ name = yes_btn_name,
+ style = "dialog_button",
+ caption = creative_mode_defines.names.gui_captions.yes,
+ })
+ end
+ if no_btn_name then
+ buttons_container.add({
+ type = "button",
+ name = no_btn_name,
+ style = "dialog_button",
+ caption = creative_mode_defines.names.gui_captions.no,
+ })
+ end
end
-- Shows the main popup for the given player.
function gui.show_main_popup(player, main_popup_content_type)
- if main_popup_content_type == gui.main_popup_content_type.enable_creative_mode then
- -- Enable Creative Mode?
- storage.creative_mode.has_asked_for_enable = true
-
- local center = player.gui.center
- local popup = center.add {
- type = "frame",
- name = creative_mode_defines.names.gui.popup,
- direction = "vertical",
- caption = {"gui.creative-mode_ask-enable-creative-mode"}
- }
- local buttons_container = popup.add {
- type = "table",
- name = creative_mode_defines.names.gui.popup_buttons_container,
- column_count = 2
- }
-
- local button_style = creative_mode_defines.names.gui_styles.long_dialog_button
- -- Yes.
- buttons_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.enable_creative_mode_yes,
- style = button_style,
- caption = creative_mode_defines.names.gui_captions.yes
- }
- -- Yes with cheats.
- buttons_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.enable_creative_mode_yes_with_cheats,
- style = button_style,
- caption = {"gui.creative-mode_enable-creative-mode-with-cheats-button"},
- tooltip = {"gui.creative-mode_enable-creative-mode-with-cheats-button-tooltip"}
- }
- -- No.
- buttons_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.enable_creative_mode_no,
- style = button_style,
- caption = {"gui.creative-mode_dont-enable-creative-mode-button"},
- tooltip = {"gui.creative-mode_dont-enable-creative-mode-button-tooltip"}
- }
- -- No permanently.
- buttons_container.add {
- type = "button",
- name = creative_mode_defines.names.gui.enable_creative_mode_no_permanently,
- style = button_style,
- caption = {"gui.creative-mode_dont-enable-creative-mode-permanently-button"},
- tooltip = {"gui.creative-mode_dont-enable-creative-mode-permanently-button-tooltip"}
- }
- elseif main_popup_content_type == gui.main_popup_content_type.disable_creative_mode then
- -- Disable Creative Mode?
- show_yes_no_popup(player, creative_mode_defines.names.gui.popup,
- {"gui.creative-mode_ask-disable-creative-mode"}, creative_mode_defines.names.gui.popup_buttons_container,
- creative_mode_defines.names.gui.disable_creative_mode_yes,
- creative_mode_defines.names.gui.disable_creative_mode_no, {
- caption = {"gui.creative-mode_disable-creative-mode-info"},
- font_color = {
- r = 1,
- g = 1,
- b = 1
- }
- }, {
- caption = remote_interface.command_enable,
- font_color = {
- r = 1,
- g = 1,
- b = 1
- }
- })
- elseif main_popup_content_type == gui.main_popup_content_type.permanent_disable_creative_mode then
- -- Permanently disable Creative Mode?
- show_yes_no_popup(player, creative_mode_defines.names.gui.popup,
- {"gui.creative-mode_ask-permanently-disable-creative-mode"},
- creative_mode_defines.names.gui.popup_buttons_container,
- creative_mode_defines.names.gui.permanent_disable_creative_mode_yes,
- creative_mode_defines.names.gui.permanent_disable_creative_mode_no, {
- caption = {"gui.creative-mode_permanently-disable-creative-mode-info"},
- font_color = {
- r = 0.98,
- g = 0.66,
- b = 0.22
- }
- }, nil)
- end
+ if main_popup_content_type == gui.main_popup_content_type.enable_creative_mode then
+ -- Enable Creative Mode?
+ storage.creative_mode.has_asked_for_enable = true
+
+ local center = player.gui.center
+ local popup = center.add({
+ type = "frame",
+ name = creative_mode_defines.names.gui.popup,
+ direction = "vertical",
+ caption = { "gui.creative-mode_ask-enable-creative-mode" },
+ })
+ local buttons_container = popup.add({
+ type = "table",
+ name = creative_mode_defines.names.gui.popup_buttons_container,
+ column_count = 2,
+ })
+
+ local button_style = creative_mode_defines.names.gui_styles.long_dialog_button
+ -- Yes.
+ buttons_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.enable_creative_mode_yes,
+ style = button_style,
+ caption = creative_mode_defines.names.gui_captions.yes,
+ })
+ -- Yes with cheats.
+ buttons_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.enable_creative_mode_yes_with_cheats,
+ style = button_style,
+ caption = { "gui.creative-mode_enable-creative-mode-with-cheats-button" },
+ tooltip = { "gui.creative-mode_enable-creative-mode-with-cheats-button-tooltip" },
+ })
+ -- No.
+ buttons_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.enable_creative_mode_no,
+ style = button_style,
+ caption = { "gui.creative-mode_dont-enable-creative-mode-button" },
+ tooltip = { "gui.creative-mode_dont-enable-creative-mode-button-tooltip" },
+ })
+ -- No permanently.
+ buttons_container.add({
+ type = "button",
+ name = creative_mode_defines.names.gui.enable_creative_mode_no_permanently,
+ style = button_style,
+ caption = { "gui.creative-mode_dont-enable-creative-mode-permanently-button" },
+ tooltip = { "gui.creative-mode_dont-enable-creative-mode-permanently-button-tooltip" },
+ })
+ elseif main_popup_content_type == gui.main_popup_content_type.disable_creative_mode then
+ -- Disable Creative Mode?
+ show_yes_no_popup(
+ player,
+ creative_mode_defines.names.gui.popup,
+ { "gui.creative-mode_ask-disable-creative-mode" },
+ creative_mode_defines.names.gui.popup_buttons_container,
+ creative_mode_defines.names.gui.disable_creative_mode_yes,
+ creative_mode_defines.names.gui.disable_creative_mode_no,
+ {
+ caption = { "gui.creative-mode_disable-creative-mode-info" },
+ font_color = {
+ r = 1,
+ g = 1,
+ b = 1,
+ },
+ },
+ {
+ caption = remote_interface.command_enable,
+ font_color = {
+ r = 1,
+ g = 1,
+ b = 1,
+ },
+ }
+ )
+ elseif main_popup_content_type == gui.main_popup_content_type.permanent_disable_creative_mode then
+ -- Permanently disable Creative Mode?
+ show_yes_no_popup(
+ player,
+ creative_mode_defines.names.gui.popup,
+ { "gui.creative-mode_ask-permanently-disable-creative-mode" },
+ creative_mode_defines.names.gui.popup_buttons_container,
+ creative_mode_defines.names.gui.permanent_disable_creative_mode_yes,
+ creative_mode_defines.names.gui.permanent_disable_creative_mode_no,
+ {
+ caption = { "gui.creative-mode_permanently-disable-creative-mode-info" },
+ font_color = {
+ r = 0.98,
+ g = 0.66,
+ b = 0.22,
+ },
+ },
+ nil
+ )
+ end
end
-- Destroys the main popup for the given player.
local function destroy_main_popup_for_player(player)
- local popup = player.gui.center[creative_mode_defines.names.gui.popup]
- if popup then
- popup.destroy()
- end
+ local popup = player.gui.center[creative_mode_defines.names.gui.popup]
+ if popup then
+ popup.destroy()
+ end
end
-- Destroys the main popup for all players.
local function destroy_main_popup_for_all_players()
- for _, player in pairs(game.players) do
- destroy_main_popup_for_player(player)
- end
+ for _, player in pairs(game.players) do
+ destroy_main_popup_for_player(player)
+ end
end
--------------------------------------------------------------------
-- Updates GUI when a player joined the game.
function gui.on_player_joined_game(event)
- gui_menu.on_player_joined_game(event)
+ gui_menu.on_player_joined_game(event)
end
-- Updates GUI when a player left the game.
function gui.on_player_left_game(event)
- gui_menu.on_player_left_game(event)
+ gui_menu.on_player_left_game(event)
end
-- Updates GUI when a player went to another surface.
function gui.on_player_changed_surface(event)
- gui_menu.on_player_changed_surface(event)
+ gui_menu.on_player_changed_surface(event)
end
function gui.on_player_cursor_stack_changed(event)
- gui_menu.on_player_cursor_stack_changed(event)
+ gui_menu.on_player_cursor_stack_changed(event)
end
-- Records the entity each player is openeing in every tick.
-- Creates or destroys entity GUI accordingly.
function gui.tick()
- for _, player in pairs(game.players) do
- if player.connected then
- local current_opened_entity = player.opened
- local last_opened_entity = storage.creative_mode.player_opened_entities[player.index]
- -- Different entities.
- if current_opened_entity ~= last_opened_entity then
- -- Destroy the opened GUI for the last entity.
- gui_entity.create_or_destroy_gui_of_entity(player, last_opened_entity, false)
- -- Create GUI for the currently opened entity if there is any.
- if current_opened_entity ~= nil then
- gui_entity.create_or_destroy_gui_of_entity(player, current_opened_entity, true)
- end
- end
- else
- storage.creative_mode.player_opened_entities[player.index] = nil
+ for _, player in pairs(game.players) do
+ if player.connected then
+ local current_opened_entity = player.opened
+ local last_opened_entity = storage.creative_mode.player_opened_entities[player.index]
+ -- Different entities.
+ if current_opened_entity ~= last_opened_entity then
+ -- Destroy the opened GUI for the last entity.
+ gui_entity.create_or_destroy_gui_of_entity(player, last_opened_entity, false)
+ -- Create GUI for the currently opened entity if there is any.
+ if current_opened_entity ~= nil then
+ gui_entity.create_or_destroy_gui_of_entity(player, current_opened_entity, true)
end
+ end
+ else
+ storage.creative_mode.player_opened_entities[player.index] = nil
end
+ end
end
-- Callback of the on_gui_click event, which is invoked when a GUI element is clicked by any player.
function gui.on_gui_click(event)
- local element = event.element
- local element_name = element.name
- local player = game.players[event.player_index]
- local button = event.button
- local alt = event.alt
- local control = event.control
- local shift = event.shift
-
- if element_name == creative_mode_defines.names.gui.enable_creative_mode_yes then
- -- Enable Creative Mode? Yes
- destroy_main_popup_for_all_players()
- cheats.enable_or_disable_creative_mode(player, true, false, false, false)
- return
- elseif element_name == creative_mode_defines.names.gui.enable_creative_mode_yes_with_cheats then
- -- Enable Creative Mode? Yes, with cheats
- destroy_main_popup_for_all_players()
- cheats.enable_or_disable_creative_mode(player, true, false, true, false)
- return
- elseif element_name == creative_mode_defines.names.gui.enable_creative_mode_no then
- -- Enable Creative Mode? No
- destroy_main_popup_for_player(player)
- return
- elseif element_name == creative_mode_defines.names.gui.enable_creative_mode_no_permanently then
- -- Enable Creative Mode? No permanently
- destroy_main_popup_for_all_players()
- cheats.enable_or_disable_creative_mode(player, false, true, false, true)
- return
- elseif element_name == creative_mode_defines.names.gui.disable_creative_mode_yes then
- -- Disable Creative Mode? Yes
- destroy_main_popup_for_all_players()
- cheats.enable_or_disable_creative_mode(player, false, false, false, false)
- return
- elseif element_name == creative_mode_defines.names.gui.disable_creative_mode_no then
- -- Disable Creative Mode? No
- destroy_main_popup_for_player(player)
- return
- elseif element_name == creative_mode_defines.names.gui.permanent_disable_creative_mode_yes then
- -- Permanently disable Creative Mode? Yes
- destroy_main_popup_for_all_players()
- cheats.enable_or_disable_creative_mode(player, false, true, false, true)
- return
- elseif element_name == creative_mode_defines.names.gui.permanent_disable_creative_mode_no then
- -- Permanently disable Creative Mode? No
- destroy_main_popup_for_player(player)
- return
- end
-
- --------------------------------------------------------------------
-
- -- Extend the event to menu GUI.
- if gui_menu.on_gui_click(element, element_name, player, button, alt, control, shift) then
- return
- end
-
- --------------------------------------------------------------------
-
- -- Extend the event to entity GUI.
- gui_entity.on_gui_click(element, element_name, player, button, alt, control, shift)
+ local element = event.element
+ local element_name = element.name
+ local player = game.players[event.player_index]
+ local button = event.button
+ local alt = event.alt
+ local control = event.control
+ local shift = event.shift
+
+ if element_name == creative_mode_defines.names.gui.enable_creative_mode_yes then
+ -- Enable Creative Mode? Yes
+ destroy_main_popup_for_all_players()
+ cheats.enable_or_disable_creative_mode(player, true, false, false, false)
+ return
+ elseif element_name == creative_mode_defines.names.gui.enable_creative_mode_yes_with_cheats then
+ -- Enable Creative Mode? Yes, with cheats
+ destroy_main_popup_for_all_players()
+ cheats.enable_or_disable_creative_mode(player, true, false, true, false)
+ return
+ elseif element_name == creative_mode_defines.names.gui.enable_creative_mode_no then
+ -- Enable Creative Mode? No
+ destroy_main_popup_for_player(player)
+ return
+ elseif element_name == creative_mode_defines.names.gui.enable_creative_mode_no_permanently then
+ -- Enable Creative Mode? No permanently
+ destroy_main_popup_for_all_players()
+ cheats.enable_or_disable_creative_mode(player, false, true, false, true)
+ return
+ elseif element_name == creative_mode_defines.names.gui.disable_creative_mode_yes then
+ -- Disable Creative Mode? Yes
+ destroy_main_popup_for_all_players()
+ cheats.enable_or_disable_creative_mode(player, false, false, false, false)
+ return
+ elseif element_name == creative_mode_defines.names.gui.disable_creative_mode_no then
+ -- Disable Creative Mode? No
+ destroy_main_popup_for_player(player)
+ return
+ elseif element_name == creative_mode_defines.names.gui.permanent_disable_creative_mode_yes then
+ -- Permanently disable Creative Mode? Yes
+ destroy_main_popup_for_all_players()
+ cheats.enable_or_disable_creative_mode(player, false, true, false, true)
+ return
+ elseif element_name == creative_mode_defines.names.gui.permanent_disable_creative_mode_no then
+ -- Permanently disable Creative Mode? No
+ destroy_main_popup_for_player(player)
+ return
+ end
+
+ --------------------------------------------------------------------
+
+ -- Extend the event to menu GUI.
+ if gui_menu.on_gui_click(element, element_name, player, button, alt, control, shift) then
+ return
+ end
+
+ --------------------------------------------------------------------
+
+ -- Extend the event to entity GUI.
+ gui_entity.on_gui_click(element, element_name, player, button, alt, control, shift)
end
-- Callback of the on_gui_text_changed event, which is invoked when the text of GUI element is changed by any player.
function gui.on_gui_text_changed(event)
- local element = event.element
- local element_name = element.name
- local player = game.players[event.player_index]
+ local element = event.element
+ local element_name = element.name
+ local player = game.players[event.player_index]
- -- Extend the event to menu GUI.
- if gui_menu.on_gui_text_changed(element, element_name, player) then
- return
- end
+ -- Extend the event to menu GUI.
+ if gui_menu.on_gui_text_changed(element, element_name, player) then
+ return
+ end
- --------------------------------------------------------------------
+ --------------------------------------------------------------------
- -- Extend the event to entity GUI.
- gui_entity.on_gui_text_changed(element, element_name, player)
+ -- Extend the event to entity GUI.
+ gui_entity.on_gui_text_changed(element, element_name, player)
end
-- Callback of the on_gui_checked_state_changed event, which is invoked when the checked state of GUI element is changed by any player.
function gui.on_gui_checked_state_changed(event)
- local element = event.element
- local element_name = element.name
- local player = game.players[event.player_index]
+ local element = event.element
+ local element_name = element.name
+ local player = game.players[event.player_index]
- -- Extend the event to menu GUI.
- if gui_menu.on_gui_checked_state_changed(element, element_name, player) then
- return
- end
+ -- Extend the event to menu GUI.
+ if gui_menu.on_gui_checked_state_changed(element, element_name, player) then
+ return
+ end
- --------------------------------------------------------------------
+ --------------------------------------------------------------------
- -- Extend the event to entity GUI.
- gui_entity.on_gui_checked_state_changed(element, element_name, player)
+ -- Extend the event to entity GUI.
+ gui_entity.on_gui_checked_state_changed(element, element_name, player)
end
-- Callback of the on_gui_selection_state_changed event, which is invoked when the selection state of GUI element is changed by any player.
function gui.on_gui_selection_state_changed(event)
- local element = event.element
- local element_name = element.name
- local player = game.players[event.player_index]
-
- -- Extend the event to menu GUI.
- if gui_menu.on_gui_selection_state_changed(element, element_name, player) then
- return
- end
+ local element = event.element
+ local element_name = element.name
+ local player = game.players[event.player_index]
+
+ -- Extend the event to menu GUI.
+ if gui_menu.on_gui_selection_state_changed(element, element_name, player) then
+ return
+ end
end
diff --git a/scripts/instant_cheats.lua b/scripts/instant_cheats.lua
index 34cbe08..da6b99e 100644
--- a/scripts/instant_cheats.lua
+++ b/scripts/instant_cheats.lua
@@ -1,72 +1,72 @@
-- Returns whether the given player is a valid candidate for instant request.
function is_player_valid_for_instant_request(player)
- return player
- and storage.creative_mode.personal_cheats.instant_request[player.index]
- and player.valid
- and player.connected
- and player.character
+ return player
+ and storage.creative_mode.personal_cheats.instant_request[player.index]
+ and player.valid
+ and player.connected
+ and player.character
end
-- Returns whether the given player is a valid candidate for instant trash.
function is_player_valid_for_instant_trash(player)
- return player
- and storage.creative_mode.personal_cheats.instant_trash[player.index]
- and player.valid
- and player.connected
- and player.character
+ return player
+ and storage.creative_mode.personal_cheats.instant_trash[player.index]
+ and player.valid
+ and player.connected
+ and player.character
end
local function refill_inventory(entity, filter)
- local requested_item = { name = filter.value.name, quality = filter.value.quality }
- local items_in_inventory = entity.get_item_count(requested_item)
- local item_count_diff = filter.min - items_in_inventory
- if item_count_diff > 0 then
- requested_item.count = item_count_diff
- if entity.can_insert(requested_item) then
- entity.insert(requested_item)
- end
+ local requested_item = { name = filter.value.name, quality = filter.value.quality }
+ local items_in_inventory = entity.get_item_count(requested_item)
+ local item_count_diff = filter.min - items_in_inventory
+ if item_count_diff > 0 then
+ requested_item.count = item_count_diff
+ if entity.can_insert(requested_item) then
+ entity.insert(requested_item)
end
+ end
end
local function handle_instant_request(entity, filter)
- if filter and next(filter) then
- if filter.value.type == "item" then
- refill_inventory(entity, filter)
- end
+ if filter and next(filter) then
+ if filter.value.type == "item" then
+ refill_inventory(entity, filter)
end
+ end
end
function handle_entity_logistic_slot_changed(data)
- if data.entity.type == "character" and is_player_valid_for_instant_request(data.entity.player) then
- if data.section and data.section.active then
- local filter = data.section.get_slot(data.slot_index)
- handle_instant_request(data.entity, filter)
- end
+ if data.entity.type == "character" and is_player_valid_for_instant_request(data.entity.player) then
+ if data.section and data.section.active then
+ local filter = data.section.get_slot(data.slot_index)
+ handle_instant_request(data.entity, filter)
end
+ end
end
function handle_player_main_inventory_changed(data)
- local player = game.get_player(data.player_index)
- if is_player_valid_for_instant_request(player) then
- local logistic = player.get_requester_point()
- if logistic and logistic.enabled then
- for _, section in ipairs(logistic.sections) do
- if section and section.active then
- for _, filter in ipairs(section.filters) do
- handle_instant_request(player, filter)
- end
- end
- end
+ local player = game.get_player(data.player_index)
+ if is_player_valid_for_instant_request(player) then
+ local logistic = player.get_requester_point()
+ if logistic and logistic.enabled then
+ for _, section in ipairs(logistic.sections) do
+ if section and section.active then
+ for _, filter in ipairs(section.filters) do
+ handle_instant_request(player, filter)
+ end
end
+ end
end
+ end
end
function handle_player_trash_inventory_changed(data)
- local player = game.get_player(data.player_index)
- if is_player_valid_for_instant_trash(player) then
- local inventory = player.get_inventory(defines.inventory.character_trash)
- if inventory then
- inventory.clear()
- end
+ local player = game.get_player(data.player_index)
+ if is_player_valid_for_instant_trash(player) then
+ local inventory = player.get_inventory(defines.inventory.character_trash)
+ if inventory then
+ inventory.clear()
end
+ end
end
diff --git a/scripts/item-providers-util.lua b/scripts/item-providers-util.lua
index 5fe925c..5ee6f7e 100644
--- a/scripts/item-providers-util.lua
+++ b/scripts/item-providers-util.lua
@@ -1,1303 +1,1298 @@
-- This file contains variables or functions that are common for our item provider entities and specific for this mod.
if not item_providers_util then
- item_providers_util = {}
+ item_providers_util = {}
end
-- Possible operation modes. Used by the ouput_or_remove_item functions.
output_or_remove_item_operation_mode = {
- output_mode = 1,
- remove_mode = 2,
- duplicate_mode = 3,
+ output_mode = 1,
+ remove_mode = 2,
+ duplicate_mode = 3,
}
-- Possible types of item containers.
static_item_container_type = {
- unknown = 1,
- crafting_machine = 2,
- lab = 3,
+ unknown = 1,
+ crafting_machine = 2,
+ lab = 3,
}
-- Possible transport belt type to work on. Used by the ouput_or_remove_item functions.
local output_or_remove_item_transport_belt_type = {
- transport_belt = 0,
- underground_belt_input = 1,
- underground_belt_output = 2,
- splitter = 3,
+ transport_belt = 0,
+ underground_belt_input = 1,
+ underground_belt_output = 2,
+ splitter = 3,
}
-- Non-movable entity types with at least one inventory that matter source, matter void and duplicator can work on.
local static_item_containers = {
- ["container"] = true,
- ["logistic-container"] = true,
- ["assembling-machine"] = true,
- ["lab"] = true,
- ["boiler"] = true,
- ["furnace"] = true,
- ["roboport"] = true,
- ["rocket-silo"] = true,
- ["turret"] = true,
- ["ammo-turret"] = true,
- ["electric-turret"] = true,
- ["fluid-turret"] = true,
- ["beacon"] = true,
- ["reactor"] = true,
+ ["container"] = true,
+ ["logistic-container"] = true,
+ ["assembling-machine"] = true,
+ ["lab"] = true,
+ ["boiler"] = true,
+ ["furnace"] = true,
+ ["roboport"] = true,
+ ["rocket-silo"] = true,
+ ["turret"] = true,
+ ["ammo-turret"] = true,
+ ["electric-turret"] = true,
+ ["fluid-turret"] = true,
+ ["beacon"] = true,
+ ["reactor"] = true,
}
-- Non-movable entity types with output slots that matter void should only work on their output slots when it has no filter.
local static_item_containers_with_output_slots = {
- ["assembling-machine"] = defines.inventory.assembling_machine_output,
- ["furnace"] = defines.inventory.furnace_result,
- ["reactor"] = defines.inventory.burnt_result,
+ ["assembling-machine"] = defines.inventory.assembling_machine_output,
+ ["furnace"] = defines.inventory.furnace_result,
+ ["reactor"] = defines.inventory.burnt_result,
}
-- Non-movable entity types with at least one fluidbox that matter void and duplicator can work on.
-- Known issue: assembling machine and mining drill have inventory. Our current logic does not support inventory + fluidbox at the same time.
local static_fluidboxes = {
- ["pipe"] = true,
- ["storage-tank"] = true,
- ["assembling-machine"] = true,
- ["boiler"] = true,
- ["furnace"] = true,
- ["generator"] = true,
- ["fluid-turret"] = true,
- ["pump"] = true,
- ["mining-drill"] = true,
+ ["pipe"] = true,
+ ["storage-tank"] = true,
+ ["assembling-machine"] = true,
+ ["boiler"] = true,
+ ["furnace"] = true,
+ ["generator"] = true,
+ ["fluid-turret"] = true,
+ ["pump"] = true,
+ ["mining-drill"] = true,
}
-- List of module inventories that matter source, duplicator and void shouldn't work on.
local module_inventories = {
- [defines.inventory.furnace_modules] = true,
- [defines.inventory.assembling_machine_modules] = true,
- [defines.inventory.lab_modules] = true,
- [defines.inventory.mining_drill_modules] = true,
- [defines.inventory.beacon_modules] = true,
+ [defines.inventory.furnace_modules] = true,
+ [defines.inventory.assembling_machine_modules] = true,
+ [defines.inventory.lab_modules] = true,
+ [defines.inventory.mining_drill_modules] = true,
+ [defines.inventory.beacon_modules] = true,
}
-- Duplicates the first itme in the given inventory.
local function duplicate_first_item_in_inventory(inventory, filter_item_name)
- if inventory.is_empty() then
- return
- end
+ if inventory.is_empty() then
+ return
+ end
- local item_name = nil
- -- If filter is set, there must be at least one of that item in the inventory.
- if filter_item_name then
- if inventory.get_item_count(filter_item_name) > 0 then
- item_name = filter_item_name
- end
- else
- k, item_name = next(inventory.get_contents())
- if k ~= nil then
- if item_name then
- item_name = item_name.name
- end
- end
- end
- if item_name then
- print(item_name)
- local stack = {
- name = item_name,
- count = 1,
- }
- inventory.insert(stack)
- end
+ local item_name = nil
+ -- If filter is set, there must be at least one of that item in the inventory.
+ if filter_item_name then
+ if inventory.get_item_count(filter_item_name) > 0 then
+ item_name = filter_item_name
+ end
+ else
+ local k
+ k, item_name = next(inventory.get_contents())
+ if k ~= nil then
+ if item_name then
+ item_name = item_name.name
+ end
+ end
+ end
+ if item_name then
+ print(item_name)
+ local stack = {
+ name = item_name,
+ count = 1,
+ }
+ inventory.insert(stack)
+ end
end
-- Duplicates the first item in each inventory of the given entity.
-- Returns the table of inventories that the given entity has if required, also returns the container type of the entity.
local function duplicate_first_item_in_each_inventory(
- entity,
- filter_item_name,
- entity_inventories,
- should_return_entity_inventories
+ entity,
+ filter_item_name,
+ entity_inventories,
+ should_return_entity_inventories
)
- -- If the entity has nothing inside, do nothing.
- if not entity.has_items_inside() then
- return entity_inventories
- end
+ -- If the entity has nothing inside, do nothing.
+ if not entity.has_items_inside() then
+ return entity_inventories
+ end
- -- If we have already known the inventories, just loop through it.
- if entity_inventories then
- for _, inv in ipairs(entity_inventories) do
- local inventory = entity.get_inventory(inv)
- if inventory then
- duplicate_first_item_in_inventory(inventory, filter_item_name)
- end
- end
- return entity_inventories
- end
+ -- If we have already known the inventories, just loop through it.
+ if entity_inventories then
+ for _, inv in ipairs(entity_inventories) do
+ local inventory = entity.get_inventory(inv)
+ if inventory then
+ duplicate_first_item_in_inventory(inventory, filter_item_name)
+ end
+ end
+ return entity_inventories
+ end
- -- We have not known the inventories yet. Find the inventories while removing items.
- if should_return_entity_inventories then
- entity_inventories = {}
- end
- for _, inv in pairs(defines.inventory) do
- local inventory = entity.get_inventory(inv)
- if inventory then
- if should_return_entity_inventories then
- table.insert(entity_inventories, inv)
- end
- duplicate_first_item_in_inventory(inventory, filter_item_name)
- end
- end
- return entity_inventories
+ -- We have not known the inventories yet. Find the inventories while removing items.
+ if should_return_entity_inventories then
+ entity_inventories = {}
+ end
+ for _, inv in pairs(defines.inventory) do
+ local inventory = entity.get_inventory(inv)
+ if inventory then
+ if should_return_entity_inventories then
+ table.insert(entity_inventories, inv)
+ end
+ duplicate_first_item_in_inventory(inventory, filter_item_name)
+ end
+ end
+ return entity_inventories
end
-- Removes one item from the given inventory.
local function remove_one_item_from_inventory(inventory, filter_item_name)
- if inventory.is_empty() then
- return
- end
+ if inventory.is_empty() then
+ return
+ end
- local item_name = nil
- -- If filter is set, there must be at least one of that item in the inventory.
- if filter_item_name then
- if inventory.get_item_count(filter_item_name) > 0 then
- item_name = filter_item_name
- end
- else
- local _, item = next(inventory.get_contents())
- item_name = item.name
- end
- if item_name then
- local stack = {
- name = item_name,
- count = 1,
- }
- inventory.remove(stack)
- end
+ local item_name = nil
+ -- If filter is set, there must be at least one of that item in the inventory.
+ if filter_item_name then
+ if inventory.get_item_count(filter_item_name) > 0 then
+ item_name = filter_item_name
+ end
+ else
+ local _, item = next(inventory.get_contents())
+ item_name = item.name
+ end
+ if item_name then
+ local stack = {
+ name = item_name,
+ count = 1,
+ }
+ inventory.remove(stack)
+ end
end
-- Removes one item from an inventory of the given entity.
-- Returns the table of inventories that the given entity has if required.
local function remove_one_item_in_entity(entity, filter_item_name, entity_inventories, should_return_entity_inventories)
- -- If the entity has nothing inside, do nothing.
- if not entity.has_items_inside() then
- return entity_inventories
- end
+ -- If the entity has nothing inside, do nothing.
+ if not entity.has_items_inside() then
+ return entity_inventories
+ end
- -- If we have already known the inventories, just loop through it.
- if entity_inventories then
- for _, inv in ipairs(entity_inventories) do
- local inventory = entity.get_inventory(inv)
- if inventory then
- remove_one_item_from_inventory(inventory, filter_item_name)
- end
- end
- return entity_inventories
- end
+ -- If we have already known the inventories, just loop through it.
+ if entity_inventories then
+ for _, inv in ipairs(entity_inventories) do
+ local inventory = entity.get_inventory(inv)
+ if inventory then
+ remove_one_item_from_inventory(inventory, filter_item_name)
+ end
+ end
+ return entity_inventories
+ end
- -- We have not known the inventories yet. Find the inventories while removing items.
- if should_return_entity_inventories then
- entity_inventories = {}
- end
- for _, inv in pairs(defines.inventory) do
- local inventory = entity.get_inventory(inv)
- if inventory then
- if should_return_entity_inventories then
- table.insert(entity_inventories, inv)
- end
- remove_one_item_from_inventory(inventory, filter_item_name)
- end
- end
- return entity_inventories
+ -- We have not known the inventories yet. Find the inventories while removing items.
+ if should_return_entity_inventories then
+ entity_inventories = {}
+ end
+ for _, inv in pairs(defines.inventory) do
+ local inventory = entity.get_inventory(inv)
+ if inventory then
+ if should_return_entity_inventories then
+ table.insert(entity_inventories, inv)
+ end
+ remove_one_item_from_inventory(inventory, filter_item_name)
+ end
+ end
+ return entity_inventories
end
-- Outputs item stacks according to the filters in the given inventory.
local function output_item_stack_according_to_inventory_slot_filters(inventory)
- for i = 1, #inventory, 1 do
- -- Check if the slot can set filter. If it cannot set filter, get_filter will cause error.
- if inventory.can_set_filter(i, "iron-plate") then
- local filter = inventory.get_filter(i)
- if filter then
- inventory[i].set_stack({
- name = filter,
- count = prototypes.item[filter].stack_size,
- })
- end
- end
- end
+ for i = 1, #inventory, 1 do
+ -- Check if the slot can set filter. If it cannot set filter, get_filter will cause error.
+ if inventory.can_set_filter(i, "iron-plate") then
+ local filter = inventory.get_filter(i)
+ if filter then
+ inventory[i].set_stack({
+ name = filter,
+ count = prototypes.item[filter].stack_size,
+ })
+ end
+ end
+ end
end
-- Outputs item stacks according to the filters on the slots of the given entity.
-- Returns the table of inventories that the given entity has if required.
local function output_item_stack_according_to_inventories_slot_filters(
- entity,
- entity_inventories,
- should_return_entity_inventories
+ entity,
+ entity_inventories,
+ should_return_entity_inventories
)
- -- If we have already known the inventories, just loop through it.
- if entity_inventories then
- for _, inv in ipairs(entity_inventories) do
- local inventory = entity.get_inventory(inv)
- if inventory then
- output_item_stack_according_to_inventory_slot_filters(inventory)
- end
- end
- return entity_inventories
- end
+ -- If we have already known the inventories, just loop through it.
+ if entity_inventories then
+ for _, inv in ipairs(entity_inventories) do
+ local inventory = entity.get_inventory(inv)
+ if inventory then
+ output_item_stack_according_to_inventory_slot_filters(inventory)
+ end
+ end
+ return entity_inventories
+ end
- -- We have not known the inventories yet. Find the inventories while outputing items.
- if should_return_entity_inventories then
- entity_inventories = {}
- end
- for _, inv in pairs(defines.inventory) do
- if not module_inventories[inv] then
- local inventory = entity.get_inventory(inv)
- if inventory then
- if should_return_entity_inventories then
- table.insert(entity_inventories, inv)
- end
- output_item_stack_according_to_inventory_slot_filters(inventory)
- end
- end
- end
- return entity_inventories
+ -- We have not known the inventories yet. Find the inventories while outputing items.
+ if should_return_entity_inventories then
+ entity_inventories = {}
+ end
+ for _, inv in pairs(defines.inventory) do
+ if not module_inventories[inv] then
+ local inventory = entity.get_inventory(inv)
+ if inventory then
+ if should_return_entity_inventories then
+ table.insert(entity_inventories, inv)
+ end
+ output_item_stack_according_to_inventory_slot_filters(inventory)
+ end
+ end
+ end
+ return entity_inventories
end
-- Inserts the given item stack on the given transport line of given transport belt entity according to the current position of the last inserted item.
local function insert_itemstack_on_transport_line_compressed(transport_line, item_stack, belt_speed, last_item_position)
- local insert_position
- repeat
- if last_item_position then
- insert_position = last_item_position + transport_belt_item_distance
- if insert_position > 1 then
- -- It is outside the belt, of course the item cannot be inserted.
- -- Wait until the last item is moved far enough.
- return last_item_position - belt_speed
- end
- else
- insert_position = 1 - transport_belt_item_distance * 0.5
- end
- -- Try to insert the item at the given position.
- if transport_line.insert_at(insert_position, item_stack) then
- -- Succeeded. Remember the item position, and maybe we can insert more items at the current tick?
- last_item_position = insert_position
- else
- -- Failed to insert the item in this tick. Just wait for the next tick.
- if last_item_position then
- if last_item_position < 1 - transport_belt_item_distance then
- -- But it doesn't make sense that we can't insert a new item even if the last item has been moved beyond item distance.
- -- The only answer is: the belt is full!
- return nil
- else
- -- The last item will be moved by belt speed.
- return last_item_position - belt_speed
- end
- else
- -- It can't even insert the item at 1. Maybe the line is stopped.
- return nil
- end
- end
- until false
+ local insert_position
+ repeat
+ if last_item_position then
+ insert_position = last_item_position + transport_belt_item_distance
+ if insert_position > 1 then
+ -- It is outside the belt, of course the item cannot be inserted.
+ -- Wait until the last item is moved far enough.
+ return last_item_position - belt_speed
+ end
+ else
+ insert_position = 1 - transport_belt_item_distance * 0.5
+ end
+ -- Try to insert the item at the given position.
+ if transport_line.insert_at(insert_position, item_stack) then
+ -- Succeeded. Remember the item position, and maybe we can insert more items at the current tick?
+ last_item_position = insert_position
+ else
+ -- Failed to insert the item in this tick. Just wait for the next tick.
+ if last_item_position then
+ if last_item_position < 1 - transport_belt_item_distance then
+ -- But it doesn't make sense that we can't insert a new item even if the last item has been moved beyond item distance.
+ -- The only answer is: the belt is full!
+ return nil
+ else
+ -- The last item will be moved by belt speed.
+ return last_item_position - belt_speed
+ end
+ else
+ -- It can't even insert the item at 1. Maybe the line is stopped.
+ return nil
+ end
+ end
+ until false
end
-- Removes the first item on the given transport line.
local function remove_first_item_on_transport_line(line, filter_item_name)
- -- Only do action if the line is full at the end (position = 0).
- if line.can_insert_at(0) and line.can_insert_at(0.1) then
- return
- end
- -- And only if there is item.
- if #line <= 0 then
- return
- end
- -- Check the first item.
- local item_name = line[1].name
- -- If filter is set, but the item mismatch, stop working.
- if filter_item_name and filter_item_name ~= item_name then
- return
- end
- -- Remove the item.
- local stack = {
- name = item_name,
- count = 1,
- }
- line.remove_item(stack)
+ -- Only do action if the line is full at the end (position = 0).
+ if line.can_insert_at(0) and line.can_insert_at(0.1) then
+ return
+ end
+ -- And only if there is item.
+ if #line <= 0 then
+ return
+ end
+ -- Check the first item.
+ local item_name = line[1].name
+ -- If filter is set, but the item mismatch, stop working.
+ if filter_item_name and filter_item_name ~= item_name then
+ return
+ end
+ -- Remove the item.
+ local stack = {
+ name = item_name,
+ count = 1,
+ }
+ line.remove_item(stack)
end
-- Outputs the given item stack or remove items on the given transport line.
-- Returns the position of the last item inserted to the line.
local function output_or_remove_item_on_transport_line(
- transport_line,
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- output_last_item_position_on_belt
+ transport_line,
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ output_last_item_position_on_belt
)
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- -- matter-source
- if should_use_insert_at_back then
- -- If only insert_at_back can be used, simply use it!
- transport_line.insert_at_back(output_stack)
- return nil
- else
- if belt_speed > transport_belt_item_distance * 0.5 then
- -- The belt is too fast that it needs our custom implementation to guarantee compressed belt.
- -- Try to insert the item as near as the last item.
- return insert_itemstack_on_transport_line_compressed(
- transport_line,
- output_stack,
- belt_speed,
- output_last_item_position_on_belt
- )
- else
- -- The belt is not fast. It is OK to simply use insert_at(position, items) because it supports minimal shifting on the position in case that position is occupied.
- transport_line.insert_at(1 - transport_belt_item_distance * 0.5, output_stack)
- return nil
- end
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- -- matter-void
- remove_first_item_on_transport_line(transport_line, filter_item_name)
- return nil
- else
- -- matter-duplicator
- local item_name = nil
- if filter_item_name then
- if transport_line.get_item_count(filter_item_name) > 0 then
- item_name = filter_item_name
- end
- else
- k, item_name = next(transport_line.get_contents())
- if k ~= nil then
- if item_name then
- item_name = item_name.name
- end
- end
- end
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ -- matter-source
+ if should_use_insert_at_back then
+ -- If only insert_at_back can be used, simply use it!
+ transport_line.insert_at_back(output_stack)
+ return nil
+ else
+ if belt_speed > transport_belt_item_distance * 0.5 then
+ -- The belt is too fast that it needs our custom implementation to guarantee compressed belt.
+ -- Try to insert the item as near as the last item.
+ return insert_itemstack_on_transport_line_compressed(
+ transport_line,
+ output_stack,
+ belt_speed,
+ output_last_item_position_on_belt
+ )
+ else
+ -- The belt is not fast. It is OK to simply use insert_at(position, items) because it supports minimal shifting on the position in case that position is occupied.
+ transport_line.insert_at(1 - transport_belt_item_distance * 0.5, output_stack)
+ return nil
+ end
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ -- matter-void
+ remove_first_item_on_transport_line(transport_line, filter_item_name)
+ return nil
+ else
+ -- matter-duplicator
+ local item_name = nil
+ if filter_item_name then
+ if transport_line.get_item_count(filter_item_name) > 0 then
+ item_name = filter_item_name
+ end
+ else
+ local k
+ k, item_name = next(transport_line.get_contents())
+ if k ~= nil then
+ if item_name then
+ item_name = item_name.name
+ end
+ end
+ end
- local stack
- if item_name then
- stack = {
- name = item_name,
- count = 1,
- }
- else
- return nil
- end
- if should_use_insert_at_back then
- -- If only insert_at_back can be used, simply use it!
- transport_line.insert_at_back(stack)
- return nil
- else
- return insert_itemstack_on_transport_line_compressed(
- transport_line,
- stack,
- belt_speed,
- output_last_item_position_on_belt
- )
- end
- end
+ local stack
+ if item_name then
+ stack = {
+ name = item_name,
+ count = 1,
+ }
+ else
+ return nil
+ end
+ if should_use_insert_at_back then
+ -- If only insert_at_back can be used, simply use it!
+ transport_line.insert_at_back(stack)
+ return nil
+ else
+ return insert_itemstack_on_transport_line_compressed(
+ transport_line,
+ stack,
+ belt_speed,
+ output_last_item_position_on_belt
+ )
+ end
+ end
end
-- Verifies the last working transport belt, container or fluidbox entity according to the given matter source data, matter void data or duplicator data.
-- If the entity fails to be verified, it will be set to nil.
-- Returns the belt and belt type if it is valid. If the belt is not valid, the container will be returned as the third output. Otherwise, the fluidbox will be returned as the forth output.
local function verify_and_get_last_working_transport_belt_or_container_or_fluidbox(entity_data)
- local is_entity_direction_same = entity_data.last_direction == entity_data.entity.direction
+ local is_entity_direction_same = entity_data.last_direction == entity_data.entity.direction
- -- Is any belt cached?
- if entity_data.last_working_transport_belt ~= nil then
- -- Is the belt valid?
- if entity_data.last_working_transport_belt.valid then
- -- Is the matter source, matter void or matter duplicator still facing the same direction when the belt is cached?
- if is_entity_direction_same then
- -- Congratulations.
- entity_data.last_working_static_container = nil
- entity_data.last_working_static_fluidbox = nil
- return entity_data.last_working_transport_belt, entity_data.last_working_transport_belt_type, nil, nil
- else
- -- Nope.
- entity_data.last_direction = entity_data.entity.direction
- entity_data.last_working_transport_belt = nil
- end
- else
- entity_data.last_working_transport_belt = nil
- end
- end
+ -- Is any belt cached?
+ if entity_data.last_working_transport_belt ~= nil then
+ -- Is the belt valid?
+ if entity_data.last_working_transport_belt.valid then
+ -- Is the matter source, matter void or matter duplicator still facing the same direction when the belt is cached?
+ if is_entity_direction_same then
+ -- Congratulations.
+ entity_data.last_working_static_container = nil
+ entity_data.last_working_static_fluidbox = nil
+ return entity_data.last_working_transport_belt, entity_data.last_working_transport_belt_type, nil, nil
+ else
+ -- Nope.
+ entity_data.last_direction = entity_data.entity.direction
+ entity_data.last_working_transport_belt = nil
+ end
+ else
+ entity_data.last_working_transport_belt = nil
+ end
+ end
- -- Is any container cached?
- if entity_data.last_working_static_container ~= nil then
- -- Is the container valid?
- if entity_data.last_working_static_container.valid then
- -- Is the matter source, matter void or matter duplicator still facing the same direction when the container is cached?
- if is_entity_direction_same then
- -- Congratulations.
- entity_data.last_working_static_fluidbox = nil
- return nil, nil, entity_data.last_working_static_container, nil
- else
- -- Nope.
- entity_data.last_direction = entity_data.entity.direction
- entity_data.last_working_static_container = nil
- end
- else
- entity_data.last_working_static_container = nil
- end
- end
+ -- Is any container cached?
+ if entity_data.last_working_static_container ~= nil then
+ -- Is the container valid?
+ if entity_data.last_working_static_container.valid then
+ -- Is the matter source, matter void or matter duplicator still facing the same direction when the container is cached?
+ if is_entity_direction_same then
+ -- Congratulations.
+ entity_data.last_working_static_fluidbox = nil
+ return nil, nil, entity_data.last_working_static_container, nil
+ else
+ -- Nope.
+ entity_data.last_direction = entity_data.entity.direction
+ entity_data.last_working_static_container = nil
+ end
+ else
+ entity_data.last_working_static_container = nil
+ end
+ end
- -- Is any fluidbox cached?
- if entity_data.last_working_static_fluidbox ~= nil then
- -- Is the fluidbox valid?
- if entity_data.last_working_static_fluidbox.valid then
- -- Is the matter source, matter void or matter duplicator still facing the same direction when the container is cached?
- if is_entity_direction_same then
- -- Congratulations.
- entity_data.last_working_static_fluidbox = nil
- return nil, nil, nil, entity_data.last_working_static_fluidbox
- else
- -- Nope.
- entity_data.last_direction = entity_data.entity.direction
- entity_data.last_working_static_fluidbox = nil
- end
- else
- entity_data.last_working_static_fluidbox = nil
- end
- end
- return nil, nil, nil, nil
+ -- Is any fluidbox cached?
+ if entity_data.last_working_static_fluidbox ~= nil then
+ -- Is the fluidbox valid?
+ if entity_data.last_working_static_fluidbox.valid then
+ -- Is the matter source, matter void or matter duplicator still facing the same direction when the container is cached?
+ if is_entity_direction_same then
+ -- Congratulations.
+ entity_data.last_working_static_fluidbox = nil
+ return nil, nil, nil, entity_data.last_working_static_fluidbox
+ else
+ -- Nope.
+ entity_data.last_direction = entity_data.entity.direction
+ entity_data.last_working_static_fluidbox = nil
+ end
+ else
+ entity_data.last_working_static_fluidbox = nil
+ end
+ end
+ return nil, nil, nil, nil
end
-- Outputs the item of given name at the given position or remove the items there.
-- For matter-source, matter-void and matter-duplicator, because they are inserters, their opposite directions should be given instead.
function item_providers_util.output_or_remove_item(
- surface,
- position,
- shift_x,
- shift_y,
- direction,
- filter_item_name,
- operation_mode,
- output_item_slot,
- entity_data
+ surface,
+ position,
+ shift_x,
+ shift_y,
+ direction,
+ filter_item_name,
+ operation_mode,
+ output_item_slot,
+ entity_data
)
- -- Create a simple item stack according to the given item name of we are going to output it.
- local output_stack = nil
+ -- Create a simple item stack according to the given item name of we are going to output it.
+ local output_stack = nil
- if operation_mode == output_or_remove_item_operation_mode.output_mode and filter_item_name then
- output_stack = {
- name = filter_item_name,
- count = 1,
- }
- end
- -- Add the offset to the position to get the actual one.
- local actual_position = {
- x = position.x + shift_x,
- y = position.y + shift_y,
- }
- -- Store the entities to insert items to or remove items from them with different priorities.
- local other_inventory_entity = nil
- local other_fluidbox_entity = nil
- local train_entity = nil
- local fluid_wagon_entity = nil
- -- There may be multiple cars and players in front of it, so we will use table to store them.
- local car_entities = nil
- local player_entities = nil
- -- Whether the item should be dropped on ground as the last resort.
- local drop_on_ground = operation_mode == output_or_remove_item_operation_mode.output_mode
- and output_stack
- and entity_data.can_drop_on_ground
- -- Whether the items on ground should be removed.
- local remove_from_ground = operation_mode == output_or_remove_item_operation_mode.remove_mode
- and entity_data.can_remove_from_ground
+ if operation_mode == output_or_remove_item_operation_mode.output_mode and filter_item_name then
+ output_stack = {
+ name = filter_item_name,
+ count = 1,
+ }
+ end
+ -- Add the offset to the position to get the actual one.
+ local actual_position = {
+ x = position.x + shift_x,
+ y = position.y + shift_y,
+ }
+ -- Store the entities to insert items to or remove items from them with different priorities.
+ local other_inventory_entity = nil
+ local other_fluidbox_entity = nil
+ local train_entity = nil
+ local fluid_wagon_entity = nil
+ -- There may be multiple cars and players in front of it, so we will use table to store them.
+ local car_entities = nil
+ local player_entities = nil
+ -- Whether the item should be dropped on ground as the last resort.
+ local drop_on_ground = operation_mode == output_or_remove_item_operation_mode.output_mode
+ and output_stack
+ and entity_data.can_drop_on_ground
+ -- Whether the items on ground should be removed.
+ local remove_from_ground = operation_mode == output_or_remove_item_operation_mode.remove_mode
+ and entity_data.can_remove_from_ground
- -- Reset item_source's table of players being inserted with item.
- local last_player_entities
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- last_player_entities = entity_data.slot1_inserted_players
- entity_data.slot1_inserted_players = nil
- elseif output_item_slot == 2 then
- last_player_entities = entity_data.slot2_inserted_players
- entity_data.slot2_inserted_players = nil
- end
- end
+ -- Reset item_source's table of players being inserted with item.
+ local last_player_entities
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ last_player_entities = entity_data.slot1_inserted_players
+ entity_data.slot1_inserted_players = nil
+ elseif output_item_slot == 2 then
+ last_player_entities = entity_data.slot2_inserted_players
+ entity_data.slot2_inserted_players = nil
+ end
+ end
- -- Do we have a valid cache of transport belt that is still working in this tick?
- local transport_belt_entity, transport_belt_type, static_container_entity, static_fluidbox_entity =
- verify_and_get_last_working_transport_belt_or_container_or_fluidbox(entity_data)
- if static_container_entity ~= nil then
- other_inventory_entity = static_container_entity
- elseif static_fluidbox_entity ~= nil then
- other_fluidbox_entity = static_fluidbox_entity
- end
+ -- Do we have a valid cache of transport belt that is still working in this tick?
+ local transport_belt_entity, transport_belt_type, static_container_entity, static_fluidbox_entity =
+ verify_and_get_last_working_transport_belt_or_container_or_fluidbox(entity_data)
+ if static_container_entity ~= nil then
+ other_inventory_entity = static_container_entity
+ elseif static_fluidbox_entity ~= nil then
+ other_fluidbox_entity = static_fluidbox_entity
+ end
- -- We will need to search for working entity if nothing is cached.
- if transport_belt_entity == nil and other_inventory_entity == nil and other_fluidbox_entity == nil then
- -- Check if there is any entity in the grid at the given position.
- for _, entity in
- ipairs(surface.find_entities_filtered({
- position = actual_position,
- force = entity_data.entity.force,
- }))
- do
- if entity.type == "transport-belt" then
- -- Transport belt.
- transport_belt_entity = entity
- transport_belt_type = output_or_remove_item_transport_belt_type.transport_belt
- -- No need to check for another entity.
- break
- elseif entity.type == "underground-belt" then
- -- Underground belt.
- transport_belt_entity = entity
- if entity.belt_to_ground_type == "output" then
- transport_belt_type = output_or_remove_item_transport_belt_type.underground_belt_output
- else
- transport_belt_type = output_or_remove_item_transport_belt_type.underground_belt_input
- end
- -- No need to check for another entity.
- break
- elseif entity.type == "splitter" then
- -- Splitter.
- transport_belt_entity = entity
- transport_belt_type = output_or_remove_item_transport_belt_type.splitter
- -- No need to check for another entity.
- break
- elseif entity.type == "locomotive" or entity.type == "cargo-wagon" then
- -- The entity is a train.
- train_entity = entity
- elseif entity.type == "fluid-wagon" then
- -- The entity is a fluid wagon.
- fluid_wagon_entity = entity
- elseif entity.type == "car" then
- -- The entity is a car.
- if not car_entities then
- car_entities = {}
- end
- table.insert(car_entities, entity)
- elseif entity.type == "character" then
- -- The entity is a player.
- if not player_entities then
- player_entities = {}
- end
- table.insert(player_entities, entity)
- else
- -- For other entity types, we have to check whether they are collidable and have inventory so that unwanted entities like particles are ignored.
- local collision_mask = entity.prototype.collision_mask
- -- Note: known issue - collision_mask is nil for rocket-silo-rocket, even though it contains "not-colliding-with-itself". Hopefully it will be fixed.
- if not collision_mask or not util.array_contains_val(collision_mask, "not-colliding-with-itself") then
- if util.has_inventory(entity) then
- -- Ignore construction robots and logistic robots. They are innocent.
- if
- entity.type ~= "construction-robot"
- and entity.type ~= "logistic-robot"
- and entity.type ~= "rocket-silo-rocket"
- then
- other_inventory_entity = entity
- end
- else
- if
- operation_mode == output_or_remove_item_operation_mode.remove_mode
- or operation_mode == output_or_remove_item_operation_mode.duplicate_mode
- then
- -- Matter Void can also remove fluids, Matter Duplicator can also duplicate fluids.
- if util.has_fluidbox(entity) then
- other_fluidbox_entity = entity
- end
- end
- end
- end
- end
- end
- end
+ -- We will need to search for working entity if nothing is cached.
+ if transport_belt_entity == nil and other_inventory_entity == nil and other_fluidbox_entity == nil then
+ -- Check if there is any entity in the grid at the given position.
+ for _, entity in
+ ipairs(surface.find_entities_filtered({
+ position = actual_position,
+ force = entity_data.entity.force,
+ }))
+ do
+ if entity.type == "transport-belt" then
+ -- Transport belt.
+ transport_belt_entity = entity
+ transport_belt_type = output_or_remove_item_transport_belt_type.transport_belt
+ -- No need to check for another entity.
+ break
+ elseif entity.type == "underground-belt" then
+ -- Underground belt.
+ transport_belt_entity = entity
+ if entity.belt_to_ground_type == "output" then
+ transport_belt_type = output_or_remove_item_transport_belt_type.underground_belt_output
+ else
+ transport_belt_type = output_or_remove_item_transport_belt_type.underground_belt_input
+ end
+ -- No need to check for another entity.
+ break
+ elseif entity.type == "splitter" then
+ -- Splitter.
+ transport_belt_entity = entity
+ transport_belt_type = output_or_remove_item_transport_belt_type.splitter
+ -- No need to check for another entity.
+ break
+ elseif entity.type == "locomotive" or entity.type == "cargo-wagon" then
+ -- The entity is a train.
+ train_entity = entity
+ elseif entity.type == "fluid-wagon" then
+ -- The entity is a fluid wagon.
+ fluid_wagon_entity = entity
+ elseif entity.type == "car" then
+ -- The entity is a car.
+ if not car_entities then
+ car_entities = {}
+ end
+ table.insert(car_entities, entity)
+ elseif entity.type == "character" then
+ -- The entity is a player.
+ if not player_entities then
+ player_entities = {}
+ end
+ table.insert(player_entities, entity)
+ else
+ -- For other entity types, we have to check whether they are collidable and have inventory so that unwanted entities like particles are ignored.
+ local collision_mask = entity.prototype.collision_mask
+ -- Note: known issue - collision_mask is nil for rocket-silo-rocket, even though it contains "not-colliding-with-itself". Hopefully it will be fixed.
+ if not collision_mask or not util.array_contains_val(collision_mask, "not-colliding-with-itself") then
+ if util.has_inventory(entity) then
+ -- Ignore construction robots and logistic robots. They are innocent.
+ if
+ entity.type ~= "construction-robot"
+ and entity.type ~= "logistic-robot"
+ and entity.type ~= "rocket-silo-rocket"
+ then
+ other_inventory_entity = entity
+ end
+ else
+ if
+ operation_mode == output_or_remove_item_operation_mode.remove_mode
+ or operation_mode == output_or_remove_item_operation_mode.duplicate_mode
+ then
+ -- Matter Void can also remove fluids, Matter Duplicator can also duplicate fluids.
+ if util.has_fluidbox(entity) then
+ other_fluidbox_entity = entity
+ end
+ end
+ end
+ end
+ end
+ end
+ end
- -- Work on transport belt.
- if transport_belt_entity ~= nil then
- -- Don't work on transport belt if it is matter source and with no filter is set.
- if operation_mode ~= output_or_remove_item_operation_mode.output_mode or output_item_slot ~= 0 then
- -- Cache it first.
- entity_data.last_working_transport_belt = transport_belt_entity
- entity_data.last_working_transport_belt_type = transport_belt_type
- -- Since we have a transport belt now, no container or fluidbox can be worked on.
- entity_data.last_working_static_container = nil
- entity_data.last_working_static_fluidbox = nil
+ -- Work on transport belt.
+ if transport_belt_entity ~= nil then
+ -- Don't work on transport belt if it is matter source and with no filter is set.
+ if operation_mode ~= output_or_remove_item_operation_mode.output_mode or output_item_slot ~= 0 then
+ -- Cache it first.
+ entity_data.last_working_transport_belt = transport_belt_entity
+ entity_data.last_working_transport_belt_type = transport_belt_type
+ -- Since we have a transport belt now, no container or fluidbox can be worked on.
+ entity_data.last_working_static_container = nil
+ entity_data.last_working_static_fluidbox = nil
- -- Now we need to check which transport line we should work on.
- -- First, find out what type of belt it is.
- local is_belt = transport_belt_type == output_or_remove_item_transport_belt_type.transport_belt
- local is_underground_belt = transport_belt_type
- == output_or_remove_item_transport_belt_type.underground_belt_input
- or transport_belt_type == output_or_remove_item_transport_belt_type.underground_belt_output
- local is_output_underground_belt = transport_belt_type
- == output_or_remove_item_transport_belt_type.underground_belt_output
- local is_splitter = transport_belt_type == output_or_remove_item_transport_belt_type.splitter
- local affected_line_num_1 = nil
- local affected_line_num_2 = nil
- -- Splitters and underground belts only support insert-at-back.
- local should_use_insert_at_back = false
- if transport_belt_entity.direction == direction then
- -- The belt is of opposite direction, i.e. perfect for matter-source, matter-void and matter-duplicator.
- if is_splitter then
- -- For splitter, the line may be a little bit tricky.
- should_use_insert_at_back = true
- if transport_belt_entity.direction == defines.direction.north then
- -- To north.
- if transport_belt_entity.position.x < position.x then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- -- Matter source can only affect one line at a time.
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.secondary_left_line
- else
- affected_line_num_1 = defines.transport_line.secondary_right_line
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- affected_line_num_1 = defines.transport_line.secondary_left_split_line
- affected_line_num_2 = defines.transport_line.secondary_right_split_line
- else
- affected_line_num_1 = defines.transport_line.secondary_left_line
- affected_line_num_2 = defines.transport_line.secondary_right_line
- end
- else
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- affected_line_num_1 = defines.transport_line.left_split_line
- affected_line_num_2 = defines.transport_line.right_split_line
- else
- affected_line_num_1 = defines.transport_line.left_line
- affected_line_num_2 = defines.transport_line.right_line
- end
- end
- elseif transport_belt_entity.direction == defines.direction.east then
- -- To east.
- if transport_belt_entity.position.y < position.y then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.secondary_left_line
- else
- affected_line_num_1 = defines.transport_line.secondary_right_line
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- affected_line_num_1 = defines.transport_line.secondary_left_split_line
- affected_line_num_2 = defines.transport_line.secondary_right_split_line
- else
- affected_line_num_1 = defines.transport_line.secondary_left_line
- affected_line_num_2 = defines.transport_line.secondary_right_line
- end
- else
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- affected_line_num_1 = defines.transport_line.left_split_line
- affected_line_num_2 = defines.transport_line.right_split_line
- else
- affected_line_num_1 = defines.transport_line.left_line
- affected_line_num_2 = defines.transport_line.right_line
- end
- end
- elseif transport_belt_entity.direction == defines.direction.south then
- -- To south.
- if transport_belt_entity.position.x > position.x then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.secondary_left_line
- else
- affected_line_num_1 = defines.transport_line.secondary_right_line
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- affected_line_num_1 = defines.transport_line.secondary_left_split_line
- affected_line_num_2 = defines.transport_line.secondary_right_split_line
- else
- affected_line_num_1 = defines.transport_line.secondary_left_line
- affected_line_num_2 = defines.transport_line.secondary_right_line
- end
- else
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- affected_line_num_1 = defines.transport_line.left_split_line
- affected_line_num_2 = defines.transport_line.right_split_line
- else
- affected_line_num_1 = defines.transport_line.left_line
- affected_line_num_2 = defines.transport_line.right_line
- end
- end
- else
- -- To west.
- if transport_belt_entity.position.y > position.y then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.secondary_left_line
- else
- affected_line_num_1 = defines.transport_line.secondary_right_line
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- affected_line_num_1 = defines.transport_line.secondary_left_split_line
- affected_line_num_2 = defines.transport_line.secondary_right_split_line
- else
- affected_line_num_1 = defines.transport_line.secondary_left_line
- affected_line_num_2 = defines.transport_line.secondary_right_line
- end
- else
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- affected_line_num_1 = defines.transport_line.left_split_line
- affected_line_num_2 = defines.transport_line.right_split_line
- else
- affected_line_num_1 = defines.transport_line.left_line
- affected_line_num_2 = defines.transport_line.right_line
- end
- end
- end
- elseif is_underground_belt then
- -- Underground belt.
- should_use_insert_at_back = true
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- -- matter-source. The belt has to be input.
- if not is_output_underground_belt then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- -- matter-void. The belt has to be output.
- if is_output_underground_belt then
- affected_line_num_1 = defines.transport_line.left_line
- affected_line_num_2 = defines.transport_line.right_line
- end
- else
- -- matter-duplicator. The belt has to be input.
- if not is_output_underground_belt then
- affected_line_num_1 = defines.transport_line.left_line
- affected_line_num_2 = defines.transport_line.right_line
- end
- end
- else
- -- Belt.
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- else
- affected_line_num_1 = defines.transport_line.left_line
- affected_line_num_2 = defines.transport_line.right_line
- end
- end
- else
- -- Check for other direction.
- -- For matter-void, the direction is opposite.
- if operation_mode == output_or_remove_item_operation_mode.remove_mode then
- direction = util.oppositedirection(direction)
- end
+ -- Now we need to check which transport line we should work on.
+ -- First, find out what type of belt it is.
+ local is_belt = transport_belt_type == output_or_remove_item_transport_belt_type.transport_belt
+ local is_underground_belt = transport_belt_type
+ == output_or_remove_item_transport_belt_type.underground_belt_input
+ or transport_belt_type == output_or_remove_item_transport_belt_type.underground_belt_output
+ local is_output_underground_belt = transport_belt_type
+ == output_or_remove_item_transport_belt_type.underground_belt_output
+ local is_splitter = transport_belt_type == output_or_remove_item_transport_belt_type.splitter
+ local affected_line_num_1 = nil
+ local affected_line_num_2 = nil
+ -- Splitters and underground belts only support insert-at-back.
+ local should_use_insert_at_back = false
+ if transport_belt_entity.direction == direction then
+ -- The belt is of opposite direction, i.e. perfect for matter-source, matter-void and matter-duplicator.
+ if is_splitter then
+ -- For splitter, the line may be a little bit tricky.
+ should_use_insert_at_back = true
+ if transport_belt_entity.direction == defines.direction.north then
+ -- To north.
+ if transport_belt_entity.position.x < position.x then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ -- Matter source can only affect one line at a time.
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.secondary_left_line
+ else
+ affected_line_num_1 = defines.transport_line.secondary_right_line
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ affected_line_num_1 = defines.transport_line.secondary_left_split_line
+ affected_line_num_2 = defines.transport_line.secondary_right_split_line
+ else
+ affected_line_num_1 = defines.transport_line.secondary_left_line
+ affected_line_num_2 = defines.transport_line.secondary_right_line
+ end
+ else
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ affected_line_num_1 = defines.transport_line.left_split_line
+ affected_line_num_2 = defines.transport_line.right_split_line
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ affected_line_num_2 = defines.transport_line.right_line
+ end
+ end
+ elseif transport_belt_entity.direction == defines.direction.east then
+ -- To east.
+ if transport_belt_entity.position.y < position.y then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.secondary_left_line
+ else
+ affected_line_num_1 = defines.transport_line.secondary_right_line
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ affected_line_num_1 = defines.transport_line.secondary_left_split_line
+ affected_line_num_2 = defines.transport_line.secondary_right_split_line
+ else
+ affected_line_num_1 = defines.transport_line.secondary_left_line
+ affected_line_num_2 = defines.transport_line.secondary_right_line
+ end
+ else
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ affected_line_num_1 = defines.transport_line.left_split_line
+ affected_line_num_2 = defines.transport_line.right_split_line
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ affected_line_num_2 = defines.transport_line.right_line
+ end
+ end
+ elseif transport_belt_entity.direction == defines.direction.south then
+ -- To south.
+ if transport_belt_entity.position.x > position.x then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.secondary_left_line
+ else
+ affected_line_num_1 = defines.transport_line.secondary_right_line
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ affected_line_num_1 = defines.transport_line.secondary_left_split_line
+ affected_line_num_2 = defines.transport_line.secondary_right_split_line
+ else
+ affected_line_num_1 = defines.transport_line.secondary_left_line
+ affected_line_num_2 = defines.transport_line.secondary_right_line
+ end
+ else
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ affected_line_num_1 = defines.transport_line.left_split_line
+ affected_line_num_2 = defines.transport_line.right_split_line
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ affected_line_num_2 = defines.transport_line.right_line
+ end
+ end
+ else
+ -- To west.
+ if transport_belt_entity.position.y > position.y then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.secondary_left_line
+ else
+ affected_line_num_1 = defines.transport_line.secondary_right_line
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ affected_line_num_1 = defines.transport_line.secondary_left_split_line
+ affected_line_num_2 = defines.transport_line.secondary_right_split_line
+ else
+ affected_line_num_1 = defines.transport_line.secondary_left_line
+ affected_line_num_2 = defines.transport_line.secondary_right_line
+ end
+ else
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ affected_line_num_1 = defines.transport_line.left_split_line
+ affected_line_num_2 = defines.transport_line.right_split_line
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ affected_line_num_2 = defines.transport_line.right_line
+ end
+ end
+ end
+ elseif is_underground_belt then
+ -- Underground belt.
+ should_use_insert_at_back = true
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ -- matter-source. The belt has to be input.
+ if not is_output_underground_belt then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ -- matter-void. The belt has to be output.
+ if is_output_underground_belt then
+ affected_line_num_1 = defines.transport_line.left_line
+ affected_line_num_2 = defines.transport_line.right_line
+ end
+ else
+ -- matter-duplicator. The belt has to be input.
+ if not is_output_underground_belt then
+ affected_line_num_1 = defines.transport_line.left_line
+ affected_line_num_2 = defines.transport_line.right_line
+ end
+ end
+ else
+ -- Belt.
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ affected_line_num_2 = defines.transport_line.right_line
+ end
+ end
+ else
+ -- Check for other direction.
+ -- For matter-void, the direction is opposite.
+ if operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ direction = util.oppositedirection(direction)
+ end
- -- Since the direction is not perfect, only one line can be affected.
- if direction == defines.direction.north then
- if transport_belt_entity.direction == defines.direction.east then
- if is_splitter then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.secondary_right_split_line
- elseif is_underground_belt then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.right_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- elseif transport_belt_entity.direction == defines.direction.west then
- if is_splitter then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.left_split_line
- elseif is_underground_belt then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.left_line
- end
- end
- elseif direction == defines.direction.east then
- if transport_belt_entity.direction == defines.direction.north then
- if is_splitter then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.left_split_line
- elseif is_underground_belt then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.left_line
- end
- elseif transport_belt_entity.direction == defines.direction.south then
- if is_splitter then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.secondary_right_split_line
- elseif is_underground_belt then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.right_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- end
- elseif direction == defines.direction.south then
- if transport_belt_entity.direction == defines.direction.east then
- if is_splitter then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.left_split_line
- elseif is_underground_belt then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.left_line
- end
- elseif transport_belt_entity.direction == defines.direction.west then
- if is_splitter then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.secondary_right_split_line
- elseif is_underground_belt then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.right_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- end
- elseif direction == defines.direction.west then
- if transport_belt_entity.direction == defines.direction.north then
- if is_splitter then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.secondary_right_split_line
- elseif is_underground_belt then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.right_line
- else
- affected_line_num_1 = defines.transport_line.right_line
- end
- elseif transport_belt_entity.direction == defines.direction.south then
- if is_splitter then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.left_split_line
- elseif is_underground_belt then
- should_use_insert_at_back = true
- affected_line_num_1 = defines.transport_line.left_line
- else
- affected_line_num_1 = defines.transport_line.left_line
- end
- end
- end
- end
+ -- Since the direction is not perfect, only one line can be affected.
+ if direction == defines.direction.north then
+ if transport_belt_entity.direction == defines.direction.east then
+ if is_splitter then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.secondary_right_split_line
+ elseif is_underground_belt then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.right_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ elseif transport_belt_entity.direction == defines.direction.west then
+ if is_splitter then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.left_split_line
+ elseif is_underground_belt then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ end
+ end
+ elseif direction == defines.direction.east then
+ if transport_belt_entity.direction == defines.direction.north then
+ if is_splitter then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.left_split_line
+ elseif is_underground_belt then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ end
+ elseif transport_belt_entity.direction == defines.direction.south then
+ if is_splitter then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.secondary_right_split_line
+ elseif is_underground_belt then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.right_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ end
+ elseif direction == defines.direction.south then
+ if transport_belt_entity.direction == defines.direction.east then
+ if is_splitter then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.left_split_line
+ elseif is_underground_belt then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ end
+ elseif transport_belt_entity.direction == defines.direction.west then
+ if is_splitter then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.secondary_right_split_line
+ elseif is_underground_belt then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.right_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ end
+ elseif direction == defines.direction.west then
+ if transport_belt_entity.direction == defines.direction.north then
+ if is_splitter then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.secondary_right_split_line
+ elseif is_underground_belt then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.right_line
+ else
+ affected_line_num_1 = defines.transport_line.right_line
+ end
+ elseif transport_belt_entity.direction == defines.direction.south then
+ if is_splitter then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.left_split_line
+ elseif is_underground_belt then
+ should_use_insert_at_back = true
+ affected_line_num_1 = defines.transport_line.left_line
+ else
+ affected_line_num_1 = defines.transport_line.left_line
+ end
+ end
+ end
+ end
- local belt_speed = transport_belt_entity.prototype.belt_speed
- -- Call the functions to actually insert or remove items.
- if affected_line_num_1 then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- entity_data.slot1_last_item_position_on_belt = output_or_remove_item_on_transport_line(
- transport_belt_entity.get_transport_line(affected_line_num_1),
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- entity_data.slot1_last_item_position_on_belt
- )
- else
- entity_data.slot2_last_item_position_on_belt = output_or_remove_item_on_transport_line(
- transport_belt_entity.get_transport_line(affected_line_num_1),
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- entity_data.slot2_last_item_position_on_belt
- )
- end
- elseif operation_mode == output_or_remove_item_operation_mode.duplicate_mode then
- entity_data.line1_last_item_position_on_belt = output_or_remove_item_on_transport_line(
- transport_belt_entity.get_transport_line(affected_line_num_1),
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- entity_data.line1_last_item_position_on_belt
- )
- else
- output_or_remove_item_on_transport_line(
- transport_belt_entity.get_transport_line(affected_line_num_1),
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- nil
- )
- end
- end
- if affected_line_num_2 then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_item_slot == 1 then
- entity_data.slot1_last_item_position_on_belt = output_or_remove_item_on_transport_line(
- transport_belt_entity.get_transport_line(affected_line_num_2),
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- entity_data.slot1_last_item_position_on_belt
- )
- else
- entity_data.slot2_last_item_position_on_belt = output_or_remove_item_on_transport_line(
- transport_belt_entity.get_transport_line(affected_line_num_2),
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- entity_data.slot2_last_item_position_on_belt
- )
- end
- elseif operation_mode == output_or_remove_item_operation_mode.duplicate_mode then
- entity_data.line2_last_item_position_on_belt = output_or_remove_item_on_transport_line(
- transport_belt_entity.get_transport_line(affected_line_num_2),
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- entity_data.line2_last_item_position_on_belt
- )
- else
- output_or_remove_item_on_transport_line(
- transport_belt_entity.get_transport_line(affected_line_num_2),
- belt_speed,
- operation_mode,
- output_stack,
- filter_item_name,
- should_use_insert_at_back,
- nil
- )
- end
- end
- end
- return
- end
+ local belt_speed = transport_belt_entity.prototype.belt_speed
+ -- Call the functions to actually insert or remove items.
+ if affected_line_num_1 then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ entity_data.slot1_last_item_position_on_belt = output_or_remove_item_on_transport_line(
+ transport_belt_entity.get_transport_line(affected_line_num_1),
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ entity_data.slot1_last_item_position_on_belt
+ )
+ else
+ entity_data.slot2_last_item_position_on_belt = output_or_remove_item_on_transport_line(
+ transport_belt_entity.get_transport_line(affected_line_num_1),
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ entity_data.slot2_last_item_position_on_belt
+ )
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.duplicate_mode then
+ entity_data.line1_last_item_position_on_belt = output_or_remove_item_on_transport_line(
+ transport_belt_entity.get_transport_line(affected_line_num_1),
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ entity_data.line1_last_item_position_on_belt
+ )
+ else
+ output_or_remove_item_on_transport_line(
+ transport_belt_entity.get_transport_line(affected_line_num_1),
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ nil
+ )
+ end
+ end
+ if affected_line_num_2 then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_item_slot == 1 then
+ entity_data.slot1_last_item_position_on_belt = output_or_remove_item_on_transport_line(
+ transport_belt_entity.get_transport_line(affected_line_num_2),
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ entity_data.slot1_last_item_position_on_belt
+ )
+ else
+ entity_data.slot2_last_item_position_on_belt = output_or_remove_item_on_transport_line(
+ transport_belt_entity.get_transport_line(affected_line_num_2),
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ entity_data.slot2_last_item_position_on_belt
+ )
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.duplicate_mode then
+ entity_data.line2_last_item_position_on_belt = output_or_remove_item_on_transport_line(
+ transport_belt_entity.get_transport_line(affected_line_num_2),
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ entity_data.line2_last_item_position_on_belt
+ )
+ else
+ output_or_remove_item_on_transport_line(
+ transport_belt_entity.get_transport_line(affected_line_num_2),
+ belt_speed,
+ operation_mode,
+ output_stack,
+ filter_item_name,
+ should_use_insert_at_back,
+ nil
+ )
+ end
+ end
+ end
+ return
+ end
- if operation_mode == output_or_remove_item_operation_mode.duplicate_mode then
- entity_data.line1_last_item_position_on_belt = nil
- entity_data.line2_last_item_position_on_belt = nil
- end
+ if operation_mode == output_or_remove_item_operation_mode.duplicate_mode then
+ entity_data.line1_last_item_position_on_belt = nil
+ entity_data.line2_last_item_position_on_belt = nil
+ end
- -- Work on other entities with different priorities.
- if other_inventory_entity then
- -- Cache it first if valid.
- if entity_data.last_working_static_container ~= other_inventory_entity then
- if static_item_containers[other_inventory_entity.type] then
- entity_data.last_working_static_container = other_inventory_entity
- else
- -- Maybe the entity has fuel slots?
- if other_inventory_entity.get_inventory(defines.inventory.fuel) then
- entity_data.last_working_static_container = other_inventory_entity
- else
- -- Unknown type.
- entity_data.last_working_static_container = nil
- return
- end
- end
- -- Renew the cached inventories since it is a new entity.
- entity_data.last_working_static_container_inventories = nil
- entity_data.last_working_static_container_type = nil
- end
- -- Since we have a container, not fluidbox can be worked on.
- entity_data.last_working_static_fluidbox = nil
+ -- Work on other entities with different priorities.
+ if other_inventory_entity then
+ -- Cache it first if valid.
+ if entity_data.last_working_static_container ~= other_inventory_entity then
+ if static_item_containers[other_inventory_entity.type] then
+ entity_data.last_working_static_container = other_inventory_entity
+ else
+ -- Maybe the entity has fuel slots?
+ if other_inventory_entity.get_inventory(defines.inventory.fuel) then
+ entity_data.last_working_static_container = other_inventory_entity
+ else
+ -- Unknown type.
+ entity_data.last_working_static_container = nil
+ return
+ end
+ end
+ -- Renew the cached inventories since it is a new entity.
+ entity_data.last_working_static_container_inventories = nil
+ entity_data.last_working_static_container_type = nil
+ end
+ -- Since we have a container, not fluidbox can be worked on.
+ entity_data.last_working_static_fluidbox = nil
- -- Other entities that are not train, car nor player.
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_stack then
- other_inventory_entity.insert(output_stack)
- else
- -- No filter is set. Let's see if we are working on a crafting machine or lab.
- if entity_data.last_working_static_container_type == nil then
- if
- other_inventory_entity.type == "assembling-machine"
- or other_inventory_entity.type == "rocket-silo"
- then
- entity_data.last_working_static_container_type = static_item_container_type.crafting_machine
- elseif other_inventory_entity.type == "lab" then
- entity_data.last_working_static_container_type = static_item_container_type.lab
- else
- entity_data.last_working_static_container_type = static_item_container_type.unknown
- end
- end
+ -- Other entities that are not train, car nor player.
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_stack then
+ other_inventory_entity.insert(output_stack)
+ else
+ -- No filter is set. Let's see if we are working on a crafting machine or lab.
+ if entity_data.last_working_static_container_type == nil then
+ if other_inventory_entity.type == "assembling-machine" or other_inventory_entity.type == "rocket-silo" then
+ entity_data.last_working_static_container_type = static_item_container_type.crafting_machine
+ elseif other_inventory_entity.type == "lab" then
+ entity_data.last_working_static_container_type = static_item_container_type.lab
+ else
+ entity_data.last_working_static_container_type = static_item_container_type.unknown
+ end
+ end
- if entity_data.last_working_static_container_type == static_item_container_type.crafting_machine then
- -- Crafting machine.
- if other_inventory_entity.get_recipe() then
- local inventories = entity_data.last_working_static_container_inventories
- if inventories == nil then
- inventories = {
- other_inventory_entity.get_inventory(defines.inventory.assembling_machine_input),
- }
- entity_data.last_working_static_container_inventories = inventories
- end
- local input_inventory = inventories[1]
- local ingredients = other_inventory_entity.get_recipe().ingredients
- local next_fluid_index = 1
- for i = 1, #ingredients, 1 do
- local ingredient = ingredients[i]
- -- Make sure it is an item. We can't "insert" fluids.
- if ingredient.type == "item" then
- if input_inventory then
- input_inventory.insert({
- name = ingredients[i].name,
- count = 1,
- })
- end
- else
- if next_fluid_index <= #other_inventory_entity.fluidbox then
- local fluid = other_inventory_entity.fluidbox[next_fluid_index]
- if fluid then
- fluid.amount = fluid.amount + 1
- else
- fluid = {
- name = ingredient.name,
- amount = 1,
- }
- end
- other_inventory_entity.fluidbox[next_fluid_index] = fluid
- next_fluid_index = next_fluid_index + 1
- end
- end
- end
- end
- elseif entity_data.last_working_static_container_type == static_item_container_type.lab then
- -- Lab.
- local inventories = entity_data.last_working_static_container_inventories
- if inventories == nil then
- inventories = { other_inventory_entity.get_inventory(defines.inventory.lab_input) }
- entity_data.last_working_static_container_inventories = inventories
- end
- local input_inventory = inventories[1]
- if input_inventory then
- -- Insert all tools (science packs) into it.
- for _, item in ipairs(storage.tool_item_list) do
- input_inventory.insert({
- name = item.name,
- count = 1,
- })
- end
- end
- else
- -- Unknown container type.
- -- We can still output items if the inventory slot has filter. (Although slot filter is only supported in vehicle and player.)
- entity_data.last_working_static_container_inventories =
- output_item_stack_according_to_inventories_slot_filters(
- other_inventory_entity,
- entity_data.last_working_static_container_inventories,
- true
- )
- end
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- local output_inventory_name = static_item_containers_with_output_slots[other_inventory_entity.type]
- if not filter_item_name and output_inventory_name then
- -- No filter, and the target entity has output slots.
- -- Clear the output slots.
- local inventory = other_inventory_entity.get_inventory(output_inventory_name)
- if inventory then
- inventory.clear()
- end
- else
- entity_data.last_working_static_container_inventories = remove_one_item_in_entity(
- other_inventory_entity,
- filter_item_name,
- entity_data.last_working_static_container_inventories,
- true
- )
- end
- else
- entity_data.last_working_static_container_inventories = duplicate_first_item_in_each_inventory(
- other_inventory_entity,
- filter_item_name,
- entity_data.last_working_static_container_inventories,
- true
- )
- end
- return
- elseif other_fluidbox_entity then
- -- Cache it first if valid.
- if entity_data.last_working_static_fluidbox ~= other_fluidbox_entity then
- if static_fluidboxes[other_fluidbox_entity.type] then
- entity_data.last_working_static_fluidbox = other_fluidbox_entity
- else
- -- Unknown type.
- entity_data.last_working_static_fluidbox = nil
- return
- end
- end
+ if entity_data.last_working_static_container_type == static_item_container_type.crafting_machine then
+ -- Crafting machine.
+ if other_inventory_entity.get_recipe() then
+ local inventories = entity_data.last_working_static_container_inventories
+ if inventories == nil then
+ inventories = {
+ other_inventory_entity.get_inventory(defines.inventory.assembling_machine_input),
+ }
+ entity_data.last_working_static_container_inventories = inventories
+ end
+ local input_inventory = inventories[1]
+ local ingredients = other_inventory_entity.get_recipe().ingredients
+ local next_fluid_index = 1
+ for i = 1, #ingredients, 1 do
+ local ingredient = ingredients[i]
+ -- Make sure it is an item. We can't "insert" fluids.
+ if ingredient.type == "item" then
+ if input_inventory then
+ input_inventory.insert({
+ name = ingredients[i].name,
+ count = 1,
+ })
+ end
+ else
+ if next_fluid_index <= #other_inventory_entity.fluidbox then
+ local fluid = other_inventory_entity.fluidbox[next_fluid_index]
+ if fluid then
+ fluid.amount = fluid.amount + 1
+ else
+ fluid = {
+ name = ingredient.name,
+ amount = 1,
+ }
+ end
+ other_inventory_entity.fluidbox[next_fluid_index] = fluid
+ next_fluid_index = next_fluid_index + 1
+ end
+ end
+ end
+ end
+ elseif entity_data.last_working_static_container_type == static_item_container_type.lab then
+ -- Lab.
+ local inventories = entity_data.last_working_static_container_inventories
+ if inventories == nil then
+ inventories = { other_inventory_entity.get_inventory(defines.inventory.lab_input) }
+ entity_data.last_working_static_container_inventories = inventories
+ end
+ local input_inventory = inventories[1]
+ if input_inventory then
+ -- Insert all tools (science packs) into it.
+ for _, item in ipairs(storage.tool_item_list) do
+ input_inventory.insert({
+ name = item.name,
+ count = 1,
+ })
+ end
+ end
+ else
+ -- Unknown container type.
+ -- We can still output items if the inventory slot has filter. (Although slot filter is only supported in vehicle and player.)
+ entity_data.last_working_static_container_inventories =
+ output_item_stack_according_to_inventories_slot_filters(
+ other_inventory_entity,
+ entity_data.last_working_static_container_inventories,
+ true
+ )
+ end
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ local output_inventory_name = static_item_containers_with_output_slots[other_inventory_entity.type]
+ if not filter_item_name and output_inventory_name then
+ -- No filter, and the target entity has output slots.
+ -- Clear the output slots.
+ local inventory = other_inventory_entity.get_inventory(output_inventory_name)
+ if inventory then
+ inventory.clear()
+ end
+ else
+ entity_data.last_working_static_container_inventories = remove_one_item_in_entity(
+ other_inventory_entity,
+ filter_item_name,
+ entity_data.last_working_static_container_inventories,
+ true
+ )
+ end
+ else
+ entity_data.last_working_static_container_inventories = duplicate_first_item_in_each_inventory(
+ other_inventory_entity,
+ filter_item_name,
+ entity_data.last_working_static_container_inventories,
+ true
+ )
+ end
+ return
+ elseif other_fluidbox_entity then
+ -- Cache it first if valid.
+ if entity_data.last_working_static_fluidbox ~= other_fluidbox_entity then
+ if static_fluidboxes[other_fluidbox_entity.type] then
+ entity_data.last_working_static_fluidbox = other_fluidbox_entity
+ else
+ -- Unknown type.
+ entity_data.last_working_static_fluidbox = nil
+ return
+ end
+ end
- -- Doesn't work on fluid if filter is set.
- if filter_item_name == nil then
- if operation_mode == output_or_remove_item_operation_mode.remove_mode then
- fluid_providers_util.remove_all_fluids(other_fluidbox_entity)
- elseif operation_mode == output_or_remove_item_operation_mode.duplicate_mode then
- fluid_providers_util.duplicate_fluid_in_each_fluidbox(other_fluidbox_entity)
- end
- end
- return
- elseif train_entity then
- -- Train.
- if
- (operation_mode == output_or_remove_item_operation_mode.output_mode and entity_data.can_insert_to_vehicle)
- or (operation_mode == output_or_remove_item_operation_mode.remove_mode and entity_data.can_remove_from_vehicle)
- or (
- operation_mode == output_or_remove_item_operation_mode.duplicate_mode
- and entity_data.can_duplicate_in_vehicle
- )
- then
- -- Output or remove only if the train is stationary.
- if train_entity.train.speed == 0 then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_stack then
- train_entity.insert(output_stack)
- else
- output_item_stack_according_to_inventories_slot_filters(train_entity, nil, false)
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- remove_one_item_in_entity(train_entity, filter_item_name, nil, false)
- else
- duplicate_first_item_in_each_inventory(train_entity, filter_item_name, nil, false)
- end
- end
- end
- return
- elseif fluid_wagon_entity then
- -- Fluid wagon.
- if
- (operation_mode == output_or_remove_item_operation_mode.remove_mode and entity_data.can_remove_from_vehicle)
- or (
- operation_mode == output_or_remove_item_operation_mode.duplicate_mode
- and entity_data.can_duplicate_in_vehicle
- )
- then
- -- Output or remove only if the train is stationary.
- if fluid_wagon_entity.train.speed == 0 then
- if operation_mode == output_or_remove_item_operation_mode.remove_mode then
- fluid_providers_util.remove_all_fluids(fluid_wagon_entity)
- else
- fluid_providers_util.duplicate_fluid_in_each_fluidbox(fluid_wagon_entity)
- end
- end
- end
- return
- elseif car_entities then
- -- Cars.
- if
- (operation_mode == output_or_remove_item_operation_mode.output_mode and entity_data.can_insert_to_vehicle)
- or (operation_mode == output_or_remove_item_operation_mode.remove_mode and entity_data.can_remove_from_vehicle)
- or (
- operation_mode == output_or_remove_item_operation_mode.duplicate_mode
- and entity_data.can_duplicate_in_vehicle
- )
- then
- -- Output or remove only if the car is stationary.
- for _, car in ipairs(car_entities) do
- if car.speed == 0 then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_stack then
- car.insert(output_stack)
- else
- output_item_stack_according_to_inventories_slot_filters(car, nil, false)
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- remove_one_item_in_entity(car, filter_item_name, nil, false)
- else
- duplicate_first_item_in_each_inventory(car, filter_item_name, nil, false)
- end
- end
- end
- end
- return
- elseif player_entities then
- -- Players.
- if
- (operation_mode == output_or_remove_item_operation_mode.output_mode and entity_data.can_insert_to_player)
- or (operation_mode == output_or_remove_item_operation_mode.remove_mode and entity_data.can_remove_from_player)
- or (
- operation_mode == output_or_remove_item_operation_mode.duplicate_mode
- and entity_data.can_duplicate_in_player
- )
- then
- if operation_mode == output_or_remove_item_operation_mode.output_mode then
- if output_stack then
- -- Change the item count if needed.
- if entity_data.insert_only_once_to_player then
- if entity_data.insert_to_player_by_stack then
- output_stack.count = prototypes.item[output_stack.name].stack_size
- * entity_data.insert_to_player_amount
- else
- output_stack.count = entity_data.insert_to_player_amount
- end
- end
- for _, player in ipairs(player_entities) do
- -- Check if the player is restricted to get the item only once so the item cannot be inserted this time.
- local not_inserted_into_player = not last_player_entities
- or not util.array_contains_val(last_player_entities, player)
- if not entity_data.insert_only_once_to_player or not_inserted_into_player then
- player.insert(output_stack)
- end
- end
- -- Set the table of player entities to make sure they are not inserted the item if config doesn't allow to.
- if output_item_slot == 1 then
- entity_data.slot1_inserted_players = player_entities
- else
- entity_data.slot2_inserted_players = player_entities
- end
- else
- for _, player in ipairs(player_entities) do
- output_item_stack_according_to_inventories_slot_filters(player, nil, false)
- end
- end
- elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
- for _, player in ipairs(player_entities) do
- remove_one_item_in_entity(player, filter_item_name, nil, false)
- end
- else
- for _, player in ipairs(player_entities) do
- duplicate_first_item_in_each_inventory(player, filter_item_name, nil, false)
- end
- end
- end
- return
- end
+ -- Doesn't work on fluid if filter is set.
+ if filter_item_name == nil then
+ if operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ fluid_providers_util.remove_all_fluids(other_fluidbox_entity)
+ elseif operation_mode == output_or_remove_item_operation_mode.duplicate_mode then
+ fluid_providers_util.duplicate_fluid_in_each_fluidbox(other_fluidbox_entity)
+ end
+ end
+ return
+ elseif train_entity then
+ -- Train.
+ if
+ (operation_mode == output_or_remove_item_operation_mode.output_mode and entity_data.can_insert_to_vehicle)
+ or (operation_mode == output_or_remove_item_operation_mode.remove_mode and entity_data.can_remove_from_vehicle)
+ or (
+ operation_mode == output_or_remove_item_operation_mode.duplicate_mode
+ and entity_data.can_duplicate_in_vehicle
+ )
+ then
+ -- Output or remove only if the train is stationary.
+ if train_entity.train.speed == 0 then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_stack then
+ train_entity.insert(output_stack)
+ else
+ output_item_stack_according_to_inventories_slot_filters(train_entity, nil, false)
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ remove_one_item_in_entity(train_entity, filter_item_name, nil, false)
+ else
+ duplicate_first_item_in_each_inventory(train_entity, filter_item_name, nil, false)
+ end
+ end
+ end
+ return
+ elseif fluid_wagon_entity then
+ -- Fluid wagon.
+ if
+ (operation_mode == output_or_remove_item_operation_mode.remove_mode and entity_data.can_remove_from_vehicle)
+ or (
+ operation_mode == output_or_remove_item_operation_mode.duplicate_mode
+ and entity_data.can_duplicate_in_vehicle
+ )
+ then
+ -- Output or remove only if the train is stationary.
+ if fluid_wagon_entity.train.speed == 0 then
+ if operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ fluid_providers_util.remove_all_fluids(fluid_wagon_entity)
+ else
+ fluid_providers_util.duplicate_fluid_in_each_fluidbox(fluid_wagon_entity)
+ end
+ end
+ end
+ return
+ elseif car_entities then
+ -- Cars.
+ if
+ (operation_mode == output_or_remove_item_operation_mode.output_mode and entity_data.can_insert_to_vehicle)
+ or (operation_mode == output_or_remove_item_operation_mode.remove_mode and entity_data.can_remove_from_vehicle)
+ or (
+ operation_mode == output_or_remove_item_operation_mode.duplicate_mode
+ and entity_data.can_duplicate_in_vehicle
+ )
+ then
+ -- Output or remove only if the car is stationary.
+ for _, car in ipairs(car_entities) do
+ if car.speed == 0 then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_stack then
+ car.insert(output_stack)
+ else
+ output_item_stack_according_to_inventories_slot_filters(car, nil, false)
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ remove_one_item_in_entity(car, filter_item_name, nil, false)
+ else
+ duplicate_first_item_in_each_inventory(car, filter_item_name, nil, false)
+ end
+ end
+ end
+ end
+ return
+ elseif player_entities then
+ -- Players.
+ if
+ (operation_mode == output_or_remove_item_operation_mode.output_mode and entity_data.can_insert_to_player)
+ or (operation_mode == output_or_remove_item_operation_mode.remove_mode and entity_data.can_remove_from_player)
+ or (operation_mode == output_or_remove_item_operation_mode.duplicate_mode and entity_data.can_duplicate_in_player)
+ then
+ if operation_mode == output_or_remove_item_operation_mode.output_mode then
+ if output_stack then
+ -- Change the item count if needed.
+ if entity_data.insert_only_once_to_player then
+ if entity_data.insert_to_player_by_stack then
+ output_stack.count = prototypes.item[output_stack.name].stack_size * entity_data.insert_to_player_amount
+ else
+ output_stack.count = entity_data.insert_to_player_amount
+ end
+ end
+ for _, player in ipairs(player_entities) do
+ -- Check if the player is restricted to get the item only once so the item cannot be inserted this time.
+ local not_inserted_into_player = not last_player_entities
+ or not util.array_contains_val(last_player_entities, player)
+ if not entity_data.insert_only_once_to_player or not_inserted_into_player then
+ player.insert(output_stack)
+ end
+ end
+ -- Set the table of player entities to make sure they are not inserted the item if config doesn't allow to.
+ if output_item_slot == 1 then
+ entity_data.slot1_inserted_players = player_entities
+ else
+ entity_data.slot2_inserted_players = player_entities
+ end
+ else
+ for _, player in ipairs(player_entities) do
+ output_item_stack_according_to_inventories_slot_filters(player, nil, false)
+ end
+ end
+ elseif operation_mode == output_or_remove_item_operation_mode.remove_mode then
+ for _, player in ipairs(player_entities) do
+ remove_one_item_in_entity(player, filter_item_name, nil, false)
+ end
+ else
+ for _, player in ipairs(player_entities) do
+ duplicate_first_item_in_each_inventory(player, filter_item_name, nil, false)
+ end
+ end
+ end
+ return
+ end
- -- The last resort. Drop item on ground or remove items on ground.
- if drop_on_ground then
- local drop_entity = {
- name = "item-on-ground",
- position = actual_position,
- stack = output_stack,
- }
- if surface.can_place_entity(drop_entity) then
- surface.create_entity(drop_entity)
- end
- elseif remove_from_ground then
- -- Get tile bounding box if it has not been gotten.
- for _, item in
- ipairs(surface.find_entities_filtered({
- area = util.get_tile_bb(actual_position),
- name = "item-on-ground",
- }))
- do
- if filter_item_name == nil or item.stack.name == filter_item_name then
- item.destroy()
- end
- end
- end
+ -- The last resort. Drop item on ground or remove items on ground.
+ if drop_on_ground then
+ local drop_entity = {
+ name = "item-on-ground",
+ position = actual_position,
+ stack = output_stack,
+ }
+ if surface.can_place_entity(drop_entity) then
+ surface.create_entity(drop_entity)
+ end
+ elseif remove_from_ground then
+ -- Get tile bounding box if it has not been gotten.
+ for _, item in
+ ipairs(surface.find_entities_filtered({
+ area = util.get_tile_bb(actual_position),
+ name = "item-on-ground",
+ }))
+ do
+ if filter_item_name == nil or item.stack.name == filter_item_name then
+ item.destroy()
+ end
+ end
+ end
end
diff --git a/scripts/item-source.lua b/scripts/item-source.lua
index 23e296f..90fe525 100644
--- a/scripts/item-source.lua
+++ b/scripts/item-source.lua
@@ -1,129 +1,129 @@
-- This file contains variables or functions that are related to the Matter Source in this mod.
if not item_source then
- item_source = {}
+ item_source = {}
end
-- The position shift for item output for each direction.
local item_source_shift = {
- -- The values are shifted from the original mod so surface.can_place_entity can work properly.
- [defines.direction.north] = {x1 = 0.3, y1 = 0.9, x2 = -0.3, y2 = 0.9, x0 = 0, y0 = 0.9},
- [defines.direction.east] = {x1 = -0.9, y1 = 0.3, x2 = -0.9, y2 = -0.3, x0 = -0.9, y0 = 0},
- [defines.direction.south] = {x1 = -0.3, y1 = -0.9, x2 = 0.3, y2 = -0.9, x0 = 0, y0 = -0.9},
- [defines.direction.west] = {x1 = 0.9, y1 = -0.3, x2 = 0.9, y2 = 0.3, x0 = 0.9, y0 = 0}
+ -- The values are shifted from the original mod so surface.can_place_entity can work properly.
+ [defines.direction.north] = { x1 = 0.3, y1 = 0.9, x2 = -0.3, y2 = 0.9, x0 = 0, y0 = 0.9 },
+ [defines.direction.east] = { x1 = -0.9, y1 = 0.3, x2 = -0.9, y2 = -0.3, x0 = -0.9, y0 = 0 },
+ [defines.direction.south] = { x1 = -0.3, y1 = -0.9, x2 = 0.3, y2 = -0.9, x0 = 0, y0 = -0.9 },
+ [defines.direction.west] = { x1 = 0.9, y1 = -0.3, x2 = 0.9, y2 = 0.3, x0 = 0.9, y0 = 0 },
}
-- Processes the item_source_data table in storage.
function item_source.tick()
- -- Loop through the table of matter-source data to output items.
- for index, item_source_data in ipairs(storage.creative_mode.item_source_data) do
- -- Get the actual matter-source entity.
- local item_source = item_source_data.entity
- -- Work only if the entity is valid.
- if item_source.valid then
- -- Check if it is active and also not marked for deconstruction.
- if item_source.active and not item_source.to_be_deconstructed(item_source.force) then
- -- Check if it is enabled according to its circuit network state and logistic network state.
- if util.is_inserter_enabled(item_source) then
- -- Get the item names in the 2 filter slots of the matter-source.
- local slot1 = nil
- local slot2 = nil
- if item_source.use_filters then
- slot1 = item_source.get_filter(1)
- slot2 = item_source.get_filter(2)
- end
- if slot1 then
- slot1 = slot1.name
- end
- if slot2 then
- slot2 = slot2.name
- end
- -- Get the matter-source's surface, position and shift for output, so we can drop items accordingly.
- local surf = item_source.surface
- local pos = item_source.position
- local dir = item_source.direction
- local shift = item_source_shift[dir]
- local opposite_dir = util.oppositedirection(dir)
- -- Output for slot1.
- if slot1 == nil then
- item_source_data.slot1_inserted_players = nil
- item_source_data.slot1_last_item_position_on_belt = nil
- else
- item_providers_util.output_or_remove_item(
- surf,
- pos,
- shift.x1,
- shift.y1,
- opposite_dir,
- slot1,
- output_or_remove_item_operation_mode.output_mode,
- 1,
- item_source_data
- )
- end
- -- Output for slot2.
- if slot2 == nil then
- item_source_data.slot2_inserted_players = nil
- item_source_data.slot2_last_item_position_on_belt = nil
- -- Output to crafting machine if no filter is set.
- if slot1 == nil then
- item_providers_util.output_or_remove_item(
- surf,
- pos,
- shift.x0,
- shift.y0,
- opposite_dir,
- nil,
- output_or_remove_item_operation_mode.output_mode,
- 0,
- item_source_data
- )
- end
- else
- item_providers_util.output_or_remove_item(
- surf,
- pos,
- shift.x2,
- shift.y2,
- opposite_dir,
- slot2,
- output_or_remove_item_operation_mode.output_mode,
- 2,
- item_source_data
- )
- end
- end
- end
- else
- -- Remove invalid entity.
- table.remove(storage.creative_mode.item_source_data, index)
- end
- end
+ -- Loop through the table of matter-source data to output items.
+ for index, item_source_data in ipairs(storage.creative_mode.item_source_data) do
+ -- Get the actual matter-source entity.
+ local item_source = item_source_data.entity
+ -- Work only if the entity is valid.
+ if item_source.valid then
+ -- Check if it is active and also not marked for deconstruction.
+ if item_source.active and not item_source.to_be_deconstructed(item_source.force) then
+ -- Check if it is enabled according to its circuit network state and logistic network state.
+ if util.is_inserter_enabled(item_source) then
+ -- Get the item names in the 2 filter slots of the matter-source.
+ local slot1 = nil
+ local slot2 = nil
+ if item_source.use_filters then
+ slot1 = item_source.get_filter(1)
+ slot2 = item_source.get_filter(2)
+ end
+ if slot1 then
+ slot1 = slot1.name
+ end
+ if slot2 then
+ slot2 = slot2.name
+ end
+ -- Get the matter-source's surface, position and shift for output, so we can drop items accordingly.
+ local surf = item_source.surface
+ local pos = item_source.position
+ local dir = item_source.direction
+ local shift = item_source_shift[dir]
+ local opposite_dir = util.oppositedirection(dir)
+ -- Output for slot1.
+ if slot1 == nil then
+ item_source_data.slot1_inserted_players = nil
+ item_source_data.slot1_last_item_position_on_belt = nil
+ else
+ item_providers_util.output_or_remove_item(
+ surf,
+ pos,
+ shift.x1,
+ shift.y1,
+ opposite_dir,
+ slot1,
+ output_or_remove_item_operation_mode.output_mode,
+ 1,
+ item_source_data
+ )
+ end
+ -- Output for slot2.
+ if slot2 == nil then
+ item_source_data.slot2_inserted_players = nil
+ item_source_data.slot2_last_item_position_on_belt = nil
+ -- Output to crafting machine if no filter is set.
+ if slot1 == nil then
+ item_providers_util.output_or_remove_item(
+ surf,
+ pos,
+ shift.x0,
+ shift.y0,
+ opposite_dir,
+ nil,
+ output_or_remove_item_operation_mode.output_mode,
+ 0,
+ item_source_data
+ )
+ end
+ else
+ item_providers_util.output_or_remove_item(
+ surf,
+ pos,
+ shift.x2,
+ shift.y2,
+ opposite_dir,
+ slot2,
+ output_or_remove_item_operation_mode.output_mode,
+ 2,
+ item_source_data
+ )
+ end
+ end
+ end
+ else
+ -- Remove invalid entity.
+ table.remove(storage.creative_mode.item_source_data, index)
+ end
+ end
end
-- Returns the entity data for the given matter source entity.
function item_source.get_data_for_entity(entity)
- for _, data in ipairs(storage.creative_mode.item_source_data) do
- if data.entity == entity then
- return data
- end
- end
- return nil
+ for _, data in ipairs(storage.creative_mode.item_source_data) do
+ if data.entity == entity then
+ return data
+ end
+ end
+ return nil
end
-- Copies the additional configurations from the source entity to the destination entity.
function item_source.on_entity_copied_pasted(source, destination)
- local source_data = item_source.get_data_for_entity(source)
- local destination_data = item_source.get_data_for_entity(destination)
- if not source_data then
- return
- end
- if not destination_data then
- return
- end
- destination_data.can_insert_to_vehicle = source_data.can_insert_to_vehicle
- destination_data.can_insert_to_player = source_data.can_insert_to_player
- destination_data.insert_only_once_to_player = source_data.insert_only_once_to_player
- destination_data.insert_to_player_amount = source_data.insert_to_player_amount
- destination_data.insert_to_player_by_stack = source_data.insert_to_player_by_stack
- destination_data.can_drop_on_ground = source_data.can_drop_on_ground
+ local source_data = item_source.get_data_for_entity(source)
+ local destination_data = item_source.get_data_for_entity(destination)
+ if not source_data then
+ return
+ end
+ if not destination_data then
+ return
+ end
+ destination_data.can_insert_to_vehicle = source_data.can_insert_to_vehicle
+ destination_data.can_insert_to_player = source_data.can_insert_to_player
+ destination_data.insert_only_once_to_player = source_data.insert_only_once_to_player
+ destination_data.insert_to_player_amount = source_data.insert_to_player_amount
+ destination_data.insert_to_player_by_stack = source_data.insert_to_player_by_stack
+ destination_data.can_drop_on_ground = source_data.can_drop_on_ground
end
diff --git a/scripts/item-void.lua b/scripts/item-void.lua
index 0c227e7..3c10120 100644
--- a/scripts/item-void.lua
+++ b/scripts/item-void.lua
@@ -1,82 +1,82 @@
-- This file contains variables or functions that are related to the Matter Void in this mod.
if not item_void then
- item_void = {}
+ item_void = {}
end
-- The position shift for item removal for each direction.
local item_void_shift = {
- [defines.direction.north] = {x = 0, y = -0.9},
- [defines.direction.east] = {x = 0.9, y = 0},
- [defines.direction.south] = {x = 0, y = 0.9},
- [defines.direction.west] = {x = -0.9, y = 0}
+ [defines.direction.north] = { x = 0, y = -0.9 },
+ [defines.direction.east] = { x = 0.9, y = 0 },
+ [defines.direction.south] = { x = 0, y = 0.9 },
+ [defines.direction.west] = { x = -0.9, y = 0 },
}
-- Processes the item_void table in storage.
function item_void.tick()
- -- Loop through the table of matter-void to nullify items.
- for index, item_void_data in ipairs(storage.creative_mode.item_void_data) do
- -- Get the actual matter-void entity.
- local item_void = item_void_data.entity
- if item_void.valid then
- -- Check if it is active and also not marked for deconstruction.
- if item_void.active and not item_void.to_be_deconstructed(item_void.force) then
- -- Give the matter-void free energy.
- item_void.energy = 100000 -- It seems not working?
- -- Check if it is enabled according to its circuit network state and logistic network state.
- if util.is_inserter_enabled(item_void) then
- -- Get the matter-void's surface, position and shift for item removal.
- local surf = item_void.surface
- local pos = item_void.position
- local dir = item_void.direction
- local shift = item_void_shift[dir]
- local filter = nil
- if item_void.use_filters then
- filter = item_void.get_filter(1)
- end
- if filter then
- filter = filter.name
- end
- -- Remove the items in front of it.
- item_providers_util.output_or_remove_item(
- surf,
- pos,
- shift.x,
- shift.y,
- util.oppositedirection(dir),
- filter,
- output_or_remove_item_operation_mode.remove_mode,
- nil,
- item_void_data
- )
- end
- end
- else
- table.remove(storage.creative_mode.item_void_data, index)
- end
- end
+ -- Loop through the table of matter-void to nullify items.
+ for index, item_void_data in ipairs(storage.creative_mode.item_void_data) do
+ -- Get the actual matter-void entity.
+ local item_void = item_void_data.entity
+ if item_void.valid then
+ -- Check if it is active and also not marked for deconstruction.
+ if item_void.active and not item_void.to_be_deconstructed(item_void.force) then
+ -- Give the matter-void free energy.
+ item_void.energy = 100000 -- It seems not working?
+ -- Check if it is enabled according to its circuit network state and logistic network state.
+ if util.is_inserter_enabled(item_void) then
+ -- Get the matter-void's surface, position and shift for item removal.
+ local surf = item_void.surface
+ local pos = item_void.position
+ local dir = item_void.direction
+ local shift = item_void_shift[dir]
+ local filter = nil
+ if item_void.use_filters then
+ filter = item_void.get_filter(1)
+ end
+ if filter then
+ filter = filter.name
+ end
+ -- Remove the items in front of it.
+ item_providers_util.output_or_remove_item(
+ surf,
+ pos,
+ shift.x,
+ shift.y,
+ util.oppositedirection(dir),
+ filter,
+ output_or_remove_item_operation_mode.remove_mode,
+ nil,
+ item_void_data
+ )
+ end
+ end
+ else
+ table.remove(storage.creative_mode.item_void_data, index)
+ end
+ end
end
-- Returns the entity data for the given matter void entity.
function item_void.get_data_for_entity(entity)
- for _, data in ipairs(storage.creative_mode.item_void_data) do
- if data.entity == entity then
- return data
- end
- end
- return nil
+ for _, data in ipairs(storage.creative_mode.item_void_data) do
+ if data.entity == entity then
+ return data
+ end
+ end
+ return nil
end
-- Copies the additional configurations from the source entity to the destination entity.
function item_void.on_entity_copied_pasted(source, destination)
- local source_data = item_void.get_data_for_entity(source)
- local destination_data = item_void.get_data_for_entity(destination)
- if not source_data then
- return
- end
- if not destination_data then
- return
- end
- destination_data.can_remove_from_vehicle = source_data.can_remove_from_vehicle
- destination_data.can_remove_from_player = source_data.can_remove_from_player
- destination_data.can_remove_from_ground = source_data.can_remove_from_ground
+ local source_data = item_void.get_data_for_entity(source)
+ local destination_data = item_void.get_data_for_entity(destination)
+ if not source_data then
+ return
+ end
+ if not destination_data then
+ return
+ end
+ destination_data.can_remove_from_vehicle = source_data.can_remove_from_vehicle
+ destination_data.can_remove_from_player = source_data.can_remove_from_player
+ destination_data.can_remove_from_ground = source_data.can_remove_from_ground
end
diff --git a/scripts/magic-wand-creator.lua b/scripts/magic-wand-creator.lua
index d3610bd..5ef8434 100644
--- a/scripts/magic-wand-creator.lua
+++ b/scripts/magic-wand-creator.lua
@@ -1,44 +1,45 @@
-- This file contains variables or functions that are related to the Creator magic wand in this mod.
if not magic_wand_creator then
- magic_wand_creator = {}
+ magic_wand_creator = {}
end
-- Returns whether tile correction should be performed for the given player.
function magic_wand_creator.get_tile_correction(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- if storage.creative_mode.magic_wand_settings.creator[player.index].tile_correction ~= nil then
- return storage.creative_mode.magic_wand_settings.creator[player.index].tile_correction
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ if storage.creative_mode.magic_wand_settings.creator[player.index].tile_correction ~= nil then
+ return storage.creative_mode.magic_wand_settings.creator[player.index].tile_correction
+ end
+ end
+ return true
end
-- Sets whether tile correction should be performed for the given player.
function magic_wand_creator.set_tile_correction(player, tile_correction)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].tile_correction = tile_correction
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].tile_correction = tile_correction
end
----
-- Returns whether the don't-kill-players-by-tiles option is turned on for the given player.
function magic_wand_creator.get_dont_kill_players_by_tiles(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- if storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_tiles ~= nil then
- return storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_tiles
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ if storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_tiles ~= nil then
+ return storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_tiles
+ end
+ end
+ return true
end
-- Sets whether the don't-kill-players-by-tiles option is turned on for the given player.
function magic_wand_creator.set_dont_kill_players_by_tiles(player, dont_kill_players_by_tiles)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_tiles = dont_kill_players_by_tiles
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_tiles =
+ dont_kill_players_by_tiles
end
----
@@ -46,27 +47,27 @@ end
-- Returns the tile prototype selected by the given player.
-- If no tile is selected, nil will be returned.
function magic_wand_creator.get_selected_tile_prototype(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- local tile_name = storage.creative_mode.magic_wand_settings.creator[player.index].tile_name
- if tile_name then
- return prototypes.tile[tile_name]
- end
- end
- -- Default to concrete. It can be nil if not existed.
- return prototypes.tile["concrete"]
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ local tile_name = storage.creative_mode.magic_wand_settings.creator[player.index].tile_name
+ if tile_name then
+ return prototypes.tile[tile_name]
+ end
+ end
+ -- Default to concrete. It can be nil if not existed.
+ return prototypes.tile["concrete"]
end
-- Sets the given tile prototype as the selected tile by the given player. It can be nil.
function magic_wand_creator.set_selected_tile_prototype(player, tile_prototype)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- if tile_prototype then
- storage.creative_mode.magic_wand_settings.creator[player.index].tile_name = tile_prototype.name
- else
- storage.creative_mode.magic_wand_settings.creator[player.index].tile_name = ""
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].resource_name = ""
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ if tile_prototype then
+ storage.creative_mode.magic_wand_settings.creator[player.index].tile_name = tile_prototype.name
+ else
+ storage.creative_mode.magic_wand_settings.creator[player.index].tile_name = ""
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].resource_name = ""
end
----
@@ -74,67 +75,67 @@ end
-- Returns the resource entity prototype selected by the given player.
-- If no resource is selected, nil will be returned.
function magic_wand_creator.get_selected_resource_prototype(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- local resource_name = storage.creative_mode.magic_wand_settings.creator[player.index].resource_name
- if resource_name then
- return prototypes.entity[resource_name]
- end
- end
- return nil
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ local resource_name = storage.creative_mode.magic_wand_settings.creator[player.index].resource_name
+ if resource_name then
+ return prototypes.entity[resource_name]
+ end
+ end
+ return nil
end
-- Sets the given resource entity prototype as the selected resource by the given player. It can be nil.
function magic_wand_creator.set_selected_resource_prototype(player, resource_prototype)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].tile_name = ""
- if resource_prototype then
- storage.creative_mode.magic_wand_settings.creator[player.index].resource_name = resource_prototype.name
- else
- storage.creative_mode.magic_wand_settings.creator[player.index].resource_name = ""
- end
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].tile_name = ""
+ if resource_prototype then
+ storage.creative_mode.magic_wand_settings.creator[player.index].resource_name = resource_prototype.name
+ else
+ storage.creative_mode.magic_wand_settings.creator[player.index].resource_name = ""
+ end
end
----
-- Returns the resource amount when creating resources for the given player.
function magic_wand_creator.get_resource_amount(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- local resource_amount = storage.creative_mode.magic_wand_settings.creator[player.index].resource_amount
- if resource_amount then
- return resource_amount
- end
- end
- return 2000
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ local resource_amount = storage.creative_mode.magic_wand_settings.creator[player.index].resource_amount
+ if resource_amount then
+ return resource_amount
+ end
+ end
+ return 2000
end
-- Sets the resource amount when creating resources for the given player.
function magic_wand_creator.set_resource_amount(player, resource_amount)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].resource_amount = resource_amount
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].resource_amount = resource_amount
end
----
-- Returns the index of used pattern for the given player.
function magic_wand_creator.get_use_pattern(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- if storage.creative_mode.magic_wand_settings.creator[player.index].used_pattern_index then
- return storage.creative_mode.magic_wand_settings.creator[player.index].used_pattern_index
- end
- end
- return 1
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ if storage.creative_mode.magic_wand_settings.creator[player.index].used_pattern_index then
+ return storage.creative_mode.magic_wand_settings.creator[player.index].used_pattern_index
+ end
+ end
+ return 1
end
-- Sets the index of the used pattern for the given player.
function magic_wand_creator.set_use_pattern(player, used_pattern_index)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].used_pattern_index = used_pattern_index
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].used_pattern_index = used_pattern_index
end
----
@@ -142,27 +143,27 @@ end
-- Returns the second tile prototype selected by the given player.
-- If no tile is selected, nil will be returned.
function magic_wand_creator.get_selected_tile_prototype_2(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- local tile_name_2 = storage.creative_mode.magic_wand_settings.creator[player.index].tile_name_2
- if tile_name_2 then
- return prototypes.tile[tile_name_2]
- end
- end
- -- Default to lab-dark-1. It can be nil if not existed.
- return prototypes.tile["lab-dark-1"]
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ local tile_name_2 = storage.creative_mode.magic_wand_settings.creator[player.index].tile_name_2
+ if tile_name_2 then
+ return prototypes.tile[tile_name_2]
+ end
+ end
+ -- Default to lab-dark-1. It can be nil if not existed.
+ return prototypes.tile["lab-dark-1"]
end
-- Sets the given tile prototype as the second selected tile by the given player. It can be nil.
function magic_wand_creator.set_selected_tile_prototype_2(player, tile_prototype_2)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- if tile_prototype_2 then
- storage.creative_mode.magic_wand_settings.creator[player.index].tile_name_2 = tile_prototype_2.name
- else
- storage.creative_mode.magic_wand_settings.creator[player.index].tile_name_2 = ""
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].resource_name_2 = ""
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ if tile_prototype_2 then
+ storage.creative_mode.magic_wand_settings.creator[player.index].tile_name_2 = tile_prototype_2.name
+ else
+ storage.creative_mode.magic_wand_settings.creator[player.index].tile_name_2 = ""
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].resource_name_2 = ""
end
----
@@ -170,457 +171,455 @@ end
-- Returns the second resource entity prototype selected by the given player.
-- If no resource is selected, nil will be returned.
function magic_wand_creator.get_selected_resource_prototype_2(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- local resource_name_2 = storage.creative_mode.magic_wand_settings.creator[player.index].resource_name_2
- if resource_name_2 then
- return prototypes.entity[resource_name_2]
- end
- end
- return nil
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ local resource_name_2 = storage.creative_mode.magic_wand_settings.creator[player.index].resource_name_2
+ if resource_name_2 then
+ return prototypes.entity[resource_name_2]
+ end
+ end
+ return nil
end
-- Sets the given resource entity prototype as the second selected resource by the given player. It can be nil.
function magic_wand_creator.set_selected_resource_prototype_2(player, resource_prototype_2)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].tile_name_2 = ""
- if resource_prototype_2 then
- storage.creative_mode.magic_wand_settings.creator[player.index].resource_name_2 = resource_prototype_2.name
- else
- storage.creative_mode.magic_wand_settings.creator[player.index].resource_name_2 = ""
- end
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].tile_name_2 = ""
+ if resource_prototype_2 then
+ storage.creative_mode.magic_wand_settings.creator[player.index].resource_name_2 = resource_prototype_2.name
+ else
+ storage.creative_mode.magic_wand_settings.creator[player.index].resource_name_2 = ""
+ end
end
----
-- Returns the resource amount when creating resources based on the second selected resource for the given player.
function magic_wand_creator.get_resource_amount_2(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- local resource_amount_2 = storage.creative_mode.magic_wand_settings.creator[player.index].resource_amount_2
- if resource_amount_2 then
- return resource_amount_2
- end
- end
- return 2000
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ local resource_amount_2 = storage.creative_mode.magic_wand_settings.creator[player.index].resource_amount_2
+ if resource_amount_2 then
+ return resource_amount_2
+ end
+ end
+ return 2000
end
-- Sets the resource amount when creating resources based on the second selected resource for the given player.
function magic_wand_creator.set_resource_amount_2(player, resource_amount_2)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].resource_amount_2 = resource_amount_2
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].resource_amount_2 = resource_amount_2
end
----
-- Returns whether the also-remove-decoratives option is turned on for the given player.
function magic_wand_creator.get_also_remove_decoratives(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- if storage.creative_mode.magic_wand_settings.creator[player.index].also_remove_decoratives ~= nil then
- return storage.creative_mode.magic_wand_settings.creator[player.index].also_remove_decoratives
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ if storage.creative_mode.magic_wand_settings.creator[player.index].also_remove_decoratives ~= nil then
+ return storage.creative_mode.magic_wand_settings.creator[player.index].also_remove_decoratives
+ end
+ end
+ return true
end
-- Sets whether the also-remove-decoratives option is turned on for the given player.
function magic_wand_creator.set_also_remove_decoratives(player, also_remove_decoratives)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].also_remove_decoratives = also_remove_decoratives
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].also_remove_decoratives = also_remove_decoratives
end
----
-- Returns whether the don't-remove-player-characters option is turned on for the given player.
function magic_wand_creator.get_dont_remove_player_characters(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- if storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_player_characters ~= nil then
- return storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_player_characters
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ if storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_player_characters ~= nil then
+ return storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_player_characters
+ end
+ end
+ return true
end
-- Sets whether the don't-remove-player-characters option is turned on for the given player.
function magic_wand_creator.set_dont_remove_player_characters(player, dont_remove_player_characters)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_player_characters =
- dont_remove_player_characters
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_player_characters =
+ dont_remove_player_characters
end
----
-- Returns whether tile removal should not be performed when there is any entity being selected for the given player.
function magic_wand_creator.get_dont_remove_tiles_if_any_entity_is_selected(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- if storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_tiles_if_any_entity_is_selected ~= nil then
- return storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_tiles_if_any_entity_is_selected
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ if
+ storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_tiles_if_any_entity_is_selected ~= nil
+ then
+ return storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_tiles_if_any_entity_is_selected
+ end
+ end
+ return true
end
-- Sets whether tile removal should not be performed when there is any entity being selected for the given player.
function magic_wand_creator.set_dont_remove_tiles_if_any_entity_is_selected(
- player,
- dont_remove_tiles_if_any_entity_is_selected)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_tiles_if_any_entity_is_selected =
- dont_remove_tiles_if_any_entity_is_selected
+ player,
+ dont_remove_tiles_if_any_entity_is_selected
+)
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].dont_remove_tiles_if_any_entity_is_selected =
+ dont_remove_tiles_if_any_entity_is_selected
end
----
-- Returns whether the don't-kill-players-by-removing-tiles option is turned on for the given player.
function magic_wand_creator.get_dont_kill_players_by_removing_tiles(player)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- if storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_removing_tiles ~= nil then
- return storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_removing_tiles
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ if storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_removing_tiles ~= nil then
+ return storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_removing_tiles
+ end
+ end
+ return true
end
-- Sets whether the don't-kill-players-by-removing-tiles option is turned on for the given player.
function magic_wand_creator.set_dont_kill_players_by_removing_tiles(player, dont_kill_players_by_removing_tiles)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_removing_tiles =
- dont_kill_players_by_removing_tiles
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].dont_kill_players_by_removing_tiles =
+ dont_kill_players_by_removing_tiles
end
----
-- Returns whether the alt-mode of the magic wand can apply on the given force for the given player.
function magic_wand_creator.get_alt_mode_apply_on_force(player, force)
- if storage.creative_mode.magic_wand_settings.creator[player.index] then
- if storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces ~= nil then
- return storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces[force.name] ~= false
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.creator[player.index] then
+ if storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces ~= nil then
+ return storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces[force.name] ~= false
+ end
+ end
+ return true
end
-- Sets whether the alt-mode of the magic wand can apply on the given force for the given player.
function magic_wand_creator.set_alt_mode_apply_on_force(player, force, apply)
- if not storage.creative_mode.magic_wand_settings.creator[player.index] then
- storage.creative_mode.magic_wand_settings.creator[player.index] = {}
- end
- if not storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces then
- storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces = {}
- end
- storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces[force.name] = apply
+ if not storage.creative_mode.magic_wand_settings.creator[player.index] then
+ storage.creative_mode.magic_wand_settings.creator[player.index] = {}
+ end
+ if not storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces then
+ storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces = {}
+ end
+ storage.creative_mode.magic_wand_settings.creator[player.index].alt_mode_forces[force.name] = apply
end
------------------------------------------------------
-- Creates smoke effect at the given position in the given surface.
local function create_smoke_at(surface, position)
- surface.create_trivial_smoke {
- name = creative_mode_defines.names.entities.magic_wand_smoke_creator,
- position = position
- }
+ surface.create_trivial_smoke({
+ name = creative_mode_defines.names.entities.magic_wand_smoke_creator,
+ position = position,
+ })
end
-- Creates smoke effect at the entity's position.
local function create_smoke_effect_at_entity_position(entity)
- create_smoke_at(entity.surface, entity.position)
+ create_smoke_at(entity.surface, entity.position)
end
------------------------------------------------------
-- Returns the dictionary of all safe positions for all connected players with characters on the given surface.
local function get_safe_positions_for_all_players_on_surface(surface)
- local player_positions = {}
- for _, player in pairs(game.connected_players) do
- local character = player.character
- if character then
- if character.surface == surface then
- local position = character.position
- local rounded_x = util.round(position.x)
- local rounded_y = util.round(position.y)
-
- -- Give him a 3x3 safe area.
- local x = rounded_x - 1
- player_positions[x] = player_positions[x] or {}
- player_positions[x][rounded_y - 1] = true
- player_positions[x][rounded_y] = true
- player_positions[x][rounded_y + 1] = true
-
- x = rounded_x
- player_positions[x] = player_positions[x] or {}
- player_positions[x][rounded_y - 1] = true
- player_positions[x][rounded_y] = true
- player_positions[x][rounded_y + 1] = true
-
- x = rounded_x + 1
- player_positions[x] = player_positions[x] or {}
- player_positions[x][rounded_y - 1] = true
- player_positions[x][rounded_y] = true
- player_positions[x][rounded_y + 1] = true
- end
- end
- end
- return player_positions
+ local player_positions = {}
+ for _, player in pairs(game.connected_players) do
+ local character = player.character
+ if character then
+ if character.surface == surface then
+ local position = character.position
+ local rounded_x = util.round(position.x)
+ local rounded_y = util.round(position.y)
+
+ -- Give him a 3x3 safe area.
+ local x = rounded_x - 1
+ player_positions[x] = player_positions[x] or {}
+ player_positions[x][rounded_y - 1] = true
+ player_positions[x][rounded_y] = true
+ player_positions[x][rounded_y + 1] = true
+
+ x = rounded_x
+ player_positions[x] = player_positions[x] or {}
+ player_positions[x][rounded_y - 1] = true
+ player_positions[x][rounded_y] = true
+ player_positions[x][rounded_y + 1] = true
+
+ x = rounded_x + 1
+ player_positions[x] = player_positions[x] or {}
+ player_positions[x][rounded_y - 1] = true
+ player_positions[x][rounded_y] = true
+ player_positions[x][rounded_y + 1] = true
+ end
+ end
+ end
+ return player_positions
end
-- Creates tiles or resources in checker pattern on the given tiles for the given player.
local function create_tiles_or_resources_in_pattern(
- player,
- tiles,
- tile_or_resource_prototype_data_list,
- pattern_function)
- local surface = player.surface
-
- local dont_kill_players_by_tiles = magic_wand_creator.get_dont_kill_players_by_tiles(player)
- local player_positions
-
- local tiles_to_be_created
- local tile_positions_to_be_created
-
- -- Iterate the selected tiles.
- for _, tile in pairs(tiles) do
- local position = tile.position
- local x = position.x
- local y = position.y
- -- Get the data to be used according to the tile position.
- local data_index = pattern_function(x, y)
- local data = tile_or_resource_prototype_data_list[data_index]
- local selected_tile = data.tile_prototype
- if selected_tile then
- -- Create tiles.
- -- Setup.
- local new_tile_name = selected_tile.name
- local can_tile_kill_player = selected_tile.collision_mask["player-layer"]
- if can_tile_kill_player and dont_kill_players_by_tiles then
- -- Don't kill players, but the selected tile is harmful.
- -- Make sure the positions of all players are not touched.
- player_positions = player_positions or get_safe_positions_for_all_players_on_surface(surface)
- end
- if tile.name ~= new_tile_name then
- if
- not can_tile_kill_player or not dont_kill_players_by_tiles or not player_positions[x] or not player_positions[x][y]
- then
- -- Prepare to set tiles.
- tiles_to_be_created = tiles_to_be_created or {}
- tile_positions_to_be_created = tile_positions_to_be_created or {}
- -- Record the position and tile name, so we can set them later.
- table.insert(
- tiles_to_be_created,
- {
- name = new_tile_name,
- position = position
- }
- )
- table.insert(tile_positions_to_be_created, position)
- create_smoke_at(surface, position)
- end
- end
- else
- -- Create resources.
- -- Setup.
- local selected_resource = data.resource_prototype
- local resource_amount = data.resource_amount
- if selected_resource then
- local new_resource_name = selected_resource.name
- -- Create entity if possible.
- if surface.can_place_entity {name = new_resource_name, position = position} then
- surface.create_entity {
- name = new_resource_name,
- position = position,
- amount = resource_amount,
- create_build_effect_smoke = true,
- raise_built = true
- }
- end
- end
- end
- end
-
- -- Actually create tiles.
- if tiles_to_be_created then
- surface.set_tiles(tiles_to_be_created, magic_wand_creator.get_tile_correction(player), true, true, true)
- end
+ player,
+ tiles,
+ tile_or_resource_prototype_data_list,
+ pattern_function
+)
+ local surface = player.surface
+
+ local dont_kill_players_by_tiles = magic_wand_creator.get_dont_kill_players_by_tiles(player)
+ local player_positions
+
+ local tiles_to_be_created
+ local tile_positions_to_be_created
+
+ -- Iterate the selected tiles.
+ for _, tile in pairs(tiles) do
+ local position = tile.position
+ local x = position.x
+ local y = position.y
+ -- Get the data to be used according to the tile position.
+ local data_index = pattern_function(x, y)
+ local data = tile_or_resource_prototype_data_list[data_index]
+ local selected_tile = data.tile_prototype
+ if selected_tile then
+ -- Create tiles.
+ -- Setup.
+ local new_tile_name = selected_tile.name
+ local can_tile_kill_player = selected_tile.collision_mask["player-layer"]
+ if can_tile_kill_player and dont_kill_players_by_tiles then
+ -- Don't kill players, but the selected tile is harmful.
+ -- Make sure the positions of all players are not touched.
+ player_positions = player_positions or get_safe_positions_for_all_players_on_surface(surface)
+ end
+ if tile.name ~= new_tile_name then
+ if
+ not can_tile_kill_player
+ or not dont_kill_players_by_tiles
+ or not player_positions[x]
+ or not player_positions[x][y]
+ then
+ -- Prepare to set tiles.
+ tiles_to_be_created = tiles_to_be_created or {}
+ tile_positions_to_be_created = tile_positions_to_be_created or {}
+ -- Record the position and tile name, so we can set them later.
+ table.insert(tiles_to_be_created, {
+ name = new_tile_name,
+ position = position,
+ })
+ table.insert(tile_positions_to_be_created, position)
+ create_smoke_at(surface, position)
+ end
+ end
+ else
+ -- Create resources.
+ -- Setup.
+ local selected_resource = data.resource_prototype
+ local resource_amount = data.resource_amount
+ if selected_resource then
+ local new_resource_name = selected_resource.name
+ -- Create entity if possible.
+ if surface.can_place_entity({ name = new_resource_name, position = position }) then
+ surface.create_entity({
+ name = new_resource_name,
+ position = position,
+ amount = resource_amount,
+ create_build_effect_smoke = true,
+ raise_built = true,
+ })
+ end
+ end
+ end
+ end
+
+ -- Actually create tiles.
+ if tiles_to_be_created then
+ surface.set_tiles(tiles_to_be_created, magic_wand_creator.get_tile_correction(player), true, true, true)
+ end
end
-- Handler of the on_player_selected_area event.
-- Returns whether the event is consumed and hence no need to further pass it to other handlers.
function magic_wand_creator.on_player_selected_area(player, area, item_name, entities, tiles)
- if item_name == creative_mode_defines.names.items.magic_wand_creator then
- if rights.can_player_use_creator_magic_wand(player) then
- -- Get the first selected tile or resource.
- local tile_or_resource_prototype_data_list = {
- {
- tile_prototype = magic_wand_creator.get_selected_tile_prototype(player),
- resource_prototype = magic_wand_creator.get_selected_resource_prototype(player),
- resource_amount = magic_wand_creator.get_resource_amount(player)
- }
- }
- -- Use pattern?
- local pattern_index = magic_wand_creator.get_use_pattern(player)
- -- Create second tile or resource?
- if pattern_index > 1 then
- -- Yes. Get the second selected tile or resource.
- table.insert(
- tile_or_resource_prototype_data_list,
- {
- tile_prototype = magic_wand_creator.get_selected_tile_prototype_2(player),
- resource_prototype = magic_wand_creator.get_selected_resource_prototype_2(player),
- resource_amount = magic_wand_creator.get_resource_amount_2(player)
- }
- )
- end
- -- Pattern function.
- local pattern_function
- local data_count = #tile_or_resource_prototype_data_list
- if pattern_index == 2 then
- -- Horizontal stripe.
- pattern_function = function(x, y)
- return y % data_count + 1
- end
- elseif pattern_index == 3 then
- -- Vertical stripe.
- pattern_function = function(x, y)
- return x % data_count + 1
- end
- elseif pattern_index == 4 then
- -- Checker.
- pattern_function = function(x, y)
- return (x + y) % data_count + 1
- end
- elseif pattern_index == 5 then
- -- Random.
- pattern_function = function(x, y)
- return util.random(1, data_count)
- end
- else
- -- Default: no pattern.
- pattern_function = function(x, y)
- return 1
- end
- end
-
- -- Create tiles or resources!
- local data_count = #tile_or_resource_prototype_data_list
- create_tiles_or_resources_in_pattern(player, tiles, tile_or_resource_prototype_data_list, pattern_function)
- else
- -- No right to use.
- player.print {"message.creative-mode_no-right-to-use-magic-wand"}
- end
-
- return true
- end
-
- return false
+ if item_name == creative_mode_defines.names.items.magic_wand_creator then
+ if rights.can_player_use_creator_magic_wand(player) then
+ -- Get the first selected tile or resource.
+ local tile_or_resource_prototype_data_list = {
+ {
+ tile_prototype = magic_wand_creator.get_selected_tile_prototype(player),
+ resource_prototype = magic_wand_creator.get_selected_resource_prototype(player),
+ resource_amount = magic_wand_creator.get_resource_amount(player),
+ },
+ }
+ -- Use pattern?
+ local pattern_index = magic_wand_creator.get_use_pattern(player)
+ -- Create second tile or resource?
+ if pattern_index > 1 then
+ -- Yes. Get the second selected tile or resource.
+ table.insert(tile_or_resource_prototype_data_list, {
+ tile_prototype = magic_wand_creator.get_selected_tile_prototype_2(player),
+ resource_prototype = magic_wand_creator.get_selected_resource_prototype_2(player),
+ resource_amount = magic_wand_creator.get_resource_amount_2(player),
+ })
+ end
+ -- Pattern function.
+ local pattern_function
+ local data_count = #tile_or_resource_prototype_data_list
+ if pattern_index == 2 then
+ -- Horizontal stripe.
+ pattern_function = function(x, y)
+ return y % data_count + 1
+ end
+ elseif pattern_index == 3 then
+ -- Vertical stripe.
+ pattern_function = function(x, y)
+ return x % data_count + 1
+ end
+ elseif pattern_index == 4 then
+ -- Checker.
+ pattern_function = function(x, y)
+ return (x + y) % data_count + 1
+ end
+ elseif pattern_index == 5 then
+ -- Random.
+ pattern_function = function(x, y)
+ return util.random(1, data_count)
+ end
+ else
+ -- Default: no pattern.
+ pattern_function = function(x, y)
+ return 1
+ end
+ end
+
+ -- Create tiles or resources!
+ local data_count = #tile_or_resource_prototype_data_list
+ create_tiles_or_resources_in_pattern(player, tiles, tile_or_resource_prototype_data_list, pattern_function)
+ else
+ -- No right to use.
+ player.print({ "message.creative-mode_no-right-to-use-magic-wand" })
+ end
+
+ return true
+ end
+
+ return false
end
-- Handler of the on_player_alt_selected_area event.
-- Returns whether the event is consumed and hence no need to further pass it to other handlers.
function magic_wand_creator.on_player_alt_selected_area(player, area, item_name, entities, tiles)
- if item_name == creative_mode_defines.names.items.magic_wand_creator then
- if rights.can_player_use_creator_magic_wand(player) then
- local surface = player.surface
-
- -- Removes decoratives.
- if magic_wand_creator.get_also_remove_decoratives(player) then
- surface.destroy_decoratives(area)
- end
-
- -- Removes the selected entities.
- local has_destroyed_entity = false
- local dont_remove_player_characters = magic_wand_creator.get_dont_remove_player_characters(player)
- for _, entity in ipairs(entities) do
- if entity.valid then -- It is possible that the entity becomes invalid.
- -- Don't select the smoke.
- if entity.name ~= creative_mode_defines.names.entities.magic_wand_smoke_creator then
- local force = entity.force
- if force then
- -- Force allowed?
- if magic_wand_creator.get_alt_mode_apply_on_force(player, force) then
- -- Player character.
- local can_destroy = true
- if dont_remove_player_characters then
- if util.get_character_owning_player(entity) then
- -- The character is owned by a player.
- can_destroy = false
- end
- end
- if can_destroy then
- create_smoke_effect_at_entity_position(entity)
- util.destroy_entity_and_raise_event(entity, player, false)
- has_destroyed_entity = true
- end
- end
- end
- end
- end
- end
-
- -- Also remove tiles.
- -- But check if we can do so first.
- if has_destroyed_entity and magic_wand_creator.get_dont_remove_tiles_if_any_entity_is_selected(player) then
- -- No, don't remove tiles.
- return
- end
- local new_tiles = nil
- local old_tiles = nil
- local player_positions = nil
- local dont_kill_players_by_removing_tiles = magic_wand_creator.get_dont_kill_players_by_removing_tiles(player)
- for _, tile in ipairs(tiles) do
- local position = tile.position
- local x = position.x
- local y = position.y
- -- Remove the tile if it is hidding a tile behind it.
- local hidden_tile_name = surface.get_hidden_tile(position)
- local hidden_tile = prototypes.tile[hidden_tile_name]
- if hidden_tile then
- local remove_this_tile = true
- if hidden_tile.collision_mask["player-layer"] and dont_kill_players_by_removing_tiles then
- -- The hidden tile is unsafe for players.
- -- Make sure the positions of all players are not touched.
- player_positions = player_positions or get_safe_positions_for_all_players_on_surface(surface)
- if player_positions[x] and player_positions[x][y] then
- remove_this_tile = false
- end
- end
- if remove_this_tile then
- if not new_tiles then
- new_tiles = {}
- end
- if not old_tiles then
- old_tiles = {}
- end
- table.insert(
- new_tiles,
- {
- name = hidden_tile_name,
- position = position
- }
- )
- create_smoke_at(surface, position)
- end
- end
- end
- if new_tiles then
- -- Set tiles and raise event.
- surface.set_tiles(new_tiles, true, true, true, true)
- end
- else
- -- No right to use.
- player.print {"message.creative-mode_no-right-to-use-magic-wand"}
- end
-
- return true
- end
-
- return false
+ if item_name == creative_mode_defines.names.items.magic_wand_creator then
+ if rights.can_player_use_creator_magic_wand(player) then
+ local surface = player.surface
+
+ -- Removes decoratives.
+ if magic_wand_creator.get_also_remove_decoratives(player) then
+ surface.destroy_decoratives(area)
+ end
+
+ -- Removes the selected entities.
+ local has_destroyed_entity = false
+ local dont_remove_player_characters = magic_wand_creator.get_dont_remove_player_characters(player)
+ for _, entity in ipairs(entities) do
+ if entity.valid then -- It is possible that the entity becomes invalid.
+ -- Don't select the smoke.
+ if entity.name ~= creative_mode_defines.names.entities.magic_wand_smoke_creator then
+ local force = entity.force
+ if force then
+ -- Force allowed?
+ if magic_wand_creator.get_alt_mode_apply_on_force(player, force) then
+ -- Player character.
+ local can_destroy = true
+ if dont_remove_player_characters then
+ if util.get_character_owning_player(entity) then
+ -- The character is owned by a player.
+ can_destroy = false
+ end
+ end
+ if can_destroy then
+ create_smoke_effect_at_entity_position(entity)
+ util.destroy_entity_and_raise_event(entity, player, false)
+ has_destroyed_entity = true
+ end
+ end
+ end
+ end
+ end
+ end
+
+ -- Also remove tiles.
+ -- But check if we can do so first.
+ if has_destroyed_entity and magic_wand_creator.get_dont_remove_tiles_if_any_entity_is_selected(player) then
+ -- No, don't remove tiles.
+ return
+ end
+ local new_tiles = nil
+ local old_tiles = nil
+ local player_positions = nil
+ local dont_kill_players_by_removing_tiles = magic_wand_creator.get_dont_kill_players_by_removing_tiles(player)
+ for _, tile in ipairs(tiles) do
+ local position = tile.position
+ local x = position.x
+ local y = position.y
+ -- Remove the tile if it is hidding a tile behind it.
+ local hidden_tile_name = surface.get_hidden_tile(position)
+ local hidden_tile = prototypes.tile[hidden_tile_name]
+ if hidden_tile then
+ local remove_this_tile = true
+ if hidden_tile.collision_mask["player-layer"] and dont_kill_players_by_removing_tiles then
+ -- The hidden tile is unsafe for players.
+ -- Make sure the positions of all players are not touched.
+ player_positions = player_positions or get_safe_positions_for_all_players_on_surface(surface)
+ if player_positions[x] and player_positions[x][y] then
+ remove_this_tile = false
+ end
+ end
+ if remove_this_tile then
+ if not new_tiles then
+ new_tiles = {}
+ end
+ if not old_tiles then
+ old_tiles = {}
+ end
+ table.insert(new_tiles, {
+ name = hidden_tile_name,
+ position = position,
+ })
+ create_smoke_at(surface, position)
+ end
+ end
+ end
+ if new_tiles then
+ -- Set tiles and raise event.
+ surface.set_tiles(new_tiles, true, true, true, true)
+ end
+ else
+ -- No right to use.
+ player.print({ "message.creative-mode_no-right-to-use-magic-wand" })
+ end
+
+ return true
+ end
+
+ return false
end
diff --git a/scripts/magic-wand-healer.lua b/scripts/magic-wand-healer.lua
index 338464d..78df8e6 100644
--- a/scripts/magic-wand-healer.lua
+++ b/scripts/magic-wand-healer.lua
@@ -1,161 +1,159 @@
-- This file contains variables or functions that are related to the Healer magic wand in this mod.
if not magic_wand_healer then
- magic_wand_healer = {}
+ magic_wand_healer = {}
end
-- Gets whether the selected ghost entities can be revived for the given player.
function magic_wand_healer.get_revive_ghosts(player)
- if storage.creative_mode.magic_wand_settings.healer[player.index] then
- if storage.creative_mode.magic_wand_settings.healer[player.index].revive_ghosts ~= nil then
- return storage.creative_mode.magic_wand_settings.healer[player.index].revive_ghosts
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.healer[player.index] then
+ if storage.creative_mode.magic_wand_settings.healer[player.index].revive_ghosts ~= nil then
+ return storage.creative_mode.magic_wand_settings.healer[player.index].revive_ghosts
+ end
+ end
+ return true
end
-- Sets whether the selected ghost entities can be revived for the given player.
function magic_wand_healer.set_revive_ghosts(player, revive_ghosts)
- if not storage.creative_mode.magic_wand_settings.healer[player.index] then
- storage.creative_mode.magic_wand_settings.healer[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.healer[player.index].revive_ghosts = revive_ghosts
+ if not storage.creative_mode.magic_wand_settings.healer[player.index] then
+ storage.creative_mode.magic_wand_settings.healer[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.healer[player.index].revive_ghosts = revive_ghosts
end
----
-- Gets whether the selected entities belonging the given force can be healed for the given player.
function magic_wand_healer.get_heal_entities_on_force(player, force)
- if storage.creative_mode.magic_wand_settings.healer[player.index] then
- if storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces ~= nil then
- return storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces[force.name] ~= false
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.healer[player.index] then
+ if storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces ~= nil then
+ return storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces[force.name] ~= false
+ end
+ end
+ return true
end
-- Sets whether the selected entities belonging the given force can be healed for the given player.
function magic_wand_healer.set_heal_entities_on_force(player, force, heal)
- if not storage.creative_mode.magic_wand_settings.healer[player.index] then
- storage.creative_mode.magic_wand_settings.healer[player.index] = {}
- end
- if not storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces then
- storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces = {}
- end
- storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces[force.name] = heal
+ if not storage.creative_mode.magic_wand_settings.healer[player.index] then
+ storage.creative_mode.magic_wand_settings.healer[player.index] = {}
+ end
+ if not storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces then
+ storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces = {}
+ end
+ storage.creative_mode.magic_wand_settings.healer[player.index].heal_forces[force.name] = heal
end
----
-- Possible alt-mode actions for the Healer magic wand.
magic_wand_healer.alt_mode_action = {
- set_hp_to_one = 1,
- kill = 2,
+ set_hp_to_one = 1,
+ kill = 2,
}
-- Returns the alt-mode action of the magic wand for the given player.
function magic_wand_healer.get_alt_mode_action(player)
- if storage.creative_mode.magic_wand_settings.healer[player.index] then
- if storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_action ~= nil then
- return storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_action
- end
- end
- return magic_wand_healer.alt_mode_action.set_hp_to_one
+ if storage.creative_mode.magic_wand_settings.healer[player.index] then
+ if storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_action ~= nil then
+ return storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_action
+ end
+ end
+ return magic_wand_healer.alt_mode_action.set_hp_to_one
end
-- Sets the alt-mode action of the magic wand for the given player.
function magic_wand_healer.set_alt_mode_action(player, alt_mode_action)
- if not storage.creative_mode.magic_wand_settings.healer[player.index] then
- storage.creative_mode.magic_wand_settings.healer[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_action = alt_mode_action
+ if not storage.creative_mode.magic_wand_settings.healer[player.index] then
+ storage.creative_mode.magic_wand_settings.healer[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_action = alt_mode_action
end
----
-- Returns whether the alt-mode action of the magic wand can affect player characters for the given player.
function magic_wand_healer.get_alt_mode_dont_affect_player_characters(player)
- if storage.creative_mode.magic_wand_settings.healer[player.index] then
- if
- storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_player_characters ~= nil
- then
- return storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_player_characters
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.healer[player.index] then
+ if storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_player_characters ~= nil then
+ return storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_player_characters
+ end
+ end
+ return true
end
-- Sets whether the alt-mode action of the magic wand can affect player characters for the given player.
function magic_wand_healer.set_alt_mode_dont_affect_player_characters(player, alt_mode_dont_affect_player_characters)
- if not storage.creative_mode.magic_wand_settings.healer[player.index] then
- storage.creative_mode.magic_wand_settings.healer[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_player_characters =
- alt_mode_dont_affect_player_characters
+ if not storage.creative_mode.magic_wand_settings.healer[player.index] then
+ storage.creative_mode.magic_wand_settings.healer[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_player_characters =
+ alt_mode_dont_affect_player_characters
end
----
-- Returns whether the alt-mode action of the magic wand can affect indestructible entities for the given player.
function magic_wand_healer.get_alt_mode_dont_affect_indestructible_entities(player)
- if storage.creative_mode.magic_wand_settings.healer[player.index] then
- if
- storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_indestructible_entities
- ~= nil
- then
- return storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_indestructible_entities
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.healer[player.index] then
+ if
+ storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_indestructible_entities
+ ~= nil
+ then
+ return storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_indestructible_entities
+ end
+ end
+ return true
end
-- Sets whether the alt-mode action of the magic wand can affect indestructible entities for the given player.
function magic_wand_healer.set_alt_mode_dont_affect_indestructible_entities(
- player,
- alt_mode_dont_affect_indestructible_entities
+ player,
+ alt_mode_dont_affect_indestructible_entities
)
- if not storage.creative_mode.magic_wand_settings.healer[player.index] then
- storage.creative_mode.magic_wand_settings.healer[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_indestructible_entities =
- alt_mode_dont_affect_indestructible_entities
+ if not storage.creative_mode.magic_wand_settings.healer[player.index] then
+ storage.creative_mode.magic_wand_settings.healer[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_dont_affect_indestructible_entities =
+ alt_mode_dont_affect_indestructible_entities
end
----
-- Returns whether the alt-mode of the magic wand can apply on the given force for the given player.
function magic_wand_healer.get_alt_mode_apply_on_force(player, force)
- if storage.creative_mode.magic_wand_settings.healer[player.index] then
- if storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces ~= nil then
- return storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces[force.name] ~= false
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.healer[player.index] then
+ if storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces ~= nil then
+ return storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces[force.name] ~= false
+ end
+ end
+ return true
end
-- Sets whether the alt-mode of the magic wand can apply on the given force for the given player.
function magic_wand_healer.set_alt_mode_apply_on_force(player, force, apply)
- if not storage.creative_mode.magic_wand_settings.healer[player.index] then
- storage.creative_mode.magic_wand_settings.healer[player.index] = {}
- end
- if not storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces then
- storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces = {}
- end
- storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces[force.name] = apply
+ if not storage.creative_mode.magic_wand_settings.healer[player.index] then
+ storage.creative_mode.magic_wand_settings.healer[player.index] = {}
+ end
+ if not storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces then
+ storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces = {}
+ end
+ storage.creative_mode.magic_wand_settings.healer[player.index].alt_mode_forces[force.name] = apply
end
------------------------------------------------------
-- Creates smoke effect at the given position in the given surface.
local function create_smoke_at(surface, position)
- surface.create_trivial_smoke({
- name = creative_mode_defines.names.entities.magic_wand_smoke_healer,
- position = position,
- })
+ surface.create_trivial_smoke({
+ name = creative_mode_defines.names.entities.magic_wand_smoke_healer,
+ position = position,
+ })
end
-- Creates smoke effect at the entity's position.
local function create_smoke_effect_at_entity_position(entity)
- create_smoke_at(entity.surface, entity.position)
+ create_smoke_at(entity.surface, entity.position)
end
------------------------------------------------------
@@ -163,107 +161,107 @@ end
-- Handler of the on_player_selected_area event.
-- Returns whether the event is consumed and hence no need to further pass it to other handlers.
function magic_wand_healer.on_player_selected_area(player, area, item_name, entities, tiles)
- if item_name == creative_mode_defines.names.items.magic_wand_healer then
- if rights.can_player_use_healer_magic_wand(player) then
- -- Heal the selected entities and revive the ghost entities.
- local revive_ghosts = magic_wand_healer.get_revive_ghosts(player)
- -- Prepare to fire events.
- local revived_tile_positions
- for _, entity in ipairs(entities) do
- if entity.valid then -- It is possible that the entity becomes invalid.
- local health = entity.health
- if health ~= nil then
- -- The entity has health. It can be healed.
- if entity.force and magic_wand_healer.get_heal_entities_on_force(player, entity.force) then
- local max_health = entity.prototype.get_max_health() -- For all entities in general
- if entity.type == "character" then -- But players have individual and force bonuses to max health
- local p = entity.player
- max_health = max_health + p.force.character_health_bonus + p.character_health_bonus
- end
- if health < max_health then
- -- Heal it.
- entity.health = max_health
- create_smoke_effect_at_entity_position(entity)
- end
- end
- else
- -- Maybe it is a ghost?
- if revive_ghosts then
- if entity.name == "entity-ghost" then
- local revived_entity = util.revive_entity_ghost_and_raise_event(entity, player, false)
- if revived_entity then
- create_smoke_effect_at_entity_position(revived_entity)
- end
- elseif entity.name == "tile-ghost" then
- local surface = entity.surface
- local position = entity.position
- -- We don't use the function in util because we want to raise the event once for all revived tiles.
- local collided_enitties = entity.revive()
- if collided_enitties then
- -- Revived. Prepare the raise the event.
- if not revived_tile_positions then
- revived_tile_positions = {}
- end
- table.insert(revived_tile_positions, position)
- create_smoke_at(surface, position)
- end
- end
- end
- end
- end
- end
- else
- -- No right to use.
- player.print({ "message.creative-mode_no-right-to-use-magic-wand" })
- end
+ if item_name == creative_mode_defines.names.items.magic_wand_healer then
+ if rights.can_player_use_healer_magic_wand(player) then
+ -- Heal the selected entities and revive the ghost entities.
+ local revive_ghosts = magic_wand_healer.get_revive_ghosts(player)
+ -- Prepare to fire events.
+ local revived_tile_positions
+ for _, entity in ipairs(entities) do
+ if entity.valid then -- It is possible that the entity becomes invalid.
+ local health = entity.health
+ if health ~= nil then
+ -- The entity has health. It can be healed.
+ if entity.force and magic_wand_healer.get_heal_entities_on_force(player, entity.force) then
+ local max_health = entity.prototype.get_max_health() -- For all entities in general
+ if entity.type == "character" then -- But players have individual and force bonuses to max health
+ local p = entity.player
+ max_health = max_health + p.force.character_health_bonus + p.character_health_bonus
+ end
+ if health < max_health then
+ -- Heal it.
+ entity.health = max_health
+ create_smoke_effect_at_entity_position(entity)
+ end
+ end
+ else
+ -- Maybe it is a ghost?
+ if revive_ghosts then
+ if entity.name == "entity-ghost" then
+ local revived_entity = util.revive_entity_ghost_and_raise_event(entity, player, false)
+ if revived_entity then
+ create_smoke_effect_at_entity_position(revived_entity)
+ end
+ elseif entity.name == "tile-ghost" then
+ local surface = entity.surface
+ local position = entity.position
+ -- We don't use the function in util because we want to raise the event once for all revived tiles.
+ local collided_enitties = entity.revive()
+ if collided_enitties then
+ -- Revived. Prepare the raise the event.
+ if not revived_tile_positions then
+ revived_tile_positions = {}
+ end
+ table.insert(revived_tile_positions, position)
+ create_smoke_at(surface, position)
+ end
+ end
+ end
+ end
+ end
+ end
+ else
+ -- No right to use.
+ player.print({ "message.creative-mode_no-right-to-use-magic-wand" })
+ end
- return true
- end
+ return true
+ end
- return false
+ return false
end
-- Handler of the on_player_alt_selected_area event.
-- Returns whether the event is consumed and hence no need to further pass it to other handlers.
function magic_wand_healer.on_player_alt_selected_area(player, area, item_name, entities, tiles)
- if item_name == creative_mode_defines.names.items.magic_wand_healer then
- if rights.can_player_use_healer_magic_wand(player) then
- -- Lower the health of the selected entities or simply kill them.
- local action = magic_wand_healer.get_alt_mode_action(player)
- local dont_affect_player_characters = magic_wand_healer.get_alt_mode_dont_affect_player_characters(player)
- local dont_affect_indestructible_entities =
- magic_wand_healer.get_alt_mode_dont_affect_indestructible_entities(player)
- for _, entity in ipairs(entities) do
- if entity.valid then -- It is possible that the entity becomes invalid.
- -- Make sure the entity can be killed.
- if entity.health ~= nil then
- if entity.force and magic_wand_healer.get_alt_mode_apply_on_force(player, entity.force) then
- if not dont_affect_player_characters or not util.get_character_owning_player(entity) then
- if not dont_affect_indestructible_entities or entity.destructible then
- if action == magic_wand_healer.alt_mode_action.set_hp_to_one then
- -- Lower the health.
- if entity.health > 1 then
- create_smoke_effect_at_entity_position(entity)
- entity.health = 1
- end
- elseif action == magic_wand_healer.alt_mode_action.kill then
- -- Kill.
- create_smoke_effect_at_entity_position(entity)
- util.kill_entity_and_raise_event(entity, player)
- end
- end
- end
- end
- end
- end
- end
- else
- -- No right to use.
- player.print({ "message.creative-mode_no-right-to-use-magic-wand" })
- end
+ if item_name == creative_mode_defines.names.items.magic_wand_healer then
+ if rights.can_player_use_healer_magic_wand(player) then
+ -- Lower the health of the selected entities or simply kill them.
+ local action = magic_wand_healer.get_alt_mode_action(player)
+ local dont_affect_player_characters = magic_wand_healer.get_alt_mode_dont_affect_player_characters(player)
+ local dont_affect_indestructible_entities =
+ magic_wand_healer.get_alt_mode_dont_affect_indestructible_entities(player)
+ for _, entity in ipairs(entities) do
+ if entity.valid then -- It is possible that the entity becomes invalid.
+ -- Make sure the entity can be killed.
+ if entity.health ~= nil then
+ if entity.force and magic_wand_healer.get_alt_mode_apply_on_force(player, entity.force) then
+ if not dont_affect_player_characters or not util.get_character_owning_player(entity) then
+ if not dont_affect_indestructible_entities or entity.destructible then
+ if action == magic_wand_healer.alt_mode_action.set_hp_to_one then
+ -- Lower the health.
+ if entity.health > 1 then
+ create_smoke_effect_at_entity_position(entity)
+ entity.health = 1
+ end
+ elseif action == magic_wand_healer.alt_mode_action.kill then
+ -- Kill.
+ create_smoke_effect_at_entity_position(entity)
+ util.kill_entity_and_raise_event(entity, player)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ else
+ -- No right to use.
+ player.print({ "message.creative-mode_no-right-to-use-magic-wand" })
+ end
- return true
- end
+ return true
+ end
- return false
+ return false
end
diff --git a/scripts/magic-wand-modifier.lua b/scripts/magic-wand-modifier.lua
index d1f25c3..41c5d10 100644
--- a/scripts/magic-wand-modifier.lua
+++ b/scripts/magic-wand-modifier.lua
@@ -1,331 +1,336 @@
-- This file contains variables or functions that are related to the Modifier magic wand in this mod.
if not magic_wand_modifier then
- magic_wand_modifier = {}
+ magic_wand_modifier = {}
end
-- Gets whether player characters should be ignored by the standard selection mode for the given player.
function magic_wand_modifier.get_std_ignore_player_characters(player)
- if storage.creative_mode.magic_wand_settings.modifier[player.index] then
- if storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_player_characters ~= nil then
- return storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_player_characters
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ if storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_player_characters ~= nil then
+ return storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_player_characters
+ end
+ end
+ return true
end
-- Sets whether player characters should be ignored by the standard selection mode for the given player.
function magic_wand_modifier.set_std_ignore_player_characters(player, ignore_player_characters)
- if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
- storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_player_characters =
- ignore_player_characters
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_player_characters =
+ ignore_player_characters
end
----
-- Gets whether healthless entities should be ignored by the standard selection mode for the given player.
function magic_wand_modifier.get_std_ignore_healthess_entities(player)
- if storage.creative_mode.magic_wand_settings.modifier[player.index] then
- if storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_healthess_entities ~= nil then
- return storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_healthess_entities
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ if storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_healthess_entities ~= nil then
+ return storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_healthess_entities
+ end
+ end
+ return true
end
-- Sets whether healthless entities should be ignored by the standard selection mode for the given player.
function magic_wand_modifier.set_std_ignore_healthess_entities(player, ignore_healthless_entities)
- if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
- storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_healthess_entities =
- ignore_healthless_entities
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_healthess_entities =
+ ignore_healthless_entities
end
----
-- Gets whether indestructible entities should be ignored by the standard selection mode for the given player.
function magic_wand_modifier.get_std_ignore_indestructible_entities(player)
- if storage.creative_mode.magic_wand_settings.modifier[player.index] then
- if storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_indestructible_entities ~= nil then
- return storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_indestructible_entities
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ if
+ storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_indestructible_entities ~= nil
+ then
+ return storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_indestructible_entities
+ end
+ end
+ return true
end
-- Sets whether indestructible entities should be ignored by the standard selection mode for the given player.
function magic_wand_modifier.set_std_ignore_indestructible_entities(player, standard_ignore_indestructible_entities)
- if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
- storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_indestructible_entities =
- standard_ignore_indestructible_entities
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.modifier[player.index].standard_ignore_indestructible_entities =
+ standard_ignore_indestructible_entities
end
----
-- Gets whether the entities belonging the given force can be selected by standard selection mode for the given player.
function magic_wand_modifier.get_std_select_entities_on_force(player, force)
- if storage.creative_mode.magic_wand_settings.modifier[player.index] then
- if storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces ~= nil then
- return storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces[force.name] ~= false
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ if storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces ~= nil then
+ return storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces[force.name] ~= false
+ end
+ end
+ return true
end
-- Sets whether the entities belonging the given force can be selected by standard selection mode for the given player.
function magic_wand_modifier.set_std_select_entities_on_force(player, force, can_select)
- if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
- storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
- end
- if not storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces then
- storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces = {}
- end
- storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces[force.name] = can_select
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
+ end
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces then
+ storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces = {}
+ end
+ storage.creative_mode.magic_wand_settings.modifier[player.index].standard_forces[force.name] = can_select
end
----
-- Gets whether player characters should be ignored by the alternate selection mode for the given player.
function magic_wand_modifier.get_alt_ignore_player_characters(player)
- if storage.creative_mode.magic_wand_settings.modifier[player.index] then
- if storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_player_characters ~= nil then
- return storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_player_characters
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ if storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_player_characters ~= nil then
+ return storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_player_characters
+ end
+ end
+ return true
end
-- Sets whether player characters should be ignored by the alternate selection mode for the given player.
function magic_wand_modifier.set_alt_ignore_player_characters(player, ignore_player_characters)
- if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
- storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_player_characters =
- ignore_player_characters
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_player_characters =
+ ignore_player_characters
end
----
-- Gets whether healthless entities should be ignored by the alternate selection mode for the given player.
function magic_wand_modifier.get_alt_ignore_healthess_entities(player)
- if storage.creative_mode.magic_wand_settings.modifier[player.index] then
- if storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_healthess_entities ~= nil then
- return storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_healthess_entities
- end
- end
- return false
+ if storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ if storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_healthess_entities ~= nil then
+ return storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_healthess_entities
+ end
+ end
+ return false
end
-- Sets whether healthless entities should be ignored by the alternate selection mode for the given player.
function magic_wand_modifier.set_alt_ignore_healthess_entities(player, ignore_healthless_entities)
- if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
- storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_healthess_entities =
- ignore_healthless_entities
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_healthess_entities =
+ ignore_healthless_entities
end
----
-- Gets whether indestructible entities should be ignored by the alternate selection mode for the given player.
function magic_wand_modifier.get_alt_ignore_indestructible_entities(player)
- if storage.creative_mode.magic_wand_settings.modifier[player.index] then
- if storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_indestructible_entities ~= nil then
- return storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_indestructible_entities
- end
- end
- return false
+ if storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ if
+ storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_indestructible_entities ~= nil
+ then
+ return storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_indestructible_entities
+ end
+ end
+ return false
end
-- Sets whether indestructible entities should be ignored by the alternate selection mode for the given player.
function magic_wand_modifier.set_alt_ignore_indestructible_entities(player, alternate_ignore_indestructible_entities)
- if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
- storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
- end
- storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_indestructible_entities =
- alternate_ignore_indestructible_entities
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
+ end
+ storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_ignore_indestructible_entities =
+ alternate_ignore_indestructible_entities
end
----
-- Gets whether the entities belonging the given force can be selected by alternate selection mode for the given player.
function magic_wand_modifier.get_alt_select_entities_on_force(player, force)
- if storage.creative_mode.magic_wand_settings.modifier[player.index] then
- if storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces ~= nil then
- return storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces[force.name] ~= false
- end
- end
- return true
+ if storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ if storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces ~= nil then
+ return storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces[force.name] ~= false
+ end
+ end
+ return true
end
-- Sets whether the entities belonging the given force can be selected by alternate selection mode for the given player.
function magic_wand_modifier.set_alt_select_entities_on_force(player, force, can_select)
- if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
- storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
- end
- if not storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces then
- storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces = {}
- end
- storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces[force.name] = can_select
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index] then
+ storage.creative_mode.magic_wand_settings.modifier[player.index] = {}
+ end
+ if not storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces then
+ storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces = {}
+ end
+ storage.creative_mode.magic_wand_settings.modifier[player.index].alternate_forces[force.name] = can_select
end
------------------------------------------------------
-- Creates smoke effect at the given position in the given surface.
local function create_smoke_at(surface, position)
- surface.create_trivial_smoke {
- name = creative_mode_defines.names.entities.magic_wand_smoke_modifier,
- position = position
- }
+ surface.create_trivial_smoke({
+ name = creative_mode_defines.names.entities.magic_wand_smoke_modifier,
+ position = position,
+ })
end
-- Creates smoke effect at the entity's position.
function magic_wand_modifier.create_smoke_effect_at_entity_position(entity)
- create_smoke_at(entity.surface, entity.position)
+ create_smoke_at(entity.surface, entity.position)
end
------------------------------------------------------
-- Returns whether the given entity can be selected by the given player according to the given tests.
local function check_can_select_entity(
- player,
- entity,
- ignore_player_characters,
- ignore_healthless_entities,
- ignore_indestructible_entities,
- get_select_entities_on_force_function)
- if entity.valid then
- if entity.name ~= creative_mode_defines.names.entities.magic_wand_smoke_modifier then
- if entity.health ~= nil or not ignore_healthless_entities then
- if entity.force and get_select_entities_on_force_function(player, entity.force) then
- if not ignore_player_characters or not util.get_character_owning_player(entity) then
- if not ignore_indestructible_entities or entity.destructible then
- return true
- end
- end
- end
- end
- end
- end
- return false
+ player,
+ entity,
+ ignore_player_characters,
+ ignore_healthless_entities,
+ ignore_indestructible_entities,
+ get_select_entities_on_force_function
+)
+ if entity.valid then
+ if entity.name ~= creative_mode_defines.names.entities.magic_wand_smoke_modifier then
+ if entity.health ~= nil or not ignore_healthless_entities then
+ if entity.force and get_select_entities_on_force_function(player, entity.force) then
+ if not ignore_player_characters or not util.get_character_owning_player(entity) then
+ if not ignore_indestructible_entities or entity.destructible then
+ return true
+ end
+ end
+ end
+ end
+ end
+ end
+ return false
end
-- Handler of the on_player_selected_area event.
-- Returns whether the event is consumed and hence no need to further pass it to other handlers.
function magic_wand_modifier.on_player_selected_area(player, area, item_name, entities, tiles)
- if item_name == creative_mode_defines.names.items.magic_wand_modifier then
- if rights.can_player_use_modifier_magic_wand(player) then
- -- Show the modification popup for the selected entities.
- -- Destroy the previous popup first.
- gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
-
- -- Filter out the unwanted entities and record the remaining ones.
- storage.creative_mode.modifier_magic_wand_selection[player.index] = {}
- local ignore_player_characters = magic_wand_modifier.get_std_ignore_player_characters(player)
- local ignore_healthless_entities = magic_wand_modifier.get_std_ignore_healthess_entities(player)
- local ignore_indestructible_entities = magic_wand_modifier.get_std_ignore_indestructible_entities(player)
- for _, entity in pairs(entities) do
- if
- check_can_select_entity(
- player,
- entity,
- ignore_player_characters,
- ignore_healthless_entities,
- ignore_indestructible_entities,
- magic_wand_modifier.get_std_select_entities_on_force
- )
- then
- table.insert(storage.creative_mode.modifier_magic_wand_selection[player.index], entity)
- end
- end
-
- -- Show popup.
- if #storage.creative_mode.modifier_magic_wand_selection[player.index] > 0 then
- gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, true)
-
- -- Mark the quick actions to be cleared once a new modification is received.
- if not storage.creative_mode.modifier_magic_wand_quick_actions[player.index] then
- storage.creative_mode.modifier_magic_wand_quick_actions[player.index] = {}
- end
- storage.creative_mode.modifier_magic_wand_quick_actions[player.index].reset_when_new_action_received = true
- end
- else
- -- No right to use.
- player.print {"message.creative-mode_no-right-to-use-magic-wand"}
- end
-
- return true
- end
-
- return false
+ if item_name == creative_mode_defines.names.items.magic_wand_modifier then
+ if rights.can_player_use_modifier_magic_wand(player) then
+ -- Show the modification popup for the selected entities.
+ -- Destroy the previous popup first.
+ gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, false)
+
+ -- Filter out the unwanted entities and record the remaining ones.
+ storage.creative_mode.modifier_magic_wand_selection[player.index] = {}
+ local ignore_player_characters = magic_wand_modifier.get_std_ignore_player_characters(player)
+ local ignore_healthless_entities = magic_wand_modifier.get_std_ignore_healthess_entities(player)
+ local ignore_indestructible_entities = magic_wand_modifier.get_std_ignore_indestructible_entities(player)
+ for _, entity in pairs(entities) do
+ if
+ check_can_select_entity(
+ player,
+ entity,
+ ignore_player_characters,
+ ignore_healthless_entities,
+ ignore_indestructible_entities,
+ magic_wand_modifier.get_std_select_entities_on_force
+ )
+ then
+ table.insert(storage.creative_mode.modifier_magic_wand_selection[player.index], entity)
+ end
+ end
+
+ -- Show popup.
+ if #storage.creative_mode.modifier_magic_wand_selection[player.index] > 0 then
+ gui_menu_magicwand.create_or_destroy_modification_popup_for_player(player, true)
+
+ -- Mark the quick actions to be cleared once a new modification is received.
+ if not storage.creative_mode.modifier_magic_wand_quick_actions[player.index] then
+ storage.creative_mode.modifier_magic_wand_quick_actions[player.index] = {}
+ end
+ storage.creative_mode.modifier_magic_wand_quick_actions[player.index].reset_when_new_action_received = true
+ end
+ else
+ -- No right to use.
+ player.print({ "message.creative-mode_no-right-to-use-magic-wand" })
+ end
+
+ return true
+ end
+
+ return false
end
-- Handler of the on_player_alt_selected_area event.
-- Returns whether the event is consumed and hence no need to further pass it to other handlers.
function magic_wand_modifier.on_player_alt_selected_area(player, area, item_name, entities, tiles)
- if item_name == creative_mode_defines.names.items.magic_wand_modifier then
- if rights.can_player_use_modifier_magic_wand(player) then
- -- Apply the recorded actions to the selected entities.
-
- -- Do nothing if no action has been recorded.
- if not storage.creative_mode.modifier_magic_wand_quick_actions[player.index] then
- return true
- end
- local actions = storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions
- if not actions or #actions <= 0 then
- return true
- end
-
- -- Filter entities.
- local filtered_entities = {}
- local ignore_player_characters = magic_wand_modifier.get_alt_ignore_player_characters(player)
- local ignore_healthless_entities = magic_wand_modifier.get_alt_ignore_healthess_entities(player)
- local ignore_indestructible_entities = magic_wand_modifier.get_alt_ignore_indestructible_entities(player)
- for _, entity in pairs(entities) do
- if
- check_can_select_entity(
- player,
- entity,
- ignore_player_characters,
- ignore_healthless_entities,
- ignore_indestructible_entities,
- magic_wand_modifier.get_alt_select_entities_on_force
- )
- then
- table.insert(filtered_entities, entity)
-
- -- Create smoke.
- magic_wand_modifier.create_smoke_effect_at_entity_position(entity)
- end
- end
-
- -- Apply actions.
- for _, action in ipairs(actions) do
- local cheat_gui_data = gui_menu_magicwand.action_code_to_cheat_gui_data[action.code]
- cheats.apply_cheat_to_targets(
- player,
- filtered_entities,
- cheats.magic_wand_modifications,
- cheat_gui_data.cheat_data,
- action.value,
- true
- )
- gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
- gui_menu_magicwand.modification_popup_cheats_gui_data,
- cheat_gui_data
- )
- end
- else
- -- No right to use.
- player.print {"message.creative-mode_no-right-to-use-magic-wand"}
- end
-
- return true
- end
-
- return false
+ if item_name == creative_mode_defines.names.items.magic_wand_modifier then
+ if rights.can_player_use_modifier_magic_wand(player) then
+ -- Apply the recorded actions to the selected entities.
+
+ -- Do nothing if no action has been recorded.
+ if not storage.creative_mode.modifier_magic_wand_quick_actions[player.index] then
+ return true
+ end
+ local actions = storage.creative_mode.modifier_magic_wand_quick_actions[player.index].actions
+ if not actions or #actions <= 0 then
+ return true
+ end
+
+ -- Filter entities.
+ local filtered_entities = {}
+ local ignore_player_characters = magic_wand_modifier.get_alt_ignore_player_characters(player)
+ local ignore_healthless_entities = magic_wand_modifier.get_alt_ignore_healthess_entities(player)
+ local ignore_indestructible_entities = magic_wand_modifier.get_alt_ignore_indestructible_entities(player)
+ for _, entity in pairs(entities) do
+ if
+ check_can_select_entity(
+ player,
+ entity,
+ ignore_player_characters,
+ ignore_healthless_entities,
+ ignore_indestructible_entities,
+ magic_wand_modifier.get_alt_select_entities_on_force
+ )
+ then
+ table.insert(filtered_entities, entity)
+
+ -- Create smoke.
+ magic_wand_modifier.create_smoke_effect_at_entity_position(entity)
+ end
+ end
+
+ -- Apply actions.
+ for _, action in ipairs(actions) do
+ local cheat_gui_data = gui_menu_magicwand.action_code_to_cheat_gui_data[action.code]
+ cheats.apply_cheat_to_targets(
+ player,
+ filtered_entities,
+ cheats.magic_wand_modifications,
+ cheat_gui_data.cheat_data,
+ action.value,
+ true
+ )
+ gui_menu_cheats.update_cheat_status_in_cheats_menu_for_all_players(
+ gui_menu_magicwand.modification_popup_cheats_gui_data,
+ cheat_gui_data
+ )
+ end
+ else
+ -- No right to use.
+ player.print({ "message.creative-mode_no-right-to-use-magic-wand" })
+ end
+
+ return true
+ end
+
+ return false
end
diff --git a/scripts/mod-compatibler.lua b/scripts/mod-compatibler.lua
index 874e304..f2a2408 100644
--- a/scripts/mod-compatibler.lua
+++ b/scripts/mod-compatibler.lua
@@ -1,6 +1,6 @@
-- This file manages variables or functions that are related to the compatibility to other mods.
if not mod_compatibler then
- mod_compatibler = {}
+ mod_compatibler = {}
end
-------------------------------------------------
@@ -8,15 +8,15 @@ end
-- Returns whether the instant blueprint mod has been installed.
function mod_compatibler.is_instant_blueprint_installed()
- return script.active_mods["instant-blueprints"]
+ return script.active_mods["instant-blueprints"]
end
-- Returns whether the instant blueprint mod has been installed and is activated for the given player.
function mod_compatibler.is_instant_blueprint_installed_and_activated_for_player(player)
- return mod_compatibler.is_instant_blueprint_installed() and player.cheat_mode
+ return mod_compatibler.is_instant_blueprint_installed() and player.cheat_mode
end
-- Returns whether the instant blueprint mod has been installed and is activated for the player of given index.
function mod_compatibler.is_instant_blueprint_installed_and_activated_for_player_index(player_index)
- return mod_compatibler.is_instant_blueprint_installed_and_activated_for_player(game.players[player_index])
+ return mod_compatibler.is_instant_blueprint_installed_and_activated_for_player(game.players[player_index])
end
diff --git a/scripts/random-item-source.lua b/scripts/random-item-source.lua
index e5061a6..8654a2d 100644
--- a/scripts/random-item-source.lua
+++ b/scripts/random-item-source.lua
@@ -1,153 +1,153 @@
-- This file contains variables or functions that are related to the Random Item Source in this mod.
if not random_item_source then
- random_item_source = {}
+ random_item_source = {}
end
-- The position shift for item output for each direction.
local random_item_source_shift = {
- -- The values are shifted from the original mod so surface.can_place_entity can work properly.
- [defines.direction.north] = {x1 = 0.3, y1 = 0.9, x2 = -0.3, y2 = 0.9, x0 = 0, y0 = 0.9},
- [defines.direction.east] = {x1 = -0.9, y1 = 0.3, x2 = -0.9, y2 = -0.3, x0 = -0.9, y0 = 0},
- [defines.direction.south] = {x1 = -0.3, y1 = -0.9, x2 = 0.3, y2 = -0.9, x0 = 0, y0 = -0.9},
- [defines.direction.west] = {x1 = 0.9, y1 = -0.3, x2 = 0.9, y2 = 0.3, x0 = 0.9, y0 = 0}
+ -- The values are shifted from the original mod so surface.can_place_entity can work properly.
+ [defines.direction.north] = { x1 = 0.3, y1 = 0.9, x2 = -0.3, y2 = 0.9, x0 = 0, y0 = 0.9 },
+ [defines.direction.east] = { x1 = -0.9, y1 = 0.3, x2 = -0.9, y2 = -0.3, x0 = -0.9, y0 = 0 },
+ [defines.direction.south] = { x1 = -0.3, y1 = -0.9, x2 = 0.3, y2 = -0.9, x0 = 0, y0 = -0.9 },
+ [defines.direction.west] = { x1 = 0.9, y1 = -0.3, x2 = 0.9, y2 = 0.3, x0 = 0.9, y0 = 0 },
}
-- Picks the name of item to be generated according to the given array of circuit signals.
local function pick_item_from_signals(signals)
- if signals == nil then
- return nil
- end
+ if signals == nil then
+ return nil
+ end
- -- Get total count.
- local total_count = 0
- local is_all_non_items = true
- for _, signal_data in pairs(signals) do
- total_count = total_count + signal_data.count
- is_all_non_items = is_all_non_items and signal_data.signal.type ~= "item"
- end
+ -- Get total count.
+ local total_count = 0
+ local is_all_non_items = true
+ for _, signal_data in pairs(signals) do
+ total_count = total_count + signal_data.count
+ is_all_non_items = is_all_non_items and signal_data.signal.type ~= "item"
+ end
- if is_all_non_items or total_count <= 0 then
- -- All signals are non items. No item will be picked.
- return nil
- end
+ if is_all_non_items or total_count <= 0 then
+ -- All signals are non items. No item will be picked.
+ return nil
+ end
- -- Pick signal by count.
- total_count = util.random(1, total_count)
- for _, signal_data in pairs(signals) do
- total_count = total_count - signal_data.count
- if total_count <= 0 then
- local signal = signal_data.signal
- if signal.type == "item" then
- return signal.name
- end
- return nil
- end
- end
+ -- Pick signal by count.
+ total_count = util.random(1, total_count)
+ for _, signal_data in pairs(signals) do
+ total_count = total_count - signal_data.count
+ if total_count <= 0 then
+ local signal = signal_data.signal
+ if signal.type == "item" then
+ return signal.name
+ end
+ return nil
+ end
+ end
end
-- Processes the random_item_source_data table in storage.
function random_item_source.tick()
- -- Loop through the table of matter-source data to output items.
- for index, random_item_source_data in ipairs(storage.creative_mode.random_item_source_data) do
- -- Get the actual random-item-source entity.
- local random_item_source = random_item_source_data.entity
- -- Work only if the entity is valid.
- if random_item_source.valid then
- -- Check if it is active and also not marked for deconstruction.
- if random_item_source.active and not random_item_source.to_be_deconstructed(random_item_source.force) then
- -- Give the random-item-source free energy.
- random_item_source.energy = 100000
- -- Check if it is enabled according to its circuit network state and logistic network state.
- if util.is_inserter_enabled(random_item_source) then
- local controller = random_item_source.get_control_behavior()
- if controller then
- local green_network = controller.get_circuit_network(defines.wire_type.green)
- local red_network = controller.get_circuit_network(defines.wire_type.red)
+ -- Loop through the table of matter-source data to output items.
+ for index, random_item_source_data in ipairs(storage.creative_mode.random_item_source_data) do
+ -- Get the actual random-item-source entity.
+ local random_item_source = random_item_source_data.entity
+ -- Work only if the entity is valid.
+ if random_item_source.valid then
+ -- Check if it is active and also not marked for deconstruction.
+ if random_item_source.active and not random_item_source.to_be_deconstructed(random_item_source.force) then
+ -- Give the random-item-source free energy.
+ random_item_source.energy = 100000
+ -- Check if it is enabled according to its circuit network state and logistic network state.
+ if util.is_inserter_enabled(random_item_source) then
+ local controller = random_item_source.get_control_behavior()
+ if controller then
+ local green_network = controller.get_circuit_network(defines.wire_type.green)
+ local red_network = controller.get_circuit_network(defines.wire_type.red)
- -- Get the left and right item names.
- local slot1 = nil
- if green_network then
- slot1 = pick_item_from_signals(green_network.signals)
- end
- local slot2 = nil
- if red_network then
- slot2 = pick_item_from_signals(red_network.signals)
- end
+ -- Get the left and right item names.
+ local slot1 = nil
+ if green_network then
+ slot1 = pick_item_from_signals(green_network.signals)
+ end
+ local slot2 = nil
+ if red_network then
+ slot2 = pick_item_from_signals(red_network.signals)
+ end
- -- Get the random-item-source's surface, position and shift for output, so we can drop items accordingly.
- local surf = random_item_source.surface
- local pos = random_item_source.position
- local dir = random_item_source.direction
- local shift = random_item_source_shift[dir]
- local opposite_dir = util.oppositedirection(dir)
- -- Output for slot1.
- if slot1 == nil then
- random_item_source_data.slot1_inserted_players = nil
- random_item_source_data.slot1_last_item_position_on_belt = nil
- else
- item_providers_util.output_or_remove_item(
- surf,
- pos,
- shift.x1,
- shift.y1,
- opposite_dir,
- slot1,
- output_or_remove_item_operation_mode.output_mode,
- 1,
- random_item_source_data
- )
- end
- -- Output for slot2.
- if slot2 == nil then
- random_item_source_data.slot2_inserted_players = nil
- random_item_source_data.slot2_last_item_position_on_belt = nil
- else
- item_providers_util.output_or_remove_item(
- surf,
- pos,
- shift.x2,
- shift.y2,
- opposite_dir,
- slot2,
- output_or_remove_item_operation_mode.output_mode,
- 2,
- random_item_source_data
- )
- end
- end
- end
- end
- else
- -- Remove invalid entity.
- table.remove(storage.creative_mode.random_item_source_data, index)
- end
- end
+ -- Get the random-item-source's surface, position and shift for output, so we can drop items accordingly.
+ local surf = random_item_source.surface
+ local pos = random_item_source.position
+ local dir = random_item_source.direction
+ local shift = random_item_source_shift[dir]
+ local opposite_dir = util.oppositedirection(dir)
+ -- Output for slot1.
+ if slot1 == nil then
+ random_item_source_data.slot1_inserted_players = nil
+ random_item_source_data.slot1_last_item_position_on_belt = nil
+ else
+ item_providers_util.output_or_remove_item(
+ surf,
+ pos,
+ shift.x1,
+ shift.y1,
+ opposite_dir,
+ slot1,
+ output_or_remove_item_operation_mode.output_mode,
+ 1,
+ random_item_source_data
+ )
+ end
+ -- Output for slot2.
+ if slot2 == nil then
+ random_item_source_data.slot2_inserted_players = nil
+ random_item_source_data.slot2_last_item_position_on_belt = nil
+ else
+ item_providers_util.output_or_remove_item(
+ surf,
+ pos,
+ shift.x2,
+ shift.y2,
+ opposite_dir,
+ slot2,
+ output_or_remove_item_operation_mode.output_mode,
+ 2,
+ random_item_source_data
+ )
+ end
+ end
+ end
+ end
+ else
+ -- Remove invalid entity.
+ table.remove(storage.creative_mode.random_item_source_data, index)
+ end
+ end
end
-- Returns the entity data for the given random item source entity.
function random_item_source.get_data_for_entity(entity)
- for _, data in ipairs(storage.creative_mode.random_item_source_data) do
- if data.entity == entity then
- return data
- end
- end
- return nil
+ for _, data in ipairs(storage.creative_mode.random_item_source_data) do
+ if data.entity == entity then
+ return data
+ end
+ end
+ return nil
end
-- Copies the additional configurations from the source entity to the destination entity.
function random_item_source.on_entity_copied_pasted(source, destination)
- local source_data = random_item_source.get_data_for_entity(source)
- local destination_data = random_item_source.get_data_for_entity(destination)
- if not source_data then
- return
- end
- if not destination_data then
- return
- end
- destination_data.can_insert_to_vehicle = source_data.can_insert_to_vehicle
- destination_data.can_insert_to_player = source_data.can_insert_to_player
- destination_data.insert_only_once_to_player = source_data.insert_only_once_to_player
- destination_data.insert_to_player_amount = source_data.insert_to_player_amount
- destination_data.insert_to_player_by_stack = source_data.insert_to_player_by_stack
- destination_data.can_drop_on_ground = source_data.can_drop_on_ground
+ local source_data = random_item_source.get_data_for_entity(source)
+ local destination_data = random_item_source.get_data_for_entity(destination)
+ if not source_data then
+ return
+ end
+ if not destination_data then
+ return
+ end
+ destination_data.can_insert_to_vehicle = source_data.can_insert_to_vehicle
+ destination_data.can_insert_to_player = source_data.can_insert_to_player
+ destination_data.insert_only_once_to_player = source_data.insert_only_once_to_player
+ destination_data.insert_to_player_amount = source_data.insert_to_player_amount
+ destination_data.insert_to_player_by_stack = source_data.insert_to_player_by_stack
+ destination_data.can_drop_on_ground = source_data.can_drop_on_ground
end
diff --git a/scripts/remote-interface.lua b/scripts/remote-interface.lua
index c4a7eca..8796cb5 100644
--- a/scripts/remote-interface.lua
+++ b/scripts/remote-interface.lua
@@ -1,6 +1,6 @@
-- This file manages remote-interface-related variables or functions that are specific for this mod.
if not remote_interface then
- remote_interface = {}
+ remote_interface = {}
end
-- Command for showing all available commands for this mod.
@@ -14,15 +14,13 @@ local command_disable = '/c remote.call("' .. creative_mode_defines.names.interf
table.insert(command_help_list, command_disable)
-- Name of the function for registering remote functions so they can be called via the modding UI.
-remote_interface.register_remote_function_name =
- 'remote.call("' ..
- creative_mode_defines.names.interface ..
- '", "register_remote_function_to_modding_ui", "