Thanks knorke and zwzsg!
Yup, I confirm it only works in
gadget!
I got this portion of the code in a gadget:
Code: Select all
function gadget:UnitDamaged(unitID,unitDefID,unitTeam,damage,paralyzer,weaponID,attackerID,attattackerDefID,attackerTeam)
local x,y,z=Spring.GetUnitPostion(unitID)
local txt = "Unit "..unitID.." from Team"..unitTeam.." is being attacked by Unit "..attackerID.." from Team "..attackerTeam.."at"..x..y..z
Spring.SendLuaUIMsg(txt)
end
Thanks! =)
Which sends the information to a widget to write it in a txt.
The portion that contains of the widget that receive the information:
Code: Select all
function widget:RecLuaMsg(txt,playerID)
write(txt)
end
My questions here:
1. The information is successfully written in a txt file.
But I randomly I will have this error message:
Code: Select all
LuaRules::RunCallIn:error=2, unitDamged, [string "LuaRules/Gadgets/logger.lua"]:16: attemot to concatenate local 'attackerTeam'(a nil value)
How should I ensure this error is prevented?