Scholar Gearswap .lua

Eorzea Time
 
 
 
Langues: JP EN FR DE
users online
Forum » FFXI » Jobs » Scholar » Scholar Gearswap .lua
Scholar Gearswap .lua
First Page 2 3 4 5
 Bismarck.Snprphnx
Offline
Serveur: Bismarck
Game: FFXI
user: Snprphnx
Posts: 2707
By Bismarck.Snprphnx 2013-12-16 19:25:26
Link | Citer | R
 
Posted below is a _SCH.lua file that I wrote using Byrths original file as an example, and tweaked and edited to work out any errors. I will not call it complete, due to me potentially missing specific rules for certain JAs or spells. However, I would say that it covers the majority of what is needed.

If you have any questions about it, please feel free to post them here for Byrths or myself to answer. Also, if you noticed I missed anything crucial, let me know and we can add it in.

This same file is included in the Gearswap download in the examples section, and I will try to keep it as up-to-date as possible.
[+]
 Cerberus.Shadowmeld
Offline
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 08:59:50
Link | Citer | R
 
Kind of curious as I haven't really looked at gearswap yet, does it have the ability to have subsets of gear? For example, lets say you have a set added to your .lua called Refresh.
Code
sets.Refresh = {head="Nefer Khat", body="Heka's Kalasiris", hands="Serpentes Cuffs", legs="Nares Trews", feet="Serpentes Sabots"}


Could you add this set as a base for an Idle set or something.
Code
sets.Idle = sets.Refresh + {neck="Twilight Torque"}


Obviously, I am unpracticed with lua, so I don't know how you would actually do the addition, just curious if the concept is there.
 Lakshmi.Byrth
VIP
Offline
Serveur: Lakshmi
Game: FFXI
user: Byrthnoth
Posts: 6193
By Lakshmi.Byrth 2013-12-17 09:16:19
Link | Citer | R
 
Yeah, this will make a set as you described:
Code
sets.Idle = set_combine(sets.Refresh,{neck="Twilight Torque"})
 Cerberus.Shadowmeld
Offline
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 09:55:24
Link | Citer | R
 
So, how does it handle overlap. If your refresh set had a neck piece, would the {neck="Twilight Torque"} overwrite the neck in the refresh set? Is there a way to lock gear to not be overwritten?
 Lakshmi.Byrth
VIP
Offline
Serveur: Lakshmi
Game: FFXI
user: Byrthnoth
Posts: 6193
By Lakshmi.Byrth 2013-12-17 10:08:03
Link | Citer | R
 
It replaces from left to right. If you want to lock a slot, use disable(slot name).
 Bismarck.Mazikeen
Offline
Serveur: Bismarck
Game: FFXI
user: Thps
Posts: 3
By Bismarck.Mazikeen 2013-12-17 10:14:54
Link | Citer | R
 
What is the benefit to using gearswap over spellcast? I'm extremely happy with my modified Motenten spellcast right now and can't see the benefit of learning a new system.
 Leviathan.Behemothx
Offline
Serveur: Leviathan
Game: FFXI
user: BehemothZ
Posts: 323
By Leviathan.Behemothx 2013-12-17 10:18:41
Link | Citer | R
 
Bismarck.Mazikeen said: »
What is the benefit to using gearswap over spellcast? I'm extremely happy with my modified Motenten spellcast right now and can't see the benefit of learning a new system.

It's probably too hard to maintain since it breaks every update.
 Lakshmi.Byrth
VIP
Offline
Serveur: Lakshmi
Game: FFXI
user: Byrthnoth
Posts: 6193
By Lakshmi.Byrth 2013-12-17 10:55:40
Link | Citer | R
 
Partially that, but also:
http://www.bluegartr.com/threads/115131-Windower-4-Open-Beta?p=5985652&viewfull=1#post5985652

There is a list at the bottom that answers your questions.
 Cerberus.Shadowmeld
Offline
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 11:13:45
Link | Citer | R
 
