Blm Lua Help For Making Nuking Sets

Langues: JP EN DE FR
users online
Forum » FFXI » Jobs » Black Mage » Blm Lua help for making nuking sets
Blm Lua help for making nuking sets
 Fenrir.Gukai
Offline
Serveur: Fenrir
Game: FFXI
user: Gukai
Posts: 30
By Fenrir.Gukai 2016-04-03 03:21:05
Link | Citer | R
 
Hello,
Can someone please review my Lua
http://pastebin.com/2magZVpR

I am looking for a way to make nuking sets based on conditions. Sometimes I want a magic acc set, sometimes a bursting set, sometimes normal nuking, etc

I do not use Includes, such as mote-includes. This is because I need 100% understanding of what goes into my lua and I dont get it with his stuff.

I need to change my self commands, I just don't know to what, and I dont know what changes in the rules will need to be done too. Right now my self-commands are more functional for TP'ing and not magic, they are something I was trying to convert but got lost in doing it.

Thank anyone in advance for your help and suggestions
 Sylph.Feary
Offline
Serveur: Sylph
Game: FFXI
user: feary
Posts: 455
By Sylph.Feary 2016-04-03 05:21:46
Link | Citer | R
 
think of selfcommand as a button to navigate thru a list or loop.

0 is your normtal set
1 is your acc set
2 is your burst set.

if selfcommand == "button" then
if button >= 1 then
-- if its greater than one reset it to 0
button = 0
else
-- increase it by 1
button = button + 1
end
end

in your midcast.

if spell = ElementalMagic then
if button == 0 then
== then equip normal
end
if button == 1 then
==then equip acc sete
end
if button == 2 then
==then equip burst
end


in game macro

/console gs c button

or chatline

//gs c button


example https://github.com/Feary/Gearswap/blob/master/BLM.lua

its not perfect its just an reference. i still need to redo and fix stuff on that lua.
 Ragnarok.Flippant
Offline
Serveur: Ragnarok
Game: FFXI
user: Enceladus
Posts: 658
By Ragnarok.Flippant 2016-04-03 06:36:32
Link | Citer | R
 
This is going to be a really long post. You mention wanting to understand your code, so I went ahead and tried to explain everything so that you can use what is here to apply to other things in the future.

There are a great number of ways you can handle toggles. Feary's solution will work, but there are two key problems: it's not flexible (you cannot easily add another set without having to write new rules), and it's not modular (you cannot combine the feature with other features without a lot of redundancies).

There is also something to consider practically: there is content in which you are magic bursting, but still need to consider magic accuracy. You can solve by adding four options, but it would be more logical and easy to rather have two toggles, one for regular/MB, and one for magic accuracy levels.

The most typical method you'll find for such toggles is based on Byrth's original GearSwap examples. First, make the tables that hold your variables. You can declare these in your get_sets() function:
Code
	m_typeIndex = 1
	m_typeArray = {'normal','MB'}
	m_accIndex = 1
	m_accArray = {'normal','midAcc','highAcc'}	

The index keeps track of where you are in the array. We will use these to "index" our table. For example, m_typeArray[1] would return "normal" while m_typeArray[2] would return "MB". As it is now, m_typeArray[m_typeIndex] would return "normal".

