Difference between revisions of "LUA"
(→General Functions) |
|||
| Line 134: | Line 134: | ||
{{Header|Conclusion|BackgroundColor=3d78b4|FontColor=ffffff}} | {{Header|Conclusion|BackgroundColor=3d78b4|FontColor=ffffff}} | ||
| − | LUA functions are added often, usually when we discover some new way that | + | LUA functions are added often, usually when we discover some new way that DayBreak does their spawns, quests or other content. If you find you are unable to achieve your goal in your scripting, it is possible you need a LUA function added. You can either choose to develop your own LUA function and submit it to the core Devs for inclusion, or post your requirements in the Feature Request forum for a script dev to add to the server. |
[[Systems|Back to Systems]] | [[Systems|Back to Systems]] | ||
Latest revision as of 07:03, 29 July 2016
LUA
Return to: Main Page | Tutorials | Portal | Forum | Project Manager | Bug Tracker
LUA Scripting is extending the functionality of the server without the need to recompile the code each time you wish to add some form of interaction with an NPC, an event happening in a zone, quest steps for players to work through, etc.
For a comprehensive look at what LUA is, please visit the lua.org website and read their own About information. On this Wiki, we shall only discuss our own implementation of LUA.
We have chosen LUA as our script engine for EQ2Emulator. Things like Quests, Spawn movement or interaction, Spells, and Zone-wide events are scripted in LUA using custom functions specific to the emulator core. Below you will find a list of current EQ2Emulator LUA Functions with links to what they do and examples of how to use them.
You will quickly see that the ease of the LUA Scripting language and it's tight integration with EQ2Emulator make our server extremely dynamic and customizable.
Currently, EQ2Emulator employs LUA scripting for the following systems:
Follow any of these links for a closer look at the system. Below is a general list of LUA functions we'll keep at this top-level for easier reference.
EQ2Emulator LUA Functions normally have parameters - that is, some value required to be passed from the World to the Script or vice-versa. An example of this is the function hailed(NPC, Spawn). Note that there are 2 parameters for function hailed(). What the parameter names are is up to you, as long as there are the proper number of parameters in the () parens.
Example: Here, the Player says Hello to the NPC.
function hailed(NPC, Player) Say(Player, "Hello NPC!") end
Current standards we have adopted are to use NPC as the value for the NPCs parameters, and depending on the type of script, Spawn or Player for the Players parameters. Nearly all other parameter values are dynamic - that is, they can be any valid variable name you choose. But when coding scripts for the Official EQ2Emulator Project, be sure to follow our guidelines or your scripts will get rejected.
Our LUA Functions list is broken into several categories for clarity of functionality. New functions are added often, so check this page often for changes.
IMPORTANT
When adding LUA Command documentation to this Wiki, please be sure to use the LUA Command Template provided to maintain consistency across all our pages.
Below are the function names and a brief description of what the function does. For details on required parameters and usage, click the function name.
All Functions
All the LUA functions EQ2Emu currently has.
Get Functions
This set of functions will GET info from the World or Database for use within any LUA script.
Set Functions
This set of functions will SET info in the World or Database from within any LUA script
Item Functions
This set of function are used to make game Items perform special tasks (clickies or quest items)
Quest Functions
These functions are for use within Quest scripts, and are some of the more complex LUA Functions in the EQ2Emulator.
Spell Functions
These functions are used within Spell scripts to generate the expected effect of casting spells or using abilities.
Spawn Functions
These are functions that normally go into SpawnScripts for interacting with NPCs or other types of Spawns.
General Functions
These are general functions that do not fall under any other classification.
Just a few examples of what you can do with LUA Scripting and EQ2Emulator custom functions... This is by no means a comprehensive list, just some concepts in use:
function hailed(NPC, Spawn) Say(NPC, "Your class is " .. GetClass(Spawn) .. "!") end
This makes the NPC respond to the player who hails it with the players class.
function ChangePlayerClass(NPC, Spawn) var = GetClass(Spawn) SetClass(Spawn, 1) -- changes Spawn to class 1 . . . SetClass(Spawn, var) -- changes Spawn back to original class end
Sets variable var to the value of the function for use in other parts of the script, for example returning to original value after function has completed.
SpawnScripts are what gives your NPC's life. The emulator uses LUA as its scripting engine, and combined with spawnscripts a NPC can preform actions like move, attack, and have conversations.
Coming Soon
LUA functions are added often, usually when we discover some new way that DayBreak does their spawns, quests or other content. If you find you are unable to achieve your goal in your scripting, it is possible you need a LUA function added. You can either choose to develop your own LUA function and submit it to the core Devs for inclusion, or post your requirements in the Feature Request forum for a script dev to add to the server.