Quantcast Reading Chat in LUA - Page 2 - LoTROInterface
VGInterface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
Thread Tools Display Modes
  #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: 243
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
  #12  
Unread 11-21-2015, 07:50 PM
Elliss11 Elliss11 is offline
The Indomitable
 
Join Date: Nov 2015
Posts: 11
hi

if i have not the buff then
Killcount=6;
do_update()


the buff calls "Schnelle Erlösung" in german Client
"Schnelle Erl\195\182sung"

i try something but it doesn´t work. i try it with other buffs too.

Quote:
localPlayer=Turbine.Gameplay.LocalPlayer:GetInstan ce();
effectList=localPlayer:GetEffects()
EffectRemovedHandler=function(sender,args)
if args.Effect:GetName()=="Schnelle Erl\195\182sung" then
killcount=6;
do_update()
end
end
AddCallback(effectList,"EffectRemoved",EffectRemov edHandler)

EffectRemoved=function(sender,args)
for k,v in pairs(args) do
Turbine.Shell.WriteLine(tostring(k)..":"..tostring (v))
end
end
... of the Rings Online\Plugins\BodyCount\BodyCount.lua:147: attempt to index field 'Effect' (a nil value)



thanks for your time

Last edited by Elliss11 : 11-21-2015 at 09:21 PM.
Reply With Quote
  #13  
Unread 11-21-2015, 10:19 PM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 243
Yep, as I noted in my earlier post, I wasn't sure what the args table contained for EffectRemoved. It turns out it contains the index of the effect being removed. Unfortunately, it is also very buggy. Many times when more than one effect are being removed simultaneously the effect has already been removed from the list before the event fires so the index is useless and there is no way to determine the effect that was removed. I will play with it some more when I find time.
Reply With Quote
  #14  
Unread 11-22-2015, 05:23 AM
Elliss11 Elliss11 is offline
The Indomitable
 
Join Date: Nov 2015
Posts: 11
Thanks
Reply With Quote
  #15  
Unread 11-22-2015, 03:08 PM
Thurallor's Avatar
Thurallor Thurallor is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: May 2013
Posts: 128
Quote:
Originally Posted by Garan
Yep, as I noted in my earlier post, I wasn't sure what the args table contained for EffectRemoved. It turns out it contains the index of the effect being removed. Unfortunately, it is also very buggy. Many times when more than one effect are being removed simultaneously the effect has already been removed from the list before the event fires so the index is useless and there is no way to determine the effect that was removed. I will play with it some more when I find time.
I played with this a while back. Based on my observations, the EffectRemoved event also supplies an Effect argument, but only if you've previously read the effects list (with a effectsObject:Get() loop). You can use that argument to get the name of the effect, although that is by no means a unique identifier. (Lots of different effects have the same names.) It may be good enough for the OP's purposes, though.
Reply With Quote
  #16  
Unread 11-22-2015, 06:39 PM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 243
Quote:
Originally Posted by Thurallor
I played with this a while back. Based on my observations, the EffectRemoved event also supplies an Effect argument, but only if you've previously read the effects list (with a effectsObject:Get() loop). You can use that argument to get the name of the effect, although that is by no means a unique identifier. (Lots of different effects have the same names.) It may be good enough for the OP's purposes, though.
Ah, thanks Thurallor, that explains some of the weirdness I was seeing. It seems if multiple effects are removed simultaneously the second (or subsequent) EffectRemoved contains the args.Effect since the args.Index is no longer valid. That makes the whole thing workable.

The code would then look like:
Code:
 localPlayer=Turbine.Gameplay.LocalPlayer:GetInstance();
 effectList=localPlayer:GetEffects()

 count=0; -- initialize variable
 -- define the AddCallback function
 function AddCallback(object, event, callback)
   if (object[event] == nil) then
     object[event] = callback;
   else
     if (type(object[event]) == "table") then
       table.insert(object[event], callback);
     else
       object[event] = {object[event], callback};
     end
   end
   return callback;
 end

 EffectRemovedHandler=function(sender,args)

   local effectName=""
   Turbine.Shell.WriteLine("args.Effect:"..tostring(args.Effect))
   if args.Effect==ni then
     effectName=effectList:Get(args.Index):GetName()
   else
     effectName=args.Effect:GetName()
   end
   if effectName=="Schnelle Erl\195\182sung" then
     killcount=6;
     do_update()
   end
-- uncomment the following line to see the name of every effect as it is removed in case the name is not "Schnelle Erl\195\182sung"
--   Turbine.Shell.WriteLine("effect:"..effectName)
 end

 AddCallback(effectList,"EffectRemoved",EffectRemovedHandler)

 ChatMonitor = Turbine.Chat;
 ChatReceived = function(f, args)
   local msg = args.Message;

   if(args.ChatType == Turbine.ChatType.PlayerCombat) then
     if string.find (args.Message,"Verbesserter Gnadenschuss",1,true)~=nil then
       killcount=6;
       do_update()
     else
       if killcount==0 then
         do_update()
       else 
         if string.find (args.Message,"Verbesserter Schneller Bogen",1,true)~=nil then
           killcount=killcount-0.333
           do_update()
         end
       end
     end
   end
 end

 AddCallback(Turbine.Chat, "Received", ChatReceived)
Note, the commented line " Turbine.Shell.WriteLine("effect:"..effectName)" can be uncommented to verify what the effect name is in case it is not "Schnelle Erl\195\182sung"
Reply With Quote
  #17  
Unread 11-23-2015, 04:52 PM
Elliss11 Elliss11 is offline
The Indomitable
 
Join Date: Nov 2015
Posts: 11
thx ... i will test it
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
16.5, now in beta on Bullroarer, has one Lua fix magill Interface Requests (L) 0 09-26-2015 06:17 AM
Update 15 has Lua Fixes !!!! magill General Authoring Discussion (L) 4 11-05-2014 01:17 PM
Multiply variable reading of io.open Calax Lua Programming Help (L) 1 10-29-2011 03:36 AM
Combat Chat bar londarhawk LotRO Wish List (L) 1 11-26-2010 06:31 PM
Chat Box AUtz Interface Help (D) 1 05-21-2009 10:56 AM


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


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | VGInterface | LoTROInterface | MMOInterface | Swtorui