z_mirror/BlueprintTools

git clone https://git.raiguard.me/z_mirror/BlueprintTools

Caleb HeuerGet control scripting working00b37f1

trunk
1.4 KiB54 linesraw
1local constants = require("constants")
2
3local buttons_gui = require("scripts.gui.buttons")
4local import_string_gui = require("scripts.gui.import-string")
5local library_shortcuts_gui = require("scripts.gui.library-shortcuts")
6
7local player_data = {}
8
9function player_data.init(player_index)
10  --- @class PlayerTable
11  storage.players[player_index] = {
12    flags = {
13      blueprint_buttons_shown = false,
14      deconstruction_planner_buttons_shown = false,
15      holding_temporary_item = false,
16      setting_temporary_item = false,
17      upgrade_planner_buttons_shown = false,
18    },
19    guis = {},
20    set_tiles_settings = {
21      fill_gaps = true,
22      margin = 0,
23      tile = "landfill",
24    },
25    settings = {},
26  }
27end
28
29function player_data.update_settings(player, player_table)
30  local mod_settings = player.mod_settings
31  local settings = {}
32
33  for internal, prototype in pairs(constants.settings) do
34    settings[internal] = mod_settings[prototype].value
35  end
36
37  player_table.settings = settings
38end
39
40function player_data.refresh(player, player_table)
41  player_data.update_settings(player, player_table)
42
43  buttons_gui.refresh(player, player_table)
44  import_string_gui.destroy(player)
45  library_shortcuts_gui.refresh(player, player_table)
46
47  -- If the tile does not exist
48  if not prototypes.tile[player_table.set_tiles_settings.tile] then
49    -- Set it to `nil`
50    player_table.set_tiles_settings.tile = nil
51  end
52end
53
54return player_data