Question To Expert Lua Scriprt Writer

言語: JP EN DE FR
2010-06-21
New Items
users online
フォーラム » Windower » Support » Question to Expert Lua Scriprt Writer
Question to Expert Lua Scriprt Writer
 Carbuncle.Galmaximas
Offline
サーバ: Carbuncle
Game: FFXI
Posts: 88
By Carbuncle.Galmaximas 2015-10-20 10:11:03  
Ok so I am reaching my intermediate levels in terms of editing gearswap luas my question is in my lua I seen I have certain lets call them "gear jump sets" that are dependent on keys such as f9 f10 etc my question is how do I assign gear sets to keys such as f7,f8 etc? thank-you for any input in advance.

P.S - I am a visual learner so any examples would be greatly appreciated.
 Carbuncle.Galmaximas
Offline
サーバ: Carbuncle
Game: FFXI
Posts: 88
By Carbuncle.Galmaximas 2015-10-20 14:27:19  
I think what I am looking for to be more specific is a explanation / example of how to implement key binds into my lua
 Shiva.Nitroustaru
Offline
サーバ: Shiva
Game: FFXI
Posts: 29
By Shiva.Nitroustaru 2015-10-20 21:01:08  
Here is a very simple example of what you're asking about. There are many other (better) ways to do it, but this should help a bit.

Code
function get_sets()
     send_command('@bind f7 gs c changeequip')
     current = "TP1"
     sets.TP            = {stuff here}
     sets.TP_Acc        = {otherstuffhere}
     sets.aftercast_TP  = sets.TP
end


function self_command(command)
   if command == "changeequip" then
        if current == "TP1" then
           current = "TP2"
           sets.aftercast_TP = sets.TP_Acc
        else
           current = "TP1"
           sets.aftercast_TP = sets.TP
       end
       if player.status == "Engaged" then
            equip(sets.aftercast_TP)
       end
   end
end