Next, we want to control them. Basically, we need a way to change the number. Our self_command function would look like:
Code
function self_command(command)	
    if command == 'mtype' then
		m_typeIndex=(m_typeIndex % #m_typeArray) + 1
		add_to_chat(200,'M Set changed to '..m_typeArray[m_typeIndex])
	elseif command == 'macc' then
		m_accIndex=(m_accIndex% #m_accArray) + 1
		add_to_chat(200,'M Acc changed to '..m_accArray[m_accIndex])
	end
end

"//gs c macc" would change accuracy, and "//gs c mtype" would change your type. This isn't the most elegant way to do it, but it's simple and works.

Next is to use these. The nice thing is that all of our sets actually make up a really huge table--think of it like a tree with a lot of branches that branch off into their own branches. For example, when we say "sets.midcast.Impact" we are looking at the "Impact" branch of the "midcast" branch of the "sets" tree.

So our "rules" can be written as a set of instructions on how to navigate the tree to the correct branch. Since we're dealing with midcast, we know that's our first branch, so let's start there:
Code
equipSet = sets.midcast

Then we look to see if the next branch exists; and if it does, we will move onto that branch. We actually want to start with the most specific, so that we can catch those first (otherwise "Impact" will get caught by "Elemental Magic"), so we'll start with the spell name:
Code
equipSet = sets.midcast
if equipSet[spell.english] then
	equipSet = equipSet[spell.english]
end

So if your spell's name is "Impact" and you have a set called "sets.midcast.Impact," it will find that. We can add any number of branches, like spell.skill, which you are using now:
Code
equipSet = sets.midcast
if equipSet[spell.english] then
	equipSet = equipSet[spell.english]
elseif equipSet[spell.skill] then
	equipSet = equipSet[spell.skill]
end

Note that we can use an "elseif" here because there is never any reason to use both spell.english and spell.skill, since every spell only has one skill.

So if you cast Haste, but there is no sets.midcast.Haste, it will look for sets.midcast["Enhancing Magic"]. If it finds it, it will move to that branch.

Next, we want to use the variables we declared, so we'll add those branches now. We want to use their own "ifs" because we want them to work independently of one another.
Code
equipSet = sets.midcast
if equipSet[spell.english] then
	equipSet = equipSet[spell.english]
elseif equipSet[spell.skill] then
	equipSet = equipSet[spell.skill]
end
if m_typeArray and equipSet[m_typeArray[m_typeIndex]] then
	equipSet = equipSet[m_typeArray[m_typeIndex]]
end
if m_accArray and equipSet[m_accArray[m_accIndex]] then
	equipSet = equipSet[m_accArray[m_accIndex]]
end	

Now you can use a multitude of sets just by creating them. For example:
sets.midcast["Elemental Magic"]
sets.midcast["Elemental Magic"].midAcc
sets.midcast["Elemental Magic"].highAcc
sets.midcast["Elemental Magic"].MB
sets.midcast["Elemental Magic"].MB.midAcc
sets.midcast["Elemental Magic"].MB.highAcc
sets.midcast.Death
sets.midcast.Death.midAcc
sets.midcast.Death.highAcc

Remember that if it doesn't find a certain branch, it won't move onto it, so you don't need a set called sets.midcast["Elemental Magic"].normal. It will just stay on the sets.midcast["Elemental Magic"] branch until further instruction.

Also note that you cannot create a branch off of a branch that doesn't exist (this will give you a run time error that says something like "Failed to index [blahblah]"). Basically, you can't make "sets.midcast.Death.MB" without a sets.midcast.Death set first. However, you're never going to use Death unless you're magic bursting anyway...so you don't need a sets.midcast.Death.MB set. Even if you set your type to MB, it will stay on the sets.midcast.Death branch.

After you're done navigating the tree, you can then add particular equip rules, like obi.
Code
function midcast(spell,action)
    if spell.action_type == 'Magic' then
        equipSet = sets.midcast
		if equipSet[spell.english] then
			equipSet = equipSet[spell.english]
		elseif equipSet[spell.skill] then
			equipSet = equipSet[spell.skill]
		end
		if m_typeArray and equipSet[m_typeArray[m_typeIndex]] then
			equipSet = equipSet[m_typeArray[m_typeIndex]]
		end
		if m_accArray and equipSet[m_accArray[m_accIndex]] then
			equipSet = equipSet[m_accArray[m_accIndex]]
		end	
		
		if spell.element == world.weather_element or spell.element == world.day_element then
			equipSet = set_combine(equipSet,sets.midcast.weather)
		end
		
		equip(equipSet)
    end
end

In this example, you would use sets.midcast as your basic set (what gets used whenever it can't find anything).

I'm not very good at explaining things, especially at 4AM, so if you have questions, don't hesitate to ask.
[+]
 Sylph.Feary
Offline
Serveur: Sylph
Game: FFXI
user: feary
Posts: 455
By Sylph.Feary 2016-04-03 21:56:13
Link | Citer | R
 
thanks flippant for explaining this in detail.

i just went with a simple on given the situation. i too went the route of skipping on motes to learn my own way. this lead me to giving him a simple answer as i found explaining arrays can be not a good starting place.

however OP, this is where you want to be.
Log in to post.