Why is this not working ?
Posted: Sat Dec 11, 2021 8:36 am
				
				 Hi,
In my scoring function, I'd like to add the killer's weapon class in the log. And it's not working. Cannot figure out why. Help welcomed.
 
In the following code, if I add the code in bold (local killer and killer.classname in the setScore function), it won't work anymore, otherwise it works:
  
local side = "Tunisia"
local currentScore = ScenEdit_GetScore(side)
local points = 0
local unit = ScenEdit_UnitX()
local killer = ScenEdit_UnitY()
 
if unit.type == "Weapon" then
return
end
 
if -- scores by unit type
unit.type == "Aircraft" then points = 100
elseif
unit.type == "Ship" then points = 300
elseif
unit.type == "Submarine" then points = 500
elseif
unit.type == "Facility" then points = 30
end
 
currentScore = currentScore + points
ScenEdit_SetScore(side, currentScore, unit.name.. " ("..unit.classname.." Sub Type: "..unit.subtype.." ) Destroyed by ".. side .." "..killer.classname.. "/ Points: "..points)
 
Can't figure out why ?
 
			In my scoring function, I'd like to add the killer's weapon class in the log. And it's not working. Cannot figure out why. Help welcomed.
In the following code, if I add the code in bold (local killer and killer.classname in the setScore function), it won't work anymore, otherwise it works:
local side = "Tunisia"
local currentScore = ScenEdit_GetScore(side)
local points = 0
local unit = ScenEdit_UnitX()
local killer = ScenEdit_UnitY()
if unit.type == "Weapon" then
return
end
if -- scores by unit type
unit.type == "Aircraft" then points = 100
elseif
unit.type == "Ship" then points = 300
elseif
unit.type == "Submarine" then points = 500
elseif
unit.type == "Facility" then points = 30
end
currentScore = currentScore + points
ScenEdit_SetScore(side, currentScore, unit.name.. " ("..unit.classname.." Sub Type: "..unit.subtype.." ) Destroyed by ".. side .." "..killer.classname.. "/ Points: "..points)
Can't figure out why ?
 )
)