warcraft-3-w3ts-utils 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.lua +13 -0
- package/dist/lua_modules/w3ts/globals/index.lua +23 -0
- package/dist/lua_modules/w3ts/globals/order.lua +2 -0
- package/dist/lua_modules/w3ts/handles/camera.lua +348 -0
- package/dist/lua_modules/w3ts/handles/destructable.lua +237 -0
- package/dist/lua_modules/w3ts/handles/dialog.lua +161 -0
- package/dist/lua_modules/w3ts/handles/effect.lua +198 -0
- package/dist/lua_modules/w3ts/handles/fogmodifier.lua +76 -0
- package/dist/lua_modules/w3ts/handles/force.lua +105 -0
- package/dist/lua_modules/w3ts/handles/frame.lua +417 -0
- package/dist/lua_modules/w3ts/handles/gamecache.lua +132 -0
- package/dist/lua_modules/w3ts/handles/group.lua +215 -0
- package/dist/lua_modules/w3ts/handles/handle.lua +38 -0
- package/dist/lua_modules/w3ts/handles/image.lua +105 -0
- package/dist/lua_modules/w3ts/handles/index.lua +226 -0
- package/dist/lua_modules/w3ts/handles/item.lua +375 -0
- package/dist/lua_modules/w3ts/handles/leaderboard.lua +211 -0
- package/dist/lua_modules/w3ts/handles/multiboard.lua +193 -0
- package/dist/lua_modules/w3ts/handles/player.lua +311 -0
- package/dist/lua_modules/w3ts/handles/point.lua +80 -0
- package/dist/lua_modules/w3ts/handles/quest.lua +176 -0
- package/dist/lua_modules/w3ts/handles/rect.lua +129 -0
- package/dist/lua_modules/w3ts/handles/region.lua +72 -0
- package/dist/lua_modules/w3ts/handles/sound.lua +174 -0
- package/dist/lua_modules/w3ts/handles/texttag.lua +97 -0
- package/dist/lua_modules/w3ts/handles/timer.lua +83 -0
- package/dist/lua_modules/w3ts/handles/timerdialog.lua +86 -0
- package/dist/lua_modules/w3ts/handles/trigger.lua +265 -0
- package/dist/lua_modules/w3ts/handles/ubersplat.lua +84 -0
- package/dist/lua_modules/w3ts/handles/unit.lua +1330 -0
- package/dist/lua_modules/w3ts/handles/weathereffect.lua +42 -0
- package/dist/lua_modules/w3ts/handles/widget.lua +53 -0
- package/dist/lua_modules/w3ts/hooks/index.lua +52 -0
- package/dist/lua_modules/w3ts/index.lua +36 -0
- package/dist/lua_modules/w3ts/system/base64.lua +108 -0
- package/dist/lua_modules/w3ts/system/binaryreader.lua +74 -0
- package/dist/lua_modules/w3ts/system/binarywriter.lua +88 -0
- package/dist/lua_modules/w3ts/system/file.lua +88 -0
- package/dist/lua_modules/w3ts/system/gametime.lua +27 -0
- package/dist/lua_modules/w3ts/system/host.lua +104 -0
- package/dist/lua_modules/w3ts/system/index.lua +58 -0
- package/dist/lua_modules/w3ts/system/sync.lua +239 -0
- package/dist/lua_modules/w3ts/utils/color.lua +189 -0
- package/dist/lua_modules/w3ts/utils/index.lua +38 -0
- package/dist/lualib_bundle.lua +2733 -0
- package/dist/package.json +41 -0
- package/dist/utils/abilities.lua +107 -0
- package/dist/utils/camera.lua +46 -0
- package/dist/utils/chat-command.lua +30 -0
- package/dist/utils/color.lua +41 -0
- package/dist/utils/index.lua +125 -0
- package/dist/utils/item.lua +173 -0
- package/dist/utils/math.lua +17 -0
- package/dist/utils/minimapIcons.lua +28 -0
- package/dist/utils/misc.lua +143 -0
- package/dist/utils/physics.lua +161 -0
- package/dist/utils/players.lua +234 -0
- package/dist/utils/point.lua +60 -0
- package/dist/utils/quests.lua +47 -0
- package/dist/utils/textTag.lua +110 -0
- package/dist/utils/timer.lua +21 -0
- package/dist/utils/units.lua +102 -0
- package/package.json +4 -6
- package/dist/index.js +0 -18
- package/dist/utils/abilities.js +0 -125
- package/dist/utils/camera.js +0 -37
- package/dist/utils/chat-command.js +0 -22
- package/dist/utils/color.js +0 -141
- package/dist/utils/index.js +0 -32
- package/dist/utils/item.js +0 -124
- package/dist/utils/math.js +0 -17
- package/dist/utils/minimapIcons.js +0 -27
- package/dist/utils/misc.js +0 -175
- package/dist/utils/physics.js +0 -194
- package/dist/utils/players.js +0 -189
- package/dist/utils/point.js +0 -74
- package/dist/utils/quests.js +0 -30
- package/dist/utils/textTag.js +0 -72
- package/dist/utils/timer.js +0 -16
- package/dist/utils/units.js +0 -81
- package/tsconfig.json +0 -40
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
do
|
|
3
|
+
local ____export = require("lua_modules.w3ts.system.base64")
|
|
4
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
5
|
+
if ____exportKey ~= "default" then
|
|
6
|
+
____exports[____exportKey] = ____exportValue
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
do
|
|
11
|
+
local ____export = require("lua_modules.w3ts.system.binaryreader")
|
|
12
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
13
|
+
if ____exportKey ~= "default" then
|
|
14
|
+
____exports[____exportKey] = ____exportValue
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
do
|
|
19
|
+
local ____export = require("lua_modules.w3ts.system.binarywriter")
|
|
20
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
21
|
+
if ____exportKey ~= "default" then
|
|
22
|
+
____exports[____exportKey] = ____exportValue
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
do
|
|
27
|
+
local ____export = require("lua_modules.w3ts.system.file")
|
|
28
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
29
|
+
if ____exportKey ~= "default" then
|
|
30
|
+
____exports[____exportKey] = ____exportValue
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
do
|
|
35
|
+
local ____export = require("lua_modules.w3ts.system.gametime")
|
|
36
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
37
|
+
if ____exportKey ~= "default" then
|
|
38
|
+
____exports[____exportKey] = ____exportValue
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
do
|
|
43
|
+
local ____export = require("lua_modules.w3ts.system.host")
|
|
44
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
45
|
+
if ____exportKey ~= "default" then
|
|
46
|
+
____exports[____exportKey] = ____exportValue
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
do
|
|
51
|
+
local ____export = require("lua_modules.w3ts.system.sync")
|
|
52
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
53
|
+
if ____exportKey ~= "default" then
|
|
54
|
+
____exports[____exportKey] = ____exportValue
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
return ____exports
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__StringSubstr = ____lualib.__TS__StringSubstr
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
6
|
+
local ____exports = {}
|
|
7
|
+
local ____player = require("lua_modules.w3ts.handles.player")
|
|
8
|
+
local MapPlayer = ____player.MapPlayer
|
|
9
|
+
local ____timer = require("lua_modules.w3ts.handles.timer")
|
|
10
|
+
local Timer = ____timer.Timer
|
|
11
|
+
local ____trigger = require("lua_modules.w3ts.handles.trigger")
|
|
12
|
+
local Trigger = ____trigger.Trigger
|
|
13
|
+
local ____base64 = require("lua_modules.w3ts.system.base64")
|
|
14
|
+
local base64Decode = ____base64.base64Decode
|
|
15
|
+
local base64Encode = ____base64.base64Encode
|
|
16
|
+
local ____binaryreader = require("lua_modules.w3ts.system.binaryreader")
|
|
17
|
+
local BinaryReader = ____binaryreader.BinaryReader
|
|
18
|
+
local ____binarywriter = require("lua_modules.w3ts.system.binarywriter")
|
|
19
|
+
local BinaryWriter = ____binarywriter.BinaryWriter
|
|
20
|
+
local ____gametime = require("lua_modules.w3ts.system.gametime")
|
|
21
|
+
local getElapsedTime = ____gametime.getElapsedTime
|
|
22
|
+
local SYNC_PREFIX = "T"
|
|
23
|
+
local SYNC_PREFIX_CHUNK = "S"
|
|
24
|
+
local SYNC_MAX_CHUNK_SIZE = 244
|
|
25
|
+
local SyncIncomingPacket = __TS__Class()
|
|
26
|
+
SyncIncomingPacket.name = "SyncIncomingPacket"
|
|
27
|
+
function SyncIncomingPacket.prototype.____constructor(self, prefix, data)
|
|
28
|
+
local isChunk = prefix == SYNC_PREFIX_CHUNK
|
|
29
|
+
local header = base64Decode(isChunk and __TS__StringSubstr(data, 0, 10) or __TS__StringSubstr(data, 0, 5))
|
|
30
|
+
local reader = __TS__New(BinaryReader, header)
|
|
31
|
+
local id = reader:readUInt16()
|
|
32
|
+
self.req = ____exports.SyncRequest:fromIndex(id)
|
|
33
|
+
self.chunks = isChunk and reader:readUInt16() or 0
|
|
34
|
+
self.chunk = isChunk and reader:readUInt16() or 0
|
|
35
|
+
self.data = isChunk and __TS__StringSubstr(data, 10) or __TS__StringSubstr(data, 5)
|
|
36
|
+
end
|
|
37
|
+
local SyncOutgoingPacket = __TS__Class()
|
|
38
|
+
SyncOutgoingPacket.name = "SyncOutgoingPacket"
|
|
39
|
+
function SyncOutgoingPacket.prototype.____constructor(self, req, data, chunk, totalChunks)
|
|
40
|
+
if chunk == nil then
|
|
41
|
+
chunk = -1
|
|
42
|
+
end
|
|
43
|
+
if totalChunks == nil then
|
|
44
|
+
totalChunks = 0
|
|
45
|
+
end
|
|
46
|
+
self.req = req
|
|
47
|
+
self.data = data
|
|
48
|
+
self.chunk = chunk
|
|
49
|
+
self.chunks = totalChunks
|
|
50
|
+
end
|
|
51
|
+
function SyncOutgoingPacket.prototype.getHeader(self)
|
|
52
|
+
local writer = __TS__New(BinaryWriter)
|
|
53
|
+
writer:writeUInt16(self.req.id)
|
|
54
|
+
if self.chunk ~= -1 then
|
|
55
|
+
writer:writeUInt16(self.chunks)
|
|
56
|
+
writer:writeUInt16(self.chunk)
|
|
57
|
+
end
|
|
58
|
+
return base64Encode(tostring(writer))
|
|
59
|
+
end
|
|
60
|
+
function SyncOutgoingPacket.prototype.__tostring(self)
|
|
61
|
+
local header = self:getHeader()
|
|
62
|
+
local writer = __TS__New(BinaryWriter)
|
|
63
|
+
writer:writeString(self.data)
|
|
64
|
+
return header .. tostring(writer)
|
|
65
|
+
end
|
|
66
|
+
--- A system which provides an easy way to synchronize data between game clients.
|
|
67
|
+
-- The data will be split into chunks and sent in order until all of them are recieved by
|
|
68
|
+
-- every player. Splitting the data is required as `BlzSendSyncData` only allows 255 characters
|
|
69
|
+
-- per request.
|
|
70
|
+
--
|
|
71
|
+
-- @example ```ts
|
|
72
|
+
-- const data = File.read("savecode.txt");
|
|
73
|
+
--
|
|
74
|
+
-- // Synchronize the contents of the file from the first player's computer.
|
|
75
|
+
-- new SyncRequest(Players[0], data).then((res, req) => {
|
|
76
|
+
-- print(res.data);
|
|
77
|
+
-- });
|
|
78
|
+
-- ```
|
|
79
|
+
____exports.SyncRequest = __TS__Class()
|
|
80
|
+
local SyncRequest = ____exports.SyncRequest
|
|
81
|
+
SyncRequest.name = "SyncRequest"
|
|
82
|
+
function SyncRequest.prototype.____constructor(self, from, data, options)
|
|
83
|
+
self._startTime = 0
|
|
84
|
+
self.chunks = {}
|
|
85
|
+
self.currentChunk = 0
|
|
86
|
+
self.destroyed = false
|
|
87
|
+
self.status = 0
|
|
88
|
+
self.options = not options and ____exports.SyncRequest.defaultOptions or options
|
|
89
|
+
self.from = from
|
|
90
|
+
self.id = ____exports.SyncRequest:allocate()
|
|
91
|
+
____exports.SyncRequest.indicies[self.id + 1] = -1
|
|
92
|
+
____exports.SyncRequest.cache[self.id + 1] = self
|
|
93
|
+
____exports.SyncRequest:init()
|
|
94
|
+
if type(data) == "string" then
|
|
95
|
+
self:start(data)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
__TS__SetDescriptor(
|
|
99
|
+
SyncRequest.prototype,
|
|
100
|
+
"startTime",
|
|
101
|
+
{get = function(self)
|
|
102
|
+
return self._startTime
|
|
103
|
+
end},
|
|
104
|
+
true
|
|
105
|
+
)
|
|
106
|
+
function SyncRequest.prototype.catch(self, callback)
|
|
107
|
+
self.onError = callback
|
|
108
|
+
return self
|
|
109
|
+
end
|
|
110
|
+
function SyncRequest.prototype.destroy(self)
|
|
111
|
+
____exports.SyncRequest.indicies[self.id + 1] = ____exports.SyncRequest.index
|
|
112
|
+
____exports.SyncRequest.index = self.id
|
|
113
|
+
self.destroyed = true
|
|
114
|
+
end
|
|
115
|
+
function SyncRequest.prototype.start(self, data)
|
|
116
|
+
if self.status ~= 0 or self.destroyed then
|
|
117
|
+
return false
|
|
118
|
+
end
|
|
119
|
+
self.currentChunk = 0
|
|
120
|
+
if #data <= SYNC_MAX_CHUNK_SIZE then
|
|
121
|
+
self:send(__TS__New(SyncOutgoingPacket, self, data))
|
|
122
|
+
else
|
|
123
|
+
local chunks = math.floor(#data / SYNC_MAX_CHUNK_SIZE)
|
|
124
|
+
do
|
|
125
|
+
local i = 0
|
|
126
|
+
while i <= chunks do
|
|
127
|
+
self:send(__TS__New(
|
|
128
|
+
SyncOutgoingPacket,
|
|
129
|
+
self,
|
|
130
|
+
__TS__StringSubstr(data, i * SYNC_MAX_CHUNK_SIZE, SYNC_MAX_CHUNK_SIZE),
|
|
131
|
+
i,
|
|
132
|
+
chunks
|
|
133
|
+
))
|
|
134
|
+
i = i + 1
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
self._startTime = getElapsedTime()
|
|
139
|
+
self.status = 1
|
|
140
|
+
if self.options.timeout > 0 then
|
|
141
|
+
Timer:create():start(
|
|
142
|
+
self.options.timeout,
|
|
143
|
+
false,
|
|
144
|
+
function()
|
|
145
|
+
local ____opt_0 = Timer:fromExpired()
|
|
146
|
+
if ____opt_0 ~= nil then
|
|
147
|
+
____opt_0:destroy()
|
|
148
|
+
end
|
|
149
|
+
if self.onError and self.status == 1 then
|
|
150
|
+
self.onError({data = "Timeout", status = 3, time = self.startTime}, self)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
)
|
|
154
|
+
end
|
|
155
|
+
return true
|
|
156
|
+
end
|
|
157
|
+
SyncRequest.prototype["then"] = function(self, callback)
|
|
158
|
+
self.onResponse = callback
|
|
159
|
+
return self
|
|
160
|
+
end
|
|
161
|
+
function SyncRequest.allocate(self)
|
|
162
|
+
if ____exports.SyncRequest.index ~= 0 then
|
|
163
|
+
local id = ____exports.SyncRequest.index
|
|
164
|
+
____exports.SyncRequest.index = ____exports.SyncRequest.indicies[id + 1]
|
|
165
|
+
return id
|
|
166
|
+
end
|
|
167
|
+
local ____exports_SyncRequest_2, ____counter_3 = ____exports.SyncRequest, "counter"
|
|
168
|
+
____exports_SyncRequest_2[____counter_3] = ____exports_SyncRequest_2[____counter_3] + 1
|
|
169
|
+
return ____exports.SyncRequest.counter
|
|
170
|
+
end
|
|
171
|
+
function SyncRequest.prototype.send(self, packet)
|
|
172
|
+
local prefix = packet.chunk == -1 and SYNC_PREFIX or SYNC_PREFIX_CHUNK
|
|
173
|
+
if self.from == MapPlayer:fromLocal() and not BlzSendSyncData(
|
|
174
|
+
prefix,
|
|
175
|
+
tostring(packet)
|
|
176
|
+
) then
|
|
177
|
+
print("SyncData: Network Error")
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
function SyncRequest.fromIndex(self, index)
|
|
181
|
+
return self.cache[index + 1]
|
|
182
|
+
end
|
|
183
|
+
function SyncRequest.init(self)
|
|
184
|
+
if self.initialized then
|
|
185
|
+
return
|
|
186
|
+
end
|
|
187
|
+
do
|
|
188
|
+
local i = 0
|
|
189
|
+
while i < bj_MAX_PLAYER_SLOTS do
|
|
190
|
+
local p = MapPlayer:fromIndex(i)
|
|
191
|
+
if p ~= nil and p.controller == MAP_CONTROL_USER and p.slotState == PLAYER_SLOT_STATE_PLAYING then
|
|
192
|
+
self.eventTrigger:registerPlayerSyncEvent(p, SYNC_PREFIX, false)
|
|
193
|
+
self.eventTrigger:registerPlayerSyncEvent(p, SYNC_PREFIX_CHUNK, false)
|
|
194
|
+
end
|
|
195
|
+
i = i + 1
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
self.eventTrigger:addAction(function()
|
|
199
|
+
self:onSync()
|
|
200
|
+
end)
|
|
201
|
+
self.initialized = true
|
|
202
|
+
end
|
|
203
|
+
function SyncRequest.onSync(self)
|
|
204
|
+
local syncPrefix = BlzGetTriggerSyncPrefix()
|
|
205
|
+
local syncData = BlzGetTriggerSyncData()
|
|
206
|
+
if syncPrefix == nil or syncData == nil then
|
|
207
|
+
return
|
|
208
|
+
end
|
|
209
|
+
local packet = __TS__New(SyncIncomingPacket, syncPrefix, syncData)
|
|
210
|
+
if packet.req == nil then
|
|
211
|
+
return
|
|
212
|
+
end
|
|
213
|
+
local ____packet_req_4, ____currentChunk_5 = packet.req, "currentChunk"
|
|
214
|
+
____packet_req_4[____currentChunk_5] = ____packet_req_4[____currentChunk_5] + 1
|
|
215
|
+
packet.req.chunks[packet.chunk + 1] = packet.data
|
|
216
|
+
if packet.chunk >= packet.chunks then
|
|
217
|
+
if packet.req.onResponse then
|
|
218
|
+
local data = table.concat(packet.req.chunks, "")
|
|
219
|
+
local status = 2
|
|
220
|
+
packet.req.status = 2
|
|
221
|
+
packet.req.onResponse(
|
|
222
|
+
{
|
|
223
|
+
data = data,
|
|
224
|
+
status = status,
|
|
225
|
+
time = getElapsedTime()
|
|
226
|
+
},
|
|
227
|
+
packet.req
|
|
228
|
+
)
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
SyncRequest.cache = {}
|
|
233
|
+
SyncRequest.counter = 0
|
|
234
|
+
SyncRequest.defaultOptions = {timeout = 0}
|
|
235
|
+
SyncRequest.eventTrigger = Trigger:create()
|
|
236
|
+
SyncRequest.index = 0
|
|
237
|
+
SyncRequest.indicies = {}
|
|
238
|
+
SyncRequest.initialized = false
|
|
239
|
+
return ____exports
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
|
+
local __TS__NumberToString = ____lualib.__TS__NumberToString
|
|
6
|
+
local ____exports = {}
|
|
7
|
+
local toHex, orderedPlayerColors
|
|
8
|
+
function toHex(value)
|
|
9
|
+
local hex = __TS__NumberToString(value, 16)
|
|
10
|
+
if #hex < 2 then
|
|
11
|
+
hex = "0" .. hex
|
|
12
|
+
end
|
|
13
|
+
return hex
|
|
14
|
+
end
|
|
15
|
+
____exports.Color = __TS__Class()
|
|
16
|
+
local Color = ____exports.Color
|
|
17
|
+
Color.name = "Color"
|
|
18
|
+
function Color.prototype.____constructor(self, red, green, blue, alpha)
|
|
19
|
+
self.red = red
|
|
20
|
+
self.green = green
|
|
21
|
+
self.blue = blue
|
|
22
|
+
if alpha then
|
|
23
|
+
self.alpha = alpha
|
|
24
|
+
else
|
|
25
|
+
self.alpha = 255
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
__TS__SetDescriptor(
|
|
29
|
+
Color.prototype,
|
|
30
|
+
"code",
|
|
31
|
+
{get = function(self)
|
|
32
|
+
return (("|c" .. toHex(self.alpha)) .. toHex(self.red)) .. toHex(self.green) .. toHex(self.blue)
|
|
33
|
+
end},
|
|
34
|
+
true
|
|
35
|
+
)
|
|
36
|
+
__TS__SetDescriptor(
|
|
37
|
+
Color.prototype,
|
|
38
|
+
"name",
|
|
39
|
+
{get = function(self)
|
|
40
|
+
local index = self:playerColorIndex()
|
|
41
|
+
if index < #____exports.playerColors then
|
|
42
|
+
return ____exports.playerColorNames[index + 1]
|
|
43
|
+
end
|
|
44
|
+
return "unknown"
|
|
45
|
+
end},
|
|
46
|
+
true
|
|
47
|
+
)
|
|
48
|
+
__TS__SetDescriptor(
|
|
49
|
+
Color.prototype,
|
|
50
|
+
"playerColor",
|
|
51
|
+
{get = function(self)
|
|
52
|
+
local index = self:playerColorIndex()
|
|
53
|
+
if index < #____exports.playerColors then
|
|
54
|
+
return orderedPlayerColors[index + 1]
|
|
55
|
+
end
|
|
56
|
+
return PLAYER_COLOR_RED
|
|
57
|
+
end},
|
|
58
|
+
true
|
|
59
|
+
)
|
|
60
|
+
function Color.prototype.equals(self, other)
|
|
61
|
+
return self.red == other.red and self.green == other.green and self.blue == other.blue and self.alpha == other.alpha
|
|
62
|
+
end
|
|
63
|
+
function Color.prototype.playerColorIndex(self)
|
|
64
|
+
local i = 0
|
|
65
|
+
do
|
|
66
|
+
while i < #____exports.playerColors do
|
|
67
|
+
if ____exports.playerColors[i + 1]:equals(self) then
|
|
68
|
+
break
|
|
69
|
+
end
|
|
70
|
+
i = i + 1
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
return i
|
|
74
|
+
end
|
|
75
|
+
function Color.prototype.lerp(self, other, factor)
|
|
76
|
+
local r = MathRound(self.red * (1 - factor) + other.red * factor)
|
|
77
|
+
local g = MathRound(self.green * (1 - factor) + other.green * factor)
|
|
78
|
+
local b = MathRound(self.blue * (1 - factor) + other.blue * factor)
|
|
79
|
+
local a = MathRound(self.alpha * (1 - factor) + other.alpha * factor)
|
|
80
|
+
return __TS__New(
|
|
81
|
+
____exports.Color,
|
|
82
|
+
math.max(
|
|
83
|
+
0,
|
|
84
|
+
math.min(255, r)
|
|
85
|
+
),
|
|
86
|
+
math.max(
|
|
87
|
+
0,
|
|
88
|
+
math.min(255, g)
|
|
89
|
+
),
|
|
90
|
+
math.max(
|
|
91
|
+
0,
|
|
92
|
+
math.min(255, b)
|
|
93
|
+
),
|
|
94
|
+
math.max(
|
|
95
|
+
0,
|
|
96
|
+
math.min(255, a)
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
end
|
|
100
|
+
____exports.color = function(red, green, blue, alpha) return __TS__New(
|
|
101
|
+
____exports.Color,
|
|
102
|
+
red,
|
|
103
|
+
green,
|
|
104
|
+
blue,
|
|
105
|
+
alpha
|
|
106
|
+
) end
|
|
107
|
+
--- The player colors sorted by index. Does not include
|
|
108
|
+
-- neutrals colors.
|
|
109
|
+
____exports.playerColors = {
|
|
110
|
+
____exports.color(255, 3, 3),
|
|
111
|
+
____exports.color(0, 66, 255),
|
|
112
|
+
____exports.color(28, 230, 185),
|
|
113
|
+
____exports.color(84, 0, 129),
|
|
114
|
+
____exports.color(255, 252, 0),
|
|
115
|
+
____exports.color(254, 138, 14),
|
|
116
|
+
____exports.color(32, 192, 0),
|
|
117
|
+
____exports.color(229, 91, 176),
|
|
118
|
+
____exports.color(149, 150, 151),
|
|
119
|
+
____exports.color(126, 191, 241),
|
|
120
|
+
____exports.color(16, 98, 70),
|
|
121
|
+
____exports.color(78, 42, 3),
|
|
122
|
+
____exports.color(155, 0, 0),
|
|
123
|
+
____exports.color(0, 0, 195),
|
|
124
|
+
____exports.color(0, 234, 255),
|
|
125
|
+
____exports.color(190, 0, 254),
|
|
126
|
+
____exports.color(235, 205, 135),
|
|
127
|
+
____exports.color(248, 164, 139),
|
|
128
|
+
____exports.color(191, 255, 128),
|
|
129
|
+
____exports.color(220, 185, 235),
|
|
130
|
+
____exports.color(80, 79, 85),
|
|
131
|
+
____exports.color(235, 240, 255),
|
|
132
|
+
____exports.color(0, 120, 30),
|
|
133
|
+
____exports.color(164, 111, 51)
|
|
134
|
+
}
|
|
135
|
+
--- The names of players colors sorted by player index.
|
|
136
|
+
____exports.playerColorNames = {
|
|
137
|
+
"red",
|
|
138
|
+
"blue",
|
|
139
|
+
"teal",
|
|
140
|
+
"purple",
|
|
141
|
+
"yellow",
|
|
142
|
+
"orange",
|
|
143
|
+
"green",
|
|
144
|
+
"pink",
|
|
145
|
+
"gray",
|
|
146
|
+
"light blue",
|
|
147
|
+
"dark green",
|
|
148
|
+
"brown",
|
|
149
|
+
"maroon",
|
|
150
|
+
"navy",
|
|
151
|
+
"turquoise",
|
|
152
|
+
"violet",
|
|
153
|
+
"wheat",
|
|
154
|
+
"peach",
|
|
155
|
+
"mint",
|
|
156
|
+
"lavender",
|
|
157
|
+
"coal",
|
|
158
|
+
"snow",
|
|
159
|
+
"emerald",
|
|
160
|
+
"peanut"
|
|
161
|
+
}
|
|
162
|
+
--- An ordered list of `playercolor`s, for lookup
|
|
163
|
+
orderedPlayerColors = {
|
|
164
|
+
PLAYER_COLOR_RED,
|
|
165
|
+
PLAYER_COLOR_BLUE,
|
|
166
|
+
PLAYER_COLOR_CYAN,
|
|
167
|
+
PLAYER_COLOR_PURPLE,
|
|
168
|
+
PLAYER_COLOR_YELLOW,
|
|
169
|
+
PLAYER_COLOR_ORANGE,
|
|
170
|
+
PLAYER_COLOR_GREEN,
|
|
171
|
+
PLAYER_COLOR_PINK,
|
|
172
|
+
PLAYER_COLOR_LIGHT_GRAY,
|
|
173
|
+
PLAYER_COLOR_LIGHT_BLUE,
|
|
174
|
+
PLAYER_COLOR_AQUA,
|
|
175
|
+
PLAYER_COLOR_BROWN,
|
|
176
|
+
PLAYER_COLOR_MAROON,
|
|
177
|
+
PLAYER_COLOR_NAVY,
|
|
178
|
+
PLAYER_COLOR_TURQUOISE,
|
|
179
|
+
PLAYER_COLOR_VIOLET,
|
|
180
|
+
PLAYER_COLOR_WHEAT,
|
|
181
|
+
PLAYER_COLOR_PEACH,
|
|
182
|
+
PLAYER_COLOR_MINT,
|
|
183
|
+
PLAYER_COLOR_LAVENDER,
|
|
184
|
+
PLAYER_COLOR_COAL,
|
|
185
|
+
PLAYER_COLOR_SNOW,
|
|
186
|
+
PLAYER_COLOR_EMERALD,
|
|
187
|
+
PLAYER_COLOR_PEANUT
|
|
188
|
+
}
|
|
189
|
+
return ____exports
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Promise = ____lualib.__TS__Promise
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__AsyncAwaiter = ____lualib.__TS__AsyncAwaiter
|
|
5
|
+
local __TS__Await = ____lualib.__TS__Await
|
|
6
|
+
local ____exports = {}
|
|
7
|
+
local ____timer = require("lua_modules.w3ts.handles.timer")
|
|
8
|
+
local Timer = ____timer.Timer
|
|
9
|
+
do
|
|
10
|
+
local ____export = require("lua_modules.w3ts.utils.color")
|
|
11
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
12
|
+
if ____exportKey ~= "default" then
|
|
13
|
+
____exports[____exportKey] = ____exportValue
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
function ____exports.sleep(howMuch)
|
|
18
|
+
return __TS__AsyncAwaiter(function(____awaiter_resolve)
|
|
19
|
+
return ____awaiter_resolve(
|
|
20
|
+
nil,
|
|
21
|
+
__TS__New(
|
|
22
|
+
__TS__Promise,
|
|
23
|
+
function(____, resolve, reject)
|
|
24
|
+
local t = Timer:create()
|
|
25
|
+
t:start(
|
|
26
|
+
howMuch,
|
|
27
|
+
false,
|
|
28
|
+
function()
|
|
29
|
+
t:destroy()
|
|
30
|
+
resolve(nil, nil)
|
|
31
|
+
end
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
end)
|
|
37
|
+
end
|
|
38
|
+
return ____exports
|