forked from EATSTEAK/CHGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_include.ms
114 lines (98 loc) · 3.01 KB
/
auto_include.ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#########################################
# Copyright 2016 ITSTAKE GPL v2.0
# Script by itstake (bexco2010@gmail.com)
# Version 1.3 (2018/02/04)
#########################################
#############
# USES VIRTUALCHEST EXTENSION
/*
proc(_itemmenu_create_vc, @array,
if(import('MenuOpen'.player()) != true) {
export('MenuOpen'.player(), true)
export('CurMenu'.player(), @array)
@title = @array['title']
@id = @array['id']
if(array_index_exists(@array, size)) {
@size = @array['size']
} else {
@size = ceil((array_size(@array['menu'])) / 9) * 9 # Dynamically set the size
}
@chest = array(id: @id, size: @size, title: @title)
@items = @array['menu']
foreach(@key:@value in @items) {
array_set(@chest, @key, @value['item'])
}
create_virtualchest(@chest)
popen_virtualchest(@id)
}
)
proc(_itemmenu_update_vc, @array,
export('MenuOpen'.player(), true)
export('CurMenu'.player(), @array)
@title = @array['title']
@id = @array['id']
if(array_index_exists(@array, size)) {
@size = @array['size']
} else {
@size = ceil((array_size(@array['menu'])) / 9) * 9 # Dynamically set the size
}
@chest = array(id: @id, size: @size, title: @title)
@items = @array['menu']
for(@i = 0, @i < @size, @i++,
if(!array_index_exists(@items, @i)) {
array_set(@chest, @i, array(type: 0,data: 0,qty: 0))
}
)
foreach(@key:@value in @items) {
array_set(@chest, @key, @value['item'])
}
update_virtualchest(@chest)
)
*/
############
# USES CORE FUNCTIONS
proc(_itemmenu_create, @array,
export('CurMenu'.player(), @array)
@title = @array['title']
@id = @array['id']
@type = 'CHEST'
if(array_index_exists(@array, 'size')) {
@size = @array['size']
} else if(array_index_exists(@array, 'type')) { # If GUI Array have a type
@type = @array['type']
} else {
@size = ceil((array_size(@array['menu'])) / 9) * 9 # Dynamically set the size
}
@menu = @array['menu']
@items = array()
foreach(@key:@value in @menu) {
array_set(@items, @key, @value['item'])
}
if(@type == 'CHEST') {
create_virtual_inventory(@id, @size, colorize(@title), @items)
} else {
create_virtual_inventory(@id, @type, colorize(@title), @items)
}
popen_inventory(player(), @id)
)
proc(_itemmenu_update, @array,
export('CurMenu'.player(), @array)
@title = @array['title']
@id = @array['id']
if(array_index_exists(@array, size)) {
@size = @array['size']
} else {
@size = ceil((array_size(@array['menu'])) / 9) * 9 # Dynamically set the size
}
@menu = @array['menu']
for(@i = 0, @i < @size, @i++,
if(!array_index_exists(@menu, @i)) {
array_set(@chest, @i, array(type: 0,data: 0,qty: 0))
}
)
@items = array()
foreach(@key:@value in @menu) {
array_set(@items, @key, @value['item'])
}
set_inventory(@id, @items)
)