Alvanaar
05-02-2009, 08:39 AM
My Lua "SetTitle" command is used to give a player a certain title, like "Alvanaar the Undying".
Player:SetTitle() would be great to make a Title NPC using Lua.
I've wanted Lua engines to have a Lua command like this so I decided to create it. :)
What you will need...
- Tortoise SVN: TortoiseSVN downloads | TortoiseSVN (http://tortoisesvn.net/downloads)
- ArcEmu SVN: svn://arcemu.info/svn
Once you've downloaded the SVN, go to:
Trunk / src / scripts / src / LUAScripting
Put this anywhere in LUAEngine.cpp, make sure it isn't in the middle of another function though.
LUAEngine.cpp:
{ "SetTitle", &luaUnit_SetTitle }, //Created by Alvanaar
Now, scroll down the page until you see the main coding. (in the same LUAEngine.cpp)
Make sure it's under a function that ends with } at least
Place this:
int luaUnit_SetTitle(lua_State * L, Unit * ptr)
{
CHECK_TYPEID(TYPEID_PLAYER);
int id = luaL_checkint(L,1);
((Player*)ptr)->AddKnownTitle(id);
return 1;
}
Now, open up LUAFunctions.h and place the following code in a spot where it won't interfere with other functions...
int luaUnit_SetTitle(lua_State * L, Unit * ptr);
Compile your files and you're done.
Here is how to use the command:
Player:SetTitle(TITLEID)
Change TITILEID to the ID of the title you wish the player to receive.
For example, to make a player's title [Player Name], Champion of the Naaru. I would go...
Player:SetTitle(36) -- Gives the player the title - Champion of the Naaru
I hope this is useful to some people!!
Cheers,
Alvanaar
Player:SetTitle() would be great to make a Title NPC using Lua.
I've wanted Lua engines to have a Lua command like this so I decided to create it. :)
What you will need...
- Tortoise SVN: TortoiseSVN downloads | TortoiseSVN (http://tortoisesvn.net/downloads)
- ArcEmu SVN: svn://arcemu.info/svn
Once you've downloaded the SVN, go to:
Trunk / src / scripts / src / LUAScripting
Put this anywhere in LUAEngine.cpp, make sure it isn't in the middle of another function though.
LUAEngine.cpp:
{ "SetTitle", &luaUnit_SetTitle }, //Created by Alvanaar
Now, scroll down the page until you see the main coding. (in the same LUAEngine.cpp)
Make sure it's under a function that ends with } at least
Place this:
int luaUnit_SetTitle(lua_State * L, Unit * ptr)
{
CHECK_TYPEID(TYPEID_PLAYER);
int id = luaL_checkint(L,1);
((Player*)ptr)->AddKnownTitle(id);
return 1;
}
Now, open up LUAFunctions.h and place the following code in a spot where it won't interfere with other functions...
int luaUnit_SetTitle(lua_State * L, Unit * ptr);
Compile your files and you're done.
Here is how to use the command:
Player:SetTitle(TITLEID)
Change TITILEID to the ID of the title you wish the player to receive.
For example, to make a player's title [Player Name], Champion of the Naaru. I would go...
Player:SetTitle(36) -- Gives the player the title - Champion of the Naaru
I hope this is useful to some people!!
Cheers,
Alvanaar