Page 2 of 2

Re: The "Has anyone got this code to work?" thread

Posted: Mon Nov 24, 2014 11:20 pm
by JKos
Like minmay said, the item is not in a map when it's in a champion slot, and for some reason triggerConnectors tries to access the item's map field which is nil in that case. So this is a bug (or a feature :) ) and should be reported to AH, I'm pretty sure that we can't do anything about this.

edit:
you can test it by placing for example a dagger_1 on your map, then in console call print(dagger_1.map) should print table0x34234243 or something.
the in dagger onEquip-hook try to print map again

Code: Select all

onEquipItem = function(self, champion, slot) 
			print(self.go.map) 
end,
and you will get nil.

Re: The "Has anyone got this code to work?" thread

Posted: Mon Nov 24, 2014 11:33 pm
by NutJob
Aye, yes. The first thing I did when I got the map is nil error was this:

Code: Select all

function specialRope(x, y, z, facing)
	local o = spawn("rope", party.level, x, y, facing, z)
	print(o.map)
	o.item:addConnector("onEquipItem", "lib", "aaa")
	o.item:addConnector("onUnequipItem", "lib", "bbb")
	print(o.map)
end
Both give me the same table.

Re: The "Has anyone got this code to work?" thread

Posted: Tue Nov 25, 2014 10:33 am
by Doridion
I'll place this as a bug in the superthread ;)

Re: The "Has anyone got this code to work?" thread

Posted: Tue Nov 25, 2014 7:39 pm
by NutJob
Thanks Doridion, I can pretty much confirm using addConnector (on the correct field) on an item, only, will produce this error. I just tried added an event to many weapons, armor, and gear, starting with meleeattack on a long sword and I get map is nil.

I use add/removeConnector() (not in the editor but manually in scripts) hundreds of times in my module with everything from the party to push blocks to floor/plate triggers to doors and buttons but it seems items refuse to accept these events. Again, any of these hooks will work fine if they're added using defineObject in the Class block.

FYI to those wondering why I manually script all my event hooks and don't just use the editor: because I use a loader that pulls all my external files into the game, the editor doesn't recognize there's functions inside the file; so the drop down menu never gets populated with all the functions in these external files. Not looking for a fix for this though. I prefer this method and it helps force me to remain organized. ha! ~cheers~

Re: The "Has anyone got this code to work?" thread

Posted: Thu Nov 27, 2014 10:18 pm
by NutJob
Does anyone out there have version .9 or .13?