Byrth, what would it take to add a method sets_combine that combines > 2 sets. In pseudocode something like this.
Code
function sets_combine(...)
  tempsets= {...}
  combinedset = {}

  for each set in tempsets
    combinedset = set_combine(combinedset, set)

  
end


I omitted some psuedocode for error handling, but would this be possible? The reason I ask is my current method of building sets is using a lot of 'basesets'

Additionally, how does gearswap do with the feature of spellcast where equip commands within a certain time (~0.5 seconds) don't always process correctly?
 Lakshmi.Byrth
VIP
Offline
Serveur: Lakshmi
Game: FFXI
user: Byrthnoth
Posts: 6193
By Lakshmi.Byrth 2013-12-17 11:30:02
Link | Citer | R
 
I'm pretty sure set_combine takes an arbitrary number of sets and combines them.

If you don't need to precompose the set for some reason, the equip command also takes an arbitrary number of sets and collapses them leftwards (so the rightmost set gets priority for slot assignments, then next rightmost, etc.)

When I say ambivalent things like "I'm pretty sure," keep in mind that GearSwap has been in its current form with only minor alterations since ~August.
 Cerberus.Shadowmeld
Offline
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 11:36:03
Link | Citer | R
 
This is mostly just personal preference on my part, I like keeping my rules as simple as possible on spellcast, so in order to do that I will make one set for a rule, such as Idle for an idle set, and then I will add basesets as needed such as Refresh for refresh gear or PDT when needed. I prefer to precompose them in order to keep the rules as simple as possible. I will play around with this and see how I like it.

I added this above, but you were already responding, so I will ask it again. Does gearswap also have the same problem as spellcast where if commands process to quickly in succession they won't equip properly. Such as nuking and you idle in hagondes coat, switch to anhur robe for fast cast and then it fails to switch back to hagondes coat because it still sees it as equipped.

Edit: I was looking at the lua and the set_combine method has an explicit number of parameters whereas the equip method is stated equip(...). I'll see if I can do multiple sets.
 Lakshmi.Byrth
VIP
Offline
Serveur: Lakshmi
Game: FFXI
user: Byrthnoth
Posts: 6193
By Lakshmi.Byrth 2013-12-17 12:32:55
Link | Citer | R
 
Okay, I can adjust set_combine to take a variable number of arguments tonight. If you don't mind, could you please open an issue for it? ( https://github.com/Byrth/Lua/issues )

GearSwap does not have that issue, because it is sending equip packets directly. That issue was due to the game refusing to send equip packets for currently equipped gear. It's like this:
* You enter an /equip command
* Game checks to see if you can equip the item (right slot? right race? right gender? right level? right job? is it already equipped? in a menu?)
* Game sends an equip packet if all those conditions are met.
* Server sends back an equip packet, along with a few other item change packets that set the inventory status to "equipped." Now your gear changes.

So if you sent two equip commands rapidly, the second one would hit before the equip packet had arrived from the server. Thus your equip command would be canceled because you were still wearing the item.

GearSwap bypasses this (and every other native check) by sending the equip packets itself. I've recreated most of the checks, but have intentionally left out the menu check and have changed the "is it equipped?" check so that this issue doesn't occur.
 Cerberus.Shadowmeld
Offline
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-17 13:18:13
Link | Citer | R
 
I will gladly do that Byrth.

Woo Hoo!!!! That is truly great to hear, that might have convinced me to switch to Gearswap from spellcast.
 Cerberus.Shadowmeld
Offline
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-18 08:38:44
Link | Citer | R
 
I have another question. How does gearswap deal with fast cast on gear? In my spellcast I have a very extensive set of rules for calculating fast cast so I can more efficiently swap gear. Because aftercast basically just automatically defaults to the cast time of the spell + 1 second or so, I was wondering whether gearswap actually dealt with the fast cast gear itself or if those extensive calculations would still need to be done.

