Hello guys !!
I don't know if it is because I have worked all night, but I am stuck on tracking a compile bug with my latest spell implementation.
I have this really long Lua function that fires a "unknown error" when WE tries to save the map.
I have narrowed the problem down to a very small part of the code.
If I comment out lines like that, the map saves and the Lua script does not trigger any compile error :
If I remove the comments from the second TriggerAddCondition (but keep the comments inside), the script triggers the unknown compile error near ")" at the line with "))" :
I know I am tired, but honestly even after looking at this for hours, I still can not see anything wrong with my adding of the trigger condition.
Can anyone identify what is wrong there ?
Just in case here is the full function :
I don't know if it is because I have worked all night, but I am stuck on tracking a compile bug with my latest spell implementation.
I have this really long Lua function that fires a "unknown error" when WE tries to save the map.
I have narrowed the problem down to a very small part of the code.
If I comment out lines like that, the map saves and the Lua script does not trigger any compile error :
Lua:
-- other actions
Roast[r]={CreateTrigger(), CreateTrigger(), b, bn} -- Initializing Roasting Ball data
TriggerRegisterUnitEvent(Roast[r][1], r, EVENT_UNIT_DAMAGED)
TriggerRegisterUnitEvent(Roast[r][2], r, EVENT_UNIT_DEATH)
TriggerAddCondition(Roast[r][1], Condition(DamagedBallActions)) -- Roasting Balls can be damaged like normal Balls
-- TriggerAddCondition(Roast[r][2], Condition(function() -- Roasting Balls require specific actions when killed
-- local r=GetTriggerUnit()
-- local bn=Roast[r][4]
-- PlayCleanSFX(SFXCubes, GetUnitX(r), GetUnitY(r), math.random()*0.4+0.2, math.random()*Pi2, 0, 3.0)
-- StoreBall(Roast[r][3], bn, math.floor((bn-1)/BallsPerLevel)+1)
-- DestroyTrigger(Roast[r][1])
-- DestroyTrigger(Roast[r][2])
-- RemoveUnit(r)
-- return false
-- ))
TimerData[t]={b, r} -- Setting up the data for the timer expiring at the end of the duration of Torrefaction.
-- other actions
If I remove the comments from the second TriggerAddCondition (but keep the comments inside), the script triggers the unknown compile error near ")" at the line with "))" :
Lua:
-- other actions
Roast[r]={CreateTrigger(), CreateTrigger(), b, bn} -- Initializing Roasting Ball data
TriggerRegisterUnitEvent(Roast[r][1], r, EVENT_UNIT_DAMAGED)
TriggerRegisterUnitEvent(Roast[r][2], r, EVENT_UNIT_DEATH)
TriggerAddCondition(Roast[r][1], Condition(DamagedBallActions)) -- Roasting Balls can be damaged like normal Balls
TriggerAddCondition(Roast[r][2], Condition(function() -- Roasting Balls require specific actions when killed
-- local r=GetTriggerUnit()
-- local bn=Roast[r][4]
-- PlayCleanSFX(SFXCubes, GetUnitX(r), GetUnitY(r), math.random()*0.4+0.2, math.random()*Pi2, 0, 3.0)
-- StoreBall(Roast[r][3], bn, math.floor((bn-1)/BallsPerLevel)+1)
-- DestroyTrigger(Roast[r][1])
-- DestroyTrigger(Roast[r][2])
-- RemoveUnit(r)
-- return false
))
TimerData[t]={b, r} -- Setting up the data for the timer expiring at the end of the duration of Torrefaction.
-- other actions
I know I am tired, but honestly even after looking at this for hours, I still can not see anything wrong with my adding of the trigger condition.
Can anyone identify what is wrong there ?
Just in case here is the full function :
Lua:
function SpellEffects()
local spellEffects=CreateTrigger()
for i=1, 4 do
if Playing[i] then
TriggerRegisterPlayerUnitEvent(spellEffects, Player(i-1), EVENT_PLAYER_UNIT_SPELL_EFFECT, nil)
end
end
TriggerAddCondition(spellEffects, Condition(function ()
local sId=GetSpellAbilityId()
if (sId==SpellID[14]) then -- Restore Tower
local c,t=GetTriggerUnit(),GetSpellTargetUnit()
local pn,on,maxlife=GetPlayerId(GetOwningPlayer(c))+1,GetPlayerId(GetOwningPlayer(t))+1,BlzGetUnitMaxHP(t)
PlayCleanSFX(SFXHeal, GetUnitX(c), GetUnitY(c), 1.4, 0.0, 0, 4.0)
PlayCleanSFX(SFXHealed, GetUnitX(t), GetUnitY(t), 1.4, 0.0, 0, 4.0)
if (pn==LocalPn) then
PlayGlobalSound(SNDHeal, SNDHealDur)
end
for i=1,4 do
if (t==Select[i]) then
UpdateHP(t, maxlife, maxlife, on, i, true)
end
end
elseif (sId==SpellID[9]) then -- Go Back Home
local b=GetSpellTargetUnit()
PlaySFXSound(SNDGBH, GetUnitX(b), GetUnitY(b), 120, SNDGBHDur)
UnitAddAbility(b, GBHTextID)
local bn=GetUnitUserData(b)
local d=math.floor((bn-1)/BallsPerLevel+1)*10+1
Destination[bn]=d
IssueDelayedPointOrder(b, "move", WPx[d], WPy[d], 0.1)
elseif (sId==SpellID[10]) then -- Flash Forward
local b=GetSpellTargetUnit()
local bn=GetUnitUserData(b)
PlayCleanSFX(SFXFF, GetUnitX(b), GetUnitY(b), 1.4, 0.0, 0, 1.0)
local d=Destination[bn]
local life=GetWidgetLife(b)*0.66 -- reduced life by 33%
SetWidgetLife(b, life)
if (math.fmod(d, 10)<7) then
local tX,tY=WPx[d],WPy[d]
PauseUnit(b, true)
SetUnitInvulnerable(b, true)
ShowUnit(b, false)
PlayCleanSFX(SFXFF, tX, tY, 1.4, 0.0, 0, 1.0)
SetUnitPosition(b, tX, tY)
SetUnitInvulnerable(b, false)
ShowUnit(b, true)
PauseUnit(b, false)
for i=1,4 do
if (b==Select[i]) then
if (i==LocalPn) then
SelectUnit(b, true)
end
UpdateHP(b, life, CurrentMaxHP, 9, i, true)
end
end
d=d+1
Destination[un]=d
IssueDelayedPointOrder(b, "move", WPx[d], WPy[d], 0.1)
end
elseif (sId==SpellID[15]) then -- Torrefaction
local t,b,type,select=CreateTimer(),GetSpellTargetUnit(),BallType[5],__jarray(false)
local bn,bx,by,ba,life=GetUnitUserData(b),GetUnitX(b),GetUnitY(b),GetUnitFacing(b),GetWidgetLife(b)
PlayCleanSFX(SFXTor, GetUnitX(b), GetUnitY(b), 1.0, 0.0, 0, 1.5)
if IsFlying then
type=BallType[6]
end
for i=1, 4 do -- saving the selection state of the Ball for all players
if IsUnitSelected(b, Player(i-1)) then
select[i]=true
end
end
ShowUnit(b, false)
PauseUnit(b, true)
SetUnitInvulnerable(b, true)
DisableBallTriggers(bn)
local r=CreateUnit(BallsMaster, type, bx, by, ba)
SetUnitUserData(r, bn)
BlzSetUnitMaxHP(r, CurrentMaxHP)
SetWidgetLife(r, life)
local size=life*ResizeFactor
if (size<MinSize) then
size=MinSize
end
SetUnitScale(r, size, size, size)
for i=1, 4 do -- Selecting the Roasting Ball if the normal Ball was selected
if select[i] and (i==LocalPn) then
SelectUnit(r, true)
end
end
Roast[r]={CreateTrigger(), CreateTrigger(), b, bn} -- Initializing Roasting Ball data
TriggerRegisterUnitEvent(Roast[r][1], r, EVENT_UNIT_DAMAGED)
TriggerRegisterUnitEvent(Roast[r][2], r, EVENT_UNIT_DEATH)
TriggerAddCondition(Roast[r][1], Condition(DamagedBallActions)) -- Roasting Balls can be damaged like normal Balls
TriggerAddCondition(Roast[r][2], Condition(function() -- Roasting Balls require specific actions when killed
-- local r=GetTriggerAnit()
-- local bn=Roast[r][4]
-- PlayCleanSFX(SFXCubes, GetUnitX(r), GetUnitY(r), math.random()*0.4+0.2, math.random()*Pi2, 0, 3.0)
-- StoreBall(Roast[r][3], bn, math.floor((bn-1)/BallsPerLevel)+1)
-- DestroyTrigger(Roast[r][1])
-- DestroyTrigger(Roast[r][2])
-- RemoveUnit(r)
-- return false
))
TimerData[t]={b, r} -- Setting up the data for the timer expiring at the end of the duration of Torrefaction.
TimerStart(t, 2+2*GetUnitAbilityLevel(GetTriggerUnit(), sId), false, function()
local t=GetExpiredTimer()
local b,r=TimerData[t][1],TimerData[t][2]
DestroyTimer(t)
-- if the Roasting Ball is dead it has been removed and then it will be nil. Its Ball is stored so we don't have to do anything
if (r~=nil) then
local life=GetWidgetLife(r)
SetWidgetLife(b, life)
local size,select=life*ResizeFactor,__jarray(false)
if (size<MinSize) then
size=MinSize
end
SetUnitScale(b, size, size, size)
for i=1, 4 do -- saving the selection state of the Roasting ball for all players
if IsUnitSelected(r, Player(i-1)) then
select[i]=true
end
end
PlayCleanSFX(SFXTor, GetUnitX(b), GetUnitY(b), 1.0, 0.0, 0, 1.5)
DestroyTrigger(Roast[r][1])
DestroyTrigger(Roast[r][2])
RemoveUnit(r)
EnableBallTriggers(bn)
SetUnitInvulnerable(b, false)
PauseUnit(b, false)
ShowUnit(b, true)
for i=1, 4 do -- Selecting the Ball if the Roasting Ball was selected
if select[i] and (i==LocalPn) then
SelectUnit(b, true)
end
end
local d=Destination[GetUnitUserData(b)]
IssueDelayedPointOrder(b, "move", WPx[d], WPy[d], 0.0)
end
end)
end
return false
end))
end
Last edited: