|
26 | 26 | --
|
27 | 27 | mod = openminer.mod_loader:register_mod("creative_inventory")
|
28 | 28 |
|
29 |
| -function show_creative_window(client, screen_width, screen_height, gui_scale) |
30 |
| - items = {} |
31 |
| - for k, v in pairs(openminer.registry:items()) do |
32 |
| - if k ~= 1 and not v:has_group("group:ci_ignore") then |
33 |
| - items[#items + 1] = {v:string_id()} |
| 29 | +mod:key { |
| 30 | + id = "creative_inventory", |
| 31 | + name = "Creative window", |
| 32 | + default_key = "H", |
| 33 | + |
| 34 | + callback = function(client, screen_width, screen_height, gui_scale) |
| 35 | + items = {} |
| 36 | + for k, v in pairs(openminer.registry:items()) do |
| 37 | + if k ~= 1 and not v:has_group("group:ci_ignore") then |
| 38 | + items[#items + 1] = {v:string_id()} |
| 39 | + end |
34 | 40 | end
|
35 |
| - end |
36 | 41 |
|
37 |
| - local gui = LuaGUI.new() |
| 42 | + local gui = LuaGUI.new() |
38 | 43 |
|
39 |
| - gui:set_size(195, 136) |
40 |
| - gui:set_centered(true) |
| 44 | + gui:set_size(195, 136) |
| 45 | + gui:set_centered(true) |
41 | 46 |
|
42 |
| - gui:image { |
43 |
| - name = "img_background", |
44 |
| - pos = {x = 0, y = 0}, |
| 47 | + gui:image { |
| 48 | + name = "img_background", |
| 49 | + pos = {x = 0, y = 0}, |
45 | 50 |
|
46 |
| - texture = mod:path() .. "/textures/gui/creative_window.png", |
47 |
| - clip = {x = 0, y = 0, width = 195, height = 136}, |
48 |
| - } |
| 51 | + texture = mod:path() .. "/textures/gui/creative_window.png", |
| 52 | + clip = {x = 0, y = 0, width = 195, height = 136}, |
| 53 | + } |
49 | 54 |
|
50 |
| - gui:inventory_data { |
51 |
| - name = "inv_data", |
| 55 | + gui:inventory_data { |
| 56 | + name = "inv_data", |
52 | 57 |
|
53 |
| - width = 9, |
54 |
| - height = 7, |
| 58 | + width = 9, |
| 59 | + height = 7, |
55 | 60 |
|
56 |
| - items = items, |
| 61 | + items = items, |
57 | 62 |
|
58 |
| - is_unlimited = true, |
59 |
| - } |
| 63 | + is_unlimited = true, |
| 64 | + } |
60 | 65 |
|
61 |
| - gui:inventory { |
62 |
| - name = "inv_creative_items", |
63 |
| - pos = {x = 8, y = 17}, |
| 66 | + gui:inventory { |
| 67 | + name = "inv_creative_items", |
| 68 | + pos = {x = 8, y = 17}, |
64 | 69 |
|
65 |
| - inventory = { |
66 |
| - source = "temp", |
67 |
| - inventory_name = "inv_data", |
68 |
| - offset = 0, |
69 |
| - count = 9 * 5, |
70 |
| - }, |
| 70 | + inventory = { |
| 71 | + source = "temp", |
| 72 | + inventory_name = "inv_data", |
| 73 | + offset = 0, |
| 74 | + count = 9 * 5, |
| 75 | + }, |
71 | 76 |
|
72 |
| - size = {x = 9, y = 7} |
73 |
| - } |
| 77 | + size = {x = 9, y = 7} |
| 78 | + } |
74 | 79 |
|
75 |
| - gui:scroll_bar { |
76 |
| - name = "scroll_bar", |
77 |
| - pos = {x = 175, y = 18}, |
| 80 | + gui:scroll_bar { |
| 81 | + name = "scroll_bar", |
| 82 | + pos = {x = 175, y = 18}, |
78 | 83 |
|
79 |
| - texture = mod:path() .. "/textures/gui/tabs.png", |
80 |
| - clip = {x = 232, y = 0, width = 12, height = 15}, |
81 |
| - clip_selected = {x = 244, y = 0, width = 12, height = 15}, |
| 84 | + texture = mod:path() .. "/textures/gui/tabs.png", |
| 85 | + clip = {x = 232, y = 0, width = 12, height = 15}, |
| 86 | + clip_selected = {x = 244, y = 0, width = 12, height = 15}, |
82 | 87 |
|
83 |
| - widget = "inv_creative_items", |
| 88 | + widget = "inv_creative_items", |
84 | 89 |
|
85 |
| - min_y = 0, |
86 |
| - max_y = 110 - 15, |
87 |
| - } |
| 90 | + min_y = 0, |
| 91 | + max_y = 110 - 15, |
| 92 | + } |
88 | 93 |
|
89 |
| - gui:inventory { |
90 |
| - name = "inv_hotbar", |
91 |
| - pos = {x = 8, y = 111}, |
| 94 | + gui:inventory { |
| 95 | + name = "inv_hotbar", |
| 96 | + pos = {x = 8, y = 111}, |
92 | 97 |
|
93 |
| - inventory = { |
94 |
| - source = "player", |
95 |
| - player = "player", |
96 |
| - inventory_name = "main", |
97 |
| - offset = 0, |
98 |
| - count = 9, |
99 |
| - }, |
| 98 | + inventory = { |
| 99 | + source = "player", |
| 100 | + player = "player", |
| 101 | + inventory_name = "main", |
| 102 | + offset = 0, |
| 103 | + count = 9, |
| 104 | + }, |
100 | 105 |
|
101 |
| - size = {x = 9, y = 1}, |
102 |
| - } |
| 106 | + size = {x = 9, y = 1}, |
| 107 | + } |
103 | 108 |
|
104 |
| - gui:show(client); |
105 |
| -end |
| 109 | + gui:show(client); |
| 110 | + end |
| 111 | +} |
106 | 112 |
|
0 commit comments