The case I am trying to address is long cast time spells like tier 5 nukes (cast time is 10 seconds). With my fast cast gear + grimoire + elemental staves, I cast them in about 1.8 seconds. With spellcast, if I let it do its normal processing, aftercast action gives me ~9 seconds of idling in my casting gear and not my refresh/pdt idle set.

Would gearswap have this same problem?
 Cerberus.Conagh
Offline
Serveur: Cerberus
Game: FFXI
user: onagh
Posts: 3189
By Cerberus.Conagh 2013-12-18 15:26:18
Link | Citer | R
 
As soon as the packet leaves saying "you are casting" it swaps, this is another benefit to Packet version gearswaps instead of Spellcast.
 Phoenix.Aerolite
Offline
Serveur: Phoenix
Game: FFXI
user: Daily
Posts: 45
By Phoenix.Aerolite 2013-12-19 19:14:29
Link | Citer | R
 
I tried that example .lua file out, and I was wondering if there's a way to get the precast swap only to occur for spells? It was kind of annoying having to gearswap every time I used light arts or a stratagem.


Also, the sublimation rule in that file doesn't work. It doesn't switch into my sublimation gear when it's activated.
 Fenrir.Jinjo
VIP
Offline
Serveur: Fenrir
Game: FFXI
user: Minjo
Posts: 2269
By Fenrir.Jinjo 2013-12-19 19:25:16
Link | Citer | R
 
if action.type ~= "Magic" then return end
[+]
 Phoenix.Aerolite
Offline
Serveur: Phoenix
Game: FFXI
user: Daily
Posts: 45
By Phoenix.Aerolite 2013-12-19 20:32:52
Link | Citer | R
 
Fenrir.Jinjo said: »
if action.type ~= "Magic" then return end
Thanks! I'm still having trouble with the sublimation set though! I thought maybe it was like spellcast where I would have to cast a spell before gearswap would recognize that it's active, but it doesn't even do that.
 Odin.Quixacotl
Offline
Serveur: Odin
Game: FFXI
user: Quixacotl
Posts: 170
By Odin.Quixacotl 2013-12-24 03:01:20
Link | Citer | R
 
Phoenix.Aerolite said: »
Thanks! I'm still having trouble with the sublimation set though!
I was also having probs with the sublimation set not firing but was able to find a fix.

Right out of the box, Snprphnx's following code doesn't work as it should.
Code
function buff_change(status,gain_or_loss)
	if status == 'Sublimation: Complete' and gain_or_loss == 'gain' and not 'stunmode' then -- True whether gained or lost
		sets.aftercast_Idle = sets.aftercast_Idle_noSub
	elseif status == 'Sublimation: Activated' and gain_or_loss == 'gain' and not 'stunmode' then
		sets.aftercast_Idle = sets.aftercast_Idle_Sub
	end
	equip(sets.aftercast_Idle)
end

What I did was to follow my own xml code and put the check in function aftercast where it belongs. Now it works.
Code
function aftercast(spell,action)
	if not spell.english['Sublimation'] and buffactive['Sublimation: Activated'] and 'stunmode' ~= 'true' then
		equip(sets['aftercast_Idle_Sub'])
	elseif spell.english == 'Sublimation' and not buffactive['Sublimation: Activated'] and 'stunmode' ~= 'true' then
		equip(sets['aftercast_Idle_Sub'])
	else
		equip(sets['aftercast_Idle_noSub'])
	end
end

function buff_change(status,gain_or_loss)
	if status == 'Sublimation: Activated' and gain_or_loss == 'loss' and'stunmode' ~= 'true' then
		equip(sets['aftercast_Idle_noSub'])
		sets.aftercast_Idle = sets.aftercast_Idle_noSub
	end
end

I also found some other discrepancies which I was able to fix. I've been using a variant based on Mortensen's xml (read: butchered and rewritten) and just now getting into lua. Below is my own SCH lua (if anyone is interested). It is based on Snprphnx's lua and a WIP. I'm still trying to figure out how to add multiple layers based on active strategems. =/

