I can't wrap my head around why this isn't working.
Created an index of a custom made object to track spell timers. For whatever reason I can't find whatever method or call or argument that I use to return the specific element within the index that matches my search criteria. The script works and populates the index just fine. I just can't make a simple call to return the element so I can play with its methods.
Would someone mind taking a look at this and tell me where I am going wrong?
The function abilSearch returns the object because it has the methods and members of the obj_abilTimer but it doesn't return the object of the element it just found in the iteration loop.
And I am sure this looks hackish to some people so please comment on any changes that you would make. In my working version I am using arrays of obj_abilTimer and the function to find the matching tgtID returns the key. So I have something that does work, it's just lacks a lot of polish.
Thank you for your time.
objectdef obj_abilTimer
{
variable collection:uint abilDict
variable int64 ID
method Initialize()
{
This.ID:Set[0]
}
method Add(int64 tgtID, string abilName="", int abilT=0)
{
This.ID:Set[${tgtID}]
echo --- abilTimer --- adding ID ${This.ID}
if ${abilName.Length}>1 && ${abilT}>0
This:Set[${abilName}, ${abilT}]
}
method Set(string abilName, int abilTime)
{
variable int64 timeAdded
timeAdded:Set[${Math.Calc[${abilTime}*1000]}]
This.abilDict:Set[${abilName}, ${Math.Calc[${Script.RunningTime}+${timeAdded}]}]
echo verying object timer was added
if ${This.abilDict.Element[${abilName}](exists)}
echo tgtID - ${This.ID} abilDict - ${abilName} timeAdded - ${timeAdded} timeEnding - ${This.abilDict[${abilName}]}
}
method Clear()
{
This.abilDict:Clear
}
member:bool isReady(string abilName)
{
if ${Math.Calc[${This.TimeRemaining[${abilName}]}-${Math.Calc[${Me.Ability[${abilName}].CastTime}*1000]}]}<=0
return TRUE
else
return FALSE
}
member:int64 TimeRemaining(string abilName)
{
if ${This.abilDict.Element[${abilName}](exists)}
echo --- TimeRemaining --- ${abilName} --- ${Script.RunningTime} versus ${This.abilDict[${abilName}]}
if !${This.abilDict.Element[${abilName}](exists)} || ${Script.RunningTime}>=${This.abilDict[${abilName}]}
return 0
else
return ${Math.Calc[${This.abilDict[${abilName}]}-${Script.RunningTime}]}
}
}
function
bj_abilTimer abilSearch(int64 tgtID)
{
echo --- abilSearch --- ${tgtID}
variable iterator abilIter2
abilTimers:GetIterator[abilIter2]
if ${abilIter2:First(exists)}
{
do
{
echo testing ${tgtID} vs ${abilIter2.Key} / ${abilIter2.Value.ID}
if ${abilIter2.Value.ID}==${tgtID}
{
echo found it key = ${abilIter2.Key} isReady ${abilIter2.Value.isReady["Recall"]}
return ${abilIter2.Value}
}
}
while ${abilIter2:Next(exists)}
}
}
variable obj_abilTimer obj_abilTimer
variable index
bj_abilTimer abilTimers
Created an index of a custom made object to track spell timers. For whatever reason I can't find whatever method or call or argument that I use to return the specific element within the index that matches my search criteria. The script works and populates the index just fine. I just can't make a simple call to return the element so I can play with its methods.
Would someone mind taking a look at this and tell me where I am going wrong?
The function abilSearch returns the object because it has the methods and members of the obj_abilTimer but it doesn't return the object of the element it just found in the iteration loop.
And I am sure this looks hackish to some people so please comment on any changes that you would make. In my working version I am using arrays of obj_abilTimer and the function to find the matching tgtID returns the key. So I have something that does work, it's just lacks a lot of polish.
Thank you for your time.
objectdef obj_abilTimer
{
variable collection:uint abilDict
variable int64 ID
method Initialize()
{
This.ID:Set[0]
}
method Add(int64 tgtID, string abilName="", int abilT=0)
{
This.ID:Set[${tgtID}]
echo --- abilTimer --- adding ID ${This.ID}
if ${abilName.Length}>1 && ${abilT}>0
This:Set[${abilName}, ${abilT}]
}
method Set(string abilName, int abilTime)
{
variable int64 timeAdded
timeAdded:Set[${Math.Calc[${abilTime}*1000]}]
This.abilDict:Set[${abilName}, ${Math.Calc[${Script.RunningTime}+${timeAdded}]}]
echo verying object timer was added
if ${This.abilDict.Element[${abilName}](exists)}
echo tgtID - ${This.ID} abilDict - ${abilName} timeAdded - ${timeAdded} timeEnding - ${This.abilDict[${abilName}]}
}
method Clear()
{
This.abilDict:Clear
}
member:bool isReady(string abilName)
{
if ${Math.Calc[${This.TimeRemaining[${abilName}]}-${Math.Calc[${Me.Ability[${abilName}].CastTime}*1000]}]}<=0
return TRUE
else
return FALSE
}
member:int64 TimeRemaining(string abilName)
{
if ${This.abilDict.Element[${abilName}](exists)}
echo --- TimeRemaining --- ${abilName} --- ${Script.RunningTime} versus ${This.abilDict[${abilName}]}
if !${This.abilDict.Element[${abilName}](exists)} || ${Script.RunningTime}>=${This.abilDict[${abilName}]}
return 0
else
return ${Math.Calc[${This.abilDict[${abilName}]}-${Script.RunningTime}]}
}
}
function
{
echo --- abilSearch --- ${tgtID}
variable iterator abilIter2
abilTimers:GetIterator[abilIter2]
if ${abilIter2:First(exists)}
{
do
{
echo testing ${tgtID} vs ${abilIter2.Key} / ${abilIter2.Value.ID}
if ${abilIter2.Value.ID}==${tgtID}
{
echo found it key = ${abilIter2.Key} isReady ${abilIter2.Value.isReady["Recall"]}
return ${abilIter2.Value}
}
}
while ${abilIter2:Next(exists)}
}
}
variable obj_abilTimer obj_abilTimer
variable index