LUA Functions Sticky
Posted: Mon Apr 28, 2008 2:18 pm
Here is a list of all the LUA functions that can currently be used (or will be added within a day or two):
//Sets
SetCurrentHP(Spawn, value)
SetMaxHP(Spawn, value)
SetCurrentPower(Spawn, value)
SetMaxPower(Spawn, value)
SetHeading(Spawn, value)
SetRaceType(Spawn, value)
SetSpeed(Spawn, value)
SetPosition(Spawn, x, y, z)
SetInt(Spawn, value)
SetWis(Spawn, value)
SetSta(Spawn, value)
SetStr(Spawn, value)
SetAgi(Spawn, value)
SetLootCoin(Spawn, amount)
SetMount(Spawn, mount_mode_type (int))
SetMountColor(Spawn, horse_color_red (int), horse_color_green (int), horse_color_blue (int), horse_color_saddle_red (int), horse_color_saddle_green (int), horse_color_saddle_blue (int))
//Gets
GetCurrentHP(Spawn)
GetMaxHP(Spawn)
GetCurrentPower(Spawn)
GetName(Spawn)
GetLeve(Spawn)
GetMaxPower(Spawn)
GetDistance(Spawn, Spawn)
GetX(Spawn)
GetY(Spawn)
GetZ(Spawn)
GetHeading(Spawn)
GetRaceType(Spawn)
GetRace(Spawn)
GetClass(Spawn)
GetSpeed(Spawn)
HasMoved(Spawn)
GetInt(Spawn)
GetWis(Spawn)
GetSta(Spawn)
GetStr(Spawn)
GetAgi(Spawn)
GetLootCoin(Spawn)
GetZone(ZoneId)
GetMount(Spawn)
//Misc
ModifyPower(Spawn, value)
ModifyHP(Spawn, value)
ModifyMaxPower(Spawn, value)
ModifyMaxHP(Spawn, value)
SpellDamage(Target, type, damage)
FaceTarget(Spawn, Target)
MoveToLocation(Spawn, x, y, z) - should be used to make an NPC run to a given spot
Say(Spawn, message)
Shout(Spawn, message)
SayOOC(Spawn, message)
Emote(Spawn, message)
IsPlayer(Spawn)
MovementLoopAddLocation(Spawn, x, y, z, speed, delay, function) - used to add movements to a spawn
function: this is a LUA function defined in the spawnscript that is called once the NPC reaches the x,y,z specified
GetCurrentZoneSafeLocation(Spawn)
PlayFlavor(Spawn, mp3_filename, text, emote, mp3_key1, mp3_key2) - this allows you to play a voice file, display chat, and do an emote all at once
PlaySound(Spawn, sound_filename, x, y, z)
PlayVoice(Spawn, mp3_filename, mp3_key1, mp3_key2)
AddLootItem(spawn, item_id)
RemoveLootItem(spawn, item_id)
AddLootCoin(spawn, amount)
CreateConversation(Spawn, value) - Used to create a new Conversation. This is necessary before you can set them
AddConversationOption(Conversation, Text option, Function) - The given function is called when the user selects this text option.
StartConversation(Conversation, NPC, Spawn, Text) - This initiates the conversation and displays what the NPC says (text) and the options that were added using the AddConversationOption function.
SummonItem(Spawn, ItemId)
HasItem(Spawn, ItemId, IncludeBank)
IncludeBank: 1 to include bank items, 0 not to
SpawnMob(Zone, SpawnID, restricted, x, y, z, heading)
Zone: Z reference to the zone. use GetZone(Spawn) to get this.
restricted: A 0 or 1 to determine if this spawn can only be seen by the player (usually quest related).
Zone(Zone, Spawn, x, y, z, heading)
Zone: A reference to the zone to zone the spawn into. Use GetZone(Spawn) to get this.
SetPlayerProximityFunction(NPC, distance, in range function name, out of range function name (optional) )
This will call the 'in range function' name when the player's distance to the NPC is less than the distance given in the function. Also if the 'out of range function' name is given, that is called when the player leaves the range.
GetSpawn(Spawn, spawn_id) - Returns the closest Spawn to the Spawn argument that matches the spawn_id. The value returned as well as the first argument can be a NPC, Widget, Sign, Object and in the case of the argument even a Player.
GetZoneID(Zone) - Returns the zone id for the zone. Pass in a Zone object retrieved with the GetZone function.
GetZoneName(Zone) - Returns the zone name for the zone. Pass in a Zone object retrieved with the GetZone function.
GetNPC(Spawn, spawn id) - returns the closest NPC of that spawn id to the given Spawn.
SpawnSet(Spawn, variable, value)
variable: certain var like "show_hand_icon"
value: must be a string
SpawnSetByDistance(Spawn, radius, variable, value)
variable: certain var like "show_hand_icon"
value: must be a string
KillSpawn(Dead, Killer, send death packet (0 or 1))
send death packet: 1 to send kill message to chat
KillSpawnByDistance(Killer, distance around, include players, send death packet)
include players: 1 to kill players also
send death packet: 1 to send kill message to chat
Despawn(Spawn, delay)
delay: optional
IsAlive(Spawn)
SendMessage(Player, Message, [Color])
Color is optional and defaults to white. Other possibilities are "red" and "yellow".
//Quest Stuff
RegisterQuest(Quest, Quest Name, Quest Type, Quest Zone, Quest level, Description) - REQUIRED
OfferQuest(NPC, Spawn, Quest ID) - Offers the quest to the Spawn (Player)
SetQuestPrereqLevel(Quest, Level)
AddQuestPrereqQuest(Quest, Quest ID)
AddQuestPrereqItem(Quest, Item ID, Quantity)
AddQuestPrereqFaction(Quest, Faction ID, Faction Amount Lower, Faction Amount Upper)
AddQuestPrereqRace(Quest, race id)
AddQuestPrereqClass(Quest, class id)
AddQuestPrereqTradeskillLevel (not used yet)
AddQuestPrereqTradeskillClass (not used yet)
AddQuestRewardItem(Quest, Item ID, Quantity)
AddQuestSelectableRewardItem(Quest, item id, quantity)
AddQuestRewardCoin(Quest, Copper, Silver, Gold, Plat)
AddQuestRewardFaction(Quest, Faction ID, Amount)
SetQuestRewardStatus(Quest, Amount)
SetQuestRewardComment(Quest, Text)
SetQuestRewardExp(Quest, Amount)
AddQuestStep(Quest, StepID, StepText, Quantity, Percentage, TaskGroupText, Icon)
AddQuestStepKill(Quest, StepID, StepText, Quantity, Percentage,TaskGroupText, Icon, NPC ID(s))
AddQuestStepChat(Quest, StepID, StepText, Quantity, TaskGroupText, Icon, NPC ID(s))
AddQuestStepObtainItem(Quest, StepID, StepText, Quantity, Percentage, TaskGroupText, Icon, Item ID(s))
AddQuestStepLocation(Quest, StepID, StepText, MaxVariation, TaskGroupText, Icon, x1, y1, z1, ...)
AddQuestStepSpell(Quest, StepID, StepText, Quantity, Percentage, TaskgroupText, Icon, Spell ID(s))
AddQuestStepCompleteAction(Quest, Step ID, Function Name)
SetQuestCompleteAction(Quest, Function Name) - Sets the LUA function name that should be called once the player completes all steps.
GiveQuestReward(Quest, Player)
SetStepComplete(Spawn, QuestID, StepID)
AddStepProgress(Spawn, QuestID, StepID, ProgressAmount)
GetQuestStep(Spawn, QuestId) - returns the first non-completed quest step
UpdateQuestStepDescription(Quest, Step ID, Description)
UpdateQuestZone(Quest, ZoneName)
GetTaskGroupStep(Spawn, QuestId)
UpdateQuestTaskGroupDescription(Quest, TaskGroupId, Text, DisplayBullets)
DisplayBullets: a boolean whether or not to display the quest steps assigned to this taskgroup. Defaults to false
UpdateQuestDescription()
SetCompletedDescription(Quest, Description)
ProvidesQuest(Quest ID)
HasQuest(Spawn, Quest ID) - returns true or false
HasCompletedQuest(Spawn, Quest ID) - returns true or false
QuestIsComplete(Spawn, Quest ID) - returns true if the player has the quest, has not turned it in, and it is completed
QuestStepIsComplete(Spawn, QuestID, StepID)
QuestReturnNPC(Quest, Spawn ID) - Sets the spawn id of the spawn that the player needs to turn the quest into.
GetQuest(Spawn, Quest ID) - Retrieves the existing active quest for the player. Returns 0 if the player doesn't have the current quest or it is completed.
SetRequiredQuest(NPC, QuestID, [StepID])
AddTimer(Spawn, time, function, max_count, player)
//Quest Functions
function Accepted(Quest, QuestGiver, Player)
NOTE: This function is called when a player accepts the quest
function Declined(Quest, QuestGiver, Player)
NOTE: This function is called when a player declines the quest
function Reload(Quest, QuestGiver, Player, Step)
Note: This function is called when a player zones or logs back in. Step is set to the last completed step for that quest.
For every step, you must tell Reload which function to complete.
//Spawn Script Functions
spawn(NPC)
NOTE: Called when the spawn is spawned
respawn(NPC)
NOTE: Called when the spawn is respawned
attacked(NPC, Spawn)
NOTE: Called when the spawn is attacked
targeted(NPC, Spawn)
NOTE: Called when the spawn is targeted
aggro(NPC, Spawn)
NOTE: Called when the spawn is aggro'd
hailed(NPC, Spawn)
NOTE: Called when the spawn is hailed
healthchanged(NPC, Spawn)
NOTE: Called when the spawn's health is changed
hailed_busy(NPC, Spawn)
NOTE: Called when the spawn is hailed and is busy (in combat, etc)
killed(NPC, Spawn)
NOTE: Called when the spawn kills something
death(NPC, Spawn)
NOTE: Called when the spawn is is killed
casted_on(NPC, Spawn, SpellName)
NOTE: Called when the spawn is casted on by a spell (command)