and a slightly longer example that i use for my paladin (i don't do it with key binds, rather i use macros but same general idea)
Code
    elseif T{'pdt','mdt','shield','reraise','hybrid'}:contains(command) then
        if command == 'pdt' then
            if spdt == false then
                sets.aftercast_TP = sets.pdt
                sets.aftercast_Idle = sets.pdt
                spdt = true
                smdt = false
                sshield = false
                shybrid = false
                reraise = false
                add_to_chat(207, 'Armor: PDT')
                display.armor = "PDT"
            else
                sets.aftercast_TP = sets.TP_Normal
                sets.aftercast_Idle = sets.Idle
                spdt = false
                add_to_chat(207, 'Armor: Normal')
                display.armor = "Normal"
            end
        elseif command == 'mdt' then
            if smdt == false then
                sets.aftercast_TP = sets.mdt
                sets.aftercast_Idle = sets.mdt
                smdt = true
                spdt = false
                sshield = false
                shybrid = false
                reraise = false
                add_to_chat(207, 'Armor: MDT')
                display.armor = "MDT"
            else
                sets.aftercast_TP = sets.TP_Normal
                sets.aftercast_Idle = sets.Idle
                smdt = false
                add_to_chat(207, 'Armor: Normal')
                display.armor = "Normal"
            end
        elseif command == 'shield' then
            if sshield == false then
                sets.aftercast_TP = sets.shield
                sets.aftercast_Idle = sets.shield
                smdt = false
                spdt = false
                sshield = true
                shybrid = false
                add_to_chat(207, 'Armor: Shield')
            else
                sets.aftercast_TP = sets.TP_Normal
                sets.aftercast_Idle = sets.Idle
                shybrid = false
                add_to_chat(207, 'Armor: Normal')
            end
        elseif command == 'reraise' then
            if reraise == false then
                reraise = true
                smdt = false
                spdt = false
                sshield = false
                hybrid = false
                sets.aftercast_TP = set_combine(sets.hybrid,sets.Reraise)
                sets.aftercast_Idle = set_combine(sets.hybrid,sets.Reraise)
                add_to_chat(207,"Armor: Reraise")
                display.armor = "Reraise"
            else
                reraise = false
                sets.aftercast_TP = sets.TP_Normal
                sets.aftercast_Idle = sets.Idle
                add_to_chat(207,"Armor: Normal")
                display.armor = "Normal"
            end
        elseif command == 'hybrid' then
            if shybrid == false then
                sets.aftercast_TP = sets.hybrid
                sets.aftercast_Idle = sets.hybrid
                smdt = false
                spdt = false
                shybrid = true
                reraise = false
                add_to_chat(207, 'Armor: Hybrid')
                display.armor = "DT-"
            else
                sets.aftercast_TP = sets.TP_Normal
                sets.aftercast_Idle = sets.Idle
                shybrid = false
                add_to_chat(207, 'Armor: Normal')
                display.armor = "Normal"
            end
        end
        
        if player.status == "Engaged" then
            equip(sets.aftercast_TP)
        else
            equip(sets.aftercast_Idle,sets.Movement)
        end
    end
 Carbuncle.Galmaximas
Offline
サーバ: Carbuncle
Game: FFXI
Posts: 88
By Carbuncle.Galmaximas 2015-10-20 22:35:41  
late reply but thx a lot I appreciate your assistance
 Shiva.Nitroustaru
Offline
サーバ: Shiva
Game: FFXI
Posts: 29
By Shiva.Nitroustaru 2015-10-21 01:18:50  
yea sorry it's so late, I really don't check forums very often
 Cerberus.Krystela
Offline
サーバ: Cerberus
Game: FFXI
Posts: 53
By Cerberus.Krystela 2015-10-21 04:16:18  
In a simpler way you can do:

Set the key bind exemple we set it to F1 and call it command C1
This goes at the start of your lua.
Code
function get_sets()
    send_command('bind f1 gs c C1') 


Then you create a command.
Code
function self_command(command)
    if command == 'C1' then 
       equip(set.name)
    end
end


If you want something too be locked until you repush the keybind you need 2 lines at start. Lets do like if we are doing it for a PDT set.
Code
function get_sets()
    send_command('bind f1 gs c C1')
    PDT = 'OFF'


Than in command it would look like:
Code
function self_command(command)
    if command == 'C1' then 
        if PDT == 'ON' then
            PDT = 'OFF'
            enable('main', 'sub' ,'range' ,'ammo','ect')	
            add_to_chat(123,'PDT Set: [OFF]')
        else
            PDT = 'ON'
            disable('main', 'sub' ,'range' ,'ammo','ect')
            equip(set.PDT)
            add_to_chat(158,'Enmity Set: [ON]')
        end
        status_change(player.status)
     end
end



Of course you would need to make the desired set for it to work.

And sorry late reply, I also dont read forums often.
 Carbuncle.Galmaximas
Offline
サーバ: Carbuncle
Game: FFXI
Posts: 88
By Carbuncle.Galmaximas 2015-10-21 10:49:07  
Both examples worked like a charm thank you very much both Nitroustaru & Krystela side question to you both so now that we established "key binds as manual commands" i.e I have to push the appropriate key to activate it I now wonder if there is a way to set a function that will activate automatically based on "conditions" I know it works for precast midcast and JAs but will it work on lets say (when my hp is under 50% equip(set.whatever I want?)
 Shiva.Nitroustaru
Offline
サーバ: Shiva
Game: FFXI
Posts: 29
By Shiva.Nitroustaru 2015-10-21 15:08:02  
There are functions in gearswap for that already i believe.. if not there are windower events based around hp.

for example:
Code
windower.register_event("hp change", function (new,old)
    if new / player.max_hp <= .5 then
        --do hp < 50% stuff here
    else
        --do hp > 50% stuff here
    end
end)


This would "Do hp < 50% stuff" if your current hp iss less than or equal to 50% of your max hp. Otherwise it would "Do HP > 50% stuff". For example it would equip reraise gear if you were < 50% or something. I assume this is what you meant. There are other events you can use as well, they are listed here: http://dev.windower.net/doku.php?id=lua:api:events:start

Some of these events have gearswap alternatives though so be careful there.

For future reference as well, here are the functions that are built in to gearswap (hp wasn't one of them so you'll have to use the above example):
http://wiki.windower.net/doku.php?id=addons:gearswap:documentation:gearswap-specific_functions:start
 Carbuncle.Galmaximas
Offline
サーバ: Carbuncle
Game: FFXI
Posts: 88
By Carbuncle.Galmaximas 2015-10-21 15:18:18  
thanks a ton
 Cerberus.Krystela
Offline
サーバ: Cerberus
Game: FFXI
Posts: 53
By Cerberus.Krystela 2015-10-21 23:39:56  
Personally I just do, exemple from my whm lua:

(Those are under aftercast and status changes)

Exemple I want to switch to a specific idle set when my MP is under 80%:
Code
	if player.mpp <80 then
            equip(sets.aftercast.Idle)
        end
	



Or I want switch to a idle PDT set if my hp is under 70%
Code
if player.hpp <70 then
        equip(sets.aftercast.Defense)
      end		
	


And lastly if I want to equips a special neck if my TP is over 100.
Code
 if player.tp >100 then
           equip(sets.aftercast.Idle, {neck="Chrys. Torque"})  
       end	
	


and sorry again I am so slow lol
 Shiva.Nitroustaru
Offline
サーバ: Shiva
Game: FFXI
Posts: 29
By Shiva.Nitroustaru 2015-10-22 00:58:40  
ha i totally forgot about those parts of the vitals table.. I knew there was probably an easier way to do it....
 Carbuncle.Galmaximas
Offline
サーバ: Carbuncle
Game: FFXI
Posts: 88
By Carbuncle.Galmaximas 2015-10-31 05:39:22  
late reply thx
Log in to post.