| 07-20-2007, 12:21 AM | #1 |
Take this example function: JASS:function HolyConcentrationRemoval takes unit u returns nothing local string udat = GetAttachmentTable(u) local priestbufftimers pbt = GetTableInt(udat, "bufftimers") set pbt.holycontimer = null call SetTableInt(udat, "bufftimers", pbt) set udat = null endfunction Is the SetTableInt() necessary to "save" the changes of pbt? I'm guessing "No" but I just want to make sure |
| 07-20-2007, 12:33 AM | #2 |
I'm pretty sure it is. If you didn't, you would only be changing the local variable, thats why you need to set it again. |
| 07-20-2007, 12:57 AM | #3 |
Don't listen to him, he doesn't know what he's talking about. You don't need to call SetTableInt() again, since the struct is basicaly a reserved index in a set of paralel arrays, that index remains the same no matter how you change the values stored under it. Also, shouldn't you destroy the timer or put it in a pool of timers or something before setting the (presumably) only pointer to it to null? |
| 07-20-2007, 01:02 AM | #4 | ||
Quote:
Thanks I was just testing it and it all works perfectly and yeah, I destroy the timer. I just edited the function to ask my quesiton here's the actual function
|
| 07-20-2007, 01:13 AM | #5 |
(sorry for double post) Okay wierd... when I attempt to destroy this struct (renewdata rd) grimore gives me an "attempt to destroy struct of null type error" JASS://****************************************************** //*Renew //****************************************************** function RenewTick takes nothing returns nothing local timer t = GetExpiredTimer() local string tdata = GetAttachmentTable(t) local renewdata rd = GetTableInt(tdata, "renewdata") local string cdata = GetAttachmentTable(rd.u) if rd.ticks > 0 and GetUnitAbilityLevel(rd.target, 'B01O') > 0 then call SetUnitState(rd.target, UNIT_STATE_LIFE, GetUnitState(rd.target, UNIT_STATE_LIFE) + rd.amount) call SCTDisplayText(rd.target, rd.target, R2I(rd.amount) , false, 2) set rd.ticks = rd.ticks - 1 //call SetTableInt(tdata, "renewdata", rd) endif if rd.ticks == 0 or GetUnitAbilityLevel(rd.target, 'B01O') == 0 then call UnitRemoveAbility(rd.target, 'A05O') call SetTableBoolean(cdata, "swpon", false) call ClearTable(tdata) call DestroyTimer(t) set t = null set cdata = null call rd.destroy() //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< This is where I get the error return endif set t = null set tdata = null set cdata = null endfunction function CastRenewC takes nothing returns boolean local unit u = GetTriggerUnit() local string cdata = GetAttachmentTable(u) local player p = GetOwningPlayer(u) if GetSpellAbilityId() == 'A069' and GetTableBoolean(cdata, "renewonPlayer"+I2S(GetPlayerId(p))) == false then set p = null set u = null set cdata = null return true else set p = null set u = null set cdata = null return false endif endfunction function CastRenewA takes nothing returns nothing local timer t = CreateTimer() local unit u = GetTriggerUnit() local unit target = GetSpellTargetUnit() local string cdata = GetAttachmentTable(u) local string tdata = GetAttachmentTable(t) local herodata hd = GetTableInt(cdata, "herodata") local renewdata rd = GetTableInt(tdata, "renewdata") //renewdata.create() local real amount = 65 * hd.t14actual local real plushealing = (hd.plushealing + hd.plushealingmod) * 1 local player p = GetOwningPlayer(u) set amount = (amount * hd.healingmod) + (plushealing/15) set rd.u = u set rd.target = target set rd.ticks = 15 set rd.amount = amount //call SetTableInt(tdata, "renewdata", rd) call SetTableBoolean(cdata, "renewonPlayer"+I2S(GetPlayerId(p)), true) call TimerStart(t, 1.00, true, function RenewTick) call UnitAddAbility(target, 'A05O') set t = null set cdata = null set tdata = null set target = null set u = null set p = null endfunction |
