View Single Post
  #4  
Unread 06-10-2012, 10:02 AM
moebius92 moebius92 is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 51
I'm not sure how familiar with object oriented programming you are, so I'll start my explanation from there.

In object oriented programming, there's two major things - Classes and Instances. Classes are templates or instructions on how to build something. So a Window class might contain all of the information to display some sort of window. Instances are actual individual objects of a particular class - so there might be multiple Window instances, and each represents a different window on your display.

Turbine.Gameplay.EffectList is a class. So you've just tried to ask the template if it has the charge effect - and it has no idea which actor's EffectList you want, because the class itself isn't associated with any particular actor.

What you probably want is the LocalPlayer's EffectList, so you should probably say:

EffectList = Turbine.Gameplay.LocalPlayer:GetInstance():GetEffe cts();

The second thing is (and it probably hasn't caused you problems, but I suspect it will) "charge" never gets defined. So your EffectList:Contains(charge) is asking if the EffectList contains a nil value (undefined variables are always nil) - which will always be false. The list only contains actual Effects.

You've got two options - one, scan the EffectList (see :GetCount() and :Get(index)), or two use args.Effect and args.Index to keep track of which effect is being added or removed. I'd do the first one - it's clunkier to handle, and once you've got that working, think about using the args.Effect and args.Index arguments.
Reply With Quote