is there a way to change spell based on recast timer not being up yet?
is there a way to change spell based on recast timer not being up yet?
You'd have to use the get_spell_recasts() function in order to check if the recast was up.It's a windower Lua interface function, not part of GearSwap. I'm not sure how to call them, but this might work(?).Code:get_spell_recasts() Returns a table containing all spells and their cooldowns. The key of this table is the spell ID, the values are the time in 1/60 second increments that remain on the cooldown.
Something likeCode:_recasts=windower.get_spell_recasts() function precast(spell) if spell.name == 'name' then if _recasts[spell id] > 0 then .................. end end
Bleh, tons of things to answer that I missed in the last couple days. Working through them sequentially, so may duplicate some other answers.
Correct. You can use the 'set' command to assign a specific value to a state variable, the 'toggle' command to change between true and false for a boolean state variable, or the 'cycle' command to increment through a list of option values associated with a state variable.
I'm not sure I understand the question? //gs c set <state> <value> doesn't go in any function. It's handled in the include library. You can enter it at the command line, make a macro for it (prefix with /console), or use a keybind (don't use the // prefix).
No. Assuming you're making a _gear sidecar file, you can override the init_gear_sets() function, but you do -not- want to use the get_sets() function. That's handled within the base job lua file. Overriding it screws lots of things up. [Edit: Assuming you're using a _gear sidecar file because your file includes a user_setup() function call, which is part of my include structure.]
However, if you just change the name of the function to init_gear_sets, you're fine in that regard.
Don't use this to determine cure spells. It can fail in multiple different ways.Code:if not string.find(spell.english,'Cur') then
What you want is:
Code:if spell.english:startswith('Cure') or spell.english:startswith('Cura') then
Three errors:Code:if spell.element == world.weather_element or spell_element == world.day_element and sets.Obi[spell.element] then
spell.element, not spell_element
Use parentheses around the two element checks, before testing the obi. Otherwise you get unexpected results.
Code:if (spell.element == world.weather_element or spell.element == world.day_element) and sets.Obi[spell.element] then
S{} is one of three general types of collections that are available to you in GearSwap. They're defined in the general lua libraries that Windower includes. The three types:
T{} - A table. Standard "Item A"="Value B" collection, where order isn't important. Gives access to the various standard collection functions, which a default table {} won't have.
S{} - A set. Arbitrary unordered list of key values. Their value is always boolean true. Useful when all you care about is whether a key value exists or not. Also useful for set operations that you may remember from your algebra class, like unions and intersections and such.
L{} - A list. A list of values with a specific ordering. A, B, C will always show up in the order of A, B, C, and never as C, A, B or whatever. This is the only type of table that guarantees results will always retain their defined order.
So, for the example given to you, all you care about is the specific spell names ("Escape", "Warp", etc). Their order doesn't matter, and you're not associating a value with each spell, but you want to be able to do a quick lookup to see if the spell exists in the list. That's exactly what a set S{} is good for.
No. spell.name == spells.transport would be comparing the name of the spell with the entire list of transport spells. That list is a table reference, and thus a number representing a location in memory. That will never, ever be a valid comparison.
I'm pretty sure I know why this doesn't work now. The get_sets() is only called once on load. I assumed that it would store the variable ws_index, but it probably stores the value ws_hat[ws_index], or Otomi Helm. Changing the value of ws_hat[ws_index] in the precast function doesn't work since the get_sets() function is never called again. In case anyone had a similar problem.Code:function get_sets() ws_hat = {"Otomi Helm", "Mekira-Oto +1"} ws_index = 1 sets.precast.WS["Stardiver"][0] = { ammo="Thew Bomblet", head=ws_hat[ws_index], body="Miki. Breastplate", hands="Miki. Gauntlets", legs="Cizin Breeches +1", feet="Mikinaak Greaves", neck="Light Gorget", waist="Light Belt", left_ear="Brutal Earring", right_ear="Moonshade Earring", left_ring="Pyrosoul Ring", right_ring="Pyrosoul Ring", back="Atheling Mantle" } end function precast(spell) if spell.type== 'WeaponSkill' then if world.day == 'Earthsday' or world.day=='Lightsday' or world.day=='Darksday' then ws_index=2 else ws_index=1 end end end
this "should" work
actually... shouldn't... and you practically gave the reason in the last post.. but they are many works around likeCode:function get_sets() ws_index = 1 ws_hat = {} ws_hat[1] = {"Otomi Helm"} ws_hat[2] = {"Mekira-Oto +1"} sets.precast.WS["Stardiver"] = { ammo="Thew Bomblet", head=ws_hat[ws_index], body="Miki. Breastplate", hands="Miki. Gauntlets", legs="Cizin Breeches +1", feet="Mikinaak Greaves", neck="Light Gorget", waist="Light Belt", left_ear="Brutal Earring", right_ear="Moonshade Earring", left_ring="Pyrosoul Ring", right_ring="Pyrosoul Ring", back="Atheling Mantle" } end function precast(spell) if spell.type== 'WeaponSkill' then if world.day == 'Earthsday' or world.day=='Lightsday' or world.day=='Darksday' then ws_index=2 else ws_index=1 end end end
Code:function get_sets() ws_index = 1 ws_hat = {} ws_hat[1] = {head="Otomi Helm"} ws_hat[2] = {head="Mekira-Oto +1"} sets.precast.WS["Stardiver"] = { ammo="Thew Bomblet", body="Miki. Breastplate", hands="Miki. Gauntlets", legs="Cizin Breeches +1", feet="Mikinaak Greaves", neck="Light Gorget", waist="Light Belt", left_ear="Brutal Earring", right_ear="Moonshade Earring", left_ring="Pyrosoul Ring", right_ring="Pyrosoul Ring", back="Atheling Mantle" } end function precast(spell) if spell.type== 'WeaponSkill' then if world.day == 'Earthsday' or world.day=='Lightsday' or world.day=='Darksday' then ws_index=2 else ws_index=1 end end if spell.name == "Stardiver" then equip(sets.precast[spell.name]) equip(ws_hat[ws_index]) end end
I think that's the same thing. It was my understanding that thisis the same asCode:table={"apples","oranges"}since they're really both short forms ofCode:table={} table[1]="apples" table[2]="oranges"In the same way:Code:table={[1]="apples",[2]="oranges"}
is equivalent toCode:table = {} table.a = {"apples"} table.b = {"oranges"}Or if you really want to confuse peopleCode:table={a="apples",b="oranges"}
is the same asCode:table={"apricots",a="apples",b="oranges"}
If you don't pick a name for the key, Lua assigns it a number.Code:table={} table.a="apples" table.b="oranges" table[1]="apricots"
Edit: Oh, sorry JSHidaka, I somehow didn't see your edit before replying. Thanks for an easy workaround.
Everything you've said is correct, as is your analysis of why the code doesn't work.
ok im having a serious issue trying to use an include
this is my main file called SAM.lua
http://pastebin.com/JMHJHwYB
this is my include called WS2.lua
http://pastebin.com/4QxMPXt9
ever time i use a weapon skill i keep getting the same error
Gearswap has detected an error in the user function precast:
(removed folder info)WS2.lua:244: attempt to call index field 'ws' (a nil value)
i have run both individualy and thay work just fine but when i add the include thats when thay error
You define the function get_sets() twice (once in each document). There's no need to put all your WS info in the get_sets() function, so just eliminate the function call there. Also, eliminate sets = {}.
but i have the percast() function in both as well but thay just over lap
but anyways
like this??
http://pastebin.com/QNDg2kGT
Very simplified method to get what you want:
Or, if you want it per weaponskill:Code:function get_sets() mekira_days = S{"Earthsday", "Lightsday", "Darksday"} headgear_if = T{true = "Mekira-Oto +1", false = "Otomi Helm"} ws_headgear = {name="Otomi Helm"} set.precast.WS = {head=ws_headgear} end function precast() if spell.type== 'WeaponSkill' then ws_headgear.name = headgear_if[mekira_days:contains(world.day)] equip(set.precast.WS) end end
Code:function get_sets() mekira_days = T{} mekira_days.Stardiver = S{"Earthsday", "Lightsday", "Darksday"} headgear_if = T{true = "Mekira-Oto +1", false = "Otomi Helm"} ws_headgear = {name="Otomi Helm"} set.precast.WS = {head=ws_headgear} end function precast() if spell.type== 'WeaponSkill' then ws_headgear.name = headgear_if[mekira_days:contains(spell.english) and mekira_days[spell.english]:contains(world.day)] equip(set.precast.WS) end end
Yeah! You're going to want to avoid calling precast twice as well. Something like this:
http://pastebin.com/P0X5j9f2
And then add this line to the precast function of sam.lua:
Then you've started to build a library (a file with a common purpose/functions that can be used in multiple documents) with your WS2.lua. Each document would have to use elemental_ws_gear(spell) in precast.Code:elemental_ws_gear(spell)
This would be another way to do the same thing: http://pastebin.com/5WXTCh9J
You would just call WS_Library.equip_neck(spell) when you want to equip the right gorget, WS_Library.equip_waist(spell) when you want to equip the right belt, or WS_Library.equip_hachimaki(spell) when you want to equip the right hachimaki.
Order of operations:
1) sets = {} is defined by GearSwap.
2) Sam.lua is loaded and processed. It's now an object in memory.
2a) Loaded lua now includes the functions: get_sets(), precast(), midcast(), aftercast(), status_change(), buff_change().
3) GearSwap calls the lua's get_sets() function.
4) get_sets() calls the include() function.
5) The include() function loads the ws2.lua file, and tries to add the things that that file defines to the existing user object in memory.
6) ws2.lua defines precast(). This replaces the existing precast() that sam.lua defined.
7) ws2.lua defines get_sets(). This tries to replace the existing get_sets() function. However that can be problematic because you're inside the get_sets() function right now. Most likely it doesn't work, but even if it does it will never be called (GearSwap only ever calls that function once).
8) You attempt an action, which calls precast(). precast() is the version inside the ws2.lua file, which tries to access sets.ws.element without checking to see if it exists first.
9) sets.ws and sets.ws.element is only defined in the get_sets() function in ws2.lua. That function was (probably) never loaded, and (definitely) wasn't run. Thus sets.ws and sets.ws.element don't exist.
10) Error for trying to access table values that don't exist.
Thanks, that's a really cool way of picking between helms. There's one part I don't understand- if I define set.precast.WS.head = ws_headgear in the get_sets() function, and ws_headgear is a table, won't it define the head slot as the table's identifier in memory? Will that be locked in, similar to how I was unable to change it earlier?
Interestingly, no. Table assignments in Lua connect the key with the table reference, as you can see by printing a tostring'd table. Tables maintain the same reference until they are reassigned or nil'd, so you can change values in them and the keys that reference them will also see the change. That is another use for advanced set tables. If you look a few pages back I include it in various examples of how to solve this problem.
No, because of one particular trick: name. Because of how GearSwap handles augmented items, if it finds a table in an equip slot, and that table has a name value, it treats that name as the item to be equipped. We didn't add anything else to the table for augments or order of eqiupping items, so nothing else gets changed. However, because we're changing a value -inside- the table (ie: name), it's valid to manipulate while leaving the table itself static as part of the set definition.