mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-26 05:22:25 +00:00
Lua Documentation
parent
39159726e0
commit
02a0e3b82b
@ -1 +1,146 @@
|
||||
PH
|
||||
All Lua General Functions are in the global table 'eq'.
|
||||
|
||||
```
|
||||
void load_encounter(std::string name);
|
||||
void unload_encounter(std::string name);
|
||||
void register_event(std::string package_name, std::string name, int evt, luabind::object func);
|
||||
void unregister_event(std::string package_name, std::string name, int evt);
|
||||
void register_npc_event(std::string name, int evt, int npc_id, luabind::object func);
|
||||
void unregister_npc_event(std::string name, int evt, int npc_id);
|
||||
void register_player_event(std::string name, int evt, luabind::object func);
|
||||
void unregister_player_event(std::string name, int evt);
|
||||
void register_item_event(std::string name, int evt, Lua_Item item, luabind::object func);
|
||||
void unregister_item_event(std::string name, int evt, Lua_Item item);
|
||||
void register_spell_event(std::string name, int evt, int spell_id, luabind::object func);
|
||||
void unregister_spell_event(std::string name, int evt, int spell_id);
|
||||
Lua_Mob spawn2(int npc_type, int grid, int unused, double x, double y, double z, double heading);
|
||||
Lua_Mob unique_spawn(int npc_type, int grid, int unused, double x, double y, double z, double heading = 0.0);
|
||||
Lua_Mob spawn_from_spawn2(uint32 spawn2_id);
|
||||
void enable_spawn2(int spawn2_id);
|
||||
void disable_spawn2(int spawn2_id);
|
||||
void set_timer(const char *timer, int time_ms);
|
||||
void stop_timer(const char *timer);
|
||||
void stop_all_timers();
|
||||
void depop();
|
||||
void depop(int npc_type);
|
||||
void depop_with_timer();
|
||||
void depop_with_timer(int npc_type);
|
||||
void depop_all();
|
||||
void depop_all(int npc_type);
|
||||
void depop_zone(bool start_spawn_status);
|
||||
void repop_zone();
|
||||
bool is_disc_tome(int item_id);
|
||||
void safe_move();
|
||||
void rain(int weather);
|
||||
void snow(int weather);
|
||||
int scribe_spells(int max);
|
||||
int scribe_spells(int max, int min);
|
||||
int train_discs(int max);
|
||||
int train_discs(int max, int min);
|
||||
void set_sky(int sky);
|
||||
void set_guild(int guild_id, int rank);
|
||||
void create_guild(const char *name, const char *leader);
|
||||
void set_time(int hour, int min);
|
||||
void signal(int npc_id, int signal_id);
|
||||
void signal(int npc_id, int signal_id, int wait);
|
||||
void set_global(const char *name, const char *value, int options, const char *duration);
|
||||
void target_global(const char *name, const char *value, const char *duration, int npc_id, int char_id, int zone_id);
|
||||
void delete_global(const char *name);
|
||||
void start(int wp);
|
||||
void stop();
|
||||
void pause(int duration);
|
||||
void move_to(float x, float y, float z, float h, bool save_guard_spot);
|
||||
void resume();
|
||||
void set_next_hp_event(int hp);
|
||||
void set_next_inc_hp_event(int hp);
|
||||
void respawn(int npc_type, int grid);
|
||||
void set_proximity(float min_x, float max_x, float min_y, float max_y);
|
||||
void set_proximity(float min_x, float max_x, float min_y, float max_y, float min_z, float max_z);
|
||||
void clear_proximity();
|
||||
void enable_proximity_say();
|
||||
void disable_proximity_say();
|
||||
void set_anim(int npc_type, int anim_num);
|
||||
void spawn_condition(const char *zone, uint32 instance_id, int condition_id, int value);
|
||||
void get_spawn_condition(const char *zone, uint32 instance_id, int condition_id);
|
||||
void toggle_spawn_event(int event_id, bool enable, bool reset);
|
||||
void summon_burried_player_corpse(uint32 char_id, float x, float y, float z, float h);
|
||||
void summon_all_player_corpses(uint32 char_id, float x, float y, float z, float h);
|
||||
int get_player_burried_corpse_count(uint32 char_id);
|
||||
bool bury_player_corpse(uint32 char_id);
|
||||
void task_selector(luabind::object table);
|
||||
void task_set_selector(int task_set);
|
||||
void enable_task(luabind::object table);
|
||||
void disable_task(luabind::object table);
|
||||
bool is_task_enabled(int task);
|
||||
bool is_task_active(int task);
|
||||
bool is_task_activity_active(int task, int activity);
|
||||
int get_task_activity_done_count(int task, int activity);
|
||||
void update_task_activity(int task, int activity, int count);
|
||||
void reset_task_activity(int task, int activity);
|
||||
void task_explored_area(int explore_id);
|
||||
void assign_task(int task_id);
|
||||
void fail_task(int task_id);
|
||||
int task_time_left(int task_id);
|
||||
int is_task_completed(int task_id);
|
||||
int enabled_task_count(int task_set);
|
||||
int first_task_in_set(int task_set);
|
||||
int last_task_in_set(int task_set);
|
||||
int next_task_in_set(int task_set, int task_id);
|
||||
int active_speak_task();
|
||||
int active_speak_activity(int task_id);
|
||||
int active_tasks_in_set(int task_set);
|
||||
int completed_tasks_in_set(int task_set);
|
||||
bool is_task_appropriate(int task);
|
||||
void popup(const char *title, const char *text, uint32 id, uint32 buttons, uint32 duration);
|
||||
void clear_spawn_timers();
|
||||
void zone_emote(int type, const char *str);
|
||||
void world_emote(int type, const char *str);
|
||||
int get_level(int type);
|
||||
void create_ground_object(uint32 item_id, float x, float y, float z, float h);
|
||||
void create_ground_object(uint32 item_id, float x, float y, float z, float h, uint32 decay_time);
|
||||
void create_ground_object_from_model(const char *model, float x, float y, float z, float h);
|
||||
void create_ground_object_from_model(const char *model, float x, float y, float z, float h, int type);
|
||||
void create_ground_object_from_model(const char *model, float x, float y, float z, float h, int type, uint32 decay_time);
|
||||
void create_door(const char *model, float x, float y, float z, float h, int open_type, int size);
|
||||
void modify_npc_stat(const char *id, const char *value);
|
||||
int collect_items(uint32 item_id, bool remove);
|
||||
void update_spawn_timer(uint32 id, uint32 new_time);
|
||||
void merchant_set_item(uint32 npc_id, uint32 item_id);
|
||||
void merchant_set_item(uint32 npc_id, uint32 item_id, uint32 quantity);
|
||||
int merchant_count_item(uint32 npc_id, uint32 item_id);
|
||||
std::string item_link(int item_id);
|
||||
void say_link(const char *phrase, bool silent, const char *link_name);
|
||||
const char *get_guild_name_by_id(uint32 guild_id);
|
||||
uint32 create_instance(const char *zone, uint32 version, uint32 duration);
|
||||
void destroy_instance(uint32 instance_id);
|
||||
int get_instance_id(const char *zone, uint32 version);
|
||||
void assign_to_instance(uint32 instance_id);
|
||||
void assign_group_to_instance(uint32 instance_id);
|
||||
void assign_raid_to_instance(uint32 instance_id);
|
||||
void flag_instance_by_group_leader(uint32 zone, uint32 version);
|
||||
void flag_instance_by_raid_leader(uint32 zone, uint32 version);
|
||||
void fly_mode(int flymode);
|
||||
int faction_value();
|
||||
void check_title(uint32 title_set);
|
||||
void enable_title(uint32 title_set);
|
||||
void remove_title(uint32 title_set);
|
||||
void wear_change(uint32 slot, uint32 texture);
|
||||
void voice_tell(const char *str, uint32 macro_num, uint32 race_num, uint32 gender_num);
|
||||
void send_mail(const char *to, const char *from, const char *subject, const char *message);
|
||||
void cross_zone_signal_client_by_char_id(uint32 player_id, int signal);
|
||||
void cross_zone_signal_client_by_name(const char *player, int signal);
|
||||
void cross_zone_message_player_by_name(uint32 type, const char *player, const char *message);
|
||||
luabind::object get_qglobals(Lua_NPC npc, Lua_Client client);
|
||||
luabind::object get_qglobals(Lua_Client client, Lua_NPC npc);
|
||||
luabind::object get_qglobals(Lua_Client client);
|
||||
luabind::object get_qglobals(Lua_NPC npc);
|
||||
luabind::object get_qglobals();
|
||||
Lua_EntityList get_entity_list();
|
||||
int get_zone_id();
|
||||
const char *get_zone_long_name();
|
||||
const char *get_zone_short_name();
|
||||
int get_zone_instance_id();
|
||||
int get_zone_instance_version();
|
||||
int get_zone_weather();
|
||||
luabind::object get_zone_time();
|
||||
```
|
||||
@ -1,4 +1,4 @@
|
||||
Lua_Object is a class exported to Lua that represent the Object object from EQEmu.
|
||||
Lua_Object is a class exported to Lua that represent the Object object from EQEmu. All Lua_Object are also [Lua_Entity](Lua-Entity).
|
||||
|
||||
### Properties
|
||||
```
|
||||
|
||||
143
Lua-Parser.md
143
Lua-Parser.md
@ -3,11 +3,23 @@ The Lua Parser is a quest parser for EQEmu that uses the Lua embedded programmin
|
||||
We use Lua 5.1 so the [Lua 5.1 Manual](http://www.lua.org/manual/5.1/manual.html) applies. Section 2 is a bit of a dense read but may be of particular interest to those just getting started with Lua.
|
||||
|
||||
## Table of Contents
|
||||
* [Init Scripts](#init-scripts)
|
||||
* [NPC Scripts](#npc-scripts)
|
||||
* [Player Scripts](#player-scripts)
|
||||
* [Item Scripts](#item-scripts)
|
||||
* [Spell Scripts](#spell-scripts)
|
||||
* [Encounter Scripts](#encounter-scripts)
|
||||
* [Events](#events)
|
||||
* [API](#api)
|
||||
|
||||
<a name="wiki-init-scripts"></a>
|
||||
### Init Scripts
|
||||
On Lua Parser reload it will attempt to load two scripts with no function env.
|
||||
*
|
||||
* ./quests/zone/script_init.lua
|
||||
* ./quests/global/script_init.lua
|
||||
|
||||
These are useful for setting up modules to load automatically or for loading encounters.
|
||||
|
||||
<a name="wiki-npc-scripts"></a>
|
||||
### NPC Scripts
|
||||
@ -25,12 +37,141 @@ NPCs will also attempt to load a global NPC script that is attached to all NPCs
|
||||
|
||||
<a name="wiki-player-scripts"></a>
|
||||
### Player Scripts
|
||||
Player Scripts are quest scripts attached to Players.
|
||||
Players will load a script on the first event that triggers them and they will load one and only one from the following location. Which ever it finds first in the following order:
|
||||
* ./quests/zone/player_v[instance_version].lua
|
||||
* ./quests/zone/player.lua
|
||||
* ./quests/global/player.lua
|
||||
|
||||
Players will also attempt ot load a global Player script that is attached to all Players from the following location:
|
||||
* ./quests/global/player.lua
|
||||
|
||||
<a name="wiki-item-scripts"></a>
|
||||
### Item Scripts
|
||||
Item Scripts are quest scripts attached to Items.
|
||||
Items will load a script on the first event that triggers them and will load one and only one from the following location. Which ever it finds first in the following order:
|
||||
* ./quests/zone/items/item_script.lua
|
||||
* ./quests/items/item_script.lua
|
||||
|
||||
The format of the item_script is as follows:
|
||||
```
|
||||
If ScriptFileID != 0
|
||||
item_script = "script_" + ScriptFileID
|
||||
Else If CharmFile != ""
|
||||
item_script = CharmFile
|
||||
Else
|
||||
item_script = item_id
|
||||
```
|
||||
|
||||
<a name="wiki-spell-scripts"></a>
|
||||
### Spell Scripts
|
||||
Spell Scripts are quest scripts attached to Spells.
|
||||
Spells will load a script on the first event that triggers them and will load one and only one from the following location. Which ever it finds first in the following order:
|
||||
* ./quests/zone/spells/spell_id.lua
|
||||
* ./quests/spells/spell_id.lua
|
||||
|
||||
<a name="wiki-encounter-scripts"></a>
|
||||
### Encounter Scripts
|
||||
### Encounter Scripts
|
||||
Encounter scripts are quest scripts that are only loaded after explicitly called with:
|
||||
|
||||
`eq.load_encounter("encounter_name")`
|
||||
|
||||
Encounter scripts listen for specific events from other script types with the following functions:
|
||||
|
||||
```
|
||||
void register_npc_event(std::string name, int evt, int npc_id, luafunction func);
|
||||
void register_player_event(std::string name, int evt, luafunction func);
|
||||
void register_item_event(std::string name, int evt, Lua_Item item, luafunction func);
|
||||
void register_spell_event(std::string name, int evt, int spell_id, luafunction func);
|
||||
```
|
||||
|
||||
Note: Encounter scripts cannot properly catch EVENT_COMMAND or EVENT_TRADE unless an existing quest is already listening for them.
|
||||
|
||||
<a name="wiki-events"></a>
|
||||
### Events
|
||||
|
||||
Quest scripts are event based, the following events are currently responded to by the Lua parser:
|
||||
* event_say
|
||||
* event_trade
|
||||
* event_death
|
||||
* event_spawn
|
||||
* event_attack
|
||||
* event_combat
|
||||
* event_aggro
|
||||
* event_slay
|
||||
* event_npc_slay
|
||||
* event_waypoint_arrive
|
||||
* event_waypoint_depart
|
||||
* event_timer
|
||||
* event_signal
|
||||
* event_hp
|
||||
* event_enter
|
||||
* event_exit
|
||||
* event_enter_zone
|
||||
* event_click_door
|
||||
* event_loot
|
||||
* event_zone
|
||||
* event_level_up
|
||||
* event_killed_merit
|
||||
* event_cast_on
|
||||
* event_task_accepted
|
||||
* event_task_stage_complete
|
||||
* event_task_update
|
||||
* event_task_complete
|
||||
* event_task_fail
|
||||
* event_aggro_say
|
||||
* event_player_pickup
|
||||
* event_popup_response
|
||||
* event_proximity_say
|
||||
* event_cast
|
||||
* event_cast_begin
|
||||
* event_scale_calc
|
||||
* event_item_enter_zone
|
||||
* event_target_change
|
||||
* event_hate_list
|
||||
* event_spell_effect
|
||||
* event_spell_buff_tic
|
||||
* event_spell_fade
|
||||
* event_spell_effect_translocate_complete
|
||||
* event_combine_success
|
||||
* event_combine_failure
|
||||
* event_item_click
|
||||
* event_item_click_cast
|
||||
* event_group_change
|
||||
* event_forage_success
|
||||
* event_forage_failure
|
||||
* event_fish_start
|
||||
* event_fish_success
|
||||
* event_fish_failure
|
||||
* event_click_object
|
||||
* event_discover_item
|
||||
* event_disconnect
|
||||
* event_connect
|
||||
* event_item_tick
|
||||
* event_duel_win
|
||||
* event_duel_lose
|
||||
* event_encounter_load
|
||||
* event_encounter_unload
|
||||
* event_command
|
||||
* event_drop_item
|
||||
* event_destroy_item
|
||||
* event_feign_death
|
||||
|
||||
<a name="wiki-api"></a>
|
||||
### API
|
||||
The Lua API consisted of many exported classes and some general functions.
|
||||
* [Lua_Client](Lua-Client)
|
||||
* [Lua_Corpse](Lua-Corpse)
|
||||
* [Lua_Door](Lua-Door)
|
||||
* [Lua_Client](Lua-Client)
|
||||
* [Lua_Entity](Lua-EntityList)
|
||||
* [Lua_Group](Lua-Group)
|
||||
* [Lua_HateList](Lua-Hate-List)
|
||||
* [Lua_Item](Lua-Item)
|
||||
* [Lua_ItemInst](Lua-ItemInst)
|
||||
* [Lua_Mob](Lua-Mob)
|
||||
* [Lua_NPC](Lua-NPC)
|
||||
* [Lua_Object](Lua-Object)
|
||||
* [Lua_Raid](Lua-Raid)
|
||||
* [Lua_Spell](Lua-Spell)
|
||||
* [Lua General Functions](Lua-General-Functions)
|
||||
Loading…
x
Reference in New Issue
Block a user