So, it works, but the coroutine.close doesn't seem to terminate the thread. Any ideas?
So, it works, but the coroutine.close doesn't seem to terminate the thread. Any ideas?
your using this exact code??
are you getting any error reports in the windower command console??Code:c_mb = 1 function end_mb() state.MagicBurst = false end windower.raw_register_event('action message', function (actor_id, target_id, actor_index, target_index, message_id, param_1, param_2, param_3) if message_id > 287 and message_id < 303 then -- Skill chain message ids start at 288 and go through 302 state.MagicBurst = true if type(c_mb) == "thread" then coroutine.close(c_mb) end c_mb = end_mb:schedule(5) end end)
only changes are variable names and a few add_to_chats. Here is what I am using.
I don't get any error messages. I made a function to test the routine just to see how it worked.Code:mb_timer = 1 mb_elem = nil function mb_fin() state.MagicBurst = false mb_elem = nil add_to_chat("Skillchain window closed: Disabling Magic Burst Mode") end function detect_magic_burst(actor_id, target_id, actor_index, target_index, message_id, param_1, param_2, param_3) if message_id > 287 and message_id < 303 then add_to_chat("Skillchain detected: >>"..elements.skillchain[message_id].name.." Enabling Magic Burst Mode") state.MagicBurst = true mb_elem = elements.skillchain[message_id].elements if type(mb_timer) == "thread" then coroutine.close(mb_timer) end mb_timer = mb_fin:schedule(5) end end windower.raw_register_event('action message', detect_magic_burst)
If I spam it with a self command, it starts the coroutine, but every single one will get to the end and run the mb_fin functionCode:function test_magic_burst() add_to_chat("Skillchain detected: Enabling Magic Burst Mode") state.MagicBurst = true if type(mb_timer) == "thread" then coroutine.close(mb_timer) end mb_timer = mb_fin:schedule(5) end
there are only 3 thing i can think of
*1. you might have to change mb_fin:schedule(5) to this coroutine.schedule(mb_fin,5) to get the thread to return correctly (this would be my mistake)
-- the same way i have it in my cp/xp ring code "xpcpcoring = coroutine.schedule(xp_cp_ring_equip: prepare(rings[rings_count]),(ring_time > 0 and ring_time or 1))"
2. coroutine might not work from gs commands (unlikely)
3. coroutine.close is some how broken (the only way to check this is to build test code as a stand alone addon) (vary unlikely)
Some part of coroutines work with gearswap user files, but most do not.
coroutine.schedule
coroutine.close
both of these work in my include setup
the only coroutine that fails in gearswap, thats listed in the windower info, is coroutine.sleep
but as i said in previous posts that sometime you can use
thenameofyourfunction:schedule(timeinseconds)
or
coroutine.schedule(thenameofyourfunction,timeinsec onds)
and there are things one can do but the other can not and i think returning the thread info is one of them
While my Chatoyant Staff was in my wardrobe 2 I noticed that part of mote's vanilla obi system doesn't work with Wardrobe 2. Putting it in my inventory or Wardrobe 1 makes it start working immediately.
From Mote-Utility.lua
The code, "if player.inventory['Chatoyant Staff'] or player.wardrobe['Chatoyant Staff'] then", would I need to add or player.wardrobe2['Chatoyant Staff'] to that?Code:-- Function to get an appropriate obi/cape/ring for the current action. function set_elemental_obi_cape_ring(spell) if spell.element == 'None' then return end local world_elements = S{world.day_element} if world.weather_element ~= 'None' then world_elements:add(world.weather_element) end local obi_name = get_elemental_item_name("obi", S{spell.element}, world_elements) gear.ElementalObi.name = obi_name or gear.default.obi_waist or "" if obi_name then if player.inventory['Twilight Cape'] or player.wardrobe['Twilight Cape'] then gear.ElementalCape.name = "Twilight Cape" end if (player.inventory['Zodiac Ring'] or player.wardrobe['Zodiac Ring']) and spell.english ~= 'Impact' and not S{'Divine Magic','Dark Magic','Healing Magic'}:contains(spell.skill) then gear.ElementalRing.name = "Zodiac Ring" end if obi_name then if player.inventory['Chatoyant Staff'] or player.wardrobe['Chatoyant Staff'] then gear.ElementalWeapon.name = "Chatoyant Staff" end end else gear.ElementalWeapon.name = gear.default.obi_weapon gear.ElementalCape.name = gear.default.obi_back gear.ElementalRing.name = gear.default.obi_ring gear.ElementalSub.name = gear.default.obi_sub end end
yes
tho you might want to do the other 2 as well like this
Code:if obi_name then if player.inventory['Twilight Cape'] or player.wardrobe['Twilight Cape'] or player.wardrobe2['Twilight Cape'] then gear.ElementalCape.name = "Twilight Cape" end if (player.inventory['Zodiac Ring'] or player.wardrobe['Zodiac Ring'] or player.wardrobe2['Zodiac Ring']) and spell.english ~= 'Impact' and not S{'Divine Magic','Dark Magic','Healing Magic'}:contains(spell.skill) then gear.ElementalRing.name = "Zodiac Ring" end if obi_name then if player.inventory['Chatoyant Staff'] or player.wardrobe['Chatoyant Staff'] or player.wardrobe['Chatoyant Staff'] then gear.ElementalWeapon.name = "Chatoyant Staff" end end else
Thanks, though I feel pretty lazy having asked that considering I could have just tested it myself >.> It'd have been a simple test afterall. I do have another, more substantial, question though. Why isn't my code for an ElementalSub working? Here is what I've added.
Mote-Utility.lua
Mote-Mappings.luaCode:-- Function to get an appropriate obi/cape/ring for the current action. function set_elemental_obi_cape_ring(spell) if spell.element == 'None' then return end local world_elements = S{world.day_element} if world.weather_element ~= 'None' then world_elements:add(world.weather_element) end local obi_name = get_elemental_item_name("obi", S{spell.element}, world_elements) gear.ElementalObi.name = obi_name or gear.default.obi_waist or "" if obi_name then if player.inventory['Twilight Cape'] or player.wardrobe['Twilight Cape'] then gear.ElementalCape.name = "Twilight Cape" end if (player.inventory['Zodiac Ring'] or player.wardrobe['Zodiac Ring']) and spell.english ~= 'Impact' and not S{'Divine Magic','Dark Magic','Healing Magic'}:contains(spell.skill) then gear.ElementalRing.name = "Zodiac Ring" end if player.inventory['Chatoyant Staff'] or player.wardrobe['Chatoyant Staff'] then gear.ElementalWeapon.name = "Chatoyant Staff" end if player.inventory['Niobid strap'] or player.wardrobe['Niobid strap'] then gear.ElementalSub.name = "Niobid Strap" end else gear.ElementalWeapon.name = gear.default.obi_weapon gear.ElementalCape.name = gear.default.obi_back gear.ElementalRing.name = gear.default.obi_ring gear.ElementalSub.name = gear.default.obi_sub end end
WHM.luaCode:elements.sub_of = {['Light']='Niobid strap'}--temporary. no, I wouldn't cure in a niobid strap!--
Please note that all of the ElementalEquip code except the ElementalSub was already working beforehand and is still working. I added the ElementalSub myself but I can't get it to work. Nothing is equipped in my sub slot during a cure midcast with or without weather.Code:-- Cure sets gear.default.obi_waist = "Pythia sash" gear.default.obi_weapon = "Queller rod" gear.default.obi_sub = "Genbu's shield" gear.default.obi_back = "Mending Cape" sets.midcast.Cure = { main=gear.ElementalWeapon, sub=gear.ElementalSub, ammo="Esper stone +1", head="Gende. caubeen +1", neck="Incanter's torque", ear1="Glorious earring", ear2="Nourish. earring +1", body="Ebers bliaud +1", hands="Kaykaus cuffs", ring1="Kuchekula ring", ring2="Sirona's ring", back=gear.ElementalCape, waist=gear.ElementalObi, legs="Ebers pant. +1", feet="Kaykaus boots"}
(Yes, gearswap can go from club/shield to weapon/grip without failing the grip equip. I tested this with just sub="Niobid strap" and it equips correctly)
I have progress as far as detecting what the problem is. I was editing the wrong Mote-Utility.lua. Since my WHM.lua uses mote-include version 1, I needed to edit the one in the rev1 folder. Adding the edits to those mote-utility and mote-mappings prints the following error when i cast cure ingame.
...indower4\/addons/GearSwap/libs/rev1/Mote-Utility.lua:474: attempt to index field 'ElementalSub' (a nil value)
I'm not sure why it would print that unless there's another place that I need to edit where these values are assigned other than mote-utility, mote-mappings, and potentially within a job.lua.
did you build your gear.ElementalSub table like
gear.ElementalSub = {name=""}
around line 143
also dont forget that when gearswap gets updated it will overwrite your additions
but you can save it by(i think)
1. creat a new folder in libs called rev0 and pitting all the mote files in there as well as your changed files
2. set mote_include_version = 0
I have two questions.
1. How do I test for if MP is below a specific percentage? Is this possible?
2. How do I have a global variable that I can set and have a default value? What I want to have happen is that when I first start playing, I use a default idle set. Then, if I use a specific set of blood pacts, I switch to a different idle set, and keep using that idle set, until I use a second set of blood pacts, in which case it switches back to the original idle set. I know that I can set a bool for these cases, but I don't know if it's possible to have that bool persist, or to have it have a default state. Is this possible?
Examples(do not put directly in to code thay might cause errors)
1: use(for less then 75 % hp)
2a. if its just a set of specific ones but not in a set order(these are absolute)Code:if player.mpp < 75 then
2.if you want to only trigger after a specif set of them in a sequence its a lot harder(these are absolute)Code:if {"<name1>","<name2>","<name3>"}:contains(spell.name) then <variable> = true if {"name4","name5","name6"}:contains(spell.name) then <variable> = false
if this is what you want it will take time to figure it out
Yeah, I know how to set a variable, I'm just not sure if the variable can persist. So, for example, if I'm focusing on magic blood pacts, I want to be in my magic blood pact idle. So I need to store that off somewhere so that when it goes to check what idle set to use, it uses the right one. So it has to be a global variable. I'm not sure if I can do that or not. I also need to have it set to a default value so I actually use an idle set before I BP.
All Lua variables default to global (persistent). You need to define them as local if you want them to be anything else.