PDA

View Full Version : New Lua "SetTitle" Command!


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

HydroGenerated
05-03-2009, 05:26 PM
Thanks bro +rep

Artilles
05-03-2009, 05:27 PM
Lol nice >_<

Alvanaar
05-03-2009, 09:27 PM
:) Thanks.

bump

bloodshed2007
05-07-2009, 03:04 PM
says:

1>..\src\luascripting\LUAEngine.cpp(4288) : error C2039: 'AddKnownTitle' : is not a member of 'Player'
1> ..\arcemu-world\Player.h(790) : see declaration of 'Player'

Alvanaar
05-08-2009, 09:19 AM
I'll try fix this up when I can. Sorry for the inconvenience.

bloodshed2007
05-08-2009, 11:30 AM
no problems :)

mattias9410
05-09-2009, 09:08 AM
this is lua not c++ lol

Alvanaar
05-09-2009, 10:19 AM
this is lua not c++ lol

Umm... No. This is C++, not Lua.

mattias9410
05-09-2009, 10:55 AM
why do you use Player:SetTitle(TITLEID) then

EDIT: nvm sorry i did'nt read the whole post

Alvanaar
05-09-2009, 11:26 AM
Haha, it's fine.

Read the whole post next time!


----

I'll fix up this Lua command when I get the time later, so it actually works :\

Protoss7
05-09-2009, 11:30 AM
Shouldn't it be
PUnit:SetTitle(ID)
?

Alvanaar
05-10-2009, 07:58 AM
We're setting the player's title.

Hense the:

Player:SetTitle()