25
25
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
26
27
27
_addon .name = ' instaLS'
28
- _addon .version = 0.220213
28
+ _addon .version = 0.250421
29
29
_addon .author = ' Byrth'
30
30
31
31
linkshell_inventories_loaded = true
32
- chatmode = {}
33
- chatcolor = {}
34
- message = false
32
+ queue = {}
35
33
require ' strings'
36
34
bit = require ' bit'
37
35
@@ -50,44 +48,87 @@ windower.register_event('incoming chunk', function(id,org)
50
48
end )
51
49
52
50
windower .register_event (' outgoing chunk' ,function (id ,org ,mod ,inj )
53
- if id == 0xB5 and not inj and # chatmode > 0 and mod :byte (5 ) == 0 then -- and org:unpack('z',7) == message
54
- -- Not injected, message currently queued
55
- local outpack = mod :sub (1 ,4 ).. string.char (table.remove (chatmode ,1 )).. mod :sub (6 )
56
- return outpack
51
+ if id == 0xB5 and not inj and mod :byte (5 ) == 0 and # queue > 0 then
52
+ local pop_index , outpack = nil , nil
53
+ for i , v in pairs (queue ) do
54
+ -- Not injected, message currently queued
55
+ if string.find (org , v .message ) then
56
+ outpack = mod :sub (1 ,4 ).. string.char (v .chatmode ).. mod :sub (6 )
57
+ if v .status == " seen" then
58
+ pop_index = i
59
+ else
60
+ v .status = " sent"
61
+ end
62
+ break
63
+ end
64
+ end
65
+ if pop_index then
66
+ table.remove (queue , pop_index )
67
+ end
68
+ if outpack then
69
+ return outpack
70
+ end
57
71
end
58
72
end )
59
73
60
74
windower .register_event (' incoming text' ,function (org , mod , col )
61
- if message and # chatcolor > 0 and string.find ( org , translate_escape ( message )) then
75
+ if # queue > 0 then
62
76
local a ,b = string.find (mod ,windower .ffxi .get_player ().name )
63
- mod = mod :sub (1 ,a - 1 ).. ' [' .. (chatcolor [1 ]== 6 and ' 1' or ' 2' ).. ' ]<' .. mod :sub (a ,b ).. ' >' .. mod :sub (b + 3 )
64
- local retarr = {mod , table.remove (chatcolor ,1 )}
65
- message = nil
66
- return unpack (retarr )
77
+ local pop_index , retarr = nil , nil
78
+ for i ,v in pairs (queue ) do
79
+ if string.find (org ,translate_escape (v .message )) then
80
+ mod = mod :sub (1 ,a - 1 ).. ' [' .. (v .chatcolor == 6 and ' 1' or ' 2' ).. ' ]<' .. mod :sub (a ,b ).. ' >' .. mod :sub (b + 3 )
81
+ retarr = {mod , v .chatcolor }
82
+ if v .status == " sent" then
83
+ pop_index = i
84
+ else
85
+ v .status = " seen"
86
+ end
87
+ break
88
+ end
89
+ end
90
+ if pop_index then
91
+ table.remove (queue , pop_index )
92
+ end
93
+ if retarr then
94
+ return unpack (retarr )
95
+ end
67
96
end
68
97
end )
69
98
70
99
windower .register_event (' outgoing text' ,function (org ,mod ,bool )
71
100
if bool or linkshell_inventories_loaded then return end
101
+ local message
72
102
if mod :sub (1 ,3 ) == ' /l ' then
73
- chatmode [# chatmode + 1 ] = 0x05
74
- chatcolor [# chatcolor + 1 ] = 6
75
103
message = mod :sub (4 )
104
+ queue [# queue + 1 ] = {
105
+ chatmode = 0x05 ,
106
+ chatcolor = 6 ,
107
+ message = message
108
+ }
76
109
elseif mod :sub (1 ,11 ) == ' /linkshell ' then
77
- chatmode [# chatmode + 1 ] = 0x05
78
- chatcolor [# chatcolor + 1 ] = 6
79
110
message = mod :sub (12 )
111
+ queue [# queue + 1 ] = {
112
+ chatmode = 0x05 ,
113
+ chatcolor = 6 ,
114
+ message = message ,
115
+ }
80
116
elseif mod :sub (1 ,4 ) == ' /l2 ' then
81
- chatmode [# chatmode + 1 ] = 0x1B
82
- chatcolor [# chatcolor + 1 ] = 213
83
117
message = mod :sub (5 )
118
+ queue [# queue + 1 ] = {
119
+ chatmode = 0x1B ,
120
+ chatcolor = 213 ,
121
+ message = message ,
122
+ }
84
123
elseif mod :sub (1 ,12 ) == ' /linkshell2 ' then
85
- chatmode [# chatmode + 1 ] = 0x1B
86
- chatcolor [# chatcolor + 1 ] = 213
87
124
message = mod :sub (13 )
125
+ queue [# queue + 1 ] = {
126
+ chatmode = 0x1B ,
127
+ chatcolor = 213 ,
128
+ message = message ,
129
+ }
88
130
else
89
131
return
90
132
end
91
-
92
133
return ' /s ' .. message
93
134
end )
0 commit comments