Page 1 of 1

New Lua Function: GetArchetypeName

Posted: Thu Jul 18, 2013 9:23 pm
by thefoof
This function returns the string value of a spawn's archetype. Example, if this function is used for a spawn with the adventure class "Defiler", GetArchetypeName() will return the string value "Priest".

Syntax: GetArchetypeName(Spawn) where Spawn is a spawn pointer.


Wiki: GetArchetypeName()

Re: New Lua Function: GetArchetypeName

Posted: Fri Jul 19, 2013 10:39 am
by John Adams
Cool. Are these being added to the Wiki too (al la Jabantiz style)? I don't want that to get any more outdated than it already is... when adding functionality.

Thanks.

Re: New Lua Function: GetArchetypeName

Posted: Fri Jul 19, 2013 2:05 pm
by thefoof
Yeah it's up there now.

Re: New Lua Function: GetArchetypeName

Posted: Fri Jul 19, 2013 2:58 pm
by Jabantiz
Great job on this lua function, even added the error logs that I usually forget and have to go back and add in later. Just 2 minor issues that are more for error catching.

First is the lua_interface pointer needs to be checked first thing.

Code: Select all

if (!lua_interface)
		return 0;
This will just prevent a server crash in the rare event that it is null.

The second is there is there is a slight chance adv_class could equal 0 skipping the if and resulting in no return value, as the function needs an int return value you just need to add

Code: Select all

return 0;
at the end. This would only be an issue on custom servers that have use the commoner class, also it will produce a warning when you compile
warning C4715: 'EQ2Emu_lua_GetArchetypeName' : not all control paths return a value
Still great job on this function.

Re: New Lua Function: GetArchetypeName

Posted: Fri Jul 19, 2013 3:10 pm
by thefoof
Okay thanks for looking it over jab :D, only reason I knew to set the error log was because the function right above it had one :wink: monkey see monkey do. I'll make that change now.

Re: New Lua Function: GetArchetypeName

Posted: Fri Jul 19, 2013 3:50 pm
by John Adams
Woot. Excellent work. I feel some good C++ stuff coming our way :mrgreen: