z_mirror/CursorEnhancements

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

raiguardFix interface paradigm Post-init setup doesn't exist848a4d4

proxies
1.2 KiB47 linesraw
1local util = {}
2
3function util.apply_overrides(data, overrides, item_prototypes)
4  for item, next_item in pairs(overrides) do
5    if item_prototypes[item] and (next_item and item_prototypes[next_item] or true) then
6      local old_next_item
7      -- this entity
8      local item_data = data[item]
9      if item_data then
10        old_next_item = item_data.next
11        if next_item then
12          item_data.next = next_item
13        else
14          item_data.next = nil
15          if not item_data.previous then
16            data[item] = nil
17          end
18        end
19      elseif next_item then
20        data[item] = {next=next_item}
21      end
22      -- old next's previous
23      if old_next_item then
24        local old_next_data = data[old_next_item]
25        if old_next_data then
26          old_next_data.previous = nil
27          if not old_next_data.next then
28            data[old_next_item] = nil
29          end
30        end
31      end
32      -- new next's previous
33      if next_item then
34        local next_item_data = data[next_item]
35        if next_item_data then
36          next_item_data.previous = item
37        elseif next_item then
38          data[next_item] = {previous=item}
39        end
40      end
41    end
42  end
43
44  return data
45end
46
47return util