Page 1 of 3

LUA Script WIKI

Posted: Fri Mar 27, 2009 8:27 am
by John Adams
We're going to start filling the Wiki with (hopefully) helpful definitions of our LUA system implementation, of which I will thank Scatman WAY in advance for helping me with - since he is our resident EQ2Emu LUA expert ;)

In talking it over with Scat, we've come up with what I believe will be the most informative "format" for our individual LUA function articles - and before we begin, wanted to run it passed the team - and the community, who are the ones that will likely need this the most.

From the Main LUA Scripting Page, each supported LUA Function will have a link to it's own page where we will lay out the definition of the function, it's params, and example(s). Hopefully it'll look something like this:

Example: GetCurrentHP


Can you guys think of anything else we might need before we begin? Note that some other LUA Functions are far more complex, so give it some thought.


So far, this is our "template", if you want to copy/paste and change the values to a new article:

Code: Select all

== LUA Functions: GetCurrentHP(param) ==

Returns the current '''current hit points''' of ''param''. The parameter can be either a player or the NPC currently being interacted with.

[[Developer:LUA_Functions | Back to LUA Functions Index]]


=== Syntax ===
var = GetCurrentHP(param) 

Must be a reference to a player or NPC.


=== Parameters ===
Required: ''param'' (int)

''param'' must be one of the vars in the function params. In the example above, it would be either "NPC" or "Spawn"


=== Usage ===
  function hailed(NPC, Spawn)
    Say(NPC, "Your current hit points are " .. GetCurrentHP(Spawn) .. "!")
  end

This makes the NPC respond to the player who hails it with the players current hit points.


== Notes ==
(optional) Additional notes or special instructions


== Reference ==
(optional) Links to forum posts or other reference pertaining to this function
This is WIKI-formatting, so don't replace the ='s, or the single-quotes around stuff.

Note: If you indent 1 space, the text gets surrounded by a box - as in the example in Usage.

Note: I would always like to offer the "[[Developer:LUA_Functions | Back to LUA Functions Index]]" BACK option if possible... since the BACK button on browsers sometimes surprises us... :/

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 10:18 am
by Scatman
To avoid as much confusion as possible (almost impossible), we should make everything as uniform as possible. Also, in your example there is a compile error ;) (how's it feel!?) The function is GetAgi, not GetAGI. If you need to reference any of the LUA functions, the method headers are defined in LuaInterface.cpp in LuaInterface::RegisterFunctions

Code: Select all

lua_register(state, "GetAgi", EQ2Emu_lua_GetAgi);
Where what is in quotes is the exact method header. For uniformity see the picture attached. I'm not saying we should include the parameters in each circled box, but the method header should be the same (and correct).

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 1:45 pm
by John Adams
Hah, okie dokie! It was an example. Wiki = Community editable. Pretty sure it was not meant as "this is how you use gEtAgI("

(leaving off the closing paren out of respect) :p

So my example has a "case-sensitivity" problem, that's the issue? For everything else, this is totally your domain, Scatman - I am just setting up the format in hopes to get others interested in helping us fill in the blanks. We obviously do not need a "Notes" section unless Notes are required.

I'm just looking for a minimal amount of data this community will need to reference to reduce the amount of questions about how a function is used - properly.


So, since you said the function format is exactly what is in the header, I changed my Wiki example.
Where what is in quotes is the exact method header.
lua_register(state, "GetAgi", EQ2Emu_lua_GetAgi);
Sure doesn't look right, but ok.

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 3:09 pm
by LethalEncounter
GetWis is fine but GetAgi needs to be GetAGI? :P

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 3:55 pm
by John Adams
Oh FFS... guys, it was an example!!! :p

lol... wow!!!

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 3:57 pm
by Scatman
Rofl :P

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 4:00 pm
by John Adams
Heh, it is Friday, and I made it home alive... it's a good day.

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 4:13 pm
by John Adams
So Scatman, you want to retract what you said up there and tell us really what a function and it's params are supposed to look like? Because

Code: Select all

lua_register(state, "GetAgi", EQ2Emu_lua_GetAgi);
ain't gonna be right. "GetAgi" is not all there is, but your words were
Scatman wrote:Where what is in quotes is the exact method header. For uniformity see the picture attached. I'm not saying we should include the parameters in each circled box, but the method header should be the same (and correct).
I was at work earlier and couldn't adequately tear into you for not being clearer, explaining things like a damn software developer ~cheesey grin~

So, seriously. WTF do you want these to look like? Change GetAgi to exactly what you want, and that's what I'll use.

Please. :)

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 4:22 pm
by Scatman
Sorry, I made my post more confusing than it was supposed to be. I think what you had there was perfect and we should keep it just how it is. I was just expressing my concern about about the two titles not having the same case in the function method name (GetAgi vs GetAGI). In the syntax section, I think we should include the function name with the parameters since it is part of the syntax. I'll change it in a minute and see if you think it looks good.

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 4:27 pm
by John Adams
Ok, thanks Scat. I will post the "template" in the opening post for anyone willing to help us add these... just copy/paste the text into a new WIKI edit window, change the text, save. Cake.

Any page needing creation in the Wiki will have a RED link, usually. Click it, and as long as you are logged in, you will be presented with an editor... that's where you paste the template and make changes.

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 4:32 pm
by Scatman
Easy enough, thanks. So we don't try to write the same things, I guess I'll start with the quest functions since that's the first thing that popped into my head :roll:

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 4:37 pm
by John Adams
Is that the hard stuff? If so, awesome. :D :D :D

I'm setting up my dedicated MySQLx64 tonight, but while it's sourcing I will try and knock out the few other Get/Sets I know about.

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 4:40 pm
by John Adams
Scatman wrote:I'll change it in a minute and see if you think it looks good.
One more thing... since "GetAgi" is not the entirety of the function, do we really want to just leave them hanging there with no () or (param1, param2, ... paramN) etc?

I know we're providing examples too, but mark my word someone will stick a function with no params, because that's what the very first line says to do and that's all they read. ;)

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 5:05 pm
by Scatman
Yeahh, might be a good idea to do that. Originally I thought it'd make the list of functions look messy and hope people would click on them to see the additional information, but now that you mention it, probably best to include the function name with parameters everywhere we reference the function.

*EDIT*
Did you want to include the parameters on the main page with the list of functions? Or just within the page that relates to the specific function?

Re: LUA Script WIKI

Posted: Fri Mar 27, 2009 5:34 pm
by John Adams
Just within the page, so the main page is easy to read through and find stuff. I was only thinking of adding the (param) stuff consistently to the detail pages.