How do I show an Indicator

Post Reply
Mirdrayn
Posts: 8
Joined: Thu Sep 08, 2011 2:43 pm

How do I show an Indicator

Post by Mirdrayn »

I am playing a mage at the moment and I have to keep certain spells up at all times. So I would like to request for a script or a tutorial on how I can build an icon to indicate if the spell is up. It could be an icon, a bar or something. Assuming the scenario below:

Cast 'Shield'

A Shield surrounds you.

icon indicates 'shield' spell is up'

Your energy shield dissipates.

icon indicates 'shield' spell has expired.

I thank you all in advance.

Darmir
Posts: 227
Joined: Sun May 01, 2011 6:51 pm
Contact:

Re: How do I show an Indicator

Post by Darmir »

Take a look at the Achaea Fancy Gui. It has a bar for mana.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: How do I show an Indicator

Post by Oneymus »

This is a very rudimentary script, and I'm writing it off the top of my head. But something like...
Code: [show] | [select all] lua
--Script: init
-- Create two labels. One on top of the other. I have a script in which I use images,
-- one grayed out for the background and the other coloured. That would work, too.
-- Instead of setBackgroundColor, you would use setBackgroundImage.
-- Define x and y depending on where you want the label, obviously.
createLabel("icon_back", x, y, 50, 50)
-- Something grayish.
setBackgroundColor("icon_back", 50, 50, 50)

createLabel("icon", x, y, 50, 50)
-- Something greenish.
setBackgroundColor("icon", 0, 0, 100)

-- We use this variable as a switch for our shield icons. Is it necessary? No, but this is a good practice, especially if
-- you plan on making use of a more robust system later on.
shieldIsActive = shieldIsActive or false

-- We call this function in our triggers. We could probably move this logic into the triggers
-- themselves, but this reduces redundancy.
function updateShield()
  if shieldIsActive then
    showWindow("icon")
  else
    hideWindow("icon")
  end
end
Code: [show] | [select all] lua
--Trigger: A Shield surrounds you.
--Script:
shieldIsActive = true
updateShield()
Code: [show] | [select all] lua
--Trigger: Your energy shield dissipates.
--Script:
shieldIsActive = false
updateShield()

Mirdrayn
Posts: 8
Joined: Thu Sep 08, 2011 2:43 pm

Re: How do I show an Indicator

Post by Mirdrayn »

Hello Oneymus, I will try to work with that for now. I'm a klutz at scripting and I have litte time on my hands to even explore scripting as a hobby :/ Thank you though!

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: How do I show an Indicator

Post by Oneymus »

No problem. That should be pretty straightforward. It's not amazing, and could use some prettying up. But it should work as intended.

Post Reply