New Lua Function: GetArchetypeName

Discussions on development of both the EQ2Emulator LUA Script Engine and Script specifications

Moderator: Team Members

Post Reply
User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

New Lua Function: GetArchetypeName

Post by thefoof » Thu Jul 18, 2013 9:23 pm

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()
Last edited by John Adams on Sat Aug 03, 2013 10:32 am, edited 1 time in total.
Reason: added link to wiki article

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: New Lua Function: GetArchetypeName

Post by John Adams » Fri Jul 19, 2013 10:39 am

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.

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: New Lua Function: GetArchetypeName

Post by thefoof » Fri Jul 19, 2013 2:05 pm

Yeah it's up there now.

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: New Lua Function: GetArchetypeName

Post by Jabantiz » Fri Jul 19, 2013 2:58 pm

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.

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: New Lua Function: GetArchetypeName

Post by thefoof » Fri Jul 19, 2013 3:10 pm

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.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: New Lua Function: GetArchetypeName

Post by John Adams » Fri Jul 19, 2013 3:50 pm

Woot. Excellent work. I feel some good C++ stuff coming our way :mrgreen:

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests