No categories assigned

LUA

Revision as of 17:54, 27 March 2009 by John Adams (talk | contribs) (LUA Parameter Basics)

The LUA Scripting System

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:

SpawnScripts

Spells

Quests

ZoneScripts

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.

LUA Parameter Basics

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 NPC says Hello to the player.

 function hailed(MyNPC, MyPlayer)
   Say(MyNPC, "Hello Player!")
 end


Example: Here, the Player says Hello to the NPC.

 function hailed(MyNPC, MyPlayer)
   Say(MyPlayer, "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.

LUA Functions

Our LUA Functions list is broken into several categories for clarity of functionality. More functions are added often, so check back if you are looking for something that you need for your scripts.


Get Functions

This set of functions will GET info from the World or Database for use within any LUA script

Developer: LethalEncounter, Scatman


GetAgi

GetClass

GetCurrentHP

GetCurrentPower

GetDistance

GetHeading

GetInt

GetLevel

GetLootCoin

GetMaxHP

GetMaxPower

GetName

GetNPC

GetRace

GetRaceType

GetSpawn

GetSpeed

GetSta

GetStr

GetWis

GetX

GetY

GetZ

GetZone

GetZoneID

GetZoneName

HasItem

HasMoved


Set Functions

This set of functions will SET info in the World or Database from within any LUA script

Developer: LethalEncounter, Scatman


ModifyHP

ModifyMaxHP

ModifyMaxPower

ModifyPower

SetAgi

SetCurrentHP

SetCurrentPower

SetHeading

SetInt

SetLootCoin

SetMaxHP

SetMaxPower

SetPosition

SetRaceType

SetSpeed

SetSta

SetStr

SetWis

SpawnSet

SpawnSetByDistance

SummonItem

RemoveItem

Quest Functions

These functions are for use within Quest scripts, and are some of the more complex LUA Functions in the EQ2Emulator.

Developer: LethalEncounter, Scatman


Accepted

AddQuestPrereqClass

AddQuestPrereqFaction

AddQuestPrereqItem

SetQuestPrereqLevel

AddQuestPrereqQuest

AddQuestPrereqRace

AddQuestPrereqTradeskillLevel

AddQuestPrereqTradeskillClass

AddQuestRewardCoin

AddQuestRewardItem

AddQuestRewardFaction

AddQuestSelectableRewardItem

AddQuestStep

AddQuestStepChat

AddQuestStepCompleteAction

AddQuestStepKill

AddQuestStepLocation

AddQuestStepObtainItem

AddQuestStepSpell

AddStepProgress

AddTimer

Declined

GetQuest

GetQuestStep

GetTaskGroupStep

GiveQuestReward

HasCompletedQuest

HasQuest

OfferQuest

ProvidesQuest

QuestIsComplete

QuestReturnNPC

QuestStepIsComplete

RegisterQuest

Reload

SetCompletedDescription

SetQuestCompleteAction

SetQuestRewardComment

SetQuestRewardExp

SetQuestRewardStatus

SetRequiredQuest

SetStepComplete

UpdateQuestDescription

UpdateQuestStepDescription

UpdateQuestTaskGroupDescription

UpdateQuestZone

Spell Functions

These functions are used within Spell scripts to generate the expected effect of casting spells or using abilities.

Developer: LethalEncounter


SPECIAL NOTE ABOUT SPELL FUNCTIONS: Many spells simply alter an existing stat of one kind or another to yourself or a target, so there are not very many "spell functions" to speak of. SpellDamage is one of the few, since buffing, debuffing, or slowing (etc) a target are done through the SET Functions inside a Spell Script.


SpellDamage

Spawn Functions

These are functions that normally go into SpawnScripts for interacting with NPCs or other types of Spawns.

Developer: LethalEncounter, Scatman


AddConversationOption

AddLootCoin

AddLootItem

aggro

attacked

casted_on

CreateConversation

death

Emote

Despawn

Face Targer

hailed

hailed_busy

healthchanged

IsAlive

killed

KillSpawn

KillSpawnByDistance

MoveToLocation

MovementLoopAdd

PlayFlavor

PlaySounds

PlayVoice

RemoveLootItem

respawn

Say

SayOOC

Shout

spawn

SpawnMob

StartConversation

targeted


General Functions

These are general functions that are either to set/retrieve player or target data, or get references to nearby objects.

Developer: LethalEncounter, Scatman


GetCurrentZoneSafeLocation

HasMoved

IsPlayer

SetPlayerProximityFunction

Zone


Conclusion

LUA functions are added often, usually when we discover some new way that SOE 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.