Page 1 of 1

To many hudprints

Posted: Sat Feb 29, 2020 3:21 am
by Eleven Warrior
With the below code it create 4 hudprints and I only want the one hudprint and that is the champ who plays the flute.

Code: Select all

function Music01()
for i=1,4 do
	local ch = party.party:getChampion(i)
	if ch:isAlive() then
		ch:gainExp(50)
	end
	hudPrint(" "..ch:getName().." plays the flute gained 50 XP.")
end
playSound("level_up")
end
Ty for the help :)

Re: To many hudprints

Posted: Sat Feb 29, 2020 6:08 am
by 7Soul
Try this

Code: Select all

function Music01()
local ch = nil
for i=1,4 do
	ch = party.party:getChampion(i)
	if ch:isAlive() then
		ch:gainExp(50)
	end
end
if ch then hudPrint(" "..ch:getName().." plays the flute gained 50 XP.") end
playSound("level_up")
end
It'll print the name of the last champion (alive or not)

Re: To many hudprints

Posted: Sat Feb 29, 2020 7:28 pm
by SluisE
You first have to find out which champion holds/plays the flute before you can print the correct name. At the moment that information is not available in the script.

Re: To many hudprints

Posted: Sun Mar 01, 2020 10:32 am
by Eleven Warrior
ty for the help