Page 1 of 1

MSDP.STRING_AFFECTS bug

PostPosted: Mon Jan 16, 2017 9:13 am
by Tuck
** problem fixed **
Here is mudlet code to parse MSDPAFFECTS correctly:
Alias:
Code: Select all
if not checkSpell("regeneration") then send("cast 'regen'") end
if not checkSpell("darksight") then send("darksi") end
if not checkSpell("stone skin") then send("cast 'stone skin'") end
if not checkSpell("infravision") then send("cast 'infravision'") end
if not checkSpell("mobility") then send("cast 'mobility'") end -- Mobility
if not checkSpell("detect magic") then send("cast 'detect m'") end
if not checkSpell("detect invisibility") then send("cast 'detect i'") end


Function:
Code: Select all
function get_affects()
   stringAffects=atcp.MSDPAFFECTS
   stringAffects=string.gsub(stringAffects,string.char(3)..string.char(1),"")
   stringAffects=string.gsub(stringAffects,string.char(1),",")
   stringAffects=string.gsub(stringAffects,string.char(2),": ")
   stringAffects=string.gsub(stringAffects,string.char(3)," ")
   stringAffects=string.gsub(stringAffects,string.char(4),"")
   affectsTable=stringAffects:split(",")
   affects={}
   for i,v in ipairs(affectsTable) do
      if not (v:split(": ")[2]=="-1") then
         affects[v:split(": ")[1]]=v:split(": ")[2]+0
      end
   end
end
function checkSpell(spell)   
   if table.contains(affects,spell) then
      return true
   else
      return false
   end
end

Re: MSDP.STRING_AFFECTS bug

PostPosted: Mon Jan 16, 2017 10:55 am
by *juggleblood*
I told you string_affects is obsolete. MSDPAFFECTS is the newer one.

Re: MSDP.STRING_AFFECTS bug

PostPosted: Mon Jan 16, 2017 11:15 am
by Tuck
yeah, it works

Thanks