Quantcast LoTROInterface - View Single Post - Reading Chat in LUA
View Single Post
  #11  
Unread 11-21-2015, 05:15 PM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 269
Quote:
Originally Posted by Elliss11
CombatChanged = function(sender, args)
if not localPlayer:IsInCombat() then
--BodyStatus:SetText("6")

<<<<<<<


killcount=6;
do_update()
end
end
AddCallback(localPlayer, "InCombatChanged", CombatChanged)



Is it still possible here with a sleep function to install ??

because the buff after end of the fight still goes 9sec
This is a tiny bit more complicated - instead of testing the combat state whenever you exit combat, it sounds as though you want to determine when the buff ends. That raises a new question, do you want the status changed whenever the buff ends, or only when it ends out of combat? In either case, you want an event handler that tracks the player EffectList, not the combat state change. Unfortunately, I haven't played with effect lists much and without knowing exactly which effect you are trying to track, I can't provide the exact code, but the basic idea is that you want to handle the EffectRemoved event for the local player EffectList and test for the specific effect you are using as a condition.

The general idea is something like:
Code:
  localPlayer=Turbine.Gameplay.LocalPlayer:GetInstance();
  effectList=localPlayer:GetEffects()
  EffectRemovedHandler=function(sender,args)
    if args.Effect:GetName()=="some effect" then
      killcount=6;
      do_update()
    end
  end
  AddCallback(effectList,"EffectRemoved",EffectRemovedHandler)
where "some effect" is the actual name of the Effect you are looking for.
Note, I didn't have a chance to test this in game so the args.Effect element may not exist in which case you would have to check what the actual elements in the args table are. To list the elements, use:
Code:
  EffectRemoved=function(sender,args)
    for k,v in pairs(args) do
      Turbine.Shell.WriteLine(tostring(k)..":"..tostring(v))
    end
  end
If you only want to set the status when out of combat then just add a test for localPlayer:IsInCombat() to the handler:
Code:
  localPlayer=Turbine.Gameplay.LocalPlayer:GetInstance();
  effectList=localPlayer:GetEffects()
  EffectRemovedHandler=function(sender,args)
    if args.Effect:GetName()=="some effect" and not localPlayer:IsInCopmbat() then
      killcount=6;
      do_update()
    end
  end
  AddCallback(effectList,"EffectRemoved",EffectRemovedHandler)

Last edited by Garan : 11-21-2015 at 05:17 PM. Reason: grammar
Reply With Quote