forked from mynameisgonz/FastFeet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastFeet.lua
More file actions
250 lines (208 loc) · 5.79 KB
/
FastFeet.lua
File metadata and controls
250 lines (208 loc) · 5.79 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
_addon.name = 'Fast Feet'
_addon.author = 'Batcher of Asura'
_addon.version = '1.0'
_addon.commands = {'FastFeet','fastfeet','FF','ff'}
res = require('resources')
config = require('config')
require('equip')
-- basic config defaults
defaults = {}
defaults.characters = {}
settings = config.load(defaults)
local me = require('me')
started = false
windower.register_event('load', function()
if windower.ffxi.get_info().logged_in then
started = true
update()
end
end)
windower.register_event('unload', function()
started = false
end)
windower.register_event('login', function(name)
if started == false then
started = true
update()
end
end)
windower.register_event('logout', function(name)
started = false
end)
windower.register_event('addon command', function(...)
local args = T{...}
local cmd = table.remove(args,1):lower()
if args ~= nil then
if cmd == 'set' then
-- the latest information about the character
local p = windower.ffxi.get_player()
-- does the xml node for the character exist? if not, create
if settings.characters[string.lower(p.name)] == nil then
settings.characters[string.lower(p.name)] = {}
settings:save('all')
end
-- does the xml node for the job exist? if not, create
if settings.characters[string.lower(p.name)][string.lower(p.main_job)] == nil then
settings.characters[string.lower(p.name)][string.lower(p.main_job)] = {}
settings:save('all')
end
if args[1] ~= nil or args[1] ~= "" then
if search_item(args[1]) then
settings.characters[string.lower(p.name)][string.lower(p.main_job)].item = args[1]
log('Fast Item set to ' .. me.fast_item.name .. ' for ' .. p.name .. ' on ' .. p.main_job)
settings:save('all')
else
log('could not find item')
end
end
end
end
end)
function update()
if started then
-- keep running this function
coroutine.schedule(update,0.2)
me:update(windower.ffxi.get_mob_by_target('me'))
if check_fast_item() then
if me:moving() then
--me:equip_item(me.fast_item)
local equipped = me:get_currently_equipped_item()
--save the previously equipped item
check_current_equip_item(equipped)
if equipped.en ~= me.fast_item.name then
me:equip_item(me.fast_item)
end
else
local equipped = me:get_currently_equipped_item()
if me.last_equipped ~= nil and equipped.en ~= me.last_equipped.name then
me:equip_item(me.last_equipped)
end
end
end
end
end
function check_fast_item()
if settings.characters[string.lower(me.name)] == nil or settings.characters[string.lower(me.name)][string.lower(me.main_job)] == nil or settings.characters[string.lower(me.name)][string.lower(me.main_job)].item == nil then
return false
else
local armor = settings.characters[string.lower(me.name)][string.lower(me.main_job)].item
local item = res.items:with('en',armor)
local found = false
if item ~= nil then
for index,i in ipairs(windower.ffxi.get_items('inventory')) do
if i.id == item.id then
found = true
local e = equip:new(item,i,index,0)
me:set_fast_item(e)
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe')) do
if i.id == item.id then
found = true
local e = equip:new(item,i,index,8)
me:set_fast_item(e)
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe2')) do
if i.id == item.id then
found = true
local e = equip:new(item,i,index,10)
me:set_fast_item(e)
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe3')) do
if i.id == item.id then
found = true
local e = equip:new(item,i,index,11)
me:set_fast_item(e)
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe4')) do
if i.id == item.id then
found = true
local e = equip:new(item,i,index,12)
me:set_fast_item(e)
end
end
end
if found then
return true
else
return false
end
end
end
function search_item(armor)
local item = res.items:with('en',armor)
local found = false
if item ~= nil then
for index,i in ipairs(windower.ffxi.get_items('inventory')) do
if i.id == item.id then
found = true
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe')) do
if i.id == item.id then
found = true
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe2')) do
if i.id == item.id then
found = true
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe3')) do
if i.id == item.id then
found = true
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe4')) do
if i.id == item.id then
found = true
end
end
end
if found then
return true
else
return false
end
end
function check_current_equip_item(armor)
if armor.en == me.fast_item.name then return end
if armor ~= nil then
for index,i in ipairs(windower.ffxi.get_items('inventory')) do
if i.id == armor.id then
local e = equip:new(armor,i,index,0)
me:set_last_equipped_item(e)
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe')) do
if i.id == armor.id then
local e = equip:new(armor,i,index,8)
me:set_last_equipped_item(e)
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe2')) do
if i.id == armor.id then
local e = equip:new(armor,i,index,10)
me:set_last_equipped_item(e)
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe3')) do
if i.id == armor.id then
local e = equip:new(armor,i,index,11)
me:set_last_equipped_item(e)
end
end
for index,i in ipairs(windower.ffxi.get_items('wardrobe4')) do
if i.id == armor.id then
local e = equip:new(armor,i,index,12)
me:set_last_equipped_item(e)
end
end
end
end
function log(message)
windower.add_to_chat(166,tostring(message))
end