http://pastebin.com/aKm0D4xv
[+]
 Cerberus.Shadowmeld
Offline
Serveur: Cerberus
Game: FFXI
Posts: 1809
By Cerberus.Shadowmeld 2013-12-25 11:41:31
Link | Citer | R
 
Adding my 2 cents, been working on this for about a week but I have a good bit of the logic from motenten's sch.xml translated over for strategems and stuff, I also added aliases so you can just type //addend or //cost to fire off the strats in game.

It has fairly extensive processing to build dynamic sets when casting spells, including active strategems. I only have savant's gloves at the moment though, so that was the only testing I have done so far. I still have a long way to go, but this is a good first draft for me. Good enough that I am willing to let people see at least.

I still need to add processing for using spells that require addendums and some other rules. I am also working on implementing the strategem queue, but that has taken a back seat to getting it to work. Here it is.

http://pastebin.com/AeERyE2X
 Bismarck.Snprphnx
Offline
Serveur: Bismarck
Game: FFXI
user: Snprphnx
Posts: 2707
By Bismarck.Snprphnx 2013-12-25 20:25:59
Link | Citer | R
 
Odin.Quixacotl said: »
Phoenix.Aerolite said: »
Thanks! I'm still having trouble with the sublimation set though!
I was also having probs with the sublimation set not firing but was able to find a fix.

Right out of the box, Snprphnx's following code doesn't work as it should.
Code
function buff_change(status,gain_or_loss)
	if status == 'Sublimation: Complete' and gain_or_loss == 'gain' and not 'stunmode' then -- True whether gained or lost
		sets.aftercast_Idle = sets.aftercast_Idle_noSub
	elseif status == 'Sublimation: Activated' and gain_or_loss == 'gain' and not 'stunmode' then
		sets.aftercast_Idle = sets.aftercast_Idle_Sub
	end
	equip(sets.aftercast_Idle)
end

What I did was to follow my own xml code and put the check in function aftercast where it belongs. Now it works.
Code
function aftercast(spell,action)
	if not spell.english['Sublimation'] and buffactive['Sublimation: Activated'] and 'stunmode' ~= 'true' then
		equip(sets['aftercast_Idle_Sub'])
	elseif spell.english == 'Sublimation' and not buffactive['Sublimation: Activated'] and 'stunmode' ~= 'true' then
		equip(sets['aftercast_Idle_Sub'])
	else
		equip(sets['aftercast_Idle_noSub'])
	end
end

function buff_change(status,gain_or_loss)
	if status == 'Sublimation: Activated' and gain_or_loss == 'loss' and'stunmode' ~= 'true' then
		equip(sets['aftercast_Idle_noSub'])
		sets.aftercast_Idle = sets.aftercast_Idle_noSub
	end
end

I also found some other discrepancies which I was able to fix. I've been using a variant based on Mortensen's xml (read: butchered and rewritten) and just now getting into lua. Below is my own SCH lua (if anyone is interested). It is based on Snprphnx's lua and a WIP. I'm still trying to figure out how to add multiple layers based on active strategems. =/

http://pastebin.com/aKm0D4xv

Thank you for finding the issue. The file posted in the OP did work, however shortly after posting it, the windower dev team pushed an update that borked the logic somehow. Even Byrth was stumped as to why it wasn't working. Between working OT and the holidays, I hadn't had a chance to log in for more that 5 minutes to figure it out.

Also, thank you for the line change for swapping to precast gear for magic only. Again, it was something that was minor, and I was planning in to addressing this coming weekend.
 Fenrir.Motenten
VIP
Offline
Serveur: Fenrir
Game: FFXI
user: Motenten
Posts: 764
By Fenrir.Motenten 2013-12-25 21:12:43
Link | Citer | R
 
This is improperly formatted:
Code
if status == 'Sublimation: Complete' and gain_or_loss == 'gain' and not 'stunmode' then -- True whether gained or lost


