EQ2Interface

EQ2Interface (https://www.eq2interface.com/forums/index.php)
-   UI Developer Discussion (https://www.eq2interface.com/forums/forumdisplay.php?f=3)
-   -   useability with buttons? (https://www.eq2interface.com/forums/showthread.php?t=13231)

Kyranius 08-17-2009 01:26 PM

useability with buttons?
 
if i have a ui that uses buttons to cast spell is there any way to make the button disabled if the spell does not exist or if the spell is in cooldown?

EQAditu 08-17-2009 06:20 PM

Presumably you're trying to avoid running the rest of the script if the spell is unable to cast. Such as a button that does not trigger chat text unless the spell it is attached to is cast.

We cannot detect if a spell doesn't exist or doesn't cast right away but we can attempt things backwards. If you split the script into two parts, it should be more or less possible. The first half of the script attempts to cast the spell and also generates a second script. The second half of the script is that generated script that triggers when the casting bar becomes visible and you're casting the spell defined by the first script. In actuality it might be best to have three scripts.

For example...
Code:

<Button Name="btn01" OnPress="Parent.CastingVis.ExpectedSpell=Parent.Spell01.Value
Parent.CastingScript.OnShow=Parent.Spell01.ScriptCommand
useability Parent.Spell01.Value" />
<Button Name="btn02" OnPress="Parent.CastingVis.ExpectedSpell=Parent.Spell02.Value
Parent.CastingScript.OnShow=Parent.Spell02.ScriptCommand
useability Parent.Spell02.Value" />

<Data Name="Spell01" Value="Spell Name III" ScriptCommand="tt You're being hit with Spell Name!" />
<Data Name="Spell02" Value="Other Spell IV" ScriptCommand="tt You're being hit with Other Spell!" />

<Text Name="CastingSpell" DynamicData="/GameData.Spells.Casting" LocalText="NoSpell" Visible="false">NoSpell</Text>
<Page Name="CastingVis" DynamicData="/GameData.Spells.Casting" DynamicDataFilter="0001" Visible="false" Blank=" " OnShow="CORRECTSPELL=Parent.SpellName.LocalText==ExpectedSpell
Parent.CastingScript.Visible=false
Parent.CastingScript.Visible=CORRECTSPELL
Parent.CastingScript.OnShow=Blank" />
<Page Name="CastingScript" Visible="false" OnShow=" " />

Two buttons with attached spells that will only execute their separate scripts if the game ends up casting their spell.

If all you were after is a visual representation of a spell being available, I wasted my time and cannot help you.

Zonx 08-18-2009 03:10 PM

Its possible to check for "spell exist", but its a bit of a pain as EQ2Aditu describes.

Basically you'd script up a macro window initialization routine that fires once when the window containing your macros is opened. It assigns a script to the casting window's onshow handler to set a spellname variable as true, then attempts to cast the spell. If the cast window pops up, the variable gets assigned and you know the spell exists, otherwise you assume it doesn't exist. Repeat for each spell you want to test. At the end of the test routine, you assign those values to the corresponding macro button's enabled property, and clear the onshow scripts so they don't get triggered by something else.

Seudo script
Code:

clearallqueuedabilities
cancel_spellcast
castingwindow.onshow='PathBackToMacroWindow.spell1Exists=true
cancel_spellcast'
useability spell1

clearallqueuedabilities
cancel_spellcast
castingwindow.onshow='PathBackToMacroWindow.spell2Exists=true
cancel_spellcast'
useability spell2
...
parent.macro1.enabled=spell1Exists
parent.macro2.enabled=spell2Exists

castingwindow.onshow=''
onShow=''

You may have some execution order problems with the final "enabled" assignments handled in the same script that's testing for existence. If so, you'll need to move that stuff out to another invisible button that gets pressed later.

Generally I find all of this more hassle and a bigger performance hit than its worth.

If you're dealing with a bunch of macro buttons, you could streamline the repetitive code by generalizing the test routine into a dedicated button script that receives the name of the spell to test as input and a returnPath for the object that should receive the result.


All times are GMT -5. The time now is 10:10 AM.

vBulletin® - Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
© MMOUI