To many hudprints

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

To many hudprints

Post 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 :)
User avatar
7Soul
Posts: 199
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: To many hudprints

Post 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)
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
SluisE
Posts: 8
Joined: Fri Nov 30, 2018 4:56 pm

Re: To many hudprints

Post 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.
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: To many hudprints

Post by Eleven Warrior »

ty for the help
Post Reply