You have [not 'stunmode'], however by quoting 'stunmode' you're making a string, not referring to a variable. Since it's an explicit string, 'stunmode' will also be considered True in a boolean check, which means that the overall line will -always- be False.

Take the quotes off from around 'stunmode' for it to work properly.

As a followup, Quixacotl's statement that that code 'belongs' in the aftercast() section is also false. Aftercast may make use of which sublimation set you want to use, but it would be best to define the set within the buff_change() function, since that will always tell you immediately when the buff is added or removed, whereas aftercast() has to wait for you to take action.

Next, Qixacotl's correction adds a new error:
Code
if status == 'Sublimation: Activated' and gain_or_loss == 'loss' and'stunmode' ~= 'true' then


In this case, he tried to fix the [not 'stunmode'] error with ['stunmode' ~= 'true']. However, he's still using strings, so it will do a literal comparison of the string 'stunmode' with the string 'true'. Since those are explicitly not the same, the comparison of 'stunmode' ~= 'true' will always be true.

For this, stunmode is a variable, so should not be in quotes, and true is a boolean value, so should also not be in quotes.

Speaking of stunmode as a variable: It's not defined or given a default value in the get_sets() function. As such, its value will be nil until it's actually toggled. This is not really a bad thing, since nil is the same as false as far as the boolean check goes, but it's not as clear since you never declare the variable at the top of the script, so you don't know that it exists.


Anyway, I've been building a few of my Spellcast scripts into lua, and they're coming along pretty well. I've done a few simple ones so far. Going to try a couple complicated ones now (thf and sch).
 Fenrir.Motenten
VIP
Offline
Serveur: Fenrir
Game: FFXI
user: Motenten
Posts: 764
By Fenrir.Motenten 2013-12-25 21:24:10
Link | Citer | R
 
Oh, and a simple way that I'd do those sublimation sets:
Code
function get_sets()
    sets.idle = {} -- normal idle gear
    sets.idle.Sublimation = {} -- idle gear with sublimation gear
    
    state.IdleMode = 'Normal'
    state.StunMode = false
end


function buff_change(buff, gain_or_lose)
    if buff == "Sublimation: Activated" then
        if gain_or_lose == 'gain' and not state.StunMode then
            state.IdleMode = 'Sublimation'
        else
            state.IdleMode = 'Normal'
        end
    end

    update_gear_sets(player.status)
end


function aftercast(spell, action)
    update_gear_sets(player.status)
end


function update_gear_sets(status)
    if status == 'idle' then
        if sets.idle[state.IdleMode] then
            equip(sets.idle[state.IdleMode])
        else
            equip(sets.idle)
        end
    elseif status == 'engaged'
        -- etc...
    end
end
 Odin.Quixacotl
Offline
Serveur: Odin
Game: FFXI
user: Quixacotl
Posts: 170
By Odin.Quixacotl 2013-12-26 00:56:54
Link | Citer | R
 
Bismarck.Snprphnx said: »
Thank you for finding the issue. The file posted in the OP did work, however shortly after posting it, the windower dev team pushed an update that borked the logic somehow. Even Byrth was stumped as to why it wasn't working. Between working OT and the holidays, I hadn't had a chance to log in for more that 5 minutes to figure it out.

Also, thank you for the line change for swapping to precast gear for magic only. Again, it was something that was minor, and I was planning in to addressing this coming weekend.
It's all good. :) Lua is all very new to me so I'm still learning as I go along. I do have some understanding of code logic and a fast learner so whatever I find I'm more than happy to share with our community. I do see the advantages and potential that lua has over xmls'

Fenrir.Motenten said: »
As a followup, Quixacotl's statement that that code 'belongs' in the aftercast() section is also false. Aftercast may make use of which sublimation set you want to use, but it would be best to define the set within the buff_change() function, since that will always tell you immediately when the buff is added or removed, whereas aftercast() has to wait for you to take action.

Next, Qixacotl's correction adds a new error:
Code
if status == 'Sublimation: Activated' and gain_or_loss == 'loss' and'stunmode' ~= 'true' then


