Page 1 of 1

Problem with changing portraits if itemSlot is empty

Posted: Sun Jun 23, 2019 4:04 pm
by maneus
I have a problem getting an issue to work.

I will change the portraits of the champions if items are changed in a slot.
If no item is equipped, then the "aurelius.tga" portrait shall spawn. But it doesn´t.

"marine_helmet.tga" and "marine_helmet_2.tga" portraits are working. But if I pick up the item and have it as cursor
nothing happens. I have no idea, how I can tell LoG that the "aurelius.tga" picture have to be shown if the slot is empty.

Can someone help me please with this little issue?

Here is the script I use for the onUnequipItem hook:

Code: Select all

onUnequipItem = function(self, itemSlot)

		local itemSlot = 1
		local currItem


		if self:getItem(itemSlot) ~= nil then 
		currItem = self:getItem(itemSlot)
		if self:getName() == "Captain Aurelius" then
		if currItem.name == "marine_helmet" then
		self:setPortrait("mod_assets/textures/portraits/marine_helmet.tga")
	else
		if currItem.name == "marine_helmet2" then
		self:setPortrait("mod_assets/textures/portraits/marine_helmet_2.tga")
	else 
		self:setPortrait("mod_assets/textures/portraits/aurelius.tga")
		end
		end
		end
		end
	end,

Re: Problem with changing portraits if itemSlot is empty

Posted: Sun Jun 23, 2019 5:44 pm
by Isaac
If I understand your intent... Then the aurelius portrait should be set when either helmet is removed, and both helmets should each set their respective portraits when equipped—and that you want to copy/paste the script into both item definitions...

If that is correct, then this should work: (Otherwise, I'd need a bit more information. ;) )

EDITED:

Code: Select all

		onEquipItem = function(champion, itemSlot)
			local itemName = champion:getItem(itemSlot).name
			if champion:getName() == "Captain Aurelius" and itemSlot == 1 then
				if itemName == "marine_helmet" then
						champion:setPortrait("mod_assets/textures/portraits/marine_helmet.tga")
				 elseif itemName == "marine_helmet2" then
						champion:setPortrait("mod_assets/textures/portraits/marine_helmet_2.tga")
				end
			end
		end,	

		onUnequipItem = function(champion, itemSlot)
			if champion:getName() == "Captain Aurelius" and itemSlot == 1 then
				champion:setPortrait("mod_assets/textures/portraits/aurelius.tga")
			end	
		end,
AlternativelyShow
If you will change the item name for the second helmet to match its texture file-name (or vice-versa), then we can omit the conditional checks for the item names.

EDITED:

Code: Select all

onEquipItem = function(champion, itemSlot)
			local itemName = champion:getItem(itemSlot).name
			if champion:getName() == "Captain Aurelius" and itemSlot == 1 then
				champion:setPortrait("mod_assets/textures/portraits/"..itemName..".tga")
			end
		end,	

		onUnequipItem = function(champion, itemSlot)
			if champion:getName() == "Captain Aurelius" and itemSlot == 1 then	
				champion:setPortrait("mod_assets/textures/portraits/aurelius.tga")
			end	
		end,

Re: Problem with changing portraits if itemSlot is empty

Posted: Sun Jun 23, 2019 10:34 pm
by maneus
Thank you Isaac for your fast reply. yes, you have understand my intend correctly.

Unfortunately your onEquipItem script doesn´t work. No pictures changed. No idea why. :?

If I use my own onEquipItem script it works. My code therefor is:

Code: Select all

onEquipItem = function(self, champ, itemSlot)
			
			local itemSlot = 1
			local currItem

	      		if self:getItem(1) ~= nil then
            		currItem = self:getItem(1)
             		if currItem.name == "marine_helmet" then
			if self:getName() == "Captain Aurelius" then
			self:setPortrait("mod_assets/textures/portraits/space_marine.tga")
			end
			end
		end
	end,
Your onUnequipItem script isn´t also working, but you gave me a hint. It was the "and itemSlot == 1" what I needed.
So I rewrote my onUnequipItem script to:

Code: Select all

onUnequipItem = function(self, itemSlot)

		if self:getName() == "Captain Aurelius" and itemSlot == 1 then
		self:setPortrait("mod_assets/textures/portraits/aurelius.tga")
		end
	end,
And now all works like a charm.

I will make a video for demonstrating your script and post it next days. Your script should work, but it doesn´t.

Re: Problem with changing portraits if itemSlot is empty

Posted: Mon Jun 24, 2019 5:01 am
by Isaac
Going over it, I find that there was indeed an issue with restoring the base portrait unexpectedly when taking the helmets from the inventory slots. :oops:
(It also affected other champion's portraits. :o )

I've corrected the original post.

Image