In this case, he tried to fix the [not 'stunmode'] error with ['stunmode' ~= 'true']. However, he's still using strings, so it will do a literal comparison of the string 'stunmode' with the string 'true'. Since those are explicitly not the same, the comparison of 'stunmode' ~= 'true' will always be true.

For this, stunmode is a variable, so should not be in quotes, and true is a boolean value, so should also not be in quotes.

Speaking of stunmode as a variable: It's not defined or given a default value in the get_sets() function. As such, its value will be nil until it's actually toggled. This is not really a bad thing, since nil is the same as false as far as the boolean check goes, but it's not as clear since you never declare the variable at the top of the script, so you don't know that it exists.
Yea I discovered the error once I switched to stun mode and found, to my dismay, that I couldn't stay idled in stun gear. So it was back to the drawing board for me.
Quote:
Anyway, I've been building a few of my Spellcast scripts into lua, and they're coming along pretty well. I've done a few simple ones so far. Going to try a couple complicated ones now (thf and sch).

Fenrir.Motenten said: »
Oh, and a simple way that I'd do those sublimation sets:
Thanks for the explaination and the Sublimation code. That makes a lot more sense and certainly helps a lot.

I'm looking forward to seeing your results. I have to admit there's a lot I don't know and having some issues of my own as I'm writing Lua code on the fly. But for me it presents new challenges and gets my interest peaked. Whatever ideas I've learned for xmls and lua I've gotten from yours and others' examples. You are da man!
necroskull Necro Bump Detected! [177 days between previous and next post]
 Quetzalcoatl.Setsuai
Offline
Serveur: Quetzalcoatl
Game: FFXI
user: Setsuai
Posts: 61
By Quetzalcoatl.Setsuai 2014-06-20 18:05:28
Link | Citer | R
 
So I have a question regarding gearswap. Would there be a reason it wouldn't be swapping to my nuking gear? On sch it swaps to the cure gear no problem, but it won't swap to nukes. The same problem is happening on my blm, expcept it won't even swap to cure gear. I just started using gearswap not even a week ago, so it could just be the fact that I'm new to the system. Any help is appreciated.
 Bismarck.Snprphnx
Offline
Serveur: Bismarck
Game: FFXI
user: Snprphnx
Posts: 2707
By Bismarck.Snprphnx 2014-06-20 18:55:32
Link | Citer | R
 
Post a link to your .lua. Without seeing the code, we can't troubleshoot
 Ragnarok.Presidentobama
Offline
Serveur: Ragnarok
Game: FFXI
user: kasain
Posts: 585
By Ragnarok.Presidentobama 2014-06-20 19:20:59
Link | Citer | R
 
How exactly do I install and activate this file for my sch?
 Bismarck.Snprphnx
Offline
Serveur: Bismarck
Game: FFXI
user: Snprphnx
Posts: 2707
By Bismarck.Snprphnx 2014-06-20 19:38:26
Link | Citer | R
 
1. Copy/Edit the file and save it as a .lua file, as charactername.lua
2. save it into the \addons\Gearswap\data folder.
3. Load Gearswap in ffxi

From there, the file should be auto loaded and run.
 Quetzalcoatl.Setsuai
Offline
Serveur: Quetzalcoatl
Game: FFXI
user: Setsuai
Posts: 61
By Quetzalcoatl.Setsuai 2014-06-20 20:40:58
Link | Citer | R
 
It's okay. I figured it out. It was because I was typing in commands for spells like I normally do instead of menu casting them.
 Bismarck.Snprphnx
Offline
Serveur: Bismarck
Game: FFXI
user: Snprphnx
Posts: 2707
By Bismarck.Snprphnx 2014-06-20 20:44:44
Link | Citer | R
 
You should still be able to type them in. Like my macros have a single line in them, example: /ma "Thunder V" <t> or /ja "Rapture" <me>
First Page 2